Exemple #1
0
    void Update()
    {
        mousePosition        = Input.mousePosition;
        mousePosition.z      = 100;
        mouseWorldPosition   = mainCamera.ScreenToWorldPoint(mousePosition);
        mouseWorldPosition.z = 0;
        controller.currentWeapon.transform.up = mouseWorldPosition - controller.currentWeapon.transform.position;

        controller.Move(Input.GetAxis(axisHorizontal));

        if (Input.GetButtonDown(commandJump))
        {
            controller.Jump();
        }

        if (Input.GetButton(commandShoot))
        {
            if (shootForce <= 20)
            {
                shootForce += Time.deltaTime * 18;
            }

            if (controller.currentWeapon.GetComponent <WeaponSet>().noChargable == false)
            {
                energia.gameObject.SetActive(true);
                energia.transform.localScale = new Vector3(shootForce / 40, 0.4f, 0.5f);
            }
        }

        if (Input.GetButtonUp(commandShoot))
        {
            energia.gameObject.SetActive(false);
            WeaponSet weps = controller.currentWeapon.GetComponent <WeaponSet>();
            weps.Shoot(shootForce);
            shootForce = 0;

            yaSeDisparo();
            //desactivar movimiento? testear...
            this.enabled       = false;
            controller.enabled = false;
        }

        flipRenderer((mouseWorldPosition - transform.position).x <= 0);
    }