Beispiel #1
0
        public void ResetState()
        {
            state = GameState.InProgress;
            moveSequence = new List<Direction>();

            // Create objects if they don't exist; if they do, clear out
            // their old state.
            if (objects == null)
            {
                objects = new List<GameObject>();

                // Player
                player = new PlayerObject(this);
                player.StartingLocation = board[0, 6];
                objects.Add(player);

                // Patrols
                PatrolObject pat1 = new PatrolObject(this, new GameSquare[] {board[2, 3],
                                                                             board[1, 4],
                                                                             board[2, 5],
                                                                             board[3, 5],
                                                                             board[3, 4],
                                                                             board[3, 3]});
                pat1.StartingLocation = board[2, 3];
                objects.Add(pat1);

                PatrolObject pat2 = new PatrolObject(this, new GameSquare[] {board[6, 2],
                                                                             board[5, 2],
                                                                             board[5, 3],
                                                                             board[5, 4],
                                                                             board[6, 4],
                                                                             board[7, 3]});
                pat2.StartingLocation = board[6, 2];
                objects.Add(pat2);

                // Probes
                ProbeObject probe1 = new ProbeObject(this,
                                                     new Direction[] {Direction.Left,
                                                                      Direction.Right},
                                                     false);
                probe1.StartingLocation = board[1, 0];
                objects.Add(probe1);

                ProbeObject probe2 = new ProbeObject(this,
                                                     new Direction[] {Direction.Left,
                                                                      Direction.DownLeft,
                                                                      Direction.Right,
                                                                      Direction.UpRight},
                                                     false);
                probe2.StartingLocation = board[3, 0];
                objects.Add(probe2);

                ProbeObject probe3 = new ProbeObject(this,
                                                     new Direction[] {Direction.Left,
                                                                      Direction.DownLeft,
                                                                      Direction.Right,
                                                                      Direction.UpLeft},
                                                     true);
                probe3.StartingLocation = board[2, 2];
                objects.Add(probe3);

                ProbeObject probe4 = new ProbeObject(this,
                                                     new Direction[] {Direction.Left,
                                                                      Direction.DownLeft,
                                                                      Direction.UpRight,
                                                                      Direction.UpLeft},
                                                     true);
                probe4.StartingLocation = board[4, 2];
                objects.Add(probe4);

                ProbeObject probe5 = new ProbeObject(this,
                                                     new Direction[] {Direction.DownLeft,
                                                                      Direction.Right},
                                                     false);
                probe5.StartingLocation = board[7, 2];
                objects.Add(probe5);

                ProbeObject probe6 = new ProbeObject(this,
                                                     new Direction[] {Direction.Left,
                                                                      Direction.DownRight,
                                                                      Direction.Right,
                                                                      Direction.UpRight},
                                                     true);
                probe6.StartingLocation = board[0, 3];
                objects.Add(probe6);

                ProbeObject probe7 = new ProbeObject(this,
                                                     new Direction[] {Direction.DownRight,
                                                                      Direction.UpLeft},
                                                     true);
                probe7.StartingLocation = board[4, 4];
                objects.Add(probe7);

                ProbeObject probe8 = new ProbeObject(this,
                                                     new Direction[] {Direction.Left,
                                                                      Direction.DownRight,
                                                                      Direction.UpRight},
                                                     false);
                probe8.StartingLocation = board[7, 4];
                objects.Add(probe8);

                ProbeObject probe9 = new ProbeObject(this,
                                                     new Direction[] {Direction.Left,
                                                                      Direction.DownRight,
                                                                      Direction.UpRight},
                                                     false);
                probe9.StartingLocation = board[1, 5];
                objects.Add(probe9);

                ProbeObject probe10 = new ProbeObject(this,
                                                      new Direction[] {Direction.DownLeft,
                                                                       Direction.DownRight,
                                                                       Direction.UpRight,
                                                                       Direction.UpLeft},
                                                      true);
                probe10.StartingLocation = board[2, 6];
                objects.Add(probe10);

                ProbeObject probe11 = new ProbeObject(this,
                                                      new Direction[] {Direction.DownLeft,
                                                                       Direction.Right,
                                                                       Direction.UpLeft},
                                                      true);
                probe11.StartingLocation = board[5, 6];
                objects.Add(probe11);
            }

            // Set initial object state
            foreach (GameObject obj in objects)
            {
                obj.ResetObjectState();
            }

            MarkSafeSquares();
        }
Beispiel #2
0
        public void ResetState()
        {
            state        = GameState.InProgress;
            moveSequence = new List <Direction>();

            // Create objects if they don't exist; if they do, clear out
            // their old state.
            if (objects == null)
            {
                objects = new List <GameObject>();

                // Player
                player = new PlayerObject(this);
                player.StartingLocation = board[0, 6];
                objects.Add(player);

                // Patrols
                PatrolObject pat1 = new PatrolObject(this, new GameSquare[] { board[2, 3],
                                                                              board[1, 4],
                                                                              board[2, 5],
                                                                              board[3, 5],
                                                                              board[3, 4],
                                                                              board[3, 3] });
                pat1.StartingLocation = board[2, 3];
                objects.Add(pat1);

                PatrolObject pat2 = new PatrolObject(this, new GameSquare[] { board[6, 2],
                                                                              board[5, 2],
                                                                              board[5, 3],
                                                                              board[5, 4],
                                                                              board[6, 4],
                                                                              board[7, 3] });
                pat2.StartingLocation = board[6, 2];
                objects.Add(pat2);

                // Probes
                ProbeObject probe1 = new ProbeObject(this,
                                                     new Direction[] { Direction.Left,
                                                                       Direction.Right },
                                                     false);
                probe1.StartingLocation = board[1, 0];
                objects.Add(probe1);

                ProbeObject probe2 = new ProbeObject(this,
                                                     new Direction[] { Direction.Left,
                                                                       Direction.DownLeft,
                                                                       Direction.Right,
                                                                       Direction.UpRight },
                                                     false);
                probe2.StartingLocation = board[3, 0];
                objects.Add(probe2);

                ProbeObject probe3 = new ProbeObject(this,
                                                     new Direction[] { Direction.Left,
                                                                       Direction.DownLeft,
                                                                       Direction.Right,
                                                                       Direction.UpLeft },
                                                     true);
                probe3.StartingLocation = board[2, 2];
                objects.Add(probe3);

                ProbeObject probe4 = new ProbeObject(this,
                                                     new Direction[] { Direction.Left,
                                                                       Direction.DownLeft,
                                                                       Direction.UpRight,
                                                                       Direction.UpLeft },
                                                     true);
                probe4.StartingLocation = board[4, 2];
                objects.Add(probe4);

                ProbeObject probe5 = new ProbeObject(this,
                                                     new Direction[] { Direction.DownLeft,
                                                                       Direction.Right },
                                                     false);
                probe5.StartingLocation = board[7, 2];
                objects.Add(probe5);

                ProbeObject probe6 = new ProbeObject(this,
                                                     new Direction[] { Direction.Left,
                                                                       Direction.DownRight,
                                                                       Direction.Right,
                                                                       Direction.UpRight },
                                                     true);
                probe6.StartingLocation = board[0, 3];
                objects.Add(probe6);

                ProbeObject probe7 = new ProbeObject(this,
                                                     new Direction[] { Direction.DownRight,
                                                                       Direction.UpLeft },
                                                     true);
                probe7.StartingLocation = board[4, 4];
                objects.Add(probe7);

                ProbeObject probe8 = new ProbeObject(this,
                                                     new Direction[] { Direction.Left,
                                                                       Direction.DownRight,
                                                                       Direction.UpRight },
                                                     false);
                probe8.StartingLocation = board[7, 4];
                objects.Add(probe8);

                ProbeObject probe9 = new ProbeObject(this,
                                                     new Direction[] { Direction.Left,
                                                                       Direction.DownRight,
                                                                       Direction.UpRight },
                                                     false);
                probe9.StartingLocation = board[1, 5];
                objects.Add(probe9);

                ProbeObject probe10 = new ProbeObject(this,
                                                      new Direction[] { Direction.DownLeft,
                                                                        Direction.DownRight,
                                                                        Direction.UpRight,
                                                                        Direction.UpLeft },
                                                      true);
                probe10.StartingLocation = board[2, 6];
                objects.Add(probe10);

                ProbeObject probe11 = new ProbeObject(this,
                                                      new Direction[] { Direction.DownLeft,
                                                                        Direction.Right,
                                                                        Direction.UpLeft },
                                                      true);
                probe11.StartingLocation = board[5, 6];
                objects.Add(probe11);
            }

            // Set initial object state
            foreach (GameObject obj in objects)
            {
                obj.ResetObjectState();
            }

            MarkSafeSquares();
        }