예제 #1
0
    /**
     * Method that checks inputs to see which weapon to use
     */
    private void UseWeapon()
    {
        switch (GameMaster.Weapon())
        {
        case "sword":
            if (upgradeFireRate == 0)
            {
                if (!GameMaster.UpgradedSword())
                {
                    if (Input.GetButton(ControllerInputManager.Fire()) && !GameMaster.PlayerTransitionState() &&
                        !GameMaster.IsPaused() && !GameMaster.Swinging())
                    {
                        Sword();
                    }
                }
                else
                {
                    if (Input.GetAxisRaw(ControllerInputManager.Vertical()) > 0 && !GameMaster.Swinging())
                    {
                        if (Input.GetButton(ControllerInputManager.Fire()) && Time.time > upgradeFireRate &&
                            !GameMaster.PlayerTransitionState() && !GameMaster.IsPaused())
                        {
                            ShootSwordBeam();
                        }
                    }
                    else
                    {
                        if (Input.GetButton(ControllerInputManager.Fire()) && !GameMaster.PlayerTransitionState() &&
                            !GameMaster.IsPaused() && !GameMaster.Swinging())
                        {
                            Sword();
                        }
                    }
                }
            }
            else
            {
                if (!GameMaster.UpgradedSword())
                {
                    if (Input.GetButton(ControllerInputManager.Fire()) && !GameMaster.PlayerTransitionState() &&
                        !GameMaster.IsPaused() && !GameMaster.Swinging())
                    {
                        Sword();
                    }
                }
                else
                {
                    if (Input.GetAxisRaw(ControllerInputManager.Vertical()) > 0 && !GameMaster.Swinging())
                    {
                        if (Input.GetButton(ControllerInputManager.Fire()) && Time.time > timeToFireUpgrade &&
                            !GameMaster.PlayerTransitionState() && !GameMaster.IsPaused())
                        {
                            timeToFireUpgrade = Time.time + 1 / upgradeFireRate;
                            //shoot sword beam
                            ShootSwordBeam();
                        }
                    }
                    else
                    {
                        if (Input.GetButton(ControllerInputManager.Fire()) && !GameMaster.PlayerTransitionState() &&
                            !GameMaster.IsPaused() && !GameMaster.Swinging())
                        {
                            Sword();
                        }
                    }
                }
            }
            break;

        case "blaster":
            if (fireRate == 0 && upgradeFireRate == 0)
            {
                if (GameMaster.UpgradedBlaster())
                {
                    if (Input.GetAxisRaw(ControllerInputManager.Vertical()) > 0 &&
                        !GameMaster.PlayerTransitionState() && !GameMaster.IsPaused())
                    {
                        if (Input.GetButtonDown(ControllerInputManager.Fire()) && Time.time > upgradeFireRate &&
                            !GameMaster.PlayerTransitionState() && !GameMaster.IsPaused())
                        {
                            if (GameMaster.Ammo() > 5)
                            {
                                ShootUpgrade();
                            }
                            else
                            {
                                timeToFireUpgrade = Time.time + 1 / upgradeFireRate;
                                GameMaster.CancelSFX();
                            }
                        }
                    }
                    else if (Input.GetButton(ControllerInputManager.Fire()) && Time.time > timeToFire &&
                             !GameMaster.PlayerTransitionState() && !GameMaster.IsPaused())
                    {
                        if (GameMaster.Ammo() > 0)
                        {
                            Shoot();
                        }
                        else
                        {
                            timeToFire = Time.time + 1 / fireRate;
                            GameMaster.CancelSFX();
                        }
                    }
                }
            }
            else
            {
                if (GameMaster.UpgradedBlaster())
                {
                    if (Input.GetAxisRaw(ControllerInputManager.Vertical()) > 0 &&
                        !GameMaster.PlayerTransitionState() && !GameMaster.IsPaused())
                    {
                        if (Input.GetButtonDown(ControllerInputManager.Fire()) && Time.time > timeToFireUpgrade &&
                            !GameMaster.PlayerTransitionState() && !GameMaster.IsPaused())
                        {
                            if (GameMaster.Ammo() > 5)
                            {
                                timeToFireUpgrade = Time.time + 1 / upgradeFireRate;
                                ShootUpgrade();
                            }
                            else
                            {
                                timeToFireUpgrade = Time.time + 1 / upgradeFireRate;
                                GameMaster.CancelSFX();
                            }
                        }
                    }
                    else if (Input.GetButton(ControllerInputManager.Fire()) && Time.time > timeToFire &&
                             !GameMaster.PlayerTransitionState() && !GameMaster.IsPaused())
                    {
                        if (GameMaster.Ammo() > 0)
                        {
                            timeToFire = Time.time + 1 / fireRate;
                            Shoot();
                        }
                        else
                        {
                            timeToFire = Time.time + 1 / fireRate;
                            GameMaster.CancelSFX();
                        }
                    }
                }
                else
                {
                    if (Input.GetButton(ControllerInputManager.Fire()) && Time.time > timeToFire &&
                        !GameMaster.PlayerTransitionState() && !GameMaster.IsPaused())
                    {
                        if (GameMaster.Ammo() > 0)
                        {
                            timeToFire = Time.time + 1 / fireRate;
                            Shoot();
                        }
                        else
                        {
                            timeToFire = Time.time + 1 / fireRate;
                            GameMaster.CancelSFX();
                        }
                    }
                }
            }
            break;

        default:
            GameMaster.SetWeapon("sword");
            break;
        }
    }