示例#1
0
 private void RemovalFromTower()
 {
     if (_tower != null)
     {
         _tower.RemoveSpher(this);
         _tower = null;
     }
 }
示例#2
0
 void Start()
 {
     isEndGame                     = true;
     isEnemyTowerDead              = false;
     isPlayerTowerDead             = false;
     GameManager.Instance.gameMode = GameMode.Level;
     CheckTowerUpdate();
     playerUnitData = PlayerTower.GetComponent <UnitData>();
     enemyUnitData  = EnemyTower.GetComponent <UnitData>();
 }
示例#3
0
 void OnCollisionEnter2D(Collision2D collision)
 {
     if (collision.gameObject.name == "right tower")
     {
         EnemyTower tower = collision.gameObject.GetComponent <EnemyTower>();
         tower.health = tower.health - this.power;
         Destroy(gameObject);
     }
     else //if (collision.gameObject.name == "EnemyShot(Clone)")
     {
         EnemyWave enemy = collision.gameObject.GetComponent <EnemyWave>();
         if (enemy.power > this.power)
         {
             enemy.power = enemy.power - this.power;
             collision.gameObject.GetComponent <Transform>().transform.localScale = new Vector3(0.2f + power * 0.3f, 0.2f + power * 0.3f);
             Destroy(this.gameObject);
         }
         else if (enemy.power < this.power)
         {
             this.power           = this.power - enemy.power;
             transform.localScale = new Vector3(0.2f + power * 0.3f, 0.2f + power * 0.3f);
             Destroy(collision.gameObject);
             transform.right = startV;
         }
         else if (enemy.power == this.power)
         {
             if (this.transform.position.x < 0)
             {
                 GameObject.Find("right tower").GetComponent <EnemyTower>().energy++;
             }
             else if (this.transform.position.x > 0)
             {
                 GameObject.Find("left tower").GetComponent <PlayerTower>().energy++;
             }
             Destroy(collision.gameObject);
             Destroy(gameObject);
         }
     }
 }
示例#4
0
    public void Initialization(EnemyTower tower, bool armored, bool quick)
    {
        _tower          = tower;
        SpeedMultiplier = 1;

        if (armored)
        {
            if (_helmet)
            {
                _helmet.gameObject.SetActive(true);
            }
            _health++;
        }
        else if (quick)
        {
            if (_quickMateril != null)
            {
                _mesh.material = _quickMateril;
            }
            SpeedMultiplier = _speedQuickMultiplier;
        }
    }
示例#5
0
    void Update()
    {
        playerHealth = playerUnitData.dataHealth.Health;

        if (playerUnitData.dataHealth.Health <= 0)
        {
            #region Audio
            if (isEndGame)
            {
                AudioManager.Instance.AudioSource.Stop();
                AudioManager.Instance.AudioSource.PlayOneShot(AudioManager.Instance.Lose, 0.1f);
                isEndGame = false;
            }
            #endregion
            Explosion.transform.position = new Vector2(X_PlayerCord, Ycord);
            Explosion.SetActive(true);
            PlayerTower.SetActive(false);
            isPlayerTowerDead = true;
            Invoke("StopTime", 1f);
        }
        else if (enemyUnitData.dataHealth.Health <= 0)
        {
            #region Audio
            if (isEndGame)
            {
                AudioManager.Instance.AudioSource.Stop();
                AudioManager.Instance.AudioSource.PlayOneShot(AudioManager.Instance.Win, 0.1f);
                isEndGame = false;
            }
            #endregion
            Explosion.transform.position = new Vector2(X_EnemyCord, Ycord);
            Explosion.SetActive(true);
            EnemyTower.SetActive(false);
            isEnemyTowerDead = true;
            Invoke("StopTime", 1f);
        }
    }