Esempio n. 1
0
        public override void OnExcute(GopherController fsm)
        {
            if (fsm.HitGroundAndDie(fsm.diggingBoxRayCaster.CheckCollisionHit(fsm.deadLayers)))
            {
                return;
            }
            if (Input.GetMouseButton(0))
            {
                fsm.movementFsm.Velocity = fsm.movementFsm.Velocity + Vector2.down * fsm.yDiggingForce * fsm.movementFsm.UpdateTime;
            }
            var bottomResult = new List <BoxRayCaster.RayTrigger>(fsm.onGroundBoxRayCaster.CheckCollision(fsm.bottomLayers));

            if (bottomResult.Count != 0 && fsm.movementFsm.Velocity.y < 0)
            {
                fsm.movementFsm.Velocity = new Vector2(fsm.movementFsm.Velocity.x, 0);
            }
            Vector2 direction = fsm.movementFsm.Velocity.normalized;
            float   angle     = Vector2.Angle(Vector2.right, direction);

            if (direction.y < 0)
            {
                angle = 360 - angle;
            }
            fsm.diggingBoxRayCaster.gameObject.transform.rotation = Quaternion.AngleAxis(angle, new Vector3(0, 0, 1));
        }
Esempio n. 2
0
 public override void OnExcute(GopherController fsm)
 {
     if (fsm.HitGroundAndDie(fsm.diggingBoxRayCaster.CheckCollisionHit(fsm.deadLayers)))
     {
         return;
     }
     if (fsm.movementFsm.current.ToString() == "OnGround")
     {
         if (Input.GetMouseButton(0))
         {
             mouseDownTime += Time.fixedDeltaTime;
         }
         if (mouseDownTime > fsm.holdMouseTime)
         {
             fsm.movementFsm.Velocity = new Vector2(fsm.movementFsm.Velocity.x, -fsm.movementFsm.yMaxSpeedInGroundDown);
             fsm.movementFsm.ChangeState(MovementFsm.InGroundStateWithEvent.Instance);
             fsm.ChangeState(DiggingState.Instance);
             mouseDownTime = 0;
             return;
         }
         if (Input.GetMouseButtonUp(0))
         {
             mouseDownTime            = 0;
             fsm.movementFsm.Velocity = new Vector2(fsm.movementFsm.Velocity.x, fsm.yJumpSpeed);
         }
     }
 }
Esempio n. 3
0
 public override void OnEnter(GopherController fsm)
 {
     fsm.movementFsm.Velocity = new Vector2(fsm.xSpeed, fsm.movementFsm.Velocity.y);
 }
Esempio n. 4
0
 public override void OnExit(GopherController fsm)
 {
     MovementFsm.InGroundStateWithEvent.Instance.exitEventMap.RemoveEnterEvent(fsm.movementFsm, fsm.ChangeStateToNormal);
 }
Esempio n. 5
0
 public override void OnExit(GopherController fsm)
 {
 }