Ejemplo n.º 1
0
    private void Fire()
    {
        // instanciate fire
        Instantiate(asset, muzzle.position, muzzle.rotation);

        // if event has a listener, invoke it
        // this sets up the bullet to have the correct properties.
        if (OnPlayerFire != null)
        {
            OnPlayerFire.Invoke(currentWeapon.bulletSpeed, currentWeapon.damage, muzzle.right, hitMask, currentWeapon.lifeTime);
        }
    }
Ejemplo n.º 2
0
    private void Update()
    {
        if (Input.GetKey(KeyCode.A))
        {
            OnPlayerHorizontal?.Invoke(-1);
            isMovingHor = true;
        }
        else if (Input.GetKey(KeyCode.D))
        {
            OnPlayerHorizontal?.Invoke(1);
            isMovingHor = true;
        }
        //DUDAS SOBRE OPTIMIZACIÓN
        else if (isMovingHor && !Input.GetKey(KeyCode.A) && !Input.GetKey(KeyCode.D))
        {
            OnPlayerHorizontal?.Invoke(0);
            isMovingHor = false;
        }

        if (Input.GetKey(KeyCode.S))
        {
            OnPlayerVertical?.Invoke(-1);
            isMovingVer = true;
        }
        else if (Input.GetKey(KeyCode.W))
        {
            OnPlayerVertical?.Invoke(1);
            isMovingVer = true;
        }
        else if (isMovingVer && !Input.GetKey(KeyCode.S) && !Input.GetKey(KeyCode.W))
        {
            OnPlayerVertical?.Invoke(0);
            isMovingVer = false;
        }

        if (Input.GetMouseButtonDown(0))
        {
            OnPlayerAttack?.Invoke();
        }
        if (Input.GetKeyDown(KeyCode.E))
        {
            OnPlayerFire?.Invoke();
        }
        if (Input.GetMouseButton(1))
        {
            OnPlayerBlock?.Invoke();
        }
        else if (Input.GetMouseButtonUp(1))
        {
            OnPlayerStopBlocking?.Invoke();
        }

        if (Input.GetKeyDown(KeyCode.Space))
        {
            OnPlayerJump?.Invoke();
        }

        if (Input.GetKeyDown(KeyCode.Escape))
        {
            OnEscape?.Invoke();
        }
    }