Exemplo n.º 1
0
 public EnemyCorpse(GameObject[] enemyKind, UnityAction <int> reachEdge, UnityAction <int> onClush, UnityAction onDeath)
 {
     enemyLine = new EnemyLine[GS.CORPSE_HEIGHT];
     for (int i = 0; i < GS.CORPSE_HEIGHT; i++)
     {
         float y = GS.ENEMY_HEIGHT_OFFSET + GS.ENEMY_HEIGHT * (i - GS.CORPSE_HEIGHT / 2);
         enemyLine[i] = new EnemyLine(enemyKind[i], y, reachEdge, onClush, onDeath);
     }
 }
Exemplo n.º 2
0
    public void DropOffWeapon(GameObject weaponDroppingOff)
    {
        Weapon weaponType = Weapon.None;

        if (weaponDroppingOff.name.Contains("Finished Axe"))
        {
            weaponType = Weapon.Axe;
        }
        else if (weaponDroppingOff.name.Contains("Finished Sword"))
        {
            weaponType = Weapon.Sword;
        }
        else if (weaponDroppingOff.name.Contains("Finished Shield"))
        {
            weaponType = Weapon.Shield;
        }

        if (weaponRequired == weaponType)
        {
            // Reward players
            // Play any feedback (audio, particle effects)

            EnemyLine enemyLine = this.GetComponentInParent <EnemyLine>();
            enemyLine.SlowDownMovement();

            // Increase weapon count
            LevelOneController levelOneController = GameObject.FindGameObjectWithTag("GameController").GetComponent <LevelOneController>();
            if (levelOneController)
            {
                switch (weaponType)
                {
                case Weapon.Shield:
                    levelOneController.IncreaseShieldCount();
                    break;

                case Weapon.Sword:
                    levelOneController.IncreaseSwordCount();
                    break;

                case Weapon.Axe:
                    levelOneController.IncreaseAxeCount();
                    break;
                }
            }

            Destroy(weaponDroppingOff);
            Destroy(this.gameObject);
        }
    }
Exemplo n.º 3
0
    void UpdateTimer()
    {
        dropoffTimer += Time.deltaTime;

        anim.speed = 1 + (dropoffTimer / destroyTime) * 2;

        if (dropoffTimer >= destroyTime)
        {
            EnemyLine enemyLine = this.GetComponentInParent <EnemyLine>();
            enemyLine.SpeedUpMovement();
            Destroy(this.gameObject);
        }
        else
        {
            fillImage.fillAmount = dropoffTimer / destroyTime;
        }
    }
Exemplo n.º 4
0
 void OnTriggerEnter2D(Collider2D other)
 {
     //moi lam demo thoi
     //sau nay kiem tra int cua Type neu > 10 thi moi thuc hien
     if (this.type == MAPTYPE.BLOCK || this.type == MAPTYPE.TREE || this.type == MAPTYPE.WOOD || this.type == MAPTYPE.BORDER)
     {
         if (other.tag == "Player")
         {
             this.OnCollision();
         }
         if (other.tag == "Enemy")
         {
             EnemyLine enemy = other.transform.parent.gameObject.GetComponent <EnemyLine>();
             if (enemy != null)
             {
                 enemy.TurnRandom();
             }
         }
     }
 }