private void PanelDraw(object sender, EventArgs e) { if ((!(sender is MapPanel))) { return; } var mapPanel = (MapPanel)sender; var pointList = Bresenham.GeneratePointsFromLine(_origin, _selectedPosition, false).ToList(); bool path = true; for (int i = 0; i < pointList.Count; i++) { var point = pointList[i]; if (path) { path = mapPanel.World.CurrentLevel.IsWalkable(point); } var adjusted = point - mapPanel.ViewOffset; if (i == pointList.Count - 1) { mapPanel.Canvas.Console.setCharBackground(adjusted.X, adjusted.Y, path ? ColorPresets.Green.TCODColor : ColorPresets.Red.TCODColor, TCODSystem.getElapsedMilli() % 1000 > 500 ? TCODBackgroundFlag.Lighten : TCODBackgroundFlag.None); } else { mapPanel.Canvas.Console.setCharBackground(adjusted.X, adjusted.Y, path ? ColorPresets.Green.TCODColor : ColorPresets.Red.TCODColor, TCODBackgroundFlag.Lighten); } } }
private int Run() { if (StateCount <= 0) { Window win = new Window(new WindowTemplate()); Push(win); } while (!TCODConsole.isWindowClosed() && !IsQuitting) { var newUpdateMilli = TCODSystem.getElapsedMilli(); var elapsedUpdateTime = newUpdateMilli - _lastUpdateMilli; // if (elapsedUpdateTime > upsFrameLength) { _lastUpdateMilli = newUpdateMilli; Update(elapsedUpdateTime); // } var newDrawMilli = TCODSystem.getElapsedMilli(); var elapsedDrawTime = newDrawMilli - _lastDrawMilli; // if (elapsedDrawTime > fpsFrameLength) { _lastDrawMilli = newDrawMilli; Draw(elapsedDrawTime); // } } return(0); }
// ///////////////////////////////////////////////////////////////////////////////// // ///////////////////////////////////////////////////////////////////////////////// /// <summary> /// Called each iteration of the main loop (each frame). /// Override and add specific logic update code after calling base method. /// </summary> protected virtual void Update() { if (UpdateEventHandler != null) { UpdateEventHandler(this, EventArgs.Empty); } uint elapsed = TCODSystem.getElapsedMilli(); CurrentWindow.OnTick(); Input.Update(elapsed); }
private void PanelDraw(object sender, EventArgs e) { if (!(sender is MapPanel)) { return; } var mapPanel = (MapPanel)sender; var adjusted = SelectedPosition - mapPanel.ViewOffset; mapPanel.Canvas.Console.setCharBackground(adjusted.X, adjusted.Y, ColorPresets.Green.TCODColor, TCODSystem.getElapsedMilli() % 1000 > 500 ? TCODBackgroundFlag.Lighten : TCODBackgroundFlag.None); }
// ///////////////////////////////////////////////////////////////////////////////// // ///////////////////////////////////////////////////////////////////////////////// /// <summary> /// Called each application loop iteration. Override to add specific update code. /// </summary> internal protected virtual void OnTick() { uint milli = TCODSystem.getElapsedMilli(); LastTickElapsed = milli - TotalElapsed; TotalElapsed = milli; if (Tick != null) { Tick(this, EventArgs.Empty); } if (scheduleList.Count > 0) { foreach (Schedule s in scheduleList) { s.Update(LastTickElapsed); } } if (scheduleRemoveList.Count > 0) { foreach (Schedule s in scheduleRemoveList) { scheduleList.Remove(s); } scheduleRemoveList.Clear(); } if (scheduleAddList.Count > 0) { foreach (Schedule s in scheduleAddList) { scheduleList.Add(s); } scheduleAddList.Clear(); } }