//Generate a map and display it. Could just as easily pass it into public MapConsole(int width, int height, int viewportWidth, int viewportHeight) : base(width, height) { Map = GenerateDungeon(100, 100); GameFrameManager = new GameFrameManager(Map); GameFrameManager.LogicFrameCompleted += OnLogicCompleted; Actions = new ActionStack(); ViewPort = new XnaRect(0, 0, viewportWidth, viewportHeight); Map.ConfigureAsRenderer(this); Map.ControlledGameObject = Game.Player; Map.ControlledGameObject.IsFocused = true; // Set player to receive input, since in this example the player handles movement // Game.Player.IsFocused = true; // Set up to recalculate FOV and set camera position appropriately when the player moves. Also make sure we hook the new // Player if that object is reassigned. // Map.ControlledGameObject.Moved += Player_Moved; // Map.ControlledGameObjectChanged += ControlledGameObjectChanged; // Calculate initial FOV and center camera Map.CalculateFOV(Game.Player.Position, Game.Player.FOVRadius, Radius.CIRCLE); this.CenterViewPortOnPoint(Game.Player.Position); this.AddObserver(OnPlayerPerformedAction, InputManager.PlayerDidMoveNotification); }
public override void Update(TimeSpan timeElapsed) { base.Update(timeElapsed); GameFrameManager.Update(this, timeElapsed); Actions.Run(timeElapsed); }
public DungeonScreen(SadConsole.Tiles.TileMap map) { // Setup map Map = map; MapConsole = new ScrollingConsole(map.Width, map.Height, SadConsole.Global.FontDefault, new Rectangle(0, 0, ScreenRegionMap.Width, ScreenRegionMap.Height), null); Map.ConfigureAsRenderer(MapConsole); MapConsole.Position = ScreenRegionMap.Location; //MapConsole.ViewPort = new Rectangle(0, 0, ScreenRegionMap.Width, ScreenRegionMap.Height); // Setup actions ActionProcessor = new SadConsole.Actions.ActionStack(); ActionProcessor.Push(new SadConsole.Actions.ActionDelegate(ActionKeyboardProcessor)); _frameManager = new GameFrameManager(map); _frameManager.LogicFrameCompleted += (s, e) => RedrawMap = true; // Setup messages Messages = new MessageConsole(ScreenRegionMessages.Width, ScreenRegionMessages.Height) { Position = ScreenRegionMessages.Location }; Children.Add(Messages); Children.Add(MapConsole); }
// Update is called once per frame public void Update() { UpdateDeviceLost(); if (!mainCam) { mainCam = Camera.main; } // 帧 GameFrameManager.OnUpdate(); // 定时器 TimerManager.OnUpdate(); DoTask(); // 当前正在载入地图,不要处理消息 if (loading != null) { if (!loading.isDone) { ViewEventHelper.Instance.SendCommand(GameLogicDef.GVIEWCMD_PROGRESSING, (int)(loading.progress * 100)); return; } else { loading = null; ViewEventHelper.Instance.SendCommand(GameLogicDef.GVIEWCMD_PROGRESSING, 100); Trace.Log("load level asyn ok!"); } } if (bCreated) { GameLogicAPI.onFrameUpdate(); } FuntionShortCutCtrl nFunctionCtr = FuntionShortCutCtrl.GetInstance(); if (InputManager.Raw_GetKeyUp(nFunctionCtr.GetKeyCodeByIndex(FuntionShortCutSlotIndex.ControlTraceOpen))) { if (!string.IsNullOrEmpty(LogFileName)) { Process.Start(LogFileName); } } SkinManager.OnUpdate(); SafeZone.Update(); SafeZoneEffectManager.Update(); if (isNeedToQuit) { bForbidQuit = false; Application.Quit(); } if (NeedToReStart) { enabled = false; NeedToReStart = false; ReStartApplication(); return; } GUIDE.GuideManager.Update(); // 通知逻辑层处理消息 //ViewEventHelper.Instance.SendCommand(GameLogicDef.GVIEWCMD_FRAME_UPDATE); }