Exemplo n.º 1
0
        private WorldRegion InstantiateWorldRegion(WorldArea area, WorldRegionData data)
        {
            if (_loadedWorldRegions.ContainsKey(data.id))
            {
                var region = _loadedWorldRegions[data.id];
                region.areas.Add(area);
                return(region);
            }

            var go          = Instantiate(worldRegionPrefab, _gameWorld.transform);
            var worldRegion = go.GetComponent <WorldRegion>();

            worldRegion.regionName = data.name;
            worldRegion.areas      = new List <WorldArea> {
                area
            };
            _loadedWorldRegions[data.id] = worldRegion;
            return(worldRegion);
        }
Exemplo n.º 2
0
        private Tuple <int, WorldRegionData> SaveRegion([CanBeNull] WorldRegion region)
        {
            if (region == null)
            {
                return(new Tuple <int, WorldRegionData>(-1, null));
            }

            if (_savedRegionsIdMap.ContainsKey(region.regionName))
            {
                return(new Tuple <int, WorldRegionData>(_savedRegionsIdMap[region.regionName], null));
            }

            var regionData = new WorldRegionData()
            {
                id   = _regionCount,
                name = region.regionName
            };

            _savedRegionsIdMap[region.regionName] = _regionCount;
            _regionCount += 1;
            return(new Tuple <int, WorldRegionData>(regionData.id, regionData));
        }