public void CreateNewBase(GameTime gametime) { if ((int)gametime.TotalGameTime.TotalMilliseconds % 10000 != 0) { return; } var structure = StructureLayoutHolder.GetStructureOnMap(mAi.Difficulty, ref mDirector); mAi.AddStructureToGame(structure.GetFirst(), structure.GetSecond()); }
public void CreateNewBase(GameTime gametime) { if (mBaseCount > 0 && !mActive) { // don't build any further bases when the AI isn't active. return; } if (!(mDirector.GetMilitaryManager.PlayerPlatformCount > PlatformCountNewBaseTrigger * mBaseCount || mDirector.GetMilitaryManager.PlayerDefensePlatformCount > DefensePlatformCountNewBaseTrigger * mBaseCount)) { return; } var requestNewPlatform = false; Pair <Triple <CommandCenter, List <PlatformBlank>, List <Road> >, Rectangle> baseToAdd; do { baseToAdd = StructureLayoutHolder.GetStructureOnMap(mAi.Difficulty, ref mDirector); // make sure the base is atleast a certain distance away from the player at start if (Vector2.Distance( mDirector.GetStoryManager.StructureMap.GetPlatformList().First().AbsolutePosition, new Vector2(baseToAdd.GetSecond().Center.X, baseToAdd.GetSecond().Center.Y)) < FirstBaseDistance) { requestNewPlatform = true; continue; } // make sure the new structure doesn't overlap with an existing enemy structure if (mBaseCount <= 0) { break; } foreach (var rect in mCollidingRects) { if (!rect.Intersects(baseToAdd.GetSecond())) { continue; } requestNewPlatform = true; break; } } while (requestNewPlatform); mAi.AddStructureToGame(baseToAdd.GetFirst(), baseToAdd.GetSecond()); mCollidingRects.Add(baseToAdd.GetSecond()); var spawners = mAi.GetSpawners(); if (spawners.Count <= mBaseCount || spawners[mBaseCount].Count <= 0) { // we don't have any spawners available in the given structure thus not able to spawn any enemy units. mBaseCount++; return; } SpawnOneUnit(EEnemyType.Scout, mAi.GetSpawners()[mBaseCount][0]); // also generate some defending units, note that these don't move away from their base, but are more or less stationary defenders. SpawnOneUnit(EEnemyType.Defend, mAi.GetSpawners()[mBaseCount][0]); SpawnOneUnit(EEnemyType.Defend, mAi.GetSpawners()[mBaseCount][0]); SpawnOneUnit(EEnemyType.Defend, mAi.GetSpawners()[mBaseCount][0]); SpawnOneUnit(EEnemyType.Defend, mAi.GetSpawners()[mBaseCount][0]); SpawnOneUnit(EEnemyType.Defend, mAi.GetSpawners()[mBaseCount][0]); mBaseCount++; }