Пример #1
0
    //check each player entity in entitystorage to determine their vision range and remove the fog for that range
    public void EntityCurrPlayerVision()
    {
        if (playerManager.currPlayer != string.Empty)
        {
            char playerChar = playerManager.currPlayer[0];
            //Debug.Log(entityStorage.PlayerEntityList(playerChar)[0].name.Substring(2));
            foreach (GameObject playerEntity in entityStorage.PlayerEntityList(playerChar))
            {
                int    visionDistance = entityStats.GetCurrVision(playerEntity);
                int    index          = entityStats.GetCellIndex(playerEntity);
                string height         = hexGrid.GetTerrain(index);

                Dictionary <int, int> vision = PlayerVisionHelper(index, visionDistance, height);
                foreach (var tile in vision)
                {
                    hexGrid.SetFog(tile.Key, false);
                    Fog fog = fogs[tile.Key];
                    fog.GetComponent <Renderer>().enabled = false;
                }
            }
            foreach (GameObject buildingEntity in buildingStorage.PlayerBuildingList(playerChar))
            {
                int    visionDistance = buildingStats.GetCurrVision(buildingEntity);
                int    index          = buildingStats.GetCellIndex(buildingEntity);
                string height         = hexGrid.GetTerrain(index);

                Dictionary <int, int> vision = PlayerVisionHelper(index, visionDistance, height);
                foreach (var tile in vision)
                {
                    if (tile.Value >= -2)
                    {
                        hexGrid.SetFog(tile.Key, false);
                        Fog fog = fogs[tile.Key];
                        fog.GetComponent <Renderer>().enabled = false;
                    }
                }
            }
        }
    }