Skip to content

Instantly share code, notes, and snippets.

@giljr
Created March 4, 2018 21:41
Show Gist options
  • Save giljr/480664e225971acd951bff3567806e9f to your computer and use it in GitHub Desktop.
Save giljr/480664e225971acd951bff3567806e9f to your computer and use it in GitHub Desktop.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class EnemyController : MonoBehaviour {
public Soldier[] Enemies;
// Use this for initialization
void Start () {
/* transfered to the Update()
* foreach (Soldier Enemy in Enemies)
{
Enemy.Activate();
}*/
}
// Update is called once per frame
void Update () {
foreach (Soldier enemy in Enemies)
{
//Enemy.Activate();
//If not active, return, so I do not activate another one
if(enemy.IsActive)
{
return;
}
}
//TODO: Check if the soldier are active
int idxSoldier = Random.Range(0, Enemies.Length);
Enemies[idxSoldier].Activate();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment