Example #1
0
 //State Related Methods////////////////////
 public void SetState(Type state)
 {
     if (_currentState.GetType() == state)
     {
         return;
     }
     Debug.Log("Player Changing from: " + _currentState.GetType() + " to: " + state);
     _currentState.EndState();
     _currentState = _states[state];
     _currentState.BeginState();
 }
Example #2
0
        public override void Start()
        {
            //Basics///////////////////////////////
            base.Start();
            Position           = CurrentNode.Position;
            _properHighlighter = GetComponent <ProperHighlighter>();
            _animator          = GetComponentInChildren <Animator>();

            //Setting up the Cache/////////////////
            _states = new Dictionary <Type, PlayerStateBase>();
            _states.Add(typeof(PlayerStateIdle), new PlayerStateIdle(this));
            _states.Add(typeof(PlayerStateWalking), new PlayerStateWalking(this));
            _states.Add(typeof(PlayerStateInteractionEnemy), new PlayerStateInteractionEnemy(this));
            _states.Add(typeof(PlayerStateInteractionBuilding), new PlayerStateInteractionBuilding(this));
            _states.Add(typeof(PlayerStateInteractionNPC), new PlayerStateInteractionNPC(this));
            _states.Add(typeof(PlayerStateInteractionProp), new PlayerStateInteractionProp(this));

            //Starting First State Manually////////
            _currentState = _states[typeof(PlayerStateIdle)];
            _currentState.BeginState();
        }