private void Run() { if (!_Display.HasFort()) { _Fort = _FortFactory.CreateFort(); _Display.BuildFort(_Fort); for (int i = 0; i < _SpawnerPool.Count; i++) { ISpawner s = GetSpawner(i); Thread th = new Thread(new ThreadStart(s.Run)); th.Start(); } } while (_Running) { if (_Fort.isDead()) { foreach (var entry in _Livables) { entry.Key.Die(); } //_Livables.Clear(); _AnimationQueue.Clear(); foreach (var entry in _SpawnerPool) { entry.Stop(); } Display.End(); Display.Gameover(); _Running = false; } } }
public void BuildFort(IFort fort) { _Fort = fort; _FortLocation = width - 10; for (int i = 0; i < height; i++) { Console.SetCursorPosition(_FortLocation, i); Console.Write("|"); } UpdateFort(); }
public void BuildAllPossibleSourceBuilding() { int hexaID; ITown town; IHexa hexa; for (int loop1 = 1; loop1 < mapController.GetMaxTownID(); loop1++) { for (byte loop2 = 0; loop2 < 3; loop2++) { town = mapController.GetITownByID(loop1); hexa = town.GetIHexa(loop2); hexaID = hexa.GetID(); if (turn > 10) { if (hexa.GetStartSource() <= 12) { if (!hasFort) { if ((myFort = town.BuildFort(loop2)) != null) { hasFort = true; } continue; } else if (!hasMarket) { if (mapController.BuildBuildingInTown(loop1, hexaID, BuildingKind.MarketBuilding)) { hasMarket = true; } continue; } if (!hasMonastery) { if (mapController.BuildBuildingInTown(loop1, hexaID, BuildingKind.MonasteryBuilding)) { hasMonastery = true; } continue; } } } mapController.BuildBuildingInTown(loop1, hexaID, BuildingKind.SourceBuilding); } } }
public void AddFort(IFort f) { fort.Add(f); }
public static void SetHexaFort(IFort fort) { hexaFort = fort; }
public bool DestroyHexa(int hexaID, IFort fort) { if (CanDestroyHexa(hexaID, fort) == DestroyHexaError.OK) { HexaModel hexa = map.GetHexaByID(hexaID); SourceAll source = new SourceAll(0); int amount = gm.GetRandomInt(70) + ((hexa.GetDestroyed()) ? 0 : 70); hexa.Destroy(); switch(hexa.GetKind()) { case HexaKind.Cornfield : source = new SourceAll(amount, 0, 0, 0, 0); break; case HexaKind.Pasture : source = new SourceAll(0, amount, 0, 0, 0); break; case HexaKind.Stone : source = new SourceAll(0, 0, amount, 0, 0); break; case HexaKind.Forest : source = new SourceAll(0, 0, 0, amount, 0); break; case HexaKind.Mountains : source = new SourceAll(0, 0, 0, 0, amount); break; } gm.GetActivePlayer().PayForSomething(Settings.costFortCrusade - source); gm.GetActivePlayer().AddFortAction(); return true; } return false; }
public bool CaptureHexa(int hexaID, IFort fort) { if (CanCaptureHexa(hexaID, fort) == CaptureHexaError.OK) { HexaModel hexa = map.GetHexaByID(hexaID); Player player = gm.GetActivePlayer(); hexa.Capture(player); player.PayForSomething(Settings.costFortCapture); player.AddFortAction(); player.AddPoints(PlayerPoints.FortCaptureHexa); return true; } return false; }
public DestroyHexaError CanDestroyHexa(int hexaID, IFort fort) { if (!Settings.costFortCrusade.HasPlayerSources(gm.GetActivePlayer())) { SetLastError(Strings.ERROR_NO_SOURCES); return DestroyHexaError.NoSources; } if (fort == null) return DestroyHexaError.OK; HexaModel.SetHexaFort(fort); HexaModel hexa = map.GetHexaByID(hexaID); if (hexa == null) { SetLastError(Strings.ERROR_INVALID_HEXA_ID); return DestroyHexaError.InvalidHexaID; } if (!hexa.IsInFortRadius()) { SetLastError(Strings.ERROR_TOO_FAR_FROM_FORT); return DestroyHexaError.TooFarFromFort; } /* if (hexa.GetDestroyed()) { SetLastError(Strings.ERROR_INVALID_HEXA_ID); return DestroyHexaError.IsDestroyed; }*/ return DestroyHexaError.OK; }
public CaptureHexaError CanCaptureHexa(int hexaID, IFort fort) { HexaModel hexa = map.GetHexaByID(hexaID); HexaModel.SetHexaFort(fort); if (!hexa.IsInFortRadius()) { SetLastError(Strings.ERROR_TOO_FAR_FROM_FORT); return CaptureHexaError.TooFarFromFort; } if (Settings.banFortCaptureHexa) { SetLastError(Strings.ERROR_BAN_FORT_CAPTURE_HEXA); return CaptureHexaError.Ban; } if (!Settings.costFortCapture.HasPlayerSources(gm.GetActivePlayer())) { SetLastError(Strings.ERROR_NO_SOURCES); return CaptureHexaError.NoSources; } if (hexa.GetKind() == HexaKind.Desert || hexa.GetKind() == HexaKind.Water || hexa.GetKind() == HexaKind.Null) return CaptureHexaError.Desert; if (hexa == null) { SetLastError(Strings.ERROR_INVALID_HEXA_ID); return CaptureHexaError.InvalidHexaID; } return CaptureHexaError.OK; }