Example #1
0
 public void AddGrowingVegetable(IBlankSpace growingVegetable)
 {
     this.growingVegetables.Add(growingVegetable);
 }
Example #2
0
        public void SeedField(IList <string> inputMatrix, string firstNinjaName, string secondNinjaName)
        {
            for (int i = 0; i < inputMatrix.Count; i++)
            {
                List <IGameObject> currentRow = new List <IGameObject>();

                string currentInputRow = inputMatrix[i];

                for (int j = 0; j < currentInputRow.Length; j++)
                {
                    char currentElement = currentInputRow[j];

                    IVegetable      newVegetable   = null;
                    IBlankSpace     newBlanckSpace = null;
                    INinja          newNinja       = null;
                    IMatrixPosition position       = new MatrixPosition(i, j);

                    switch (currentElement)
                    {
                    case 'A':
                        newVegetable = new Asparagus(position);
                        break;

                    case 'B':
                        newVegetable = new Broccoli(position);
                        break;

                    case 'C':
                        newVegetable = new CherryBerry(position);
                        break;

                    case 'M':
                        newVegetable = new Mushroom(position);
                        break;

                    case 'R':
                        newVegetable = new Royal(position);
                        break;

                    case '*':
                        newVegetable = new MeloLemonMelon(position);
                        break;

                    case '-':
                        newBlanckSpace = new BlankSpace(position, -1, VegetableType.Blank);
                        break;
                    }

                    if (currentElement.Equals(firstNinjaName[0]))
                    {
                        newNinja = new Ninja(position, firstNinjaName);
                    }

                    if (currentElement.Equals(secondNinjaName[0]))
                    {
                        newNinja = new Ninja(position, secondNinjaName);
                    }

                    if (newVegetable != null)
                    {
                        this.AddVegetable(newVegetable);
                        currentRow.Add(newVegetable);
                    }

                    if (newNinja != null)
                    {
                        this.AddNinja(newNinja);
                        currentRow.Add(newNinja);
                    }

                    if (newBlanckSpace != null)
                    {
                        currentRow.Add(newBlanckSpace);
                    }
                }

                this.gameField.Add(currentRow);
            }
        }
 public void AddGrowingVegetable(IBlankSpace growingVegetable)
 {
     this.growingVegetables.Add(growingVegetable);
 }