Esempio n. 1
0
        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));
        }
Esempio n. 2
0
        /// <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);
        }
Esempio n. 3
0
 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);
        }
Esempio n. 5
0
        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;
        }
Esempio n. 6
0
 /// <summary>
 /// Changes the game phase on the controller
 /// </summary>
 /// <param name="phaseType">Phase type</param>
 protected void GoToPhase(GamePhaseType phaseType)
 {
     Controller.SetPhase(phaseType);
 }
Esempio n. 7
0
 /// <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);
 }
Esempio n. 8
0
 private void _controller_GamePhaseChanged(object sender, GamePhaseType e)
 {
 }
Esempio n. 9
0
 public virtual void GamePhaseChanged(GamePhaseType phase)
 {
 }