예제 #1
0
 public GameBoard(int width, int height)
 {
     Height     = height;
     Width      = width;
     TileArea   = new TileArea(Width, Height);
     ObjectArea = new GameObjectArea(Width, Height);
 }
예제 #2
0
 public EditCommand(Key key, MovementArea movementArea,
                    GameObjectArea objectArea) :
     base(key)
 {
     this.objectArea   = objectArea;
     this.movementArea = movementArea;
 }
예제 #3
0
        public bool IsGameOver(GameObjectArea objectArea)
        {
            bool isGameOver = true;

            for (int i = 0; i < tileArea.Height; ++i)
            {
                for (int j = 0; j < tileArea.Width; ++j)
                {
                    if (objectArea[i, j].Name == Pipe.Name)
                    {
                        if (objectArea[i, j] is Pipe pipe && !pipe.IsFilled)
                        {
                            IList <Point> neigbors         = tileArea[i, j].Neighbors;
                            bool          isSourceNear     = CanContinue(objectArea, neigbors, IsSource);
                            bool          isFilledPipeNear = CanContinue(objectArea, neigbors, IsFilledPipe);
                            isGameOver = !(isSourceNear || isFilledPipeNear);
                            if (!isGameOver)
                            {
                                break;
                            }
                        }
                    }
                }
                if (!isGameOver)
                {
                    break;
                }
            }
            return(isGameOver);
        }
예제 #4
0
 private void FillNeighbors(GameObjectArea objectSpace, IList <Point> neighbors)
 {
     foreach (var neighbor in neighbors)
     {
         if (objectSpace[neighbor.X, neighbor.Y] is Pipe pipe && !pipe.IsFilled)
         {
             pipe.IsFilled = true;
         }
     }
 }
예제 #5
0
        private bool CanContinue(GameObjectArea objectArea, IList <Point> neighbors,
                                 GameObjectPredicate predicate)
        {
            bool canContinue = false;

            foreach (var neighbor in neighbors)
            {
                canContinue = predicate(objectArea[neighbor.X, neighbor.Y]);
                if (canContinue)
                {
                    break;
                }
            }
            return(canContinue);
        }
예제 #6
0
 public EnterCommand(Key key, MovementArea movementArea,
                     GameObjectArea objectArea, TileArea tileArea) :
     base(key, movementArea, objectArea)
 {
     this.tileArea = tileArea;
 }
예제 #7
0
 public SCommand(Key key, MovementArea movementArea,
                 GameObjectArea objectArea) :
     base(key, movementArea, objectArea)
 {
 }