예제 #1
0
    public void MoveCharacter(MoveCharacterModel model)
    {
        //player out of dashes
        if (playerStatsLogic.dashNum <= 0)
        {
            return;
        }
        playerStatsLogic.dashNum--;
        soundLogic.playJumpSound();
        ResetRotation();
        animationLogic.SetDashing();

        Vector2 target     = new Vector2(model.touchPoint.x, model.touchPoint.y);
        Vector2 vecBetween = target - model.player.position;
        var     distToGo   = vecBetween.magnitude;

        if (distToGo > dashDist)
        {
            distToGo = dashDist;
            target   = model.player.position + model.Direction * distToGo;
        }
        RotateToDash(vecBetween);
        animationLogic.OnMoveSetDirection(new moveAnimationModel {
            direction = vecBetween.normalized
        });


        LeanTween.cancel(character.gameObject, true);
        LeanTween.move(model.player.gameObject, (Vector2)target, CalculateTimeForDistance(distToGo)).setEase(LeanTweenType.easeInOutQuad).setOnComplete(
            () =>
        {
            FinishedMoving(playerStatsLogic.combo);
        });
    }
예제 #2
0
    public void Move(Vector2 dir, Vector2 touch)
    {
        MoveCharacterModel model = new MoveCharacterModel
        {
            Direction  = dir,
            player     = this.gameObject.GetComponent <Rigidbody2D>(),
            touchPoint = touch
        };

        PlayerMovmentLogic.MoveCharacter(model);
    }