Exemplo n.º 1
0
    private void Update()
    {
        if (isPlayerVessel)
        {
            Action.Type actionMaybe = Action.fromInput;
            if (actionMaybe != Action.Type.none)
            {
                timeline.AddCurrentAction(actionMaybe);
            }
        }

        Action currentAction = timeline.currentAction;

        if (currentAction != null)
        {
            switch (currentAction.type)
            {
            case Action.Type.moveRight:
                transform.forward = Vector3.right;
                animator.SetBool(walkAnimBool, true);
                goingRight    = true;
                rightPrecedes = true;
                break;

            case Action.Type.stopRight:
                animator.SetBool(walkAnimBool, false);
                goingRight = false;
                break;

            case Action.Type.moveLeft:
                transform.forward = Vector3.left;
                animator.SetBool(walkAnimBool, true);
                goingLeft     = true;
                rightPrecedes = false;
                break;

            case Action.Type.stopLeft:
                animator.SetBool(walkAnimBool, false);
                goingLeft = false;
                break;

            case Action.Type.useObject:
                Lever.UseFromPosition(transform.position);
                break;
            }
            currentAction.executed = true;
        }


        rigidbody.velocity = new Vector3(velocityHorizontal, rigidbody.velocity.y, 0f);
    }