void Start() { curBehavior = EBehavior.None; myHealth = GetComponent <Enemy_Handler>().myHealth; //Set the Boss's target to player so it will follow GetComponent <EnemyBehavior_FollowTarget>().target = GameObject.Find("Player").transform; //Start the boss's behavior routine StopCoroutine(BehaviorCoroutine()); StartCoroutine(BehaviorCoroutine()); }
///<summary>动画后的处理,移除不可见对象</summary> public void anicomplete() { if (behavior == EBehavior.扩展子项 || behavior == EBehavior.被收缩) { owner.mgModel.Children.Remove(zmodel); owner.mgLabel.Children.Remove(zlabel); } behavior = EBehavior.无; oldTranslate = new Vector3D(absoluteTranslateVec.X, absoluteTranslateVec.Y, absoluteTranslateVec.Z); if (haveChild) foreach (SettleNode e0 in nodes) e0.anicomplete(); }
IEnumerator BehaviorCoroutine() { //loop infinitely until the object is destroyed while (true) { //Debug.Log(this.gameObject.name + ": " + curBehavior); yield return(new WaitForSeconds(3)); curBehavior = EBehavior.Move; UpdateState(); //Debug.Log(this.gameObject.name + ": " + curBehavior); yield return(new WaitForSeconds(2)); curBehavior = EBehavior.Attack1; UpdateState(); //Debug.Log(this.gameObject.name + ": " + curBehavior); yield return(new WaitForSeconds(4)); curBehavior = EBehavior.Attack1; UpdateState(); //Debug.Log(this.gameObject.name + ": " + curBehavior); yield return(new WaitForSeconds(1)); curBehavior = EBehavior.Move; UpdateState(); //Debug.Log(this.gameObject.name + ": " + curBehavior); yield return(new WaitForSeconds(2)); curBehavior = EBehavior.Attack2; UpdateState(); //Debug.Log(this.gameObject.name + ": " + curBehavior); yield return(new WaitForSeconds(1)); curBehavior = EBehavior.Attack3; UpdateState(); } }
// Update is called once per frame void Update() { if (firstBehavior == 0) { behavior = EBehavior.Patrol; } else if (firstBehavior == 1) { behavior = EBehavior.Hunt; } else if (firstBehavior == 2) { behavior = EBehavior.Evade; } // -----------------------------Enemy Movement-------------------------- switch (behavior) { case EBehavior.Patrol: InvokeRepeating("Patrol", startPatrol, waitPatrol); break; case EBehavior.Hunt: InvokeRepeating("Hunt", startHunt, waitHunt); break; case EBehavior.Evade: InvokeRepeating("Evade", startEvade, waitEvade); break; } if (enemyHealth <= 0) { int score = int.Parse(scoreGT.text); score += 1000; scoreGT.text = score.ToString(); Destroy(this.gameObject); } }