// When the spread of the weapon has changed public void SpreadChanged(float newValue) { // Variable for slider input SliderInputPanel panel; // Varaibles for weapon float projCount; float burstCount; float cooldown; float refire; // weapon FireMode set to single WeaponFireMode mode = WeaponFireMode.Single; // get the ProjectileCount panel input // set the Slider panel value to projCount panel = ProjectileCountPanel.GetComponent <SliderInputPanel>(); projCount = panel.transform.FindChild("Slider").GetComponent <Slider>().value; // get the BurstFireCount panel input // set the Slider panel value to burstCount panel = BurstFireCountPanel.GetComponent <SliderInputPanel>(); burstCount = panel.transform.FindChild("Slider").GetComponent <Slider>().value; // get the RefireRate panel input // set the Slider panel value to refire panel = RefireRatePanel.GetComponent <SliderInputPanel>(); refire = panel.transform.FindChild("Slider").GetComponent <Slider>().value; // get the CooldownSpeed panel input // set the Slider panel value to cooldown panel = CooldownSpeedPanel.GetComponent <SliderInputPanel>(); cooldown = panel.transform.FindChild("Slider").GetComponent <Slider>().value; // if fire mode is single // set fire mode if (FireModeSingle.isOn) { mode = WeaponFireMode.Single; } // if fire mode is burst // set fire mode else if (FireModeBurst.isOn) { mode = WeaponFireMode.Burst; } // if fire mdoe is auto // set fire mode else if (FireModeAuto.isOn) { mode = WeaponFireMode.Auto; } // Updates the test ship with the given paramaters UpdateTestShip(isPrimary, projCount, Mathf.Round(newValue), mode, cooldown, refire, burstCount); }
// Updates the Primary and Secondary Wepaons public void UpdateWeapons(bool updatePrimary, float projCount, float spread, WeaponFireMode mode, float cooldown, float refire, float burstCount) { // list of new weapons List <Weapon> updateList; // if primary weapons // add primaryWeapons to new list of weapons if (updatePrimary) { updateList = primaryWeapons; } // if secondary weapons // add secondaryWeapons to the new list of weapons else { updateList = secondaryWeapons; } // for each weapon in the new list of weapons foreach (var weapon in updateList) { // set the weapon ProjectileCount weapon.ProjectileCount = (int)projCount; // set the weapon ProjectileSpread weapon.ProjectileSpread = spread; // set the weapon FireMode weapon.FireMode = mode; // set the weapon CooldownTime weapon.CooldownTime = cooldown; // set the weapon FireRate weapon.FireRate = refire; // set the weapon BurstFireCount weapon.BurstFireCount = (int)burstCount; } }
// Updates the gun public void UpdateGun() { // Variable for slider input SliderInputPanel panel; // Variables for gun float refireRate; float reloadSpeed; float clipSize; // Fire mode for weapon WeaponFireMode mode = WeaponFireMode.Single; // Variable for change float newValue = 0; // gets the RefireRate panel // set the refire rate to the panel value panel = RefireRate.GetComponent <SliderInputPanel>(); refireRate = panel.transform.FindChild("Slider").GetComponent <Slider>().value; // gets the ReloadSpeed // set reload speed to panel value panel = ReloadSpeed.GetComponent <SliderInputPanel>(); reloadSpeed = panel.transform.FindChild("Slider").GetComponent <Slider>().value; // gets the ClipSize // set clip size to panel value panel = ClipSize.GetComponent <SliderInputPanel>(); clipSize = panel.transform.FindChild("Slider").GetComponent <Slider>().value; // updates the range for the panel panel.UpdateRange(Mathf.Round(newValue), panel.Max); // Updates the test weapon with the given parameters UpdateTestWeapon(refireRate, reloadSpeed, mode, clipSize); }
// Updates the Primary and Secondary Wepaons public void UpdateWeapons(bool updatePrimary, float projCount, float spread, WeaponFireMode mode, float cooldown, float refire, float burstCount) { // list of new weapons List<Weapon> updateList; // if primary weapons // add primaryWeapons to new list of weapons if (updatePrimary) updateList = primaryWeapons; // if secondary weapons // add secondaryWeapons to the new list of weapons else updateList = secondaryWeapons; // for each weapon in the new list of weapons foreach (var weapon in updateList) { // set the weapon ProjectileCount weapon.ProjectileCount = (int)projCount; // set the weapon ProjectileSpread weapon.ProjectileSpread = spread; // set the weapon FireMode weapon.FireMode = mode; // set the weapon CooldownTime weapon.CooldownTime = cooldown; // set the weapon FireRate weapon.FireRate = refire; // set the weapon BurstFireCount weapon.BurstFireCount = (int)burstCount; } }
public override IEnumerator FlagUpdate() { m = this; turnDone = false; NullifyUnits(); for (int i = 0; i < units.Count; i++) { units[i].ResetActions(); } while (true) { if (units.Count == 0) { Debug.Log("No units left for player."); break; } if (NoActionsLeft()) { break; } if (Input.GetKeyDown(KeyCode.Escape)) { break; } slot = SelectionManager.GetMouseAsSlot2D(); if (slot == null) { yield return(null); continue; } unit = slot.filledBy; if (unit == null) { unit = SelectionManager.GetMouseAsUnit2D(); } // -- Map changes for selected player unit -- Unit.activeUnit = null; if (curPlayerUnit && curPlayerUnit.HasActions) { Unit.activeUnit = curPlayerUnit; curMask = curPlayerUnit.abilities.BasicMask; //RemaskActive(3); if (!unit) // can move // RemaskUnit(1); { } else if (unit.flag.allianceId == 0) // player, can select // RemaskUnit(3); { } else if (unit.flag.allianceId != 0) // enemy, maybe can attack //RemaskUnit(2); { } } // -- end map changes bool selectionChanged = false; bool mousePress = Input.GetKeyDown(KeyCode.Mouse0); bool selectedPlayerUnit = unit && unit.flag.allianceId == 0; // -- Input -- // For player units, just select it. For enemy, attack them if player unit is selected. if (mousePress && selectedPlayerUnit && unit != curPlayerUnit) { selectionChanged = true; DeselectUnit(); if (selectedPlayerUnit && unit.HasActions) { curPlayerUnit = unit; } if (curPlayerUnit) { PlayerUIAbilityList.AssignAbilitiesToUI(curPlayerUnit.abilities); } } if (curPlayerUnit) { curMask = curPlayerUnit.pathing.moveMask; RemaskActive(3); curMask = curPlayerUnit.abilities.BasicMask; RemaskActive(2); RemaskUnit(1); } // move if (Input.GetKeyDown(KeyCode.Mouse1) && !RunningAbility) { selectionChanged = true; // if unit is already selected, move to that slot if (slot && slot.Walkable && curPlayerUnit && curPlayerUnit.CanMoveTo(slot)) { curMask = curPlayerUnit.abilities.BasicMask; curMask = curPlayerUnit.pathing.moveMask; RemaskActive(0); curMask = curPlayerUnit.abilities.BasicMask; RemaskActive(0); RemaskUnit(0); curPlayerUnit.MoveAction(slot); yield return(null); } } // attack if (!RunningAbility && mousePress && !selectedPlayerUnit && curPlayerUnit && curPlayerUnit.CanAttack) // unit = enemy unit { if (GridManager.IsUnitInAttackRange(curPlayerUnit, unit, curPlayerUnit.abilities.BasicAttack)) { bool aimSuccesful = true;// by default, always hit, if weapon doesn't use cone ability. if (curPlayerUnit.equippedWeapon && curPlayerUnit.equippedWeapon.conePref) { yield return(curPlayerUnit.StartCoroutine(WeaponFireMode.WaitPlayerToSetAim(curPlayerUnit, unit, curPlayerUnit.equippedWeapon.conePref, curPlayerUnit.equippedWeapon.StandardAttack.attackMask.Range))); aimSuccesful = CheckIfEnemyHit(unit); } if (aimSuccesful) { curPlayerUnit.AttackAction(slot, unit, curPlayerUnit.abilities.BasicAttack); curMask = curPlayerUnit.abilities.BasicMask; curMask = curPlayerUnit.pathing.moveMask; RemaskActive(0); curMask = curPlayerUnit.abilities.BasicMask; RemaskActive(0); RemaskUnit(0); } } yield return(null); } // Reload env interaction buttons when player is selected. if (selectionChanged) { if (curPlayerUnit) { UIInteractionController.ShowEnvInteractions(curPlayerUnit); } else { UIInteractionController.ClearEnvInteractions(); } } UIManager.PlayerStandardUi(!curPlayerUnit); UIManager.PlayerSelectAllyUnitUi(curPlayerUnit); // map decolor when unit run out of actions. if (curPlayerUnit && curPlayerUnit.NoActions) { DeselectUnit(); UIInteractionController.ClearEnvInteractions(); } yield return(null); if (slot && curPlayerUnit) { slot.RecolorSlot(0); } NullifyUnits(); } // Wait until all actions are complete for (int i = 0; i < units.Count; i++) { units[i].curSlot.RecolorSlot(0); while (units[i].moving) { yield return(null); } } turnDone = true; yield return(null); }
// Update Test Ship // This allows the player to see what their ship will do in combat public void UpdateTestShip(bool updatePrimary, float projCount, float spread, WeaponFireMode mode, float cooldown, float refire, float burstCount) { TestShip.GetComponent <TestShip>().UpdateWeapons(updatePrimary, projCount, spread, mode, cooldown, refire, burstCount); var button = transform.parent.FindChild("NavPanel").FindChild("PlayGame_Button").GetComponent <Button>(); button.interactable = Credits.instance.currentValue - Credits.instance.oldValue <= Credits.instance.currentCredits; }
// Update the spread of the weapon public void UpdateSpread() { // Variable for slider input SliderInputPanel panel; // Variables for weapon float projCount; float burstCount; float cooldown; float refire; // weapon FireMode set to single WeaponFireMode mode = WeaponFireMode.Single; // Variable for change float newValue = 0; // get the ProjectileCount panel input // set the Slider panel value to projCount panel = ProjectileCountPanel.GetComponent <SliderInputPanel>(); projCount = panel.transform.FindChild("Slider").GetComponent <Slider>().value; // get the BurstFireCount panel input // set the Slider panel value to burstCount panel = BurstFireCountPanel.GetComponent <SliderInputPanel>(); burstCount = panel.transform.FindChild("Slider").GetComponent <Slider>().value; // get the RefireRate panel input // set the Slider panel value to refire panel = RefireRatePanel.GetComponent <SliderInputPanel>(); refire = panel.transform.FindChild("Slider").GetComponent <Slider>().value; // get the CooldownSpeed panel input // set the Slider panel value to cooldown panel = CooldownSpeedPanel.GetComponent <SliderInputPanel>(); cooldown = panel.transform.FindChild("Slider").GetComponent <Slider>().value; // if fire mode is single if (FireModeSingle.isOn) { // set new value newValue = projCount + (.25f * projCount * (1 / cooldown)); // set weapon fire mode mode = WeaponFireMode.Single; } // if fire mode is burst else if (FireModeBurst.isOn) { // variable for RefireRate float avgRefire = ((burstCount - 1) * refire + cooldown) / burstCount; // set new value newValue = projCount + (.50f * projCount * (1 / avgRefire)); // set weapon fire mode mode = WeaponFireMode.Burst; } // if fire mode is auto else if (FireModeAuto.isOn) { // set new value newValue = projCount + (.75f * projCount * (1 / refire)); // set weapon fire mode mode = WeaponFireMode.Auto; } // get the SliderInputPanel components panel = SpreadPanel.GetComponent <SliderInputPanel>(); // Updates range for panel panel.UpdateRange(Mathf.Round(newValue), panel.Max); // Updates the test ship with the given paramaters UpdateTestShip(isPrimary, projCount, Mathf.Round(panel.transform.FindChild("Slider").GetComponent <Slider>().value), mode, cooldown, refire, burstCount); }
// Update Test Ship // This allows the player to see what their ship will do in combat public void UpdateTestShip(bool updatePrimary, float projCount, float spread, WeaponFireMode mode, float cooldown, float refire, float burstCount) { TestShip.GetComponent<TestShip>().UpdateWeapons(updatePrimary, projCount, spread, mode, cooldown, refire, burstCount); }
// Update Test Weapon // This allows the player to see what their weapon will do in combat public void UpdateTestWeapon(float refireRate, float reloadSpeed, WeaponFireMode mode, float clipSize) { //TestWeapon.GetComponent<TestWeapon>().UpdateGun(refireRate, reloadSpeed, mode, clipSize); }
// Update Test Ship // This allows the player to see what their ship will do in combat public void UpdateTestShip(bool updatePrimary, float projCount, float spread, WeaponFireMode mode, float cooldown, float refire, float burstCount) { TestShip.GetComponent<TestShip>().UpdateWeapons(updatePrimary, projCount, spread, mode, cooldown, refire, burstCount); var button = transform.parent.FindChild("NavPanel").FindChild("PlayGame_Button").GetComponent<Button>(); button.interactable = Credits.instance.currentValue - Credits.instance.oldValue <= Credits.instance.currentCredits; }