Esempio n. 1
0
    private void Update()
    {
        var inputs = new InputsParameters();

        if (InputManager.GetButtonDown("jump"))
        {
            this.Controller.StartJump();
        }
        else if (InputManager.GetButtonUp("jump"))
        {
            this.Controller.EndJump();
        }

        bool  isRunning          = InputManager.GetAxis("run") > 0.9 || InputManager.GetButton("run");
        float horizontalMovement = InputManager.GetAxisRaw("lateral");

        // dead zone
        horizontalMovement = Mathf.Abs(horizontalMovement) > this.HorizontalDeadZone ? horizontalMovement : 0;

        if (horizontalMovement != 0 &&
            Time.timeScale != 0 &&
            this.Controller.Grounded)
        {
            AudioManager.Play("Marche");
        }
        else
        {
            AudioManager.Stop("Marche");
        }

        this.Controller.SetMove(
            horizontalMovement,
            isRunning
            );

        inputs.AttackOne = InputManager.GetButton("mele");
        inputs.AttackTwo = InputManager.GetButton("fireBall");
        inputs.Dash      = this.Dash._canDash && (InputManager.GetAxis("dash") > 0.9 || InputManager.GetButton("dash"));

        float absoluteSpeed = Mathf.Abs(horizontalMovement);

        this.PlayerAnimator.SetBool("PlayerRunning", absoluteSpeed > this.walkSpeedLimit && isRunning);
        this.PlayerAnimator.SetFloat("PlayerMovement", absoluteSpeed);

        this.CharacterSkills.LaunchSkills(inputs);
    }
Esempio n. 2
0
    public void LaunchSkills(InputsParameters inputs)
    {
        foreach (ISkill skill in this.skills)
        {
            // sum metaprograming TODO : refactor this using a decorator patern
            // get the input info as a string
            // getting the type, the prop of the typy and getting the value on the object
            Type         inputType  = inputs.GetType();
            PropertyInfo inputProp  = inputType.GetProperty(skill.GetInputName());
            bool         inputValue = (bool)inputProp.GetValue(inputs, null);

            if (inputValue && this.CanAct) // test inputs
            {
                this.StartCoroutine(skill.Launch());
            }
        }
    }