public void CmdSpeedUpEnemies(int skillCost, int plusSpeed) { playerSkill.decreaseBar(skillCost); enemy = GameObject.FindGameObjectsWithTag("Enemy"); for (int i = 0; i < enemy.Length; i++) { float yPositionOffset = enemy[i].transform.position.y - gameObject.transform.position.y; if (yPositionOffset > 1 || yPositionOffset < -1) //We speed up the enemy on the opposition bridge { enemyMovement = enemy[i].GetComponent <EnemyMovementMult>(); enemyMovement.speed += plusSpeed; } } Debug.Log("Enemy Speed Increased"); }
void Awake() { GameObject[] players = GameObject.FindGameObjectsWithTag("Player"); //get all the players on the scene //Get the player that the enemy will track //It will track the player that is standing on the same 'bridge' for (int i = 0; i < 2; i++) { float playerLocationOffset = gameObject.transform.position.y - players[i].transform.position.y; if ((playerLocationOffset < Center) && (playerLocationOffset > -(Center))) { playerSkill = players[i].GetComponent <PlayerSkillMult>(); playerScore = players[i].GetComponent <PlayerScore>(); } } anim = GetComponent <Animator> (); currentHealth = startingHealth; enemyMovement = GetComponent <EnemyMovementMult> (); enemyAttack = GetComponent <EnemyAttackMult> (); }