当前位置: 首页 > news >正文

网站建设常用六大布局/营销类网站

网站建设常用六大布局,营销类网站,做seo网站优化多少钱,网站百度指数脚本1 触发器脚本 这个脚本是主角身上的脚本,用于检测是否碰到其他触发器,并做出对应的行为 using System.Collections; using System.Collections.Generic; using UnityEngine; public class ColliidisonTrigger : MonoBehaviour { //触发检测 …

脚本1 触发器脚本 

这个脚本是主角身上的脚本,用于检测是否碰到其他触发器,并做出对应的行为 
 

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class ColliidisonTrigger : MonoBehaviour
{
    //触发检测  1.碰到金币克隆区,克隆金币 2.恐克隆怪物  3.碰撞金币 吃掉它 加分 4.碰到怪物,掉血 5碰到加速带加速、减速
    //该触发检测脚本挂到 主角身上
    //PlayerCont onePlayer = new PlayerCont();
  
    GameObject BeiPengObj;
    public GameObject MosterMuban;
    public GameObject CloneStruFather;

    public GameObject JInbiMUban;
    public GameObject JinbiFather;
    
    private void OnTriggerEnter(Collider other)
    {
          
           BeiPengObj = other.transform.gameObject;
        //如果碰到触发器,执行一次 
        Debug.Log("碰到了别人");
        if (BeiPengObj.tag == "MonsterTrigger")//碰到了怪物克隆区触发器
        {
            CloneMonster();

        }
        if (BeiPengObj.tag == "rCoinTrigger")//碰到了金币克隆区触发器
        {
            Debug.Log("kelongjinbi");
            CloneCoin();
        }


        if (BeiPengObj.tag == "TriggerSpeedUp")//碰到了加速区触发器
        {
            Debug.Log("开始加速");
            Speedup();
        }

        if (BeiPengObj.tag == "Coin")//碰到了金币触发器
        {
            Debug.Log("吃掉,消失金币,加分");
            Destroy(BeiPengObj);
            addScore();
        }

        if (BeiPengObj.tag == "Monster")//碰到了怪物障碍物
        {
            Debug.Log("掉血");
            ScoreManager.SubBlood(); //跨类访问并执行分数类里面的掉血函数    
        }
    }

    void CloneMonster()
    {
        for (int i = 0; i < 10; i++)
        {
            Vector3 ONETEMPPOS = new Vector3(156, 0, BeiPengObj.transform.position.z + 50f+i*3);
            Debug.Log("克隆怪物去");
            GameObject.Instantiate(MosterMuban, ONETEMPPOS, Quaternion.Euler(0, 0, 0), CloneStruFather.transform);
        }
    }
    void CloneCoin()
    {
        for (int i = 0; i < 10; i++)
        {
            Vector3 ONETEMPPOS = new Vector3(156, 0, BeiPengObj.transform.position.z + 50f + i * 3);
            Debug.Log("克隆怪物去");
            GameObject.Instantiate(JInbiMUban, ONETEMPPOS, Quaternion.Euler(0, 0, 0), JinbiFather.transform);
        }
    }
    void Speedup()
    {
        PlayerCont.RunSpeed = 20f;
    }

    void addScore()
    {
        ScoreManager.ScoreAdd();//跨类访问并执行分数类里面的加分函数
    }

   
}//end class

 

脚本2 分数管理脚本

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class ScoreManager : MonoBehaviour
{
    //分数管理 血量管理
    // 如果撞击到金币就加分,如果撞击到障碍物就掉血

    public static  int CurrentScore=0;
    public static int CurrentBlood = 10000;


    public static void ScoreAdd()
    {
        Debug.Log("加分函数开始执行");
        CurrentScore += 10;
        Debug.Log("分:"+CurrentScore);
    }


    public static void SubBlood()
    {
        Debug.Log("掉血函数开始执行");
        CurrentBlood -= 100;
        Debug.Log("血:" + CurrentBlood);
    }
    private void OnGUI()
    {
        Rect oneLableRec = new Rect(100, 100, 50, 50);
        GUILayout.Box(CurrentBlood.ToString(), GUILayout.Width(200), GUILayout.Height(50), GUILayout.ExpandWidth(false)); 
        // 创建另一个矩形框,背景色为红色,边框宽度为3像素
        GUILayout.Box(CurrentScore.ToString(), GUILayout.Width(200), GUILayout.Height(70), GUILayout.ExpandWidth(false));
        GUILayout.TextField("", GUILayout.Width(200), GUILayout.Height(50), GUILayout.ExpandWidth(false));
    }

}
 

脚本3 空物体移动的脚本

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class PlayerCont : MonoBehaviour
{
    //Horizontal
    //1.控制玩家移动,input.getaix
    //2.A、D控制向左、右移动
    //3.W控制跳跃
    public GameObject Player;
    public float LRSPEED = 10F;
    public float JUMPSPEED = 5;
   
    public static float RunSpeed;

    private void Start()
    {
        RunSpeed = 10f;
    }
    private void Update()
    {
        UserInput();
 
    }
    //*=========================
  public  void UserInput()
    {
        //Debug.Log("检测用户按下的键盘A D W");
        float MoveZuoY = Input.GetAxis("Horizontal");
        ControlMove(MoveZuoY);
        
        if (Input.GetKey(KeyCode.W))
        {
            Jump();
        }
    }
    void ControlMove(float ZuoyouMove)
    {
        Player.transform.Translate(new Vector3(ZuoyouMove * LRSPEED * Time.deltaTime, 0, 0));

    }
   
    void Jump()
    {
        Player.transform.Translate(new Vector3(0, JUMPSPEED * Time.deltaTime, 0));
        //Debug.Log("角色开始移动了");
    }
    private void FixedUpdate()
    {
        AwalysRun();
    }
 void AwalysRun()
    {
        Player.transform.Translate(new Vector3(0, 0, 1 * RunSpeed * Time.deltaTime));
    }
}
 

 

http://www.jmfq.cn/news/5327461.html

相关文章:

  • 中小型网站建设怎么样/橙子建站官网
  • 网站建设找什么工作室/谷歌广告投放教程
  • 互联网网站建设挣钱吗/友情链接地址
  • 十堰学网站建设培训班/刷赞业务推广网站
  • 福建 建设网站/青岛网站建设方案优化
  • 辽宁建设厅网站首页/2021小说排行榜百度风云榜
  • 隆化县建设局网站/整合营销方案怎么写
  • 长沙做网站建设公司哪家好/专业软文发布平台
  • 大大福利站网站建设/合肥seo按天收费
  • 网站建设的运用场景/网站设计制作的服务怎么样
  • 青岛市城乡建设局网站/企业查询网
  • 宁德市住房和城乡建设局新网站/seo排名工具
  • 环保行业网站建设/危机公关
  • 广州微网站建设/搜狗搜索引擎推广
  • 龙岩市住房和城乡建设厅网站首页/关键词营销优化
  • 桂林住房城乡建设委员会网站/seo常用的工具
  • 建设网站的产品规划/免费宣传平台
  • 青秀区网站建设/宁德seo公司
  • 农业公司网站建设/上海关键词排名手机优化软件
  • 网站建设中怎么添加源码/宁波正规seo推广
  • 网络网站建设10大指标/打开百度网站首页
  • 普洱市住房城乡建设局网站/郑州网络推广服务
  • 长城集团建设有限公司网站/123网址之家
  • 济南网站建设公司有哪些/中国突然宣布一重磅消息
  • 对网站建设的评价/站长工具使用方法
  • 个人网站建设与维护/中国进入一级战备2023
  • 七里河微信网站建设/关键词优化简易
  • 网站建设工程师职责说明书/刷seo排名
  • 浙江省旅游企业网站建设情况/怎样策划一个营销型网站
  • 网站建设客服用户咨询话术/外贸网站有哪些平台