コード例 #1
0
ファイル: Zone.cs プロジェクト: RogueCollab/RogueEssence
 public void UnloadMap(SegLoc id)
 {
     if (maps.ContainsKey(id))
     {
         maps.Remove(id);
     }
 }
コード例 #2
0
ファイル: Zone.cs プロジェクト: RogueCollab/RogueEssence
        /// <summary>
        /// Loads a new map of the specified name into the current zone (temporarily) for dev usage.
        /// </summary>
        /// <param name="mapname"></param>
        public void DevLoadMap(string mapname)
        {
            exitMap();

            CurrentMap   = DataManager.Instance.GetMap(mapname);
            CurrentMapID = new SegLoc(0, 0);
        }
コード例 #3
0
ファイル: Zone.cs プロジェクト: RogueCollab/RogueEssence
        /// <summary>
        /// Loads a new ground map of the specified name into the current zone (temporarily) for dev usage.
        /// </summary>
        /// <param name="mapname"></param>
        public void DevLoadGround(string mapname)
        {
            exitMap();

            CurrentGround = DataManager.Instance.GetGround(mapname);
            CurrentMapID  = new SegLoc(-1, 0);
        }
コード例 #4
0
ファイル: Zone.cs プロジェクト: RogueCollab/RogueEssence
        /// <summary>
        /// Creates a new ground map of the specified name into the current zone (temporarily) for dev usage.
        /// </summary>
        public void DevNewGround()
        {
            exitMap();

            CurrentGround = new GroundMap();
            CurrentGround.CreateNew(16, 16, Content.GraphicsManager.DungeonTexSize);
            CurrentMapID = new SegLoc(-1, 0);
        }
コード例 #5
0
ファイル: Zone.cs プロジェクト: RogueCollab/RogueEssence
        /// <summary>
        /// Creates a new map of the specified name into the current zone (temporarily) for dev usage.
        /// </summary>
        public void DevNewMap()
        {
            exitMap();

            CurrentMap = new Map();
            CurrentMap.CreateNew(10, 10);

            CurrentMapID = new SegLoc(0, 0);
        }
コード例 #6
0
ファイル: Zone.cs プロジェクト: Parakoopa/RogueEssence
        /// <summary>
        /// Creates a new map of the specified name into the current zone (temporarily) for dev usage.
        /// </summary>
        public void DevNewMap()
        {
            exitMap();

            CurrentMap = new Map();
            CurrentMap.CreateNew(10, 10);
            CurrentMap.EntryPoints.Add(new LocRay8(new Loc(CurrentMap.Width / 2, CurrentMap.Height / 2), Dir8.Down));

            CurrentMapID = new SegLoc(0, -1);
        }
コード例 #7
0
ファイル: Zone.cs プロジェクト: Parakoopa/RogueEssence
        public Map GetMap(SegLoc id)
        {
            if (!maps.ContainsKey(id))
            {
                //NOTE: with the way this is currently done, the random numbers used by the maps end up being related to the random numbers used by the postprocs
                //not that anyone would really notice...
                ReRandom totalRand = new ReRandom(rand.FirstSeed);
                for (int ii = 0; ii < id.Segment; ii++)
                {
                    totalRand.NextUInt64();
                }
                ulong structSeed = totalRand.NextUInt64();
                DiagManager.Instance.LogInfo("Struct Seed: " + structSeed);
                ReRandom structRand = new ReRandom(structSeed);
                for (int ii = 0; ii < id.ID; ii++)
                {
                    structRand.NextUInt64();
                }

                ulong mapSeed = structRand.NextUInt64();

                //load the struct context if it isn't present yet
                if (!structureContexts.ContainsKey(id.Segment))
                {
                    ReRandom       initRand   = new ReRandom(structSeed);
                    ZoneGenContext newContext = new ZoneGenContext();
                    newContext.CurrentZone    = zoneIndex;
                    newContext.CurrentSegment = id.Segment;
                    foreach (ZonePostProc zoneStep in Structures[id.Segment].PostProcessingSteps)
                    {
                        //TODO: find a better way to feed ZonePostProcs into full structures.
                        //Is there a way for them to be stateless?
                        //Additionally, the ZonePostProcs themselves sometimes hold IGenSteps that are copied over to the layouts.
                        //Is that really OK? (I would guess yes because there is no chance by design for them to be mutated when generating...)
                        ZonePostProc newStep = zoneStep.Instantiate(initRand.NextUInt64());
                        newContext.ZoneSteps.Add(newStep);
                    }
                    structureContexts[id.Segment] = newContext;
                }
                ZoneGenContext zoneContext = structureContexts[id.Segment];
                zoneContext.CurrentID = id.ID;
                zoneContext.Seed      = mapSeed;

                //TODO: remove the need for this explicit cast
                //make a parameterized version of zonestructure and then make zonestructure itself put in basemapgencontext as the parameter
                Map map = ((BaseMapGenContext)Structures[id.Segment].GetMap(zoneContext)).Map;

                //uncomment this to cache the state of every map after its generation.  it's not nice on memory though...
                //maps.Add(id, map);
                return(map);
            }
            return(maps[id]);
        }
コード例 #8
0
        //include a current groundmap, with moveto methods included

        public void MoveToZone(int zoneIndex, SegLoc mapId, ulong seed)
        {
            if (CurrentZone != null)
            {
                CurrentZone.DoCleanup();
            }
            CurrentZoneID = zoneIndex;
            ZoneData zone = DataManager.Instance.GetZone(zoneIndex);

            if (zone != null)
            {
                CurrentZone = zone.CreateActiveZone(seed, zoneIndex);
                CurrentZone.SetCurrentMap(mapId);
            }
        }
コード例 #9
0
ファイル: Zone.cs プロジェクト: RogueCollab/RogueEssence
        /// <summary>
        /// Finds the mapname in this zone's map list, and loads it.
        /// </summary>
        /// <param name="mapname"></param>
        public void SetCurrentGround(string mapname)
        {
            exitMap();

            int index = GroundMaps.FindIndex((str) => (str == mapname));

            if (index > -1)
            {
                CurrentGround = GetGround(new SegLoc(-1, index));
            }
            else
            {
                throw new Exception(String.Format("Cannot find ground map of name {0} in {1}.", mapname, Name.DefaultText));
            }

            CurrentMapID = new SegLoc(-1, index);
        }
コード例 #10
0
ファイル: Zone.cs プロジェクト: RogueCollab/RogueEssence
        public void SetCurrentMap(SegLoc map)
        {
            exitMap();

            if (map.IsValid())
            {
                if (map.Segment > -1)
                {
                    CurrentMap = GetMap(map);
                }
                else
                {
                    CurrentGround = GetGround(map);
                }
            }
            CurrentMapID = map;
        }
コード例 #11
0
 public ZoneLoc(int id, SegLoc structId, int entryPoint)
 {
     ID         = id;
     StructID   = structId;
     EntryPoint = entryPoint;
 }
コード例 #12
0
 public ZoneLoc(int id, SegLoc structId)
 {
     ID         = id;
     StructID   = structId;
     EntryPoint = 0;
 }
コード例 #13
0
 public ZoneLoc(int structure, int id)
 {
     ID         = -1;
     StructID   = new SegLoc(structure, id);
     EntryPoint = 0;
 }
コード例 #14
0
ファイル: Zone.cs プロジェクト: RogueCollab/RogueEssence
 public GroundMap GetGround(SegLoc id)
 {
     return(DataManager.Instance.GetGround(GroundMaps[id.ID]));
 }