예제 #1
0
        // Ends the game, signals every player whetPrinther they won or lost
        public void endGame()
        {
            Player winner = null;

            for (int i = 0; i < players.Count(); i++)
            {
                int place = GameField.GetInstance().GetPlace(players[i].GetCI().id);
                if (place == 1)
                {
                    players[i].won();
                    winner = players[i];
                }
                else
                {
                    players[i].lost();
                }
            }
            // shall iterate through the colors and Getting each color's place
            // htf do we reach all colors?

            if (winner != null)
            {
                Console.WriteLine("winner:" + winner.GetName());
            }
        }
예제 #2
0
 // Visitor pattern core, Gets the given Moveable type as argument
 // In this case, the given object is a Box
 // If the box is compatible, then isolating and signaling to the game field, to increment score
 public void Visit(Box b)
 {
     if (compatible.Contains(b))
     {
         b.Isolate();
         GameField.GetInstance().Score(b.pushedByColor);
     }
 }
예제 #3
0
        //creates new player and Adds it to players
        public void createPlayer(string name, string color, string UP, string RIGHT, string DOWN, string LEFT, string PUT_LIQUID)
        {
            Player player = new Player(name);

            player.AddControl(GameField.GetInstance()
                              .createControlInterface(
                                  Color.FromName(color),
                                  UP,
                                  RIGHT,
                                  DOWN,
                                  LEFT,
                                  PUT_LIQUID
                                  )
                              );

            players.Add(player);
        }
예제 #4
0
파일: Box.cs 프로젝트: Hollo1996/AllSokoban
 // Destroys the box by removing it from the field and from the game field
 public override void Destroy()
 {
     underThis.RemoveMoveable();
     GameField.GetInstance().RemoveBox(this);
 }
예제 #5
0
 // ReMoves the worker from the control interface
 // and signals this action to the game field
 public void RemoveWorker()
 {
     worker = null;
     GameField.GetInstance().OutOfWorkers();
 }