private float[] enemysDis; // 距離陣列 : 存放所有敵人的距離 private void Start() { rig = GetComponent <Rigidbody2D>(); ani = GetComponent <Animator>(); hpValueManager = GetComponentInChildren <HpValueManager>(); // 取得子物件元件 hp = data.hpMax; //將Hp獨立儲存 }
private Vector3 posBullet; // 子彈座標 private void Start() { instance = this; rig = GetComponent <Rigidbody2D>(); ani = GetComponent <Animator>(); // 動畫控制器 = 取得文件<動畫控制器>() hpValueManager = GetComponentInChildren <HpValueManager>(); // 取得子物件元件 // Physics2D.IgnoreLayerCollision(8, 10); Physics2D.IgnoreLayerCollision(9, 12); }
private HpValueManager hpValueManager; // 血條數值管理器 private void Start() { hp = data.hpMax; ani = GetComponent <Animator>(); target = GameObject.Find("玩家").transform; // 目標 = 尋找 hpValueManager = GetComponentInChildren <HpValueManager>(); // 取得子物件元件 rig = GetComponent <Rigidbody2D>(); Physics2D.IgnoreLayerCollision(8, 8); Physics2D.IgnoreLayerCollision(8, 11); }
private float hp; // 每一隻怪物獨立 private void Start() { ani = GetComponent <Animator>(); agent = GetComponent <NavMeshAgent>(); agent.speed = data.speed; agent.stoppingDistance = data.stopDistance; hp = data.hp; target = GameObject.Find("玩家").transform; hpDamManager = GetComponentInChildren <HpValueManager>(); // 取得子物件的元件 (僅限於子物件內只有一個) }
private void Start() { rig = GetComponent <Rigidbody>(); ani = GetComponent <Animator>(); js = GameObject.Find("虛擬搖桿").GetComponent <FixedJoystick>(); target = GameObject.Find("目標").transform; levelManager = FindObjectOfType <LevelMananger>(); // 透過類型尋找物件 ( 場景上只有一個 ) hpvaluemanager = GetComponentInChildren <HpValueManager>(); }
private HpValueManager hpvalueManager; // 血條數值管理器 private void Start() { ani = GetComponent <Animator>(); nav = GetComponent <NavMeshAgent>(); nav.speed = data.speed; // 調整 代理器.速度 nav.stoppingDistance = data.stopDistance; hp = data.hp; hpvalueManager = GetComponentInChildren <HpValueManager>(); // 取得子物件元件 tra = GameObject.Find("Fox").GetComponent <Transform>(); // 取得玩家變形 }
private HpValueManager hpValueManager; // 血條數值管理器 private void Start() { ani = GetComponent <Animator>(); nav = GetComponent <NavMeshAgent>(); nav.speed = data.speed; // 調整 代理器.速度 nav.stoppingDistance = data.stopDistance; hp = data.hp; target = GameObject.Find("鼠王").transform; // 目標 = 尋找 hpValueManager = GetComponentInChildren <HpValueManager>(); // 取得子物件元件 }
private float[] enemysDis; // 距離陣列:存放所有敵人的距離 #endregion #region 事件 private void Start() { rig = GetComponent <Rigidbody>(); ani = GetComponent <Animator>(); // 動畫控制器 = 取得元件<動畫控制器>() joystick = GameObject.Find("虛擬搖桿").GetComponent <FixedJoystick>(); //target = GameObject.Find("目標").GetComponent<Transform>(); target = GameObject.Find("目標").transform; levelManager = FindObjectOfType <LevelManager>(); // 透過類行尋找物件 (場景上只有一個) hpValueManager = GetComponentInChildren <HpValueManager>(); // 取得子物件元件 }
private float[] enemysDistance; // 儲存所有敵人距離陣列 private void Start() { rig = GetComponent <Rigidbody>(); // 取得元件<泛型>() (取得相同屬性面板) ani = GetComponent <Animator>(); joystick = GameObject.Find("虛擬搖桿").GetComponent <Joystick>(); // 遊戲物件.尋找("物件名稱").取得元件<泛型>() // target = GameObject.Find("目標").GetComponent<Transform>(); // 原本寫法 target = GameObject.Find("目標").transform; // 簡寫 - GetComponent<Transform>() 可以直接寫成 transform //levelManager = GameObject.Find("遊戲管理器").GetComponent<LevelManager>(); levelManager = FindObjectOfType <LevelManager>(); // 僅限於一個 hpDamManager = GetComponentInChildren <HpValueManager>(); // 取得子物件的元件 (僅限於子物件內只有一個) }
private void Start() { ani = GetComponent <Animator>(); nav = GetComponent <NavMeshAgent>(); nav.speed = data.speed; nav.stoppingDistance = data.stopDistance; hp = data.hp; target = GameObject.Find("機器人").transform; hpvaluemanager = GetComponentInChildren <HpValueManager>(); }
// Start is called before the first frame update void Start() { hpValueManager = GetComponentInChildren <HpValueManager>(); // 取得子物件元件 }