// 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()); } }
// 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); } }
static void Main(string[] args) { GameField gf = GameField.GetInstance(); gf.LoadMap("test_map2"); gf.listFeatures("bu"); gf.listFeatures("ft"); gf.listFeatures("ho"); gf.listFeatures("bc"); gf.listFields(); gf.listFieldFieldConnectivities(); gf.listWorkers(); gf.listBoxes(); Console.ReadKey(); }
//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); }
// ReMoves the worker from the control interface // and signals this action to the game field public void RemoveWorker() { worker = null; GameField.GetInstance().OutOfWorkers(); }
// Destroys the box by removing it from the field and from the game field public override void Destroy() { underThis.RemoveMoveable(); GameField.GetInstance().RemoveBox(this); }