Exemple #1
0
 public void EnableState(GameStateBase state, object model)
 {
     if (CurrentState != null)
     {
         CurrentState.OnStateLeave();
         PreviousState         = CurrentState;
         PreviousState.enabled = false;
     }
     CurrentState         = state;
     CurrentState.enabled = true;
     CurrentState.OnStateEnter(model);
 }
Exemple #2
0
        public override void Load()
        {
            States       = new List <GameStateBase>(Object.FindObjectsOfType <GameStateBase>());
            Translations = new List <GameStateTranslation>(Object.FindObjectsOfType <GameStateTranslation>());
            InitialState = States.FirstOrDefault(s => s.GetType().GetCustomAttributes(typeof(EntryStateAttribute), false).Any());

            if (InitialState == null)
            {
                Logs.Instance.ProcessError("Initial game state not found. Using '" + States.FirstOrDefault().GetType().Name + "' state");
                InitialState = States.FirstOrDefault();
            }
        }
Exemple #3
0
        public void EnableStateWithTranslation(GameStateBase state, GameStateTranslation translation, object stateModel,
                                               object translationModel)
        {
            if (IsInTranslation)
            {
                Logs.Instance.ProcessError("Already in translation!");
                return;
            }

            nextStateModel = stateModel;
            nextState      = state;

            currentTranslation = translation;

            translation.PreviousState = CurrentState;
            translation.NextState     = state;

            translation.OnTranslationBegin(translationModel);
            translation.enabled = true;
            CurrentState.OnTranslationFromStateBegin();
            state.OnTranslationToStateBegin();
        }