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)); }
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); } } }
public override void OnEnter(GopherController fsm) { fsm.movementFsm.Velocity = new Vector2(fsm.xSpeed, fsm.movementFsm.Velocity.y); }
public override void OnExit(GopherController fsm) { MovementFsm.InGroundStateWithEvent.Instance.exitEventMap.RemoveEnterEvent(fsm.movementFsm, fsm.ChangeStateToNormal); }
public override void OnExit(GopherController fsm) { }