Exemplo n.º 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();
                }
            }
        }
Exemplo n.º 2
0
        public void OpenBoard(int index)
        {
            if (this.ParentBoard != null)
            {
                this.ParentBoard.EntitiesToRemove.Add(this);
                this.ParentBoard.SaveToFile(this.ParentBoard.BoardNum);
            }
            var n = NoxicoGame.Me;

            this.ParentBoard = n.GetBoard(index);
            n.CurrentBoard   = this.ParentBoard;
            this.ParentBoard.Entities.Add(this);
            ParentBoard.CheckCombatStart();
            ParentBoard.CheckCombatFinish();
            ParentBoard.UpdateLightmap(this, true);
            ParentBoard.Redraw();
            ParentBoard.PlayMusic();
            NoxicoGame.Immediate = true;

            if (ParentBoard.BoardType == BoardType.Town)
            {
                var boardName = ParentBoard.Name;
                var known     = NoxicoGame.TravelTargets.ContainsValue(boardName);
                if (!known)
                {
                    NoxicoGame.TravelTargets.Add(index, boardName);
                    Program.WriteLine("Registered {0} as a fast-travel target.", boardName);
                }
            }

            this.ParentBoard.AimCamera(XPosition, YPosition);

            if (this.DijkstraMap != null)
            {
                this.DijkstraMap.UpdateWalls(ParentBoard, !Character.IsSlime);
                this.DijkstraMap.Update();
            }
            if (this.AutoTravelMap == null)
            {
                this.AutoTravelMap = new Dijkstra(this.ParentBoard);
                this.AutoTravelMap.Hotspots.Add(new Point(this.XPosition, this.YPosition));
            }
            this.AutoTravelMap.UpdateWalls(ParentBoard, !Character.IsSlime);
        }