Beispiel #1
0
        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);
        }