Exemplo n.º 1
0
 public override void OnExcuteWithEvent(MovementFsm fsm)
 {
     //fsm.ProcessCollisionBacktrack(fsm.boxRayCaster.Right);
     //fsm.ProcessCollisionBacktrack(fsm.boxRayCaster.Left);
     if (!fsm.boxRayCaster.Down.CheckCollision(fsm.onGroundLayer))
     {
         fsm.ChangeState(InAirStateWithEvent.Instance);
         return;
     }
 }
Exemplo n.º 2
0
        public override void OnEnterWithEvent(MovementFsm fsm)
        {
            var     dieHits        = fsm.dieHits;
            Vector2 originVelocity = fsm.Velocity;
            Vector2 averageNormal  = Vector2.zero;

            foreach (var dieHit in dieHits)
            {
                averageNormal += dieHit.normal.normalized;
            }
            originVelocity = Vector2.Reflect(originVelocity, averageNormal.normalized);
            fsm.Velocity   = originVelocity;
        }
Exemplo n.º 3
0
 public override void OnExcuteWithEvent(MovementFsm fsm)
 {
     fsm.Velocity = fsm.Velocity + Vector2.down * fsm.yGravityForce * fsm.UpdateTime;
     if (Mathf.Abs(fsm.Velocity.y) > fsm.yMaxSpeed)
     {
         fsm.Velocity = new Vector2(fsm.Velocity.x, Mathf.Sign(fsm.Velocity.y) * fsm.yMaxSpeed);
     }
     //fsm.ProcessCollisionBacktrack(fsm.boxRayCaster.Right);
     //fsm.ProcessCollisionBacktrack(fsm.boxRayCaster.Left);
     if (fsm.boxRayCaster.Down.CheckCollision(fsm.onGroundLayer))
     {
         fsm.ChangeState(OnGroundStateWithEvent.Instance);
         fsm.Backtrack(fsm.boxRayCaster.Down);
     }
 }
Exemplo n.º 4
0
        public override void OnExcuteWithEvent(MovementFsm fsm)
        {
            float velocityY = fsm.Velocity.y;

            velocityY   += fsm.yUpForceInGround * fsm.UpdateTime;
            velocityY    = Mathf.Clamp(velocityY, -fsm.yMaxSpeedInGroundDown, fsm.yMaxSpeedInGroundUp);
            fsm.Velocity = new Vector2(fsm.Velocity.x, velocityY);
            if (!fsm.boxRayCaster.Down.CheckCollision(fsm.onGroundLayer))
            {
                //var result = new List<BoxRayCaster.RayTrigger>(fsm.boxRayCaster.CheckCollision(fsm.onGroundLayer));
                //if(result.Count == 0) {
                //Debug.Log(fsm.boxRayCaster.Down.CollisionStatus);
                //Debug.Break();
                fsm.Velocity = new Vector2(fsm.Velocity.x, fsm.yDigJumpSpeed);
                fsm.ChangeState(InAirStateWithEvent.Instance);
            }
        }
Exemplo n.º 5
0
 public override void OnExcuteWithEvent(MovementFsm fsm)
 {
     fsm.Velocity += Vector2.down * fsm.yDieGravityForce * fsm.UpdateTime;
 }
Exemplo n.º 6
0
 public override void OnExitWithEvent(MovementFsm fsm)
 {
 }
Exemplo n.º 7
0
 public override void OnEnterWithEvent(MovementFsm fsm)
 {
 }