Ejemplo n.º 1
0
    public PlayerShootHandler(PlayerShootSignal onPlayerShoot, ChangeWeaponSignal onWeaponChange,
                              ShootPosition shootPosition,
                              [Inject(Id = "first slot")]
                              Weapon firstSlot,
                              [Inject(Id = "second slot")]
                              Weapon secondSlot,
                              [Inject(Id = "third slot")]
                              Weapon thirdSlot)
    {
        this.onPlayerShoot  = onPlayerShoot;
        this.onWeaponChange = onWeaponChange;
        this.shootPosition  = shootPosition;

        this.firstSlot  = firstSlot;
        this.secondSlot = secondSlot;
        this.thirdSlot  = thirdSlot;
    }
    public void Shoot(Vector3 direction, ShootPosition position, Quaternion rotation)
    {
        if (!canShoot)
        {
            return;
        }
        Bullet bulletScript = bullets[bulletIdx].GetComponent <Bullet>();

        bulletScript.shootTeam = team;
        bulletScript.direction = direction;
        bullets[bulletIdx].transform.localScale = transform.localScale;
        if (position == ShootPosition.Barrel)
        {
            Instantiate(bullets[bulletIdx], barrel.transform.position, rotation);
        }
        else if (position == ShootPosition.MySelf)
        {
            Instantiate(bullets[bulletIdx], transform.position, rotation);
        }
    }