// Used to initialize any variables or
        // game state before the game starts
        public void Awake()
        {
            // if the PrimaryWeapon is null
            // set the DefaultPrimaryWeapon as the PrimaryWeapon
            if (PlayerData.PrimaryWeapon == null)
                PlayerData.PrimaryWeapon = PrimaryWeapon = Instantiate(DefaultPrimaryWeapon) as Weapon;

            // if the PrimaryWeapon is not null
            // set the PrimaryWeapon to the PrimaryWeapon
            else
                PrimaryWeapon = PlayerData.PrimaryWeapon;

            // if the SecondaryWeapon is null
            // set the DefaultSecondaryWeapon as the SecondaryWeapon
            if (PlayerData.SecondaryWeapon == null)
                PlayerData.SecondaryWeapon = SecondaryWeapon = Instantiate(DefaultSecondaryWeapon) as Weapon;

            // if the SecondaryWeapon is not null
            // set the SecondaryWeapon to the SecondaryWeapon
            else
                SecondaryWeapon = PlayerData.SecondaryWeapon;

            // get the TestShip components
            var ship = TestShip.GetComponent<TestShip>();

            // set the test ships primary and secondary weapons
            ship.PrimaryWeapon = PrimaryWeapon;
            ship.SecondaryWeapon = SecondaryWeapon;
        }
        // Load the specified weapon
        public void LoadWeapon(Weapon weapon)
        {
            // Variable for slider input
            SliderInputPanel panel;

            // get the ProjectileCount panel
            // set the slider value to the weapons ProjectileCount
            panel = ProjectileCountPanel.GetComponent<SliderInputPanel>();
            panel.transform.FindChild("Slider").GetComponent<Slider>().value = weapon.ProjectileCount;

            // get the BurstFireCount panel
            // set the slider value to th weapons BurstFireCount
            panel = BurstFireCountPanel.GetComponent<SliderInputPanel>();
            panel.transform.FindChild("Slider").GetComponent<Slider>().value = weapon.BurstFireCount;

            // get the RefireRate panel
            // set the slider value to the weapon FireRate
            panel = RefireRatePanel.GetComponent<SliderInputPanel>();
            panel.transform.FindChild("Slider").GetComponent<Slider>().value = weapon.FireRate;

            // get the CooldownSpeed panel
            // set the slider value to the weapon cooldownTime
            panel = CooldownSpeedPanel.GetComponent<SliderInputPanel>();
            panel.transform.FindChild("Slider").GetComponent<Slider>().value = weapon.CooldownTime;

            // check between the different fire modes
            switch (weapon.FireMode)
            {
                // if fire mode is single
                case WeaponFireMode.Single:
                    // set weapon fire mode single to true
                    // everything else is set to false
                    FireModeSingle.isOn = true;
                    FireModeBurst.isOn = false;
                    FireModeAuto.isOn = false;
                    break;
                // if fire mode is burst
                case WeaponFireMode.Burst:
                    // set weapon fire mode burst to true
                    // everything else is set to false
                    FireModeSingle.isOn = false;
                    FireModeBurst.isOn = true;
                    FireModeAuto.isOn = false;
                    break;
                // if fire mode is auto
                case WeaponFireMode.Auto:
                    // set fire mode auto to true
                    // everything else is set to false
                    FireModeSingle.isOn = false;
                    FireModeBurst.isOn = false;
                    FireModeAuto.isOn = true;
                    break;
            }
            // get the SliderInput panel components
            panel = SpreadPanel.GetComponent<SliderInputPanel>();

            // set the value of the slider to the weapon ProjectileSpread
            panel.transform.FindChild("Slider").GetComponent<Slider>().value = weapon.ProjectileSpread;
        }
Example #3
0
        // Used to inititalize any variables or game state before the game starts
        protected void Awake()
        {
            // set the PrimaryWeapon to the players PrimaryWeapon
            PrimaryWeapon = PlayerData.PrimaryWeapon;

            // set the SecondaryWeapon to the players SecondaryWeapon
            SecondaryWeapon = PlayerData.SecondaryWeapon;
        }
Example #4
0
 private void InitializeWeapon()
 {
     if (this.CurrentWeapon != null)
     {
         Transform weapon = Instantiate(this.CurrentWeapon);
         this._currentWeapon = weapon.GetComponent<Weapon>();
         this._currentWeapon.AttachTo(this.RightArm);
     }
 }
        // Updates the weapons in the game
        protected void UpdateWeapon(Weapon weapon)
        {
            // if weapon is on single fire
            // set the FireMode to Single
            if (isSingleFire.isOn)
                weapon.FireMode = WeaponFireMode.Single;

            // if the weapon is on burst fire
            // set the FireMode to burst
            else if (isBurstFire.isOn)
                weapon.FireMode = WeaponFireMode.Burst;

            // if the weapon is on auto fire
            // set the FireMode to auto
            else if (isAutoFire.isOn)
                weapon.FireMode = WeaponFireMode.Auto;

            // sets the weapons ProjectileCount to be
            // the input from the slider projectileCount
            weapon.ProjectileCount = (int)projectileCount.value;

            // sets the weapons ProjectileSpread to be
            // the input from the slider spread
            weapon.ProjectileSpread = spread.value;

            // sets the weapons BurstFireCount to be
            // the input from the slider burstFireCount
            weapon.BurstFireCount = (int)burstFireCount.value;

            // sets the weapons CooldownTime to be
            // the input from the slider cooldown
            weapon.CooldownTime = cooldown.value;

            // sets the weapons FireRate to be
            // the input from the slider refireRate
            weapon.FireRate = refireRate.value;
        }