示例#1
0
    public virtual int GetBaseLevel()
    {
        var stairVec     = HushPuppy.GetVecAsTileVec(this.transform.position);
        var stairBaseVec = stairVec + Vector3Int.down;

        return(GetLevel(stairBaseVec));
    }
示例#2
0
 Vector3Int GetCurrentPosInt()
 {
     return(HushPuppy.GetVecAsTileVec(new Vector3(
                                          this.transform.position.x - 0.5f,
                                          this.transform.position.y - 0.5f,
                                          this.transform.position.z
                                          )));
 }
示例#3
0
    public static Vector3 TilePosInFrontOfObj(GameObject obj, Vector3 direction, bool local = true)
    {
        Vector3 target = local ? obj.transform.localPosition : obj.transform.position;

        target = target + direction * 0.5f;
        target = HushPuppy.GetVecAsTileVec(target, false, true);
        return(target);
    }
示例#4
0
    public bool IsPositionValid(Vector3 position)
    {
        Vector3Int vec = HushPuppy.GetVecAsTileVec(position);

        TileBase seaTile   = seaTilemap.GetTile(vec);
        bool     insideSea = seaTile != null;

        return(!insideSea);
    }
示例#5
0
    void ClearPath()
    {
        var walls  = TilemapHelper.GetWallsTilemap();
        var posInt = HushPuppy.GetVecAsTileVec(this.transform.position);

        var tile = walls.GetTile(posInt);

        if (tile != null)
        {
            var sprite = ((Tile)tile).sprite;
            fakeWall.sprite = sprite;
            walls.SetTile(posInt, null);
        }
    }
示例#6
0
    public static int GetFloor(Vector3 position)
    {
        var posInt   = HushPuppy.GetVecAsTileVec(position);
        int maxLevel = -1;

        foreach (var tilemap in GetAllFloors())
        {
            var targetTile = tilemap.map.GetTile(posInt);
            if (targetTile != null)
            {
                maxLevel = tilemap.level > maxLevel ? tilemap.level : maxLevel;
            }
        }

        return(maxLevel);
    }
示例#7
0
    public override int GetTopLevel()
    {
        Vector3Int targetTileInt = Vector3Int.zero;
        int        maxLevel      = -1;

        if (destinationRoom != null)
        {
            targetTileInt = HushPuppy.GetVecAsTileVec(destinationRoom.startingPos.transform.position);
        }
        else if (destinationPos)
        {
            targetTileInt = HushPuppy.GetVecAsTileVec(destinationPos.transform.position);
        }

        var tilemaps = new List <Tilemap>(FindObjectsOfType <Tilemap>());

        foreach (var tilemap in tilemaps)
        {
            string tilemapLayerName = LayerMask.LayerToName(tilemap.gameObject.layer);
            if (!tilemapLayerName.Contains("Floor"))
            {
                continue;
            }

            int tilemapLevel = int.Parse(tilemapLayerName.Split('_')[1]);
            tilemapLevel -= 1; //in the layers, we start counting on 1

            var targetTile = tilemap.GetTile(targetTileInt);

            if (targetTile != null)
            {
                maxLevel = tilemapLevel > maxLevel ? tilemapLevel : maxLevel;
            }
        }

        return(maxLevel);
    }