Exemplo n.º 1
0
 void HitAnimation()
 {
     if (endAttack || canAttack == false)
     {
         return;
     }
     mHitDelta += RealTime.deltaTime;
     if (data.attackRate < mHitDelta)
     {
         mHitDelta = (data.attackRate > 0f) ? mHitDelta - data.attackRate : 0f;
         if (curFps > 0)
         {
             curFps = 0;
             GetTransform().GetChild(0).localPosition = new Vector3(0.0f, 0.3f, 0.0f);
             QuadTextureNgui gui = GetTransform().GetChild(0).GetComponent <QuadTextureNgui>();
             gui.ScaleFactor = 0.5f;
             endAttack       = true;
             canAttack       = false;
         }
         else
         {
             if (curEnemy != null)
             {
                 GameObject  bulletgo = (GameObject)GameObject.Instantiate(Resources.Load("laserbullet"));
                 LaserBullet bullet   = bulletgo.GetComponent <LaserBullet>();
                 bulletgo.transform.position = GetTransform().position + GetTransform().forward * 0.6f;
                 //bulletgo.transform.position = gun.position ;
                 bullet.parent10 = this;
                 if (enemyLists.Count > 0)
                 {
                     for (int i = 0; i < EnemySpawnManager._instance.enemyList.Count; i++)
                     {
                         for (int j = 0; j < enemyLists.Count; j++)
                         {
                             if (EnemySpawnManager._instance.enemyList[i].ID == enemyLists[j].ID)
                             {
                                 curEnemy = enemyLists[j];
                                 break;
                             }
                         }
                         if (curEnemy != null)
                         {
                             break;
                         }
                     }
                     if (curEnemy != null)
                     {
                         AudioSource.PlayClipAtPoint(AudioManager._instance.tower10FireMusic, this.GetPos());
                         bullet.Fire(curEnemy);
                     }
                     Vector3 dir = Vector3.back * moveDistance;
                     GetTransform().GetChild(0).localPosition = new Vector3(dir.x, dir.y + 0.3f, dir.z);
                     QuadTextureNgui gui = GetTransform().GetChild(0).GetComponent <QuadTextureNgui>();
                     gui.ScaleFactor = scalefactor;
                     curFps++;
                 }
                 else if (enemyLists.Count == 0)
                 {
                     curEnemy = null;
                     return;
                 }
             }
         }
     }
 }