/// <summary> /// Erzeugt eine neue Instanz der Volk-Klasse. Erzeugt ein Ameisen-Volk. /// </summary> /// <param name="spielfeld">Das Spielfeld.</param> /// <param name="spieler">Das Spieler zu dem das Volk gehört.</param> /// <param name="team">Das dazugehörige Team.</param> internal CoreColony(CorePlayground spielfeld, PlayerInfo spieler, CoreTeam team) { InitPlayground(spielfeld); Team = team; Player = spieler; Klasse = spieler.assembly.GetType(spieler.ClassName, true, false); // Basisameisenkaste erstellen, falls keine Kasten definiert wurden if (spieler.Castes.Count == 0) { spieler.Castes.Add(new CasteInfo()); } GeschwindigkeitI = new int[spieler.Castes.Count]; Drehgeschwindigkeit = new int[spieler.Castes.Count]; Last = new int[spieler.Castes.Count]; SichtweiteI = new int[spieler.Castes.Count]; Grids = new Grid <CoreInsect> [spieler.Castes.Count]; ReichweiteI = new int[spieler.Castes.Count]; Energie = new int[spieler.Castes.Count]; Angriff = new int[spieler.Castes.Count]; antsInCaste = new int[spieler.Castes.Count]; int index = 0; foreach (CasteInfo caste in spieler.Castes) { GeschwindigkeitI[index] = SimulationEnvironment.PLAYGROUND_UNIT; GeschwindigkeitI[index] *= SimulationSettings.Custom.CasteSettings[caste.Speed].Speed; Drehgeschwindigkeit[index] = SimulationSettings.Custom.CasteSettings[caste.RotationSpeed].RotationSpeed; Last[index] = SimulationSettings.Custom.CasteSettings[caste.Load].Load; SichtweiteI[index] = SimulationEnvironment.PLAYGROUND_UNIT; SichtweiteI[index] *= SimulationSettings.Custom.CasteSettings[caste.ViewRange].ViewRange; ReichweiteI[index] = SimulationEnvironment.PLAYGROUND_UNIT; ReichweiteI[index] *= SimulationSettings.Custom.CasteSettings[caste.Range].Range; Energie[index] = SimulationSettings.Custom.CasteSettings[caste.Energy].Energy; Angriff[index] = SimulationSettings.Custom.CasteSettings[caste.Attack].Attack; Grids[index] = Grid <CoreInsect> .Create ( spielfeld.Width *SimulationEnvironment.PLAYGROUND_UNIT, spielfeld.Height *SimulationEnvironment.PLAYGROUND_UNIT, SichtweiteI[index]); index++; } }
/// <summary> /// Initialisiert die Simulation um mit Runde 1 zu beginnen /// </summary> /// <param name="configuration">Konfiguration der Simulation</param> /// <throws><see cref="ArgumentException"/></throws> /// <throws><see cref="ArgumentNullException"/></throws> /// <throws><see cref="PathTooLongException"/></throws> /// <throws><see cref="DirectoryNotFoundException"/></throws> /// <throws><see cref="IOException"/></throws> /// <throws><see cref="UnauthorizedAccessException"/></throws> /// <throws><see cref="FileNotFoundException"/></throws> /// <throws><see cref="NotSupportedException"/></throws> /// <throws><see cref="SecurityException"/></throws> /// <throws><see cref="FileLoadException"/></throws> /// <throws><see cref="BadImageFormatException"/></throws> /// <throws><see cref="RuleViolationException"/></throws> /// <throws><see cref="TypeLoadException"/></throws> public void Init(SimulatorConfiguration configuration) { // Init some varialbes currentRound = 0; if (configuration.MapInitialValue != 0) { random = new Random(configuration.MapInitialValue); } else { random = new Random(); } // count players playerCount = 0; foreach (TeamInfo team in configuration.Teams) { playerCount += team.Player.Count; } // Sugar-relevant stuff sugarDelay = 0; sugarCountDown = (int)(SimulationSettings.Custom.SugarTotalCount * (1 + (SimulationSettings.Custom.SugarTotalCountPlayerMultiplier * playerCount))); sugarLimit = (int)(SimulationSettings.Custom.SugarSimultaneousCount * (1 + (SimulationSettings.Custom.SugarCountPlayerMultiplier * playerCount))); // Fruit-relevant stuff fruitDelay = 0; fruitCountDown = (int)(SimulationSettings.Custom.FruitTotalCount * (1 + (SimulationSettings.Custom.FruitTotalCountPlayerMultiplier * playerCount))); fruitLimit = (int)(SimulationSettings.Custom.FruitSimultaneousCount * (1 + (SimulationSettings.Custom.FruitCountPlayerMultiplier * playerCount))); // Ant-relevant stuff int antCountDown = (int)(SimulationSettings.Custom.AntTotalCount * (1 + (SimulationSettings.Custom.AntTotalCountPlayerMultiplier * playerCount))); antLimit = (int)(SimulationSettings.Custom.AntSimultaneousCount * (1 + (SimulationSettings.Custom.AntCountPlayerMultiplier * playerCount))); // Spielfeld erzeugen float area = SimulationSettings.Custom.PlayGroundBaseSize; area *= 1 + (playerCount * SimulationSettings.Custom.PlayGroundSizePlayerMultiplier); int playgroundWidth = (int)Math.Round(Math.Sqrt(area * 4 / 3)); int playgroundHeight = (int)Math.Round(Math.Sqrt(area * 3 / 4)); Playground = new CorePlayground(playgroundWidth, playgroundHeight, random, playerCount); // Bugs-relevant stuff Bugs = new CoreColony(Playground); Bugs.insectCountDown = (int)(SimulationSettings.Custom.BugTotalCount * (1 + (SimulationSettings.Custom.BugTotalCountPlayerMultiplier * playerCount))); bugLimit = (int)(SimulationSettings.Custom.BugSimultaneousCount * (1 + (SimulationSettings.Custom.BugCountPlayerMultiplier * playerCount))); // Völker erzeugen Teams = new CoreTeam[configuration.Teams.Count]; for (int i = 0; i < configuration.Teams.Count; i++) { TeamInfo team = configuration.Teams[i]; Teams[i] = new CoreTeam(i, team.Guid, team.Name); Teams[i].Colonies = new CoreColony[team.Player.Count]; // Völker erstellen for (int j = 0; j < team.Player.Count; j++) { PlayerInfo player = team.Player[j]; CoreColony colony = new CoreColony(Playground, player, Teams[i]); Teams[i].Colonies[j] = colony; colony.AntHills.Add(Playground.NeuerBau(colony.Id)); colony.insectCountDown = antCountDown; } } }