Exemplo n.º 1
0
 /// <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);
 }
Exemplo n.º 2
0
        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;
        }
Exemplo n.º 3
0
        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;
            }
        }
Exemplo n.º 4
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="team"></param>
 public void SetTeam(DisplayQualifier team)
 {
     this.Team = team;
 }
Exemplo n.º 5
0
 /// <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;
 }
Exemplo n.º 6
0
        /// <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);
        }
Exemplo n.º 7
0
 /// <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);
     }
 }
Exemplo n.º 8
0
        /// <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);
        }
Exemplo n.º 9
0
 /// <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));
 }