void Start() { Player = GameObject.FindGameObjectWithTag(TagMgr.Player).transform; playerAtkAndDamage = Player.GetComponent <PlayerAtkAndDamage>(); //cc = this.GetComponent<CharacterController>(); animator = this.GetComponent <Animator>(); agent = GetComponent <NavMeshAgent>(); }
private float timer = 0; //计时器 // Start is called before the first frame update void Start() { player = GameObject.FindGameObjectWithTag(Tags.player).transform; playerAtkAndDamage = player.GetComponent <PlayerAtkAndDamage>(); cc = this.GetComponent <CharacterController>(); animator = this.GetComponent <Animator>(); timer = attackTime; }
void Start() { //获取角色位置及血量信息 Player = GameObject.FindGameObjectWithTag(TagMgr.Player).transform; playerAtkAndDamage = Player.GetComponent <PlayerAtkAndDamage>(); monsterAtkAndDamage = this.GetComponent <SoulMonsterAtkAndDamage>(); //获取自身控制器及状态机 //cc = this.GetComponent<CharacterController>(); animator = this.GetComponent <Animator>(); agent = GetComponent <NavMeshAgent>(); }
//为攻击按钮绑定监听方法 public void init() { playerAtk = GameObject.FindGameObjectWithTag(TagMgr.Player).GetComponent <PlayerAtkAndDamage>(); animator = GameObject.FindGameObjectWithTag(TagMgr.Player).GetComponent <Animator>(); //将当前脚本的点击事件处理方法放到OnClick事件触发列表中 EventDelegate NormalAttackEvent = new EventDelegate(this, "OnNormalAttackClick"); GameObject.Find("NormalAttack").GetComponent <UIButton>().onClick.Add(NormalAttackEvent); EventDelegate RangeAttackEvent = new EventDelegate(this, "OnRangeAttackClick"); GameObject.Find("RangeAttack").GetComponent <UIButton>().onClick.Add(RangeAttackEvent); GameObject Redattack = GameObject.Find("RedAttack"); EventDelegate RedAttackEvent = new EventDelegate(this, "OnRedAttackClick"); GameObject.Find("RedAttack").GetComponent <UIButton>().onClick.Add(RedAttackEvent); }
void Start() { playerAtkAndDamage = GameObject.FindGameObjectWithTag(TagMgr.Player).GetComponent <PlayerAtkAndDamage>(); StartCoroutine(Spawn()); StartCoroutine(checkOver()); }