示例#1
0
 private static void StdTick(GameModel gameModel)
 {
     if (gameModel.IsRunning)
     {
         if (gameModel.PlayerShip.Alignment != Alignment.Player)
         {
             OnLose.Invoke();
         }
         CrewActionsHandler.TickCrew(gameModel.PlayerShip);
         CrewActionsHandler.TickCrew(gameModel.OtherShip);
         if (gameModel.OtherShip != null && gameModel.OtherShip.Alignment == Alignment.Enemy)
         {
             WeaponsHandler.Tick(gameModel.PlayerShip, gameModel.OtherShip, gameModel.TickLength);
             WeaponsHandler.Tick(gameModel.OtherShip, gameModel.PlayerShip, gameModel.TickLength);
             if (gameModel.OtherShip.Alignment == Alignment.Wrekage)
             {
                 foreach (var weapon in gameModel.PlayerShip.Weapons)
                 {
                     weapon.TimeLeftToCoolDown = weapon.CoolDownTime;
                 }
                 LastFuelReward   = random.Next(0, 4);
                 LastMoneyReward  = random.Next(10, 31);
                 gameModel.Fuel  += LastFuelReward;
                 gameModel.Money += LastMoneyReward;
                 if (OnWin != null)
                 {
                     OnWin.Invoke();
                 }
             }
         }
         SpecialRoomBonusCalculator.Recalculate(gameModel.PlayerShip);
         SpecialRoomBonusCalculator.Recalculate(gameModel.OtherShip);
     }
 }
示例#2
0
 public TestTitan(Alignment alignment)
 {
     this.Alignment = alignment;
     Stats          = new ShipStat(2000);
     GenerateCells();
     GenerateCrew();
     GenerateRooms();
     GenerateSpecialRooms(GenerateSpecialRoomsStat());
     GenerateWeapons();
     SpecialRoomBonusCalculator.Recalculate(this);
 }
示例#3
0
        public void TestHealingOutOfLivingRoom()
        {
            var ship = new TestShip(Alignment.Player);

            Assert.IsTrue(ship.Crew.All(c => c.Action == CrewAction.Idle));
            CrewActionsHandler.TickCrew(ship);

            PlayerCommands.TrySetRoomEnergyConsumption(ship.SpecialRooms[2], 2, ship);
            SpecialRoomBonusCalculator.Recalculate(ship);
            foreach (var crew in ship.Crew)
            {
                crew.CurrentHP = 10;
            }
            CrewActionsHandler.TickCrew(ship);
            Assert.IsTrue(ship.Crew.All(c => c.CurrentHP == 10));
        }
示例#4
0
        public void TestOverHealCrewMember()
        {
            var ship = new TestShip(Alignment.Player);

            Assert.IsTrue(ship.Crew.All(c => c.Action == CrewAction.Idle));
            CrewActionsHandler.TickCrew(ship);

            PlayerCommands.MoveCrewMember(ship.Crew[1], ship.Cells[5], ship);
            CrewActionsHandler.TickCrew(ship);
            Assert.AreEqual(ship.Cells[5], ship.Crew[1].Cell);

            PlayerCommands.TrySetRoomEnergyConsumption(ship.SpecialRooms[2], 2, ship);
            SpecialRoomBonusCalculator.Recalculate(ship);
            ship.Crew[1].CurrentHP = 99;
            CrewActionsHandler.TickCrew(ship);
            Assert.AreEqual(100, ship.Crew[1].CurrentHP);
        }
示例#5
0
        public static void ControlIsRecalculated()
        {
            var ship = new TestTitan(Alignment.Player);

            PlayerCommands.TrySetRoomEnergyConsumption(ship.SpecialRooms[1], 1, ship);

            Assert.AreEqual(1.0, ship.Stats.DamageMultiplier, 0.001);
            Assert.AreEqual(4, ship.Stats.CurrentEnergy);
            Assert.AreEqual(0, ship.Stats.Evasion);
            Assert.AreEqual(5, ship.Stats.FullEnergy);
            Assert.AreEqual(0, ship.Stats.Heal);
            Assert.AreEqual(0, ship.Stats.Radar);

            SpecialRoomBonusCalculator.Recalculate(ship);
            Assert.AreEqual(4, ship.Stats.CurrentEnergy);
            Assert.AreEqual(1.0, ship.Stats.DamageMultiplier, 0.001);
            Assert.AreEqual(5, ship.Stats.Evasion);
            Assert.AreEqual(5, ship.Stats.FullEnergy);
            Assert.AreEqual(0, ship.Stats.Heal);
            Assert.AreEqual(0, ship.Stats.Radar);
        }
示例#6
0
        public static void GeneratorIsRecalculated()
        {
            var ship = new TestTitan(Alignment.Player);

            ship.SpecialRooms[3].Stat.CurrentEnergyLimit = 4;
            SpecialRoomBonusCalculator.Recalculate(ship);
            for (var i = 0; i < ship.SpecialRooms.Count; i++)
            {
                if (ship.SpecialRooms[i].Type != RoomType.Generator)
                {
                    PlayerCommands.TrySetRoomEnergyConsumption(ship.SpecialRooms[i], 2, ship);
                }
            }
            PlayerCommands.TrySetRoomEnergyConsumption(ship.SpecialRooms[2], 1, ship);
            SpecialRoomBonusCalculator.Recalculate(ship);
            var energy = 0;

            foreach (var room in ship.SpecialRooms.Where(room => room.Type != RoomType.Generator))
            {
                energy += room.Stat.CurrentEnergy;
            }
            Assert.AreEqual(ship.Stats.FullEnergy - ship.Stats.CurrentEnergy, energy);
        }