예제 #1
0
        public void RewindMakeInvisible(Game g, GameEventState oldstate)
        {
#if (DEBUG_EVENTS)
            Console.WriteLine("RewindMakeInvisible");
#endif
            g.EntityManager.Add(this);
        }
예제 #2
0
        public void Create(Game g, GameEventState oldstate)
        {
#if (DEBUG_EVENTS)
            Console.WriteLine("Create: {0}", pos.CurrentPosition);
#endif
            g.EntityManager.Add(this);
        }
예제 #3
0
        public void MakeInvisible(Game g, GameEventState oldstate)
        {
#if (DEBUG_EVENTS)
            Console.WriteLine("MakeInvisible: {0}", pos.CurrentPosition);
#endif
            g.EntityManager.Remove(this);
        }
예제 #4
0
        public void RewindDestroy(Game g, GameEventState oldstate)
        {
#if (DEBUG_EVENTS)
            Console.WriteLine("RewindDestroy");
#endif
            g.EntityManager.Add(this);
        }
예제 #5
0
        public void RewindCreate(Game g, GameEventState oldstate)
        {
#if (DEBUG_EVENTS)
            Console.WriteLine("RewindCreate");
#endif
            g.EntityManager.Remove(this);
        }
예제 #6
0
 public GameEvent(double time, GameEventRunner doer, GameEventRunner rwnd, GameEventRunner undo)
 {
     Time        = time;
     this.doer   = doer;
     this.rewind = rwnd;
     this.undo   = undo;
     state       = GameEventState.Unprocessed;
 }
예제 #7
0
        public bool Unpack(BinaryReader reader)
        {
            Name = Util.ReadString(reader, true);

            StartTime = reader.ReadInt32();
            EndTime   = reader.ReadInt32();

            GameEventState = (GameEventState)reader.ReadInt32();

            return(true);
        }
예제 #8
0
 public void Do(Game g)
 {
     if (state == GameEventState.Undone)
     {
         throw new InvalidOperationException();
     }
     if (state == GameEventState.Processed)
     {
         return;
     }
     doer(g, state);
     state = GameEventState.Processed;
 }
예제 #9
0
        public void Undo(Game g)
        {
            switch (state)
            {
            case GameEventState.Undone:
                return;

            case GameEventState.Unprocessed:
                return;

            default:
                undo(g, state);
                break;
            }
            state = GameEventState.Undone;
        }
예제 #10
0
        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;
        }
예제 #11
0
        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);
        }
예제 #12
0
 public void UndoMakeInvisible(Game g, GameEventState oldstate)
 {
     g.EntityManager.Add(this);
     iTime        = -1;
     invisibility = null;
 }
예제 #13
0
 public void UndoDestroy(Game g, GameEventState oldstate)
 {
     g.EntityManager.Add(this);
     dTime       = -1;
     destruction = null;
 }
예제 #14
0
 public void UndoCreate(Game g, GameEventState oldstate)
 {
     g.EntityManager.RemovePermanently(this);
 }
예제 #15
0
    /// <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);
    }
예제 #16
0
 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;
 }