예제 #1
0
        public void TestSetNegativeEnergy()
        {
            var ship      = new TestShip(Alignment.Player);
            var enemyShip = new TestShip(Alignment.Enemy);
            var gameModel = new GameModel(ship, "Player-Empty-100,100");

            gameModel.OtherShip = enemyShip;
            GameTick.Tick(gameModel);

            Assert.AreEqual(5, gameModel.PlayerShip.Stats.CurrentEnergy);

            PlayerCommands.TrySetRoomEnergyConsumption(gameModel.PlayerShip.SpecialRooms[0], -1, gameModel.PlayerShip);
            Assert.AreEqual(5, gameModel.PlayerShip.Stats.CurrentEnergy);
        }
예제 #2
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));
        }
예제 #3
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);
        }
예제 #4
0
        public void TestSetEnergyAfterUpgrade()
        {
            var ship      = new TestShip(Alignment.Player);
            var enemyShip = new TestShip(Alignment.Enemy);
            var gameModel = new GameModel(ship, "Player-Empty-100,100");

            gameModel.OtherShip = enemyShip;
            gameModel.Money     = 1000;
            GameTick.Tick(gameModel);

            Assert.AreEqual(2, gameModel.PlayerShip.SpecialRooms[0].Stat.CurrentEnergyLimit);

            PlayerCommands.UpgradeRoom(gameModel.PlayerShip.SpecialRooms[0], gameModel);
            Assert.AreEqual(3, gameModel.PlayerShip.SpecialRooms[0].Stat.CurrentEnergyLimit);

            PlayerCommands.TrySetRoomEnergyConsumption(gameModel.PlayerShip.SpecialRooms[0], 3, gameModel.PlayerShip);
            Assert.AreEqual(3, gameModel.PlayerShip.SpecialRooms[0].Stat.CurrentEnergyLimit);
        }
예제 #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);
        }
예제 #7
0
파일: EnergyBar.cs 프로젝트: MexBanDoc/game
        public EnergyBar(SpecialRoom room, Ship ship)
        {
            InitializeComponent();
            this.ship = ship;
            if (!allBars.ContainsKey(room))
            {
                allBars[room] = new List <EnergyBar>();
            }
            allBars[room].Add(this);
            Max      = room.Stat.MaxEnergyLimit;
            Unlocked = room.Stat.CurrentEnergyLimit;
            Active   = room.Stat.CurrentEnergy;
            if (room.Type == RoomType.Generator)
            {
                Active = ship.Stats.FullEnergy - ship.Stats.CurrentEnergy;
            }
            this.room = room;
            var t = new TableLayoutPanel();

            table = t;
            //this.BackColor = Color.Transparent;
            t.ColumnCount = Max;
            for (int i = 0; i < Max; i++)
            {
                t.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, (float)(1.0 / Max + 0.1)));
            }
            t.RowCount = 1;
            t.RowStyles.Add(new RowStyle(SizeType.Percent, 100));
            t.Dock = DockStyle.Fill;
            //this.Padding = new Padding(0, 0, 0, 0);
            //t.BackColor = Color.Transparent;
            //t.BackColor = Color.Black;
            for (int i = 0; i < Max; i++)
            {
                var cell = new EnergyCell();
                var j    = i + 1;
                cell.Click += (s, e) =>
                {
                    if (cells[j - 1].state == 2 && ((j < Max && cells[j].state != 2) || (j == Max)))
                    {
                        PlayerCommands.TrySetRoomEnergyConsumption(room, j - 1, ship);
                    }
                    else
                    {
                        PlayerCommands.TrySetRoomEnergyConsumption(room, j, ship);
                    }
                    foreach (var bar in ship.SpecialRooms.SelectMany(r => allBars[r]))
                    {
                        bar.Invalidate();
                    }
                };
                cell.Dock    = DockStyle.Fill;
                cell.Margin  = new Padding(0, 0, 0, 0);
                cell.Padding = new Padding(0, 0, 0, 0);
                cells.Add(cell);
                t.Controls.Add(cell, i, 0);
            }
            t.Margin     = new Padding(0, 0, 0, 0);
            t.Padding    = new Padding(0, 0, 0, 0);
            this.Padding = new Padding(0, 0, 0, 0);
            this.Margin  = new Padding(0, 0, 0, 0);
            Controls.Add(t);
        }
예제 #8
0
        public static void Recalculate(Ship ship)
        {
            if (ship == null)
            {
                return;
            }
            int    radar      = 0;
            int    evasion    = 0;
            int    heal       = 0;
            int    energy     = 0;
            int    maxEnergy  = 0;
            double damegeMult = 1.0;

            foreach (var room in ship.SpecialRooms)
            {
                var roomLevel = 0;
                switch (room.Type)
                {
                case RoomType.Radar:
                    roomLevel = room.Stat.CurrentEnergy + room.Stat.MaxWorkingSpaces - room.Stat.EmptyWorkingSpaces;
                    roomLevel = roomLevel * room.CurrentDurability / room.MaxDurability;
                    radar    += roomLevel;
                    evasion  += radar * 2;
                    energy   -= room.Stat.CurrentEnergy;
                    break;

                case RoomType.Control:
                    roomLevel = room.Stat.CurrentEnergy + room.Stat.MaxWorkingSpaces - room.Stat.EmptyWorkingSpaces;
                    roomLevel = roomLevel * room.CurrentDurability / room.MaxDurability;
                    evasion  += 5 * roomLevel;
                    energy   -= room.Stat.CurrentEnergy;
                    break;

                case RoomType.Engine:
                    roomLevel = room.Stat.CurrentEnergy + room.Stat.MaxWorkingSpaces - room.Stat.EmptyWorkingSpaces;
                    roomLevel = roomLevel * room.CurrentDurability / room.MaxDurability;
                    evasion  += 5 * roomLevel;
                    energy   -= room.Stat.CurrentEnergy;
                    break;

                case RoomType.Living:
                    roomLevel = room.Stat.CurrentEnergy;
                    roomLevel = roomLevel * room.CurrentDurability / room.MaxDurability;
                    heal     += roomLevel;
                    energy   -= room.Stat.CurrentEnergy;
                    break;

                case RoomType.Generator:
                    roomLevel  = room.Stat.CurrentEnergyLimit;
                    roomLevel  = roomLevel * room.CurrentDurability / room.MaxDurability;
                    maxEnergy += roomLevel;
                    energy    += maxEnergy;
                    break;

                case RoomType.Weapon:
                    roomLevel   = room.Stat.CurrentEnergy + room.Stat.MaxWorkingSpaces - room.Stat.EmptyWorkingSpaces;
                    roomLevel   = roomLevel * room.CurrentDurability / room.MaxDurability;
                    damegeMult += 0.1 * (roomLevel);
                    energy     -= room.Stat.CurrentEnergy;
                    break;
                }
            }
            if (energy < 0)
            {
                while (energy < 0)
                {
                    var vr   = ship.SpecialRooms.Where(r => r.Stat.CurrentEnergy > 0 && r.Type != RoomType.Generator).ToList();
                    var room = vr[random.Next(0, vr.Count)];
                    PlayerCommands.TrySetRoomEnergyConsumption(room, room.Stat.CurrentEnergy - 1, ship);
                    energy++;
                }
                Recalculate(ship);
                return;
            }
            ship.Stats.CurrentEnergy    = energy;
            ship.Stats.DamageMultiplier = damegeMult;
            ship.Stats.FullEnergy       = maxEnergy;
            ship.Stats.Radar            = radar;
            ship.Stats.Evasion          = evasion;
            ship.Stats.Heal             = heal;
        }