Example #1
0
    void DrawGround()
    {
        foreach (var cell in GroundMap.GetAllCells())
        {
            if (!cell.IsExplored)
            {
                continue;
            }

            GameObject tileType;
            if (GroundMap.IsInFov(cell.X, cell.Y))
            {
                if (cell.IsWalkable)
                {
                    tileType = Floor;
                }
                else
                {
                    tileType = Wall;
                }
                if (groundTiles[cell.X, cell.Y] == null)
                {
                    GameObject instance = GameObject.Instantiate <GameObject>(tileType, new Vector2(cell.X, cell.Y),
                                                                              Quaternion.identity);
                    instance.transform.SetParent(boardHolder);
                    groundTiles[cell.X, cell.Y] = instance;
                }
                groundTiles[cell.X, cell.Y].GetComponent <Renderer>().material.color = Color.white;
            }
            else
            {
                if (cell.IsWalkable)
                {
                    tileType = Floor;
                }
                else
                {
                    tileType = Wall;
                }
                if (groundTiles[cell.X, cell.Y] == null)
                {
                    GameObject instance = GameObject.Instantiate <GameObject>(tileType, new Vector2(cell.X, cell.Y),
                                                                              Quaternion.identity);
                    instance.transform.SetParent(boardHolder);
                    groundTiles[cell.X, cell.Y] = instance;
                }
                groundTiles[cell.X, cell.Y].GetComponent <Renderer>().material.color = Color.gray;
            }
        }
    }
Example #2
0
    void UpdatePlayerFieldOfView()
    {
        GroundMap.ComputeFov((int)Player.transform.position.x, (int)Player.transform.position.y, 8, true);
        ItemsMap.ComputeFov((int)Player.transform.position.x, (int)Player.transform.position.y, 8, true);

        foreach (var cell in GroundMap.GetAllCells())
        {
            if (GroundMap.IsInFov(cell.X, cell.Y))
            {
                GroundMap.SetCellProperties(cell.X, cell.Y, cell.IsTransparent, cell.IsWalkable, true);
            }
        }

        foreach (var cell in ItemsMap.GetAllCells())
        {
            if (ItemsMap.IsInFov(cell.X, cell.Y))
            {
                ItemsMap.SetCellProperties(cell.X, cell.Y, cell.IsTransparent, cell.IsWalkable, true);
            }
        }
    }