Ejemplo n.º 1
0
 // Update is called once per frame
 void Update()
 {
     playerControls = this.GetComponent <PlayerController>();
     if (!playerControls.playerBench && combatState)
     {
         target = findEnemy();
         if (target != null)
         {
             targetCoords = target.transform.position;
             anim.SetBool("IsWalking", true);
             if (findDistance(this.transform.position, targetCoords) < range)
             {
                 anim.SetBool("IsWalking", false);
                 agent.isStopped = true;
                 timer          -= Time.deltaTime;
                 if (timer < 0)
                 {
                     if (target.GetComponent <Warrior_Enemy>() != null)
                     {
                         Warrior_Enemy instance = target.GetComponent <Warrior_Enemy>();
                         instance.takeDamage(attack());
                     }
                     else if (target.GetComponent <Assasin_Enemy>() != null)
                     {
                         Assasin_Enemy instance = target.GetComponent <Assasin_Enemy>();
                         instance.takeDamage(attack());
                     }
                     else if (target.GetComponent <FireBenderEnemy>() != null)
                     {
                         FireBenderEnemy instance = target.GetComponent <FireBenderEnemy>();
                         instance.takeDamage(attack());
                     }
                     else if (target.GetComponent <WaterBender_Enemy>() != null)
                     {
                         WaterBender_Enemy instance = target.GetComponent <WaterBender_Enemy>();
                         instance.takeDamage(attack());
                     }
                     else if (target.GetComponent <EarthBender_Enemy>() != null)
                     {
                         EarthBender_Enemy instance = target.GetComponent <EarthBender_Enemy>();
                         instance.takeDamage(attack());
                     }
                     else if (target.GetComponent <Airbender_Enemy>() != null)
                     {
                         Airbender_Enemy instance = target.GetComponent <Airbender_Enemy>();
                         instance.takeDamage(attack());
                     }
                 }
             }
             else
             {
                 agent.isStopped = false;
                 agent.SetDestination(targetCoords);
             }
         }
     }
 }
Ejemplo n.º 2
0
    public void turnOnCombat()
    {
        enemyArray  = GameObject.FindGameObjectsWithTag("Enemy_Piece");
        playerArray = GameObject.FindGameObjectsWithTag("Player_Piece");

        for (int i = 0; i < enemyArray.Length; ++i)
        {
            if (enemyArray[i].GetComponent <Warrior_Enemy>() != null)
            {
                Warrior_Enemy instance = enemyArray[i].GetComponent <Warrior_Enemy>();
                instance.isCombat();
            }
            else if (enemyArray[i].GetComponent <Assasin_Enemy>() != null)
            {
                Assasin_Enemy instance = enemyArray[i].GetComponent <Assasin_Enemy>();
                instance.isCombat();
            }
            else if (enemyArray[i].GetComponent <FireBenderEnemy>() != null)
            {
                FireBenderEnemy instance = enemyArray[i].GetComponent <FireBenderEnemy>();
                instance.isCombat();
            }
            else if (enemyArray[i].GetComponent <WaterBender_Enemy>() != null)
            {
                WaterBender_Enemy instance = enemyArray[i].GetComponent <WaterBender_Enemy>();
                instance.isCombat();
            }
            else if (enemyArray[i].GetComponent <EarthBender_Enemy>() != null)
            {
                EarthBender_Enemy instance = enemyArray[i].GetComponent <EarthBender_Enemy>();
                instance.isCombat();
            }
            else if (enemyArray[i].GetComponent <Airbender_Enemy>() != null)
            {
                Airbender_Enemy instance = enemyArray[i].GetComponent <Airbender_Enemy>();
                instance.isCombat();
            }
        }

        for (int i = 0; i < playerArray.Length; ++i)
        {
            if (playerArray[i].GetComponent <AirBender>() != null)
            {
                AirBender instance = playerArray[i].GetComponent <AirBender>();
                instance.isCombat();
            }
            else if (playerArray[i].GetComponent <Assasin>() != null)
            {
                Assasin instance = playerArray[i].GetComponent <Assasin>();
                instance.isCombat();
            }
            else if (playerArray[i].GetComponent <EarthBender>() != null)
            {
                EarthBender instance = playerArray[i].GetComponent <EarthBender>();
                instance.isCombat();
            }
            else if (playerArray[i].GetComponent <FireBender>() != null)
            {
                FireBender instance = playerArray[i].GetComponent <FireBender>();
                instance.isCombat();
            }
            else if (playerArray[i].GetComponent <Warrior>() != null)
            {
                Warrior instance = playerArray[i].GetComponent <Warrior>();
                instance.isCombat();
            }
            else if (playerArray[i].GetComponent <WaterBender>() != null)
            {
                WaterBender instance = playerArray[i].GetComponent <WaterBender>();
                instance.isCombat();
            }
        }
    }