Example #1
0
    public void UpdateEnemyByState()
    {
        if (!dieAlready)
        {
            switch (enemyState)
            {
            case BasicInfo.enemyStates.Walk:
            {
                pathMoveTween.Play();
                //modelAnim.Play("walk");



                if (enemyLastState == BasicInfo.enemyStates.Attack)
                {
                    transform.DOLookAt(pathList[nextWayPointIndex], 0.3f, AxisConstraint.Y, Vector3.up);
                }
                break;
            }

            case BasicInfo.enemyStates.Stop:
            {
                pathMoveTween.Pause();
                //modelAnim.Play("idle");

                break;
            }

            case BasicInfo.enemyStates.Attack:
            {
                pathMoveTween.Pause();

                transform.DOLookAt(detectedTowerList[0].transform.position, 0.3f, AxisConstraint.Y, Vector3.up);

                modelAnim.Play("attack");



                //Debug.Log("检测到塔");
                //Debug.Log (2 / enemyAttackSpeed);
                if (TimersManager.GetTimerByName(AttackTimer) == null)
                {
                    TimersManager.SetTimer(this, 1f, AttackTimer);
                }
                break;
            }

            default:
            {
                break;
            }
            }
        }
    }
Example #2
0
 // Update is called once per frame
 void Update()
 {
     //Debug.Log(healthBarDefineTransform.position);
     healthBarTransform.position = Camera.main.WorldToScreenPoint(healthBarDefineTransform.position);
     Detect();
     if (detectedEnemyList.Count > 0)
     {
         //Debug.Log("侦测到敌人");
         if (TimersManager.GetTimerByName(AttackTimer) == null)
         {
             TimersManager.SetTimer(this, 1f, AttackTimer);
         }
     }
 }