コード例 #1
0
ファイル: LevelController.cs プロジェクト: cmvanb/VRJam2017
    public void Dig(int x, int z)
    {
        if (!LevelHelpers.TileIsInBounds(Model, x, z))
        {
            return;
        }

        LevelTile tile = Model.Tiles[x, z];

        if (tile.Opened)
        {
            return;
        }

        tile.Opened = true;
        UpdateTileDigMarker(tile);

        List <LevelTile> surroundingTiles = LevelHelpers.GetSurroundingTiles(Model, x, z);

        foreach (LevelTile t in surroundingTiles)
        {
            Model.EvaluateTile(t.X, t.Z);
            UpdateObjectsForTile(t);
        }

        Model.UpdateContiguousTilesFrom(x, z);
        UpdateCeilingMask();
    }
コード例 #2
0
    public static List <LevelTile> GetAdjacentTiles(LevelModel model, int xPosition, int zPosition)
    {
        List <LevelTile> tiles = new List <LevelTile>();

        for (int x = (int)xPosition - 1; x <= (int)xPosition + 1; ++x)
        {
            if (!LevelHelpers.TileIsInBounds(model, x, zPosition))
            {
                continue;
            }

            tiles.Add(model.Tiles[x, zPosition]);
        }

        for (int z = (int)zPosition - 1; z <= (int)zPosition + 1; ++z)
        {
            if (!LevelHelpers.TileIsInBounds(model, xPosition, z))
            {
                continue;
            }

            tiles.Add(model.Tiles[xPosition, z]);
        }

        return(tiles);
    }
コード例 #3
0
    public void PunchHole(Vector2 origin, int size)
    {
        float radius   = (float)size / 2f;
        int   halfSize = Mathf.CeilToInt(radius);

        for (int z = (int)origin.y - halfSize; z < (int)origin.y + halfSize; ++z)
        {
            for (int x = (int)origin.x - halfSize; x < (int)origin.x + halfSize; ++x)
            {
                if (!LevelHelpers.TileIsInBounds(this, x, z))
                {
                    continue;
                }

                if (Vector2.Distance(origin, new Vector2(x, z)) < radius)
                {
                    Tiles[x, z].Opened = true;
                }
            }
        }
    }
コード例 #4
0
ファイル: PlayerFlyer.cs プロジェクト: cmvanb/VRJam2017
    public bool PositionIsValidLandingZone(Vector3 destination)
    {
        Vector2 tilePos = LevelHelpers.TilePosFromWorldPos(destination);

        LevelModel model = LevelController.Instance.Model;

        int x = (int)tilePos.x;
        int z = (int)tilePos.y;

        if (!LevelHelpers.TileIsInBounds(model, x, z))
        {
            return(false);
        }

        LevelTile tile = model.Tiles[x, z];

        if (tile.Opened)
        {
            return(true);
        }

        return(false);
    }