private void FixedUpdate()
        {
            switch (Character.CurrentState)
            {
            case Character.State.Stunned:
                Speed.Reinitialize();
                break;

            default:
                Move();
                if (Type == MovementType.GroundOnly && Character.GroundCheck.Evaluate())
                {
                    int savedLayer = Character.gameObject.layer;
                    Character.gameObject.layer = 2;
                    bool v = !Character.GroundCheck.Check.Evaluate();
                    Character.gameObject.layer = savedLayer;
                    if (v && previousState == Character.State.Moving && Character.CurrentState == Character.State.Idle && Character.Input.Dir == CharacterInput.Direction.None)
                    {
                        // If Character falls off of an edge, and does not want to move, drop straight below!
                        Character.MovementExecution.Reinitialize();
                        Character.MovementExecution.Rigidbody.velocity = Vector2.zero;
                    }
                }
                break;
            }
            previousState = Character.CurrentState;
            if (Character.Input.Dir != CharacterInput.Direction.None)
            {
                previousDirection = Character.Input.Dir;
            }
        }
示例#2
0
        private Vector3 Headbob()
        {
            if (HookPlayer.Instance == null)
            {
                return(Vector3.zero);
            }
            PlayerCharacter playerCharacter = HookPlayer.Instance.Get <PlayerCharacter>();

            if (playerCharacter == null)
            {
                return(Vector3.zero);
            }

            Character.State state = playerCharacter.GetCharacterState();
            if (!state.isGrounded)
            {
                return(Vector3.zero);
            }

            float speed = Mathf.Abs(state.forwardSpeed.magnitude);

            return(new Vector3(
                       Mathf.Sin((speed / this.headbobPeriod * 2.0f) * Time.time) * this.headbobAmount.x,
                       Mathf.Sin((speed / this.headbobPeriod * 1.0f) * Time.time) * this.headbobAmount.y,
                       Mathf.Sin((speed / this.headbobPeriod * 1.0f) * Time.time) * this.headbobAmount.z
                       ));
        }
        public override bool CanEnter(MemoryEvent target)
        {
            Character.State state = character.GetState(id);

            return
                /// can transition happen from current state?
                ((requireTransition || character.GetCurrentState().GetTransition(state) != null) &&
                 /// can enter atm?
                 state.CanEnterSoft());
        }
示例#4
0
 /// <summary>
 /// <para>name : IsEndState</para>
 /// <para>parameter : Character.State</para>
 /// <para>return : bool</para>
 /// <para>describe : Check character's state of the immovable character.</para>
 /// </summary>
 private static bool IsEndState(Character.State state)
 {
     switch (state)
     {
     case Character.State.Damage:
     case Character.State.Death:
     case Character.State.MidairDamage:
         return(true);
     }
     return(false);
 }
示例#5
0
    override public bool SetState(Character.State State)
    {
        switch (State)
        {
        case Character.State.Respawn:
            return(true);

        default:
            break;
        }
        return(false);
    }
示例#6
0
    private static Event CharacterStateToEvent(Character.State state)
    {
        switch (state)
        {
        case Character.State.Chomp:
            return(Event.Eaten);

        case Character.State.Squash:
            return(Event.Smashed);

        default:
            return(Event.Fell);
        }
    }
示例#7
0
    private void OnCharacterKilled(Character.State state)
    {
        this.HUD.StopStopWatch();
        this.HUD.ReactTo(CharacterStateToEvent(state));

        this.Terrain.Deactivate();
        this.Music.Stop();
        this.HUD.DisplaySkipMessage();

        this.GameState.TrackTime(this.HUD.GetTime());

        this.LostSound.Play();

        this.RegisterNextScene("res://scenes/menus/GameOverMenu.tscn");
        this.GetTree().CreateTimer(WaitTimeAfterEnd).Connect("timeout", this, "GoToScene");
    }
        private Vector3 Headbob()
        {
            if (HookPlayer.Instance == null)
            {
                return(Vector3.zero);
            }

            PlayerCharacter playerCharacter = HookPlayer.Instance.Get <PlayerCharacter>();

            if (playerCharacter == null)
            {
                return(Vector3.zero);
            }

            if (Mathf.Approximately(this.headbobPeriod, 0f))
            {
                return(Vector3.zero);
            }

            Character.State state = playerCharacter.GetCharacterState();
            if (!playerCharacter.IsGrounded())
            {
                return(Vector3.zero);
            }

            float speed = Mathf.Abs(state.forwardSpeed.magnitude);

            speed = (
                speed > playerCharacter.characterLocomotion.runSpeed - 0.1f ? 1f :
                speed > (playerCharacter.characterLocomotion.runSpeed / 2f) - 0.1f ? 0.5f :
                0f
                );

            this.headbobLerpAmount = Mathf.SmoothDamp(
                this.headbobLerpAmount, speed,
                ref this.headbobLerpVelocity, 0.1f
                );

            Vector3 headbobVector = new Vector3(
                Mathf.Sin((speed / this.headbobPeriod) * 2.0f * Time.time) * this.headbobAmount.x,
                Mathf.Sin((speed / this.headbobPeriod) * 1.0f * Time.time) * this.headbobAmount.y,
                Mathf.Sin((speed / this.headbobPeriod) * 1.0f * Time.time) * this.headbobAmount.z
                );

            return(Vector3.Slerp(Vector3.zero, headbobVector, this.headbobLerpAmount));
        }
示例#9
0
        private void Character_StateChanged(Character character, Character.State currentState, Character.State previousState)
        {
            switch (currentState)
            {
            case Character.State.Idle:
                SpriteAnimator.SetAnimation(IdleAnimation);
                break;

            case Character.State.Moving:
                SpriteAnimator.SetAnimation(WalkAnimation);
                break;

            case Character.State.Jumping:
                SpriteAnimator.SetAnimation(JumpAnimation);
                JumpParticleSystem.Play();
                break;
            }
        }
示例#10
0
        public virtual float GetShootDeviation()
        {
            if (this.character != null)
            {
                Character.State state = this.character.GetCharacterState();
                if (state.forwardSpeed.magnitude <= 0.1f)
                {
                    return(0);
                }
                else if (this.character.IsGrounded())
                {
                    return(0.5f);
                }
                else
                {
                    return(1f);
                }
            }

            return(0f);
        }
示例#11
0
        private Vector3 Headbob()
        {
            if (HookPlayer.Instance == null)
            {
                return(Vector3.zero);
            }

            PlayerCharacter playerCharacter = HookPlayer.Instance.Get <PlayerCharacter>();

            if (playerCharacter == null)
            {
                return(Vector3.zero);
            }

            if (Mathf.Approximately(this.headbobPeriod, 0f))
            {
                return(Vector3.zero);
            }

            Character.State state = playerCharacter.GetCharacterState();
            if (!playerCharacter.IsGrounded())
            {
                return(Vector3.zero);
            }

            float speed = Mathf.Abs(state.forwardSpeed.magnitude);
            float coeff = Mathf.InverseLerp(
                playerCharacter.characterLocomotion.runSpeed / 2f,
                playerCharacter.characterLocomotion.runSpeed,
                speed
                );

            Vector3 headbobVector = new Vector3(
                Mathf.Sin((1f / this.headbobPeriod) * 2.0f * Time.time) * this.headbobAmount.x,
                Mathf.Sin((1f / this.headbobPeriod) * 1.0f * Time.time) * this.headbobAmount.y,
                Mathf.Sin((1f / this.headbobPeriod) * 1.0f * Time.time) * this.headbobAmount.z
                );

            return(headbobVector * coeff);
        }
示例#12
0
        protected override void Update()
        {
            base.Update();

            if (!Application.isPlaying)
            {
                return;
            }

            if (this.isReloading || this.isHolstering || this.isDrawing)
            {
                this.targPrecision = 1f;
            }
            else
            {
                Character.State state    = this.character.GetCharacterState();
                Vector3         movement = state.forwardSpeed + (Vector3.up * state.verticalSpeed);
                this.targPrecision = movement.magnitude / this.character.characterLocomotion.runSpeed;
            }

            float smoothDown = (
                this.currentAmmo != null &&
                this.currentAmmo.aimingMode == Ammo.AimType.Crosshair
                    ? this.currentAmmo.crosshairFocusTime
                    : WeaponCrosshair.SMOOTH_TIME_DN
                );

            this.currPrecision = Mathf.SmoothDamp(
                this.currPrecision,
                this.targPrecision,
                ref this.veloPrecision,
                (this.currPrecision > this.targPrecision
                    ? smoothDown : WeaponCrosshair.SMOOTH_TIME_UP
                )
                );
        }
示例#13
0
 public FallingState(FSM <Character.State, Character.Trigger, Character.ChangedStateEventArgs> fsm, Character.State state, Character character) : base(fsm, state, character)
 {
     rigidbody2D = character.GetComponent <Rigidbody2D>();
     collider    = character.GetComponent <BoxCollider2D>();
     diameter    = collider.size.y / 2;
 }
示例#14
0
 public MovingState(FSM <Character.State, Character.Trigger, Character.ChangedStateEventArgs> fsm, Character.State state, Character character) : base(fsm, state, character)
 {
     rigidbody2D = character.GetComponent <Rigidbody2D>();
 }
 private void OnEnable()
 {
     previousState     = Character.CurrentState;
     previousDirection = Character.Input.Dir;
 }
示例#16
0
 private void Character_StateChanged(Character character, Character.State currentState, Character.State previousState)
 {
     enabled = currentState == Character.State.Idle;
 }
示例#17
0
 public CharacterHiddenState(Character.State stateId, string debugName = null) : base(stateId, debugName)
 {
 }
示例#18
0
 public JumpingState(FSM <Character.State, Character.Trigger, Character.ChangedStateEventArgs> fsm, Character.State state, Character character) : base(fsm, state, character)
 {
     rigidbody2D = character.GetComponent <Rigidbody2D>();
     collider    = character.GetComponent <Collider2D>();
     height      = collider.bounds.size.y;
 }
 public override void Beggin()
 {
     state = character.GetState(id);
     delay = 5;
 }
示例#20
0
 virtual public bool SetState(Character.State State)
 {
     return(false);
 }
示例#21
0
 public CharacterChoiceJumpOrFallState(Character.State stateId, string debugName = null) : base(stateId, debugName)
 {
 }
示例#22
0
 public CharacterIdleState(FSM <Character.State, Character.Trigger, Character.ChangedStateEventArgs> fsm, Character.State state, Character character) : base(fsm, state, character)
 {
 }
示例#23
0
 public CharacterChoiceIdleOrWalkState(Character.State stateId, string debugName = null) : base(stateId, debugName)
 {
 }
示例#24
0
 public CharacterWalkingState(Character.State stateId, string debugName = null) : base(stateId, debugName)
 {
 }
示例#25
0
 public CharacterGroundedState(Character.State stateId, string debugName = null)
     : base(stateId, debugName)
 {
 }