public void InitializeSimulation() { if (this.yellowTeam != null) { //AI Unit spawning. GameObject obj = MonoBehaviour.Instantiate(this.AIUnitPrefab) as GameObject; obj.transform.SetParent(this.yellowTeamUnits.transform); obj.transform.position = this.yellowTeamStartPosiiton.position; AIUnit unit = obj.GetComponent <AIUnit>(); //AI manager spawning. AIManager AImanager = this.yellowTeam.GetComponentInChildren <AIManager>(); if (AImanager != null) { this.yellowTeamAI = AImanager; unit.unitManager = AImanager; unit.teamFaction = AImanager.teamFaction; unit.SetTeamColor(YELLOW_TEAM_INDEX); AImanager.Deactivate(); } } if (this.blueTeam != null) { //AI Unit spawning. GameObject obj = MonoBehaviour.Instantiate(this.AIUnitPrefab) as GameObject; obj.transform.SetParent(this.blueTeamUnits.transform); obj.transform.position = this.blueTeamUnits.position; AIUnit unit = obj.GetComponent <AIUnit>(); //AI manager spawning. AIManager AImanager = this.blueTeam.GetComponentInChildren <AIManager>(); if (AImanager != null) { this.blueTeamAI = AImanager; unit.unitManager = AImanager; unit.teamFaction = AImanager.teamFaction; unit.SetTeamColor(BLUE_TEAM_INDEX); AImanager.Deactivate(); } } }
public void Start() { this.timePauseCounter = 1f; if (this.redTeamUnits != null) { int childs = this.redTeamUnits.transform.childCount; for (int i = childs; i > 0; i--) { MonoBehaviour.Destroy(this.redTeamUnits.transform.GetChild(i - 1).gameObject); } } if (this.blueTeamUnits != null) { int childs = this.blueTeamUnits.transform.childCount; for (int i = childs; i > 0; i--) { MonoBehaviour.Destroy(this.blueTeamUnits.transform.GetChild(i - 1).gameObject); } } if (this.redTeam != null) { //AI Unit spawning. GameObject obj = MonoBehaviour.Instantiate(this.AIUnitPrefab) as GameObject; obj.transform.SetParent(this.redTeamUnits.transform); obj.transform.position = this.redTeamStartPosiiton.position; AIUnit unit = obj.GetComponent <AIUnit>(); //AI manager spawning. AIManager AImanager = this.redTeam.GetComponentInChildren <AIManager>(); if (AImanager != null) { this.redTeamAI = AImanager; unit.unitManager = AImanager; unit.teamFaction = AImanager.teamFaction; unit.SetTeamColor(0); AImanager.Activate(); } } if (this.blueTeam != null) { //AI Unit spawning. GameObject obj = MonoBehaviour.Instantiate(this.AIUnitPrefab) as GameObject; obj.transform.SetParent(this.blueTeamUnits.transform); obj.transform.position = this.blueTeamUnits.position; AIUnit unit = obj.GetComponent <AIUnit>(); unit.SetTeamColor(1); //AI manager spawning. AIManager AImanager = this.blueTeam.GetComponentInChildren <AIManager>(); if (AImanager != null) { this.blueTeamAI = AImanager; unit.unitManager = AImanager; unit.teamFaction = AImanager.teamFaction; unit.SetTeamColor(1); AImanager.Activate(); } } this.gameMatchStart = true; }