/// <summary> /// Adds the color at the given coordinates to be painted during the next loop /// </summary> /// <param name="elementCoordinates"></param> /// <param name="qualifier"></param> public void SetDynamicElement(ICoordinates elementCoordinates, DisplayQualifier qualifier) { if (!this.UpdatedElements.ContainsKey(elementCoordinates)) this.UpdatedElements.Add(elementCoordinates, this.colorPanel.GetCorrespondingColor(qualifier)); else if (this.UpdatedElements[elementCoordinates] == this.BackgroundGrid[elementCoordinates.X, elementCoordinates.Y].GetColor()) this.UpdatedElements[elementCoordinates] = this.colorPanel.GetCorrespondingColor(qualifier); }
private List<ICell> GetEnemyCells(DisplayQualifier friendlyTeam, IList<ICell> allCells) { List<ICell> enemyCells = new List<ICell>(); foreach (ICell potCell in allCells) { if (potCell.GetTeam() != friendlyTeam) enemyCells.Add(potCell); } return enemyCells; }
public Color GetCorrespondingColor(DisplayQualifier qualifier) { switch(qualifier) { // Altitude case DisplayQualifier.VeryLowAltitude: return Color.SaddleBrown; case DisplayQualifier.LowAltitude: return Color.Sienna; case DisplayQualifier.GroundAltitude: return Color.Peru; case DisplayQualifier.HighAltitude: return Color.BurlyWood; case DisplayQualifier.VeryHighAltitude: return Color.Wheat; // Teams case DisplayQualifier.Team1: return Color.Red; case DisplayQualifier.Team2: return Color.DodgerBlue; case DisplayQualifier.Team3: return Color.BlueViolet; case DisplayQualifier.Team4: return Color.Fuchsia; // Other case DisplayQualifier.DeadCell: return Color.LightBlue; case DisplayQualifier.RessourcesAvailable: return Color.LimeGreen; case DisplayQualifier.RessourcesPlant: return Color.LawnGreen; default: return Color.Transparent; } }
/// <summary> /// /// </summary> /// <param name="team"></param> public void SetTeam(DisplayQualifier team) { this.Team = team; }
/// <summary> /// Notify the world that a cell moved /// </summary> /// <param name="oldCoordinates">The old coordinates where the cell was</param> /// <param name="newCoordinates">The new coordinates where the cell is</param> /// <param name="team">The qualifier of the team</param> private void NotifyMovement(ICoordinates oldCoordinates, ICoordinates newCoordinates, DisplayQualifier team) { world.RegisterCellMovement(oldCoordinates, newCoordinates, team); return; }
/// <summary> /// /// </summary> /// <param name="brainType"></param> /// <param name="teamNumber"></param> /// <param name="spawnLife"></param> /// <param name="position"></param> private void CreateCell(String brainType, DisplayQualifier teamNumber, Int16? spawnLife = null, ICoordinates position = null) { var cell = this.localKernel.Get<IInternalCell>(); var brain = this.globalKernel.Get(Type.GetType(brainType)) as IBrain; cell.SetBrain(brain); cell.Position = position ?? (cell.Position = GetRandomCoordinates()); spawnLife = spawnLife ?? Settings.Default.CellMaxInitialLife; cell.SetLife(RandomGenerator.GetRandomInt16((Int16)spawnLife)); cell.SetTeam(teamNumber); RegisterNewCell(cell); }
/// <summary> /// /// </summary> /// <param name="brainType"></param> /// <param name="numberOfCells"></param> /// <param name="teamColor"></param> private void CreateCellPopulation(String brainType, short numberOfCells, DisplayQualifier team) { for (int i = 0; i < numberOfCells; i++) { CreateCell(brainType, team); } }
/// <summary> /// Registers the movement of the cell /// </summary> /// <param name="oldCoordinates">Coordinates where the cell was before it moved</param> /// <param name="newCoordinates">Coordinates where the cell is after it moved</param> /// <param name="team">Team Color of the cell</param> public void RegisterCellMovement(ICoordinates oldCoordinates, ICoordinates newCoordinates, DisplayQualifier team) { // Clear the previous position from the display this.displayController.SetBackgroundToBePaintAt(oldCoordinates); // Signals the new position to display this.displayController.SetDynamicElement(newCoordinates, team); // Update the map this.masterMap.MoveCell(oldCoordinates, newCoordinates); }
/// <summary> /// Registers the given color at the given coordinates on the background /// </summary> /// <param name="elementCoordinates"></param> /// <param name="elementColor"></param> public void SetStaticElement(ICoordinates elementCoordinates, DisplayQualifier qualifier) { StaticElements.Add(elementCoordinates, this.colorPanel.GetCorrespondingColor(qualifier)); BackgroundGrid[elementCoordinates.X, elementCoordinates.Y] = new VisualTile(this.colorPanel.GetCorrespondingColor(qualifier)); }