示例#1
0
    public override PlayerState FixedUpdate(float delta)
    {
        player.Velocity.y += 100 * delta;
        player.MoveAndSlide(player.Velocity);

        Rope.RemovePoint(Rope.GetPointCount() - 1);
        Rope.AddPoint(Hook.GetCastTo());

        if (Hook.IsColliding())
        {
            DestroyHook = false;
            Hook.SetCastTo(Hook.GetCollisionPoint() - Hook.GetGlobalPosition());
            Rope.RemovePoint(Rope.GetPointCount() - 1);
            Rope.AddPoint(Hook.GetCastTo());
            RotationPoints.Push(Hook.GetCollisionPoint());

            HookState h = new HookWalkState();
            h.Init(Slack, RotationPoints);
            return(h);
        }
        if (Hook.GetCastTo().Length() > 8 * 32)
        {
            DestroyHook = true; return(new OnGroundState());
        }

        Hook.SetCastTo(Hook.GetCastTo() + delta * 1000 * Hook.GetCastTo().Normalized());

        return(null);
    }