Exemplo n.º 1
0
    void HitAnimation()
    {
        Debug.Log("33");
        if (endAttack || canAttack == false)
        {
            return;
        }
        mHitDelta += RealTime.deltaTime;
        float rate = 0.5f;

        if (rate < mHitDelta)
        {
            mHitDelta = (rate > 0f) ? mHitDelta - rate : 0f;
            if (curFps > 0)
            {
                Debug.Log("11");
                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
            {
                Debug.Log("22");
                GameObject   bulletgo = (GameObject)GameObject.Instantiate(Resources.Load("cannonbullet"));
                CannonBullet bullet   = bulletgo.GetComponent <CannonBullet>();
                bulletgo.transform.position = GetTransform().position + GetTransform().forward * 0.6f;
                bullet.parent = this;
                curEnemy      = EnemySpawnManager._instance.enemyList[0];

                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++;
            }
        }
    }
Exemplo n.º 2
0
    void HitAni()
    {
        if (endAttack || canAttack == false)
        {
            return;
        }
        mHitDelta += RealTime.deltaTime;
        float rate = 1f / mFPS;

        if (rate < mHitDelta)
        {
            mHitDelta = (rate > 0f) ? mHitDelta - rate : 0f;
            if (curFps > 0)
            {
                curFps = 0;
                GetTransform().GetChild(0).localPosition = new Vector3(0.0f, 0.3f, 0.0f);
                QuadTexture4Ngui gui = GetTransform().GetChild(0).GetComponent <QuadTexture4Ngui>();
                gui.ScaleFactor = 0.5f;

                endAttack = true;
                canAttack = false;
            }
            else
            {
                GameObject bulletgo = (GameObject)GameObject.Instantiate(Resources.Load("cannonbullet"));

                CannonBullet bullet = bulletgo.GetComponent <CannonBullet>();
                Transform    gun    = GetTransform().GetChild(0);
                bulletgo.transform.position = GetTransform().position + GetTransform().forward * 0.6f;

                bullet.parent = this;

                bullet.Fire(curEnemy.GetTransform().gameObject);
                Vector3 dir = Vector3.back * moveDistance;
                GetTransform().GetChild(0).localPosition = new Vector3(dir.x, dir.y + 0.3f, dir.z);
                QuadTexture4Ngui gui = GetTransform().GetChild(0).GetComponent <QuadTexture4Ngui>();
                gui.ScaleFactor = scaleFactor;
                ++curFps;
            }
        }
    }
Exemplo n.º 3
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("cannonbullet1"));
                 CannonBullet bullet   = bulletgo.GetComponent <CannonBullet>();
                 bulletgo.transform.position = GetTransform().position + GetTransform().forward * 0.6f;
                 bullet.parent2 = this;
                 if (curEnemy != null)
                 {
                     AudioSource.PlayClipAtPoint(AudioManager._instance.tower2FireMusic, 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++;
             }
             if (secondEnemy != null)
             {
                 GameObject   bulletgo1 = (GameObject)GameObject.Instantiate(Resources.Load("cannonbullet2"));
                 CannonBullet bullet1   = bulletgo1.GetComponent <CannonBullet>();
                 bulletgo1.transform.position = GetTransform().position + GetTransform().forward * 0.6f;
                 //bulletgo.transform.position = gun.position ;
                 bullet1.parent2 = this;
                 if (secondEnemy != null)
                 {
                     bullet1.Fire(secondEnemy);
                 }
                 Vector3 dir1 = Vector3.back * moveDistance;
                 GetTransform().GetChild(0).localPosition = new Vector3(dir1.x, dir1.y + 0.3f, dir1.z);
                 QuadTextureNgui gui1 = GetTransform().GetChild(0).GetComponent <QuadTextureNgui>();
                 gui1.ScaleFactor = scalefactor;
                 curFps++;
             }
             if (thirdEnemy != null)
             {
                 GameObject   bulletgo2 = (GameObject)GameObject.Instantiate(Resources.Load("cannonbullet3"));
                 CannonBullet bullet2   = bulletgo2.GetComponent <CannonBullet>();
                 bulletgo2.transform.position = GetTransform().position + GetTransform().forward * 0.6f;
                 //bulletgo.transform.position = gun.position ;
                 bullet2.parent2 = this;
                 if (thirdEnemy != null)
                 {
                     bullet2.Fire(thirdEnemy);
                 }
                 Vector3 dir1 = Vector3.back * moveDistance;
                 GetTransform().GetChild(0).localPosition = new Vector3(dir1.x, dir1.y + 0.3f, dir1.z);
                 QuadTextureNgui gui1 = GetTransform().GetChild(0).GetComponent <QuadTextureNgui>();
                 gui1.ScaleFactor = scalefactor;
                 curFps++;
             }
             if (forthEnemy != null)
             {
                 GameObject   bulletgo3 = (GameObject)GameObject.Instantiate(Resources.Load("cannonbullet4"));
                 CannonBullet bullet3   = bulletgo3.GetComponent <CannonBullet>();
                 bulletgo3.transform.position = GetTransform().position + GetTransform().forward * 0.6f;
                 //bulletgo.transform.position = gun.position ;
                 bullet3.parent2 = this;
                 if (forthEnemy != null)
                 {
                     bullet3.Fire(forthEnemy);
                 }
                 Vector3 dir1 = Vector3.back * moveDistance;
                 GetTransform().GetChild(0).localPosition = new Vector3(dir1.x, dir1.y + 0.3f, dir1.z);
                 QuadTextureNgui gui1 = GetTransform().GetChild(0).GetComponent <QuadTextureNgui>();
                 gui1.ScaleFactor = scalefactor;
                 curFps++;
             }
         }
     }
 }
Exemplo n.º 4
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 = BulletPool.instance.Pop();
                 CannonBullet bullet   = bulletgo.GetComponent <CannonBullet>();
                 bullet.move = true;
                 bulletgo.transform.position = GetTransform().position + GetTransform().forward * 0.6f;
                 bullet.parent1 = 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.tower1FireMusic, 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;
                 }
             }
         }
     }
 }