コード例 #1
0
ファイル: GameTick.cs プロジェクト: MexBanDoc/game
 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 void TestStatsAfterFireWeapon()
        {
            var ship      = new TestShip(Alignment.Player);
            var enemyShip = new TestShip(Alignment.Enemy);

            PlayerCommands.TargetWeapon(ship.Weapons[0], enemyShip.Rooms[0], ship, enemyShip);

            PlayerCommands.TryChangeWeaponState(ship.Weapons[0], ship);

            Assert.AreEqual(100, enemyShip.Rooms[0].CurrentDurability);
            Assert.AreEqual(100, enemyShip.SpecialRooms[0].CurrentDurability);
            Assert.AreEqual(200, enemyShip.Stats.CurrentHP);
            Assert.AreEqual(100, enemyShip.Crew[0].CurrentHP);
            Assert.AreEqual(100, enemyShip.Crew[1].CurrentHP);
            Assert.AreEqual(2000, ship.Weapons[0].TimeLeftToCoolDown);

            WeaponsHandler.Tick(ship, enemyShip, 1000);
            Assert.AreEqual(100, enemyShip.Rooms[0].CurrentDurability);
            Assert.AreEqual(100, enemyShip.SpecialRooms[0].CurrentDurability);
            Assert.AreEqual(200, enemyShip.Stats.CurrentHP);
            Assert.AreEqual(100, enemyShip.Crew[0].CurrentHP);
            Assert.AreEqual(100, enemyShip.Crew[1].CurrentHP);
            Assert.AreEqual(1000, ship.Weapons[0].TimeLeftToCoolDown);

            WeaponsHandler.Tick(ship, enemyShip, 1000);
            Assert.AreEqual(90, enemyShip.Rooms[0].CurrentDurability);
            Assert.AreEqual(90, enemyShip.SpecialRooms[0].CurrentDurability);
            Assert.AreEqual(190, enemyShip.Stats.CurrentHP);
            Assert.AreEqual(90, enemyShip.Crew[0].CurrentHP);
            Assert.AreEqual(90, enemyShip.Crew[1].CurrentHP);
            Assert.AreEqual(2000, ship.Weapons[0].TimeLeftToCoolDown);
        }
コード例 #3
0
        public void TestFireWithNoTargetOnlineWeaponOwerflowCooldown()
        {
            var ship      = new TestShip(Alignment.Player);
            var enemyShip = new TestShip(Alignment.Enemy);

            PlayerCommands.TryChangeWeaponState(ship.Weapons[0], ship);

            WeaponsHandler.Tick(ship, enemyShip, 3000);
            Assert.AreEqual(100, enemyShip.Rooms[0].CurrentDurability);
            Assert.AreEqual(100, enemyShip.SpecialRooms[0].CurrentDurability);
            Assert.AreEqual(200, enemyShip.Stats.CurrentHP);
            Assert.AreEqual(-1000, ship.Weapons[0].TimeLeftToCoolDown);
        }
コード例 #4
0
        public void TestFireWithNoTargetOfflineWeapon()
        {
            var ship      = new TestShip(Alignment.Player);
            var enemyShip = new TestShip(Alignment.Enemy);

            WeaponsHandler.Tick(ship, enemyShip, 1000);
            Assert.AreEqual(100, enemyShip.Rooms[0].CurrentDurability);
            Assert.AreEqual(100, enemyShip.SpecialRooms[0].CurrentDurability);
            Assert.AreEqual(200, enemyShip.Stats.CurrentHP);
            Assert.AreEqual(2000, ship.Weapons[0].TimeLeftToCoolDown);

            WeaponsHandler.Tick(ship, enemyShip, 1000);
            Assert.AreEqual(100, enemyShip.Rooms[0].CurrentDurability);
            Assert.AreEqual(100, enemyShip.SpecialRooms[0].CurrentDurability);
            Assert.AreEqual(200, enemyShip.Stats.CurrentHP);
            Assert.AreEqual(2000, ship.Weapons[0].TimeLeftToCoolDown);
        }
コード例 #5
0
        public void TestFireWithAllCoolDownWeapon()
        {
            var ship      = new TestShip(Alignment.Player);
            var enemyShip = new TestShip(Alignment.Enemy);

            PlayerCommands.TargetWeapon(ship.Weapons[0], enemyShip.Rooms[0], ship, enemyShip);
            PlayerCommands.TryChangeWeaponState(ship.Weapons[0], ship);

            Assert.AreEqual(2000, ship.Weapons[0].TimeLeftToCoolDown);

            WeaponsHandler.Tick(ship, enemyShip, 500);
            Assert.AreEqual(1500, ship.Weapons[0].TimeLeftToCoolDown);

            WeaponsHandler.Tick(ship, enemyShip, 500);
            Assert.AreEqual(1000, ship.Weapons[0].TimeLeftToCoolDown);

            WeaponsHandler.Tick(ship, enemyShip, 500);
            Assert.AreEqual(500, ship.Weapons[0].TimeLeftToCoolDown);

            WeaponsHandler.Tick(ship, enemyShip, 500);
            Assert.AreEqual(2000, ship.Weapons[0].TimeLeftToCoolDown);
        }