public Dungeon(Creature pCreator, int pRegionStart, DungeonScript pScript, out int nextAvailableRegion) { //TODO: Party support when parties are once again added Creators.Add(pCreator); if (!ChannelServer.Instance.World.HasRegion(pRegionStart)) { ChannelServer.Instance.World.AddRegion(pRegionStart); } this.EntryRegion = ChannelServer.Instance.World.GetRegion(pRegionStart); _script = Activator.CreateInstance(pScript.GetType()) as DungeonScript; _script.OnLoad(); _script.Dungeon = this; _script.RegionIndex = ++pRegionStart; this.InstanceID = ChannelServer.Instance.World.DungeonManager.NewInstance(); this.Build(); Log.Info("Region Index: {0}", _script.RegionIndex); //Set up props long entryPropIndex = 0x00A0000000000000 + ((long)this.EntryRegion.Id << 32) + ((long)0x0001 << 16); var leaveStatue = new Prop(entryPropIndex + 2, "", "", 0, this.EntryRegion.Id, 3250, 3250, Direction.North); leaveStatue.Behavior = new PropFunc( (Creature pCreature, Prop pProp) => { this.RemovePlayer(pCreature); }); var moveDownProp = new Prop(entryPropIndex + 3, "", "", 0, this.EntryRegion.Id, 3250, 4500, Direction.North); moveDownProp.Behavior = new PropFunc( (Creature pCreature, Prop pProp) => { var ePos = Floors[0].EntrancePosition; pCreature.Warp(Floors[0].Region.Id, ePos.X, ePos.Y); Send.DungeonWarp(pCreature); Send.WarpRegion(pCreature as PlayerCreature); }); this.EntryRegion.AddProp(leaveStatue); this.EntryRegion.AddProp(moveDownProp); //Warp player in this.AddPlayer(pCreator); nextAvailableRegion = _script.RegionIndex; Log.Info("Next Available Region {0}", nextAvailableRegion); }
public void AddScript(DungeonScript pScript) { var key = Tuple.Create(pScript.Lobby, pScript.Level); if (!_scripts.ContainsKey(key)) { _scripts[key] = new List <DungeonScript>(); } _scripts[key].Add(pScript); }
void Load() { if (File.Exists(Application.persistentDataPath + "/" + SaveFileScript.CurrentSaveFile.ToString() + "/" + DungeonName.ToString() + "/BaseDungeon.dat")) { BinaryFormatter bf = new BinaryFormatter(); FileStream file = File.Open(Application.persistentDataPath + "/" + SaveFileScript.CurrentSaveFile.ToString() + "/" + DungeonName.ToString() + "/BaseDungeon.dat", FileMode.Open); DungeonInfo dungeon = (DungeonInfo)bf.Deserialize(file); file.Close(); GeneratedLevelIndexes = dungeon.GeneratedLevels; MaxLevelIndex = dungeon.MaxLevels; BossDeceased = dungeon.bossDeceased; CurrentLevelIndex = dungeon.CurrentLevel; if (dungeon.isCurrentDungeon) { CurrentDungeon = this; } List <GameObject> children = new List <GameObject>(); // make sure we clear out all the old levels if any foreach (Transform child in gameObject.transform) { children.Add(child.gameObject); } foreach (GameObject child in children) { Destroy(child); } //recreate all the levels that we had for (int i = 0; i < GeneratedLevelIndexes; i++) { GameObject level = Instantiate(Resources.Load("Level") as GameObject); level.transform.SetParent(gameObject.transform); level.transform.SetSiblingIndex(i); level.GetComponent <LevelScript>().Load(); Levels.Add(level.GetComponent <LevelScript>()); } } }
public void SetAsCurrentDungeon() { //StaticDungeonScript.dungeon.dungeonThemes.Clear(); //StaticDungeonScript.dungeon.dungeonThemes.Add(DungeonTheme); CurrentDungeon = gameObject.GetComponent <DungeonScript>(); }