void SpawnTrees() { trees = new List <GameObject>(); Vector3[] treeSpawnLocations = mapInitializer.GenerateSpawns(5.18442f, 5.448769f, true); for (int i = 0; i < numTrees; i++) { trees.Add(Instantiate(treePrefab, treeSpawnLocations[i], Quaternion.identity)); } }
void Start() { GLOBALS = GlobalVariables.Instance; gameState = GameState.LoadingScene; isTurnFinished = false; //Set initial state Time.timeScale = 1.0f; //Set normal time for game to run PlaneSpawnPoint = new Vector3(GLOBALS.mapXMax + 50f, GLOBALS.mapYMax + 20f, 0); //Initialize array to hold each soldier object team[Team][Avatar] teams = new GameObject[GLOBALS.numTeams, GLOBALS.teamSize]; //Initialize array to hold health of each soldier of each team soldiersHealth = new int[GLOBALS.numTeams, GLOBALS.teamSize]; //Initialize array to hold health of each team teamsHealth = new int[GLOBALS.numTeams]; //default value is already 0 //Initialize array to keep track of turn of soldiers, since each team will have a different order currSoldierTurn = Enumerable.Repeat(-1, GLOBALS.numTeams).ToArray(); //initialize Array with -1 currTeamTurn = -1; //-1 since we always add 1 when starting a turn //Get reference to this GameManager component on this object thisGM = gameObject.GetComponent <GameManager>(); GLOBALS.GM = thisGM; /****** Call Map generator and get spawn locations for players*******/ spawnLocations = mapInitializer.GenerateSpawns(1.503002f, 2.663491f, false); //mapInitializer = gameObject.GetComponent<MapInitializer>(); int count = 0; //Create Teams PlayerSettings.arsenalAmmo = new List <List <int> >(); for (int i = 0; i < GLOBALS.numTeams; i++) { List <int> subArsenal = new List <int>(); for (int weaponCode = 0; weaponCode < GLOBALS.arsenalAmmo.Count; weaponCode++) { subArsenal.Add(GLOBALS.arsenalAmmo[weaponCode]); } PlayerSettings.arsenalAmmo.Add(subArsenal); for (int j = 0; j < GLOBALS.teamSize; j++) { //Spawn Player teams[i, j] = Instantiate(soldierPrefab, spawnLocations[count++], transform.rotation); //teams[i, j].GetComponent<AIController>().GM = thisGM; ps = teams[i, j].GetComponent <PlayerSettings>(); ps.gameManager = thisGM; //Self reference to each soldier to keep contact ps.cam = cam; //pass camera reference ps.SetColor(GLOBALS.teamColors[i]); ps.teamID = i; //set team id (unique for each team) ps.ID = j; //set player id (unique inside each team) ps.iAmAI = GLOBALS.isTeamAI[i]; //Mark Soldier as AI or not if (GLOBALS.teams[i] != null) { ps.nameGiven = GLOBALS.teams[i].roster[j].playerName; } else { ps.nameGiven = GLOBALS.teamNames[i, j];//GLOBALS.teams[i].roster[j].playerName; } //Set Health of player teams[i, j].GetComponent <DamageHandler>().SetHealth(GLOBALS.healthPerAvatar); soldiersHealth[i, j] = GLOBALS.healthPerAvatar; //Add Heath of this soldier to the team health teamsHealth[i] += GLOBALS.healthPerAvatar; //Deactivate movement script. teams[i, j].GetComponent <PlayerSettings>().isMyTurn = false; } } //Check if GLOBALS.TimePerGame have a valid time if (GLOBALS.TimePerGame <= 0) { GLOBALS.TimePerGame = (float)(GLOBALS.timePerTurn * GLOBALS.numTeams * 5f); //around 5 turns per team } //Start gameClock Timer coroutineGameClock = SetGameClock(GLOBALS.TimePerGame); StartCoroutine(coroutineGameClock); coroutineStarted = false; gameState = GameState.TurnTransition; AudioListener.pause = false;//un-pause all sound affected by time }