public void SpawnRandomEnemyOnSide(List <Transform> sideSpawn) { GameObject player; // Make sure we can still spawn enemies if (sideSpawn == leftMapEnemySpawns) { if (leftSideEnemies.Count > maxEnemiesPerSide - 1) { return; } player = playerOne; } else { if (rightSideEnemies.Count > maxEnemiesPerSide - 1) { return; } player = playerTwo; } Vector3 spawnPos = GetRandomCircleSpawnPosisiton(sideSpawn); GameObject enemy = Instantiate(werewolfPrefab, spawnPos, Quaternion.LookRotation(spawnPos - player.transform.position)); AIStateMachine stateMachine = enemy.GetComponent <AIStateMachine>(); if (stateMachine) { if (sideSpawn == leftMapEnemySpawns) { stateMachine.isLeftMapEnemy = true; stateMachine.AssignPlayerTarget(playerOne.GetComponent <PlayerControl>()); leftSideEnemies.Add(enemy.gameObject); } else { stateMachine.isLeftMapEnemy = false; stateMachine.AssignPlayerTarget(playerTwo.GetComponent <PlayerControl>()); rightSideEnemies.Add(enemy.gameObject); } } }
public void DoSetEnemySpawn(List <Transform> sideSpawn, Vector3 spawnPos, Quaternion spawnRot) { GameObject enemy = Instantiate(werewolfPrefab, spawnPos, spawnRot); AIStateMachine stateMachine = enemy.GetComponent <AIStateMachine>(); if (stateMachine) { if (sideSpawn == leftMapEnemySpawns) { stateMachine.isLeftMapEnemy = true; stateMachine.AssignPlayerTarget(playerOne.GetComponent <PlayerControl>()); leftSideEnemies.Add(enemy.gameObject); } else { stateMachine.isLeftMapEnemy = false; stateMachine.AssignPlayerTarget(playerTwo.GetComponent <PlayerControl>()); rightSideEnemies.Add(enemy.gameObject); } } }