private void ShieldMenu(IShip playerShip) { if (Shields.For(playerShip).Damaged()) { return; } Shields.SHIELD_PANEL = new List <string>(); Shields.SHIELD_PANEL.Add(Environment.NewLine); var currentShieldEnergy = Shields.For(playerShip).Energy; if (currentShieldEnergy > 0) { Shields.SHIELD_PANEL.Add("─── Shield Control: ── <CURRENTLY AT: " + currentShieldEnergy + "> ──"); Shields.SHIELD_PANEL.Add("add = Add energy to shields."); Shields.SHIELD_PANEL.Add("sub = Subtract energy from shields."); } else { Shields.SHIELD_PANEL.Add("─── Shield Control: ── <DOWN> ──"); Shields.SHIELD_PANEL.Add("add = Add energy to shields."); } this.Strings(Shields.SHIELD_PANEL); this.WithNoEndCR("Enter shield control command: "); var shieldsCommand = Console.ReadLine().Trim().ToLower(); Shields.For(playerShip).MaxTransfer = playerShip.Energy; //todo: this does nothing! Shields.For(playerShip).Controls(shieldsCommand); }
private static string GetShieldColor(string shield, Shields shields) { if (shield == "build") { if (shields.Message != BuildResult.Succeeded.ToString()) { return("Red"); } } else if (shield == "coverage") { var coverage = int.Parse(shields.Message.Replace("%", "")); if (coverage < 50) { return("Red"); } if (coverage < 70) { return("Yellow"); } } else { if (!shields.Message.Contains("Failed: 0")) { return("Red"); } } return("Green"); }
void Start() { inventory = Shields.instance; inventory.onItemChanhgedCallback += UpdateUI; slots = itemsParent.GetComponentsInChildren <ShopSlot>(); }
public void ALLHostilesAttack_ShipUndocked_WithNoShields() { //todo: verify that Regions are set up correctly. //todo: This test does not run alone. what do the other tests set up that this needs? why don't thea other tests tear down their stuff? //todo: will we need to mock out the Console.write process just so that we can test the output? I'm thinking so.. _setup.SetupMapWith1Hostile(); Assert.AreEqual(_setup.TestMap.Playership.Energy, (new StarTrekKGSettings()).GetSetting <int>("energy"), "Ship energy not at expected amount"); Shields.For(_setup.TestMap.Playership).SetEnergy(0); Assert.AreEqual(_setup.TestMap.Playership.Energy, (new StarTrekKGSettings()).GetSetting <int>("energy"), "Ship energy not at expected amount"); const int expectedHitsTilldestruction = 4; for (int i = 0; i < 100; i++) { var testGame = (new Game((new StarTrekKGSettings()))); TakeShots(testGame, expectedHitsTilldestruction); } //todo: use a mock to determine that Ship.AbsorbHitFrom() was called twice. }
public void ALLHostilesAttack_ShipUndocked_WithShields() { //todo: verify that Regions are set up correctly. //todo: This test does not run alone. what do the other tests set up that this needs? why don't thea other tests tear down their stuff? //todo: will we need to mock out the Console.write process just so that we can test the output? I'm thinking so.. _setup.SetupMapWith2Hostiles(); Assert.AreEqual(_setup.TestMap.Playership.Energy, (new StarTrekKGSettings()).GetSetting <int>("energy"), "Ship energy not at expected amount"); //raise shields Shields.For(_setup.TestMap.Playership).SetEnergy(2500); //hopefully a single hit wont be harder than this! Assert.AreEqual(2500, Shields.For(_setup.TestMap.Playership).Energy, "Unexpected shield energy level"); //shields charged correctly // todo: do more tests on this in ShieldTests //Assert.AreEqual((new StarTrekKGSettings()).GetSetting<int>("energy"), _testMap.Playership.Energy, "Ship energy not at maximum"); //ship has no damage Assert.AreEqual(_setup.TestMap.Playership.Energy, (new StarTrekKGSettings()).GetSetting <int>("energy"), "Ship energy not at expected amount"); (new Game((new StarTrekKGSettings()))).ALLHostilesAttack(_setup.TestMap); Assert.IsFalse(_setup.TestMap.Playership.Destroyed); Assert.Less(Shields.For(_setup.TestMap.Playership).Energy, 2500); Assert.AreEqual((new StarTrekKGSettings()).GetSetting <int>("energy"), _setup.TestMap.Playership.Energy, "expected no change to ship energy. Ship should have been protected by shields."); //Assert that ship has taken 2 hits. //todo: use a mock to determine that Ship.AbsorbHitFrom() was called twice. }
public void PhasersWontFireWhenToldTooMuchEnergy() { _setup.SetupMapWith1FriendlyAtSector(new Coordinate(2, 1)); var ship = _setup.TestMap.Playership; var startingEnergy = (new StarTrekKGSettings()).GetSetting <int>("energy"); Assert.AreEqual(startingEnergy, ship.Energy); const int testBoltEnergy = 4000; var beforeEnergy = ship.Energy; //This action will hit every single hostile in the Region. In this case, it will hit no one :D Phasers.For(_setup.TestMap.Playership).Fire(testBoltEnergy); Assert.AreEqual(ship.Energy, beforeEnergy); //verify that no energy xfer happened. Assert.Greater(Shields.For(ship).Energy, -1); //Todo: Mock up Output so we can see the text result //Without a mock for Output, we can't see the output, but the conclusion we can draw here is that the phasers didn't fire, and no energy was expended Assert.AreEqual(startingEnergy, _setup.TestMap.Playership.Energy); }
public void AddShield(Shields shield) { if (!shields.ContainsKey(shield.Name)) { shields.Add(shield.Name, shield); } }
public static bool Auto_Raise_Shields(IMap map, IRegion Region) { bool shieldsRaised = false; if (Region.Type != RegionType.Nebulae) { var thisShip = map.Playership; var thisShipEnergy = thisShip.Energy; var thisShipShields = Shields.For(thisShip); if (thisShipShields.Energy == 0) //todo: resource this out { if (thisShipEnergy > 500) //todo: resource this out { thisShipShields.Energy = 500; //todo: resource this out thisShip.Energy -= 500; shieldsRaised = true; } else if (thisShipEnergy > 1) { var energyLeft = thisShipEnergy / 2; //todo: resource this out thisShipShields.Energy = Convert.ToInt32(energyLeft); thisShip.Energy = energyLeft; shieldsRaised = true; } } } return(shieldsRaised); }
private void CheckShip(IGameLogger logger, int accountId, VaultView vault, Ship ship) { // check ship if (!vault.Ships.Contains(ship.ID)) { throw logger.LogError(new Exception($"Check for player {accountId} on hangar with ship {ship.ID} resulted in a assigned ship which is not even owned!")); } // check amount of items packed into the ship if (Weapons.Count > ship.WeaponSlots) { Weapons = Weapons.Take(ship.WeaponSlots).ToList(); } if (Generators.Count + Shields.Count > ship.GeneratorSlots) { int diff = Math.Abs((Generators.Count + Shields.Count) - ship.GeneratorSlots); int generatorsToRemove = Math.Min(diff, Generators.Count); int shieldsToRemove = Math.Min(diff - generatorsToRemove, Shields.Count); Generators = Generators.Take(Generators.Count - generatorsToRemove).ToList(); Shields = Shields.Take(Shields.Count - shieldsToRemove).ToList(); if (diff != 0) { logger.LogWarning($"Check for player {accountId} on hangar with ship {ship.ID} resulted with a problematic difference of {diff}"); } } }
public void Test_AbsorbHit_NoDamage() { _mockSettings.Setup(u => u.GetSetting <string>("Hostile")).Returns("blah Blah Blah!!!"); var shipToTest = new Ship(FactionName.Klingon, "TestShip", _mockSector.Object, _mockMap.Object, _mockMap.Object.Game); Shields.For(shipToTest).Energy = 100; //this is syntactic sugar for: ship.Subsystems.Single(s => s.Type == SubsystemType.Shields); Assert.AreEqual(100, Shields.For(shipToTest).Energy); _mockWrite.Setup(w => w.Line(It.IsAny <string>())); _mockMap.Object.Write = _mockWrite.Object; _mockSector.Setup(s => s.X).Returns(-2); _mockSector.Setup(s => s.Y).Returns(-3); var attacker = new Ship(FactionName.Klingon, "The attacking Ship", _mockSector.Object, _mockMap.Object, _mockMap.Object.Game); shipToTest.AbsorbHitFrom(attacker, 50); Assert.AreEqual(50, Shields.For(shipToTest).Energy); //Verifications of Output to User _mockSector.Verify(s => s.X, Times.Exactly(1)); _mockSector.Verify(s => s.Y, Times.Exactly(1)); _mockWrite.Verify(w => w.Line(It.IsAny <string>()), Times.Exactly(2)); _mockWrite.Verify(w => w.Line("Your Ship has been hit by The attacking Ship at sector [-2,-3]."), Times.AtLeastOnce()); _mockWrite.Verify(w => w.Line("No Damage."), Times.Once()); }
///interesting.. one could take a hit from another map.. Wait for the multidimensional version of this game. (now in 3D!) :D /// returns true if ship was destroyed. (hence, ship could not absorb all energy) public void AbsorbHitFrom(IShip attacker, int attackingEnergy) { var shields = Shields.For(this); if (attackingEnergy > 0) { string hitMessage = Write.ShipHitMessage(attacker); this.Map.Write.Line(hitMessage); shields.Energy -= attackingEnergy; } else { string message = Write.MisfireMessage(attacker); this.Map.Write.Line(message); } bool shieldsWorking = (this.GetRegion().Type != RegionType.Nebulae); if (!shieldsWorking) { this.Map.Write.Line("Shields ineffective due to interference from Nebula"); } if ((shields.Energy < 0) || !shieldsWorking) { this.TakeDamageOrDestroyShip(attackingEnergy, shields); } else { this.Map.Write.Line("No Damage."); } }
/* * Set the docked status of the ship */ public void SetDocked(bool docked) { if (!this.docked && docked) { this.energyLevel = 100; ComsChatter("Commander Scot reports reports, 'Docking is complete, Captain.'"); } if (this.docked && !docked) { ComsChatter("Lt Sulu reports, 'We're clear for maneuvering, Captain.'"); } DamageControl.Docked(docked); Impulse.Docked(docked); LRS.Docked(docked); Phasers.Docked(docked); Probes.Docked(docked); Shields.Docked(docked); SRS.Docked(docked); Torpedoes.Docked(docked); Warp.Docked(docked); this.docked = docked; }
public Shields RUN_UpdateShieldsBroken(Shields copiedData) { if (Time.time - copiedData.mBrokeTmStmp > copiedData._brokenTime) { copiedData.mState = Shields.STATE.RECHARGING; } return(copiedData); }
public void SetupPlayershipShields() { var starshipShields = Shields.For(this.Playership); //starshipShields.ShipConnectedTo = this.Playership; starshipShields.Energy = 0; //starshipShields.Damage = 0; }
/// <summary> /// this is really only used for initialization. Use Entity.Mass for the ship's mass as it pertains to the physics model /// </summary> /// <returns>the mass of all combined shipParts</returns> private float getTotalMass() { return(Reactors.Select(x => x.GetMass()).Sum() + Shields.Select(x => x.GetMass()).Sum() + Weapons.Select(x => x.GetMass()).Sum() + Engines.Select(x => x.GetMass()).Sum() + CrewDecks.Select(x => x.GetMass()).Sum()); }
// For now he just fires his rifle. void Update() { cRifle.FAttemptFire(rPC, gShotPoint.transform.position); cRifle.mData = cRifle.FRunUpdate(cRifle.mData); mShields = RUN_UpdateShieldsData(mShields); gUI.FUpdateShieldHealthBars(mHealth, _maxHealth, mShields.mStrength, mShields._max, true); }
public void Awake() { if (instance != null) { Debug.LogWarning("More than one instance of Inventory found!"); return; } instance = this; }
private List <IShipPart> getDamageableParts() { return(new List <IShipPart>() .Concat(Reactors.Where(x => !x.IsDestroyed())) .Concat(Engines.Where(x => !x.IsDestroyed())) .Concat(Shields.Where(x => !x.IsDestroyed())) .Concat(Weapons.Where(x => !x.IsDestroyed())) .Concat(CrewDecks.Where(x => !x.IsDestroyed())).ToList()); }
public Shields RUN_UpdateShieldsFull(Shields copiedData) { if (copiedData.mStrength < copiedData._max) { Debug.Log("Mistake: Shields in full state while not fully charged."); copiedData.mState = Shields.STATE.BROKEN; } return(copiedData); }
public Shields RUN_UpdateShieldsRecharging(Shields copiedData) { copiedData.mStrength += Time.deltaTime * copiedData._rechSpd; if (copiedData.mStrength >= copiedData._max) { copiedData.mStrength = copiedData._max; copiedData.mState = Shields.STATE.FULL; } return(copiedData); }
private void AddHostileFederale(IRegion Region, ISector sector, Stack <string> federaleNames) { var newPissedOffFederale = new Ship(FactionName.Federation, federaleNames.Pop(), sector, this, this.Game); Shields.For(newPissedOffFederale).Energy = Utility.Utility.Random.Next(100, 500); //todo: resource those numbers out Region.AddShip(newPissedOffFederale, sector); this.Write.Line("Comm Reports a Federation starship has warped into Region: " + Region.Name); }
public override void DrawWornExtras() { base.DrawWornExtras(); if (!Shields.NullOrEmpty()) { foreach (var item in Shields) { item.DrawShield(); } } }
public void CountDuplicatesTest_GiveDuplicatesAndSingleItems_WillPrintThemGrouped() { Swords testSword = new Swords(); testSword.Name = "testSword"; testSword.Price = 5; Shields testShield = new Shields(); testShield.Name = "testShield"; testShield.Price = 10; Consumables testConsumable = new Consumables(); testConsumable.Name = "testConsumable"; testConsumable.Price = 15; Potions testPotion = new Potions(); testPotion.Name = "testPotion"; testPotion.Price = 20; Masks testMask = new Masks(); testMask.Name = "testMask"; testMask.Price = 25; List <Product> testCart = new List <Product>(); for (int i = 0; i < 5; i++) { testCart.Add(testSword); } for (int i = 0; i < 132; i++) { testCart.Add(testShield); } testCart.Add(testConsumable); for (int i = 0; i < 45; i++) { testCart.Add(testPotion); } for (int i = 0; i < 98; i++) { testCart.Add(testMask); } string expected = "testSword x 5 - - - 25 Rupees\n\ntestShield x 132 - - - 1320 Rupees\n\ntestConsumable" + " x 1 - - - 15 Rupees\n\ntestPotion x 45 - - - 900 Rupees\n\ntestMask x 98 - - - 2450 Rupees\n\n"; string itemizerTest = Itemizer.CountDuplicates(testCart); Assert.AreEqual(expected, itemizerTest); }
public virtual void InflictDamages(Damages damages) { if (!ObjectAvailable) { return; } damages.Apply(); if (!Stats.IsLifeStealImmune && damages.ApplyAutoAttack && damages.Type == DamageType.DAMAGE_TYPE_PHYSICAL) { damages.Source.Stats.Health.Heal(damages.Delta * damages.Source.Stats.LifeSteal.TotalSafe); } if (Shields.Magical > 0 && damages.Type == DamageType.DAMAGE_TYPE_MAGICAL) { float value = Shields.UseMagicalShield(damages.Delta); Stats.Health.Current -= value; float shieldLoss = -(damages.Delta - value); OnShieldModified(true, false, shieldLoss); } else if (Shields.Physical > 0 && damages.Type == DamageType.DAMAGE_TYPE_PHYSICAL) { float value = Shields.UsePhysicalShield(damages.Delta); Stats.Health.Current -= value; float shieldLoss = -(damages.Delta - value); OnShieldModified(false, true, shieldLoss); } else if (Shields.MagicalAndPhysical > 0) { float value = Shields.UseMagicalAndPhysicalShield(damages.Delta); Stats.Health.Current -= value; float shieldLoss = -(damages.Delta - value); OnShieldModified(true, true, shieldLoss); } else { Stats.Health.Current -= damages.Delta; Game.Send(new DamageDoneMessage(damages.Result, damages.Type, damages.Delta, NetId, damages.Source.NetId)); } UpdateStats(); damages.Source.UpdateStats(); EventsBinder.OnDamagesInflicted(damages); if (Stats.Health.Current <= 0) { OnDead(damages.Source); } }
public Shields RUN_UpdateShieldsData(Shields copiedData) { switch (copiedData.mState) { case Shields.STATE.FULL: copiedData = RUN_UpdateShieldsFull(copiedData); break; case Shields.STATE.RECHARGING: copiedData = RUN_UpdateShieldsRecharging(copiedData); break; case Shields.STATE.BROKEN: copiedData = RUN_UpdateShieldsBroken(copiedData); break; } return(copiedData); }
public void GetTotalTest_GiveRandomPricedProducts_WillPrintTheTotalPrice() { Swords testSword = new Swords(); testSword.Name = "testSword"; testSword.Price = 5; Shields testShield = new Shields(); testShield.Name = "testShield"; testShield.Price = 10; Consumables testConsumable = new Consumables(); testConsumable.Name = "testConsumable"; testConsumable.Price = 15; Potions testPotion = new Potions(); testPotion.Name = "testPotion"; testPotion.Price = 20; Masks testMask = new Masks(); testMask.Name = "testMask"; testMask.Price = 25; List <Product> testCart = new List <Product>(); for (int i = 0; i < 5; i++) { testCart.Add(testSword); } for (int i = 0; i < 132; i++) { testCart.Add(testShield); } testCart.Add(testConsumable); for (int i = 0; i < 45; i++) { testCart.Add(testPotion); } for (int i = 0; i < 98; i++) { testCart.Add(testMask); } int actual = Itemizer.GetTotal(testCart); Assert.AreEqual(4710, actual); }
public void ChangeHealth(int points) { if (!isImmune) { if (points < 0 || lives[PlayerIndex] < MaxLives) { lives[PlayerIndex] += points; if (lives[PlayerIndex] < 0) { lives[PlayerIndex] = 0; } uIManager.UpdateLives(lives[PlayerIndex], PlayerIndex); isImmune = true; StartCoroutine(ImmuneTimer()); } } else { isImmune = false; Shields.SetActive(false); } switch (lives[PlayerIndex]) { case 0: animator.SetTrigger("DeathTrigger"); audioSource.PlayOneShot(ExplosionClip); Thrusters.SetActive(false); RightEngineFire.SetActive(false); LeftEngineFire.SetActive(false); Destroy(GetComponent <Collider2D>()); Destroy(this.gameObject, 2.65f); break; case 1: RightEngineFire.SetActive(true); break; case 2: LeftEngineFire.SetActive(true); RightEngineFire.SetActive(false); break; case 3: LeftEngineFire.SetActive(false); break; default: Debug.LogError("Error in Player" + PlayerIndex + 1 + "Lives"); break; } }
public void OutputScanWarnings(IRegion Region, IMap map, bool shieldsAutoRaised) { if (Region.GetHostiles().Count > 0) { this.SRSScanHostile(Region); } this.Write.OutputConditionAndWarnings(map.Playership, this.Config.GetSetting <int>("ShieldsDownLevel")); if (shieldsAutoRaised) { map.Write.Line("Shields automatically raised to " + Shields.For(map.Playership).Energy); } }
public void ALLHostilesAttack_ShipDocked() { _setup.SetupMapWith2Hostiles(); //cheating so we can cover this line Navigation.For(_setup.TestMap.Playership).Docked = true; this.Game.ALLHostilesAttack(_setup.TestMap); //Ship has taken no damage. Assert.IsFalse(_setup.TestMap.Playership.Destroyed); Assert.AreEqual(Shields.For(_setup.TestMap.Playership).Energy, 0); //never even needed to raise shields! Assert.AreEqual(_setup.TestMap.Playership.Energy, (new StarTrekKGSettings()).GetSetting <int>("energy")); }
public void LoadAll() { Floors.LoadAll(); Items.LoadAll(); Creatures.LoadAll(); Templates.LoadAll(); Animations.LoadAll(); Heads.LoadAll(); Chests.LoadAll(); Legs.LoadAll(); Arms.LoadAll(); Weapons.LoadAll(); Shields.LoadAll(); }