public IGamePhase CreatePhase(GamePhaseType phaseType, IGameController controller) { Type phaseTypeToCreate; switch (phaseType) { case GamePhaseType.Initialization: phaseTypeToCreate = typeof(TInitializationPhase); break; case GamePhaseType.HandicapPlacement: phaseTypeToCreate = typeof(THandicapPlacementPhase); break; case GamePhaseType.Main: phaseTypeToCreate = typeof(TMainPhase); break; case GamePhaseType.LifeDeathDetermination: phaseTypeToCreate = typeof(TLifeAndDeathPhase); break; case GamePhaseType.Finished: phaseTypeToCreate = typeof(TFinishedPhase); break; default: throw new ArgumentOutOfRangeException(nameof(phaseType), phaseType, null); } return((IGamePhase)Activator.CreateInstance(phaseTypeToCreate, controller)); }
/// <summary> /// Sets the default phase of the game /// </summary> /// <param name="phase">Phase type to set</param> internal void SetPhase(GamePhaseType phase) { //create new phase of the requested type from the factory var newPhase = this.PhaseFactory.CreatePhase(phase, this); SetPhase(newPhase); }
public override void GamePhaseChanged(GamePhaseType phase) { if (phase == GamePhaseType.Finished) { (AI as OldFuego)?.Finished(); } base.GamePhaseChanged(phase); }
public object Convert(object value, Type targetType, object parameter, string language) { GamePhaseType currentPhase = (GamePhaseType)value; if (currentPhase == RequiredGamePhase) { return(Visibility.Visible); } return(Visibility.Collapsed); }
protected virtual void OnGamePhaseChanged(GamePhaseChangedEventArgs phaseState) { if (phaseState.PreviousPhase != null) { _phaseEndHandlers.ItemOrDefault(phaseState.PreviousPhase.Type)? .Invoke(phaseState.PreviousPhase); } if (phaseState.NewPhase != null) { _phaseStartHandlers.ItemOrDefault(phaseState.NewPhase.Type)? .Invoke(phaseState.NewPhase); } // Define publicly the new phase GamePhase = phaseState.NewPhase.Type; }
/// <summary> /// Changes the game phase on the controller /// </summary> /// <param name="phaseType">Phase type</param> protected void GoToPhase(GamePhaseType phaseType) { Controller.SetPhase(phaseType); }
/// <summary> /// Server indicates that it wants to change the game phase /// </summary> /// <param name="gamePhase">Game phase type to start</param> public void SetPhaseFromServer(GamePhaseType gamePhase) { _gameController.SetPhase(gamePhase); }
private void _controller_GamePhaseChanged(object sender, GamePhaseType e) { }
public virtual void GamePhaseChanged(GamePhaseType phase) { }