Example #1
0
        public bool placeWall(int x, int y, WallType type)
        {
            if (getWall(x, y) != null) { return false; }

            // Check for walls or block to attach to
            if (getWall(x - 1, y) == null && getWall(x + 1, y) == null && getWall(x, y - 1) == null && getWall(x, y + 1) == null && getBlock(x - 1, y) == null && getBlock(x + 1, y) == null && getBlock(x, y - 1) == null && getBlock(x, y + 1) == null)
            {
                return false;
            }

            // Check range from player

            Walls[x, y] = new Wall(type);
            return true;
        }
Example #2
0
        /// <summary>
        /// Does damage to a block, returns true if broken
        /// </summary>
        /// <param name="x"></param>
        /// <param name="y"></param>
        public bool mineBlock(int x, int y)
        {
            if (!inBounds(x, y)) { return false; }

            if (Blocks[x, y] == null) { return false; }

            Blocks[x, y].Health -= 2;
            if (Blocks[x, y].Health < 1)
            {
                Blocks[x, y] = null;
                Walls[x, y] = new Wall(WallTypes[1]);
                return true;
            }
            return false;
        }