示例#1
0
        public void CheckWarps()
        {
            var warp = ParentBoard.Warps.Find(w => /* !String.IsNullOrEmpty(w.TargetBoard) && */ w.XPosition == XPosition && w.YPosition == YPosition);

            if (warp != null)
            {
                if (warp.TargetBoard == -1)                 //ungenerated dungeon
                {
                    DungeonGenerator.DungeonGeneratorEntranceBoardNum = ParentBoard.BoardNum;
                    DungeonGenerator.DungeonGeneratorEntranceWarpID   = warp.ID;
                    DungeonGenerator.DungeonGeneratorBiome            = (int)ParentBoard.GetToken("biome").Value;
                    DungeonGenerator.CreateDungeon();
                    return;
                }
                else if (warp.TargetBoard == -2)                 //unconnected dungeon
                {
                    Travel.Open();
                    return;
                }

                var game        = NoxicoGame.Me;
                var targetBoard = game.GetBoard(warp.TargetBoard);                 //game.Boards[warp.TargetBoard]; //.Find(b => b.ID == warp.TargetBoard);

                var sourceBoard = ParentBoard;

                ParentBoard.EntitiesToRemove.Add(this);
                game.CurrentBoard = targetBoard;
                ParentBoard       = targetBoard;
                ParentBoard.Entities.Add(this);
                var twarp = targetBoard.Warps.Find(w => w.ID == warp.TargetWarpID);
                if (twarp == null)
                {
                    XPosition = 0;
                    YPosition = 0;
                }
                else
                {
                    XPosition = twarp.XPosition;
                    YPosition = twarp.YPosition;
                }
                ParentBoard.AimCamera();
                ParentBoard.UpdateLightmap(this, true);
                ParentBoard.Redraw();
                ParentBoard.PlayMusic();
                NoxicoGame.Immediate = true;

                //Going from a dungeon to a wild board?
                if (targetBoard.GetToken("type").Value == 0 && sourceBoard.GetToken("type").Value == 2)
                {
                    game.FlushDungeons();
                }
            }
        }