예제 #1
0
 public Player(Color myColor)
 {
     this.MyColor = myColor;
     MyPawns = new Pawn[4];
     MyBases = new BaseField[4];
     MyHomes = new HomeField[4];
 }
예제 #2
0
 public void AddBase(BaseField basef)
 {
     for (int i = 0; i < 4; i++)
     {
         if (MyBases[i] == null)
         {
             MyBases[i] = basef;
             break;
         }
     }
 }
예제 #3
0
        public void BuildBaseFields(string[] lines)
        {
            Field currentField = null;
            Field previousField = null;
            Player currentPlayer;
            int numberY = 1, numberG = 1, numberR = 1, numberB = 1;
            for (int y = 0; y < 1; y++)
            {
                for (int x = 0; x < lines[y].Length; x++)
                {
                    if (OriginBaseField != null)
                    {
                        previousField = currentField;
                    }
                    switch (lines[y][x])
                    {
                        case 'Y': currentField = new BaseField(Color.Yellow, numberY);
                            currentField.MyPawn = new Pawn(currentField, Color.Yellow, numberY);
                            if (GetPlayerByColor(Color.Yellow) != null)
                            {
                                currentPlayer = GetPlayerByColor(Color.Yellow);
                                currentPlayer.AddBase((BaseField)currentField);
                                currentPlayer.AddPawn(currentField.MyPawn);
                            }
                            numberY++;
                            break;
                        case 'G': currentField = new BaseField(Color.Green, numberG);
                            currentField.MyPawn = new Pawn(currentField, Color.Green, numberG);
                            if (GetPlayerByColor(Color.Green) != null)
                            {
                                currentPlayer = GetPlayerByColor(Color.Green);
                                currentPlayer.AddBase((BaseField)currentField);
                                currentPlayer.AddPawn(currentField.MyPawn);
                            }
                            numberG++;
                            break;
                        case 'R': currentField = new BaseField(Color.Red,numberR);
                            currentField.MyPawn = new Pawn(currentField, Color.Red, numberR);
                            if (GetPlayerByColor(Color.Red) != null)
                            {
                                currentPlayer = GetPlayerByColor(Color.Red);
                                currentPlayer.AddBase((BaseField)currentField);
                                currentPlayer.AddPawn(currentField.MyPawn);
                            }
                            numberR++;
                            break;
                        case 'B': currentField = new BaseField(Color.Blue,numberB);
                            currentField.MyPawn = new Pawn(currentField, Color.Blue, numberB);
                            if (GetPlayerByColor(Color.Blue) != null)
                            {
                                currentPlayer = GetPlayerByColor(Color.Blue);
                                currentPlayer.AddBase((BaseField)currentField);
                                currentPlayer.AddPawn(currentField.MyPawn);
                            }
                            numberB++;
                            break;
                        case '5': currentField = new BaseField(Color.Yellow,numberY);
                            if(GetPlayerByColor(Color.Yellow) != null)
                            {
                                currentPlayer = GetPlayerByColor(Color.Yellow);
                                currentPlayer.AddBase((BaseField) currentField);
                            }
                            numberY++;
                            break;
                        case '6': currentField = new BaseField(Color.Green,numberG);
                            if(GetPlayerByColor(Color.Green) != null)
                            {
                                currentPlayer = GetPlayerByColor(Color.Green);
                                currentPlayer.AddBase((BaseField) currentField);
                            }
                            numberG++;
                            break;
                        case '7': currentField = new BaseField(Color.Red,numberR);
                            if(GetPlayerByColor(Color.Red) != null)
                            {
                                currentPlayer = GetPlayerByColor(Color.Red);
                                currentPlayer.AddBase((BaseField) currentField);
                            }
                            numberR++;
                            break;
                        case '8': currentField = new BaseField(Color.Blue,numberB);
                            if(GetPlayerByColor(Color.Blue) != null)
                            {
                                currentPlayer = GetPlayerByColor(Color.Blue);
                                currentPlayer.AddBase((BaseField) currentField);
                            }
                            numberB++;
                            break;
                        default:
                            break;
                    }
                    if (x == 0 && y == 0) { OriginBaseField = (BaseField)currentField; }
                    if (x > 0) { currentField.Previous = previousField; previousField.Next = currentField; }

                }
            }
        }