Example #1
0
 public override void OnNewStateAdded(RexState _state)
 {
     if (_state.id == JumpState.idString && jumpState == null)
     {
         jumpState = _state as JumpState;
     }
 }
Example #2
0
		public override void OnNewStateAdded(RexState _state)
		{
			if(_state.id == WallClingState.idString && wallClingState == null)
			{
				wallClingState = _state as WallClingState;
			}	
		}
Example #3
0
 public void OnNewStateAdded(RexState _state)
 {
     if (_state.id == JumpState.idString && !jump.jumpState)
     {
         jump.jumpState = _state as JumpState;
     }
 }
Example #4
0
        private static void AddWallClingState()
        {
            GameObject selectedObject = GetSelectGameObject();

            if (selectedObject)
            {
                RexState state = selectedObject.AddComponent <WallClingState>();
                state.controller = selectedObject.GetComponent <RexController>();
            }
        }
Example #5
0
        public void SetStateToDefault(bool canInterruptSelf = false)         //Sets currentState either to DefaultState or to FallingState depending on whether or not it is grounded
        {
            RexState movement          = defaultState;
            bool     canMoveVertically = (movingState && movingState.canMoveVertically);

            if (slots.physicsObject && (!slots.physicsObject.IsOnSurface() && (slots.physicsObject.gravitySettings.usesGravity && !canMoveVertically)))
            {
                movement = fallingState;
            }

            if (!isKnockbackActive)
            {
                SetState(movement, canInterruptSelf);
            }
        }
Example #6
0
        public void AddState(RexState _state)
        {
            if (concurrentStates == null)
            {
                concurrentStates = new List <RexState>();
            }

            if (states == null)
            {
                states = new List <RexState>();
            }

            bool isStateAlreadyAdded = false;

            if (_state.isConcurrent)
            {
                for (int i = 0; i < concurrentStates.Count; i++)
                {
                    if (concurrentStates[i].id == _state.id)
                    {
                        isStateAlreadyAdded = true;
                        return;
                    }
                }

                if (!isStateAlreadyAdded)
                {
                    concurrentStates.Add(_state);
                }
            }
            else
            {
                for (int i = 0; i < states.Count; i++)
                {
                    if (states[i].id == _state.id)
                    {
                        isStateAlreadyAdded = true;
                        return;
                    }
                }

                if (!isStateAlreadyAdded)
                {
                    states.Add(_state);
                }
            }

            if (isStateAlreadyAdded)
            {
                return;
            }

            for (int i = 0; i < concurrentStates.Count; i++)
            {
                concurrentStates[i].OnNewStateAdded(_state);
            }

            for (int i = 0; i < states.Count; i++)
            {
                states[i].OnNewStateAdded(_state);
            }

            if (_state.id == BounceState.idString)
            {
                bounceState = _state.GetComponent <BounceState>();
            }
        }
Example #7
0
        //Attempts to set currentState to a new state
        public void SetState(RexState _state, bool canInterruptSelf = false)
        {
            bool isStateBlocked = false;

            if (_state.id == KnockbackState.idString && !currentState.isKnockbackEnabled)
            {
                isStateBlocked = true;
            }

            if (currentState && currentState.id == CrouchState.idString && !currentState.GetComponent <CrouchState>().CanExitCrouch())
            {
                isStateBlocked = true;
            }

            if (_state.id == KnockbackState.idString && isStateBlocked)
            {
                if (slots.audio && _state.audioClip)                //Play the damaged sound even if knockback itself doesn't happen
                {
                    slots.actor.PlaySoundIfOnCamera(_state.audioClip, 1.0f, slots.audio);
                }
            }

            if (isStateBlocked || slots.actor && slots.actor.isDead || !_state.isEnabled)
            {
                return;
            }

            if (_state != currentState || canInterruptSelf)
            {
                _state.hasEnded = false;

                if (_state != null)
                {
                    previousState = currentState;
                    currentState  = _state;
                }

                if (previousState)
                {
                    if (_state.id == KnockbackState.idString)
                    {
                        isKnockbackActive = true;
                        previousState.End();
                    }

                    previousState.OnStateChanged();
                }

                if (!_state.IsTurnAnimationOverriding())
                {
                    CancelTurn();
                }

                if (slots.actor)
                {
                    slots.actor.OnStateChanged(_state);
                    slots.actor.OnStateEntered(_state);
                    slots.actor.OnStateExited(previousState);
                }

                _state.OnBegin();

                if (slots.audio && _state.audioClip)
                {
                    slots.actor.PlaySoundIfOnCamera(_state.audioClip, 1.0f, slots.audio);
                }

                /*if(slots.actor.tag == "Player" && previousState)
                 *      Debug.Log(slots.actor.gameObject.name + " :: Begin State " + _state.id + "   from: " + previousState.id);*/

                if ((_state.willPlayAnimationOnBegin || slots.actor.currentAttack != null) && (!isKnockbackActive || _state.id == KnockbackState.idString))
                {
                    //Debug.Log("Playing animation for state: " + _state.id);
                    _state.PlayAnimation();
                }
            }
        }
Example #8
0
 public virtual void OnNewStateAdded(RexState _state)
 {
 }
Example #9
0
 //Called whenever the controller changes state. This can be overidden to have unique secondary effects when an actor changes to a particular state.
 public virtual void OnStateExited(RexState newState)
 {
 }
Example #10
0
 //Called whenever the controller changes state. This can be overidden to have unique secondary effects when an actor changes to a particular state.
 public virtual void OnStateEntered(RexState newState)
 {
 }
Example #11
0
 //Called whenever the controller changes state. This can be overidden to have unique secondary effects when an actor changes to a particular state.
 public virtual void OnStateChanged(RexState newState)
 {
 }