public void RewindMakeInvisible(Game g, GameEventState oldstate) { #if (DEBUG_EVENTS) Console.WriteLine("RewindMakeInvisible"); #endif g.EntityManager.Add(this); }
public void Create(Game g, GameEventState oldstate) { #if (DEBUG_EVENTS) Console.WriteLine("Create: {0}", pos.CurrentPosition); #endif g.EntityManager.Add(this); }
public void MakeInvisible(Game g, GameEventState oldstate) { #if (DEBUG_EVENTS) Console.WriteLine("MakeInvisible: {0}", pos.CurrentPosition); #endif g.EntityManager.Remove(this); }
public void RewindDestroy(Game g, GameEventState oldstate) { #if (DEBUG_EVENTS) Console.WriteLine("RewindDestroy"); #endif g.EntityManager.Add(this); }
public void RewindCreate(Game g, GameEventState oldstate) { #if (DEBUG_EVENTS) Console.WriteLine("RewindCreate"); #endif g.EntityManager.Remove(this); }
public GameEvent(double time, GameEventRunner doer, GameEventRunner rwnd, GameEventRunner undo) { Time = time; this.doer = doer; this.rewind = rwnd; this.undo = undo; state = GameEventState.Unprocessed; }
public bool Unpack(BinaryReader reader) { Name = Util.ReadString(reader, true); StartTime = reader.ReadInt32(); EndTime = reader.ReadInt32(); GameEventState = (GameEventState)reader.ReadInt32(); return(true); }
public void Do(Game g) { if (state == GameEventState.Undone) { throw new InvalidOperationException(); } if (state == GameEventState.Processed) { return; } doer(g, state); state = GameEventState.Processed; }
public void Undo(Game g) { switch (state) { case GameEventState.Undone: return; case GameEventState.Unprocessed: return; default: undo(g, state); break; } state = GameEventState.Undone; }
public void Rewind(Game g) { switch (state) { case GameEventState.Undone: throw new InvalidOperationException(); case GameEventState.Unprocessed: return; case GameEventState.Rewound: return; case GameEventState.Processed: rewind(g, state); break; } state = GameEventState.Rewound; }
public async Task <int> SlowMainLoop(Func <bool> turnEndFunc, Action gameFinishedFunc) { // Wait for GUI initialization await Task.Delay(TimeSpan.FromSeconds(1)); State = GameEventState.SettingUpTurn; var state = _gameInstance.State; _gameInstance.Reset(); int totalTurns = 0; state.SlowUpdateIsFinished(_gameInstance.MobManager); while (!_gameInstance.IsFinished) { while (IsPaused) { await Task.Delay(TimeSpan.FromMilliseconds(100)); } totalTurns++; await _gameInstance.CurrentController.SlowPlayTurn(this); ActionEvaluator.FNoCopy(_gameInstance, UctAction.EndTurnAction()); turnEndFunc(); await Task.Delay(200); } ReplayRecorder.Instance.SaveAndClear(_gameInstance); Console.WriteLine(Constants.GetLogBuffer()); gameFinishedFunc(); return(totalTurns); }
public void UndoMakeInvisible(Game g, GameEventState oldstate) { g.EntityManager.Add(this); iTime = -1; invisibility = null; }
public void UndoDestroy(Game g, GameEventState oldstate) { g.EntityManager.Add(this); dTime = -1; destruction = null; }
public void UndoCreate(Game g, GameEventState oldstate) { g.EntityManager.RemovePermanently(this); }
/// <summary> /// 用來作初始化 /// </summary> void Start() { _gameGUIPanel = GameGUIPanel.Instance; _gameState = GameNone.Instance; _dataTableManager = new DataTableManager(); _sceneManager = new SceneManager(); _playerInput = PlayerInput.Instance; _cameraManager = new CameraManager(); _gameEventManager = new GameEventManager(); _gameEventState = new GameEventState(); _npcUnitManager = NPCUnitManager.Instance; // 進入遊戲前需處理好的class,加載位置可能要換 _startDependencies.Add(_dataTableManager); }
void OnDestroy() { _gameGUIPanel = null; _gameState = null; _dataTableManager = null; _sceneManager = null; if (_playerInput != null) { Destroy(_playerInput); _playerInput = null; } _cameraManager = null; _gameEventManager = null; _gameEventState = null; if (_npcUnitManager != null) { Destroy(_npcUnitManager); _npcUnitManager = null; } _instance = null; }