Beispiel #1
0
        /**
         * Checks that unit, standing in position will have access (to dig, open a chest) to target tile.
         * Same Z-level tiles are always accessible.
         * Tiles are accessible vertically with stairs or ramps.
         */
        public bool tileIsAccessibleFromNeighbour(int targetX, int targetY, int targetZ, int x, int y, int z, BlockType targetType)
        {
            if (!localMap.inMap(targetX, targetY, targetZ) || !localMap.inMap(x, y, z) || passage.get(x, y, z) == IMPASSABLE.VALUE)
            {
                return(false);
            }
            if (targetZ == z)
            {
                return(true);
            }
            BlockType fromType = BlockTypeEnum.get(blockTypeMap.get(x, y, z));
            BlockType lower    = targetZ < z ? targetType : fromType;

            if ((targetX == x) != (targetY == y))
            {
                return(lower == RAMP);                                  // ramp near and lower
            }
            if (targetX != x)
            {
                return(false);
            }
            BlockType upper = targetZ > z ? targetType : fromType;

            return(lower == STAIRS && (upper == STAIRS || upper == DOWNSTAIRS));
        }
Beispiel #2
0
        /**
         * Tile is passable, if its block type allows walking(like floor, ramp, etc.), plants are passable(not tree trunks), buildings are impassable.
         * TODO add water depth checking, etc.
         */
        public Passage calculateTilePassage(Vector3Int position)
        {
            Passage tilePassage = BlockTypeEnum.get(blockTypeMap.get(position)).PASSAGE;

            // TODO
            if (tilePassage == PASSABLE)   // tile still can be blocked by plants or buildings
            {
                bool plantPassable = true;
                //  GameModel.map(plantContainer => plantContainer.isPlantBlockPassable(position)).orElse(true);
                if (!plantPassable)
                {
                    return(IMPASSABLE);
                }

                bool buildingPassable = true;
                //        model.optional(BuildingContainer.class)
                //        .map(container -> container.buildingBlocks.get(position))
                //        .map(block -> block.passage == PASSABLE).orElse(true);
                if (!buildingPassable)
                {
                    return(IMPASSABLE);
                }

                bool waterPassable = true;
                //model.optional(LiquidContainer.class)
                //.map(container -> container.getTile(position))
                //.map(tile -> tile.amount <= 4).orElse(true);
                if (!waterPassable)
                {
                    return(IMPASSABLE);
                }
            }
            return(tilePassage);
        }
        // when current tile is SPACE, draw special topping tile if lower tile is not SPACE.
        private void setToppingForSpace(int x, int y, int z)
        {
            if (z <= 0)
            {
                return;
            }
            string    material  = selectMaterial(x, y, z - 1);
            BlockType blockType = BlockTypeEnum.get(map.blockType.get(x, y, z - 1));

            if (blockType != SPACE && blockType != FLOOR)
            {
                string type = (blockType == RAMP ? selectRamp(x, y, z - 1) : blockType.PREFIX) + "F";
                layers[z].SetTile(floorPosition, tileSetHolder.tilesets[material][type]); // topping corresponds lower tile
            }
        }
        public void updateTile(int x, int y, int z, bool withRamps)
        {
            wallPosition.Set(x, y, WALL_LAYER);
            floorPosition.Set(x, y, FLOOR_LAYER);
            string    material  = selectMaterial(x, y, z);
            BlockType blockType = BlockTypeEnum.get(map.blockType.get(x, y, z));
            Tile      floorTile = null;
            Tile      wallTile  = null;

            if (blockType != SPACE)
            {
                string type = blockType == RAMP?selectRamp(x, y, z) : blockType.PREFIX;

                floorTile = tileSetHolder.tilesets[material]["WALLF"]; // floor is drawn under all tiles
                wallTile  = tileSetHolder.tilesets[material][type];    // draw wall part
            }
            layers[z].SetTile(floorPosition, floorTile);
            layers[z].SetTile(wallPosition, wallTile);
            if (blockType == SPACE)
            {
                setToppingForSpace(x, y, z);
            }
        }
Beispiel #5
0
 public BlockType getEnumValue(int x, int y, int z)
 {
     return(BlockTypeEnum.get(get(x, y, z)));
 }
Beispiel #6
0
 public static bool validateDigging(BlockType targetBlockType, Vector3Int position)
 {
     return(targetBlockType.OPENNESS > BlockTypeEnum.get(GameModel.localMap.blockType.get(position)).OPENNESS);
 }