Esempio n. 1
0
        private Inventory getLoot(CombatGroup group)
        {
            Inventory loot = new Inventory();

            foreach (Ship ship in group.Ships)
            {
                //Add the ship's inventory to the loot list
                loot.AddInventoryList(ship.Inventory.GetInventoryList());
                ship.Inventory.ClearInventory();

                //Add the modules of each ship to the loot list
                foreach (ShipNode node in ship.Nodes)
                {
                    if (node.Empty)
                    {
                        continue;
                    }
                    loot.AddItem(node.Module, 1);
                    node.Empty  = true;
                    node.Module = null;
                }
            }

            return(loot);
        }
Esempio n. 2
0
        public CombatGroup SimulateCombat()
        {
            if (groupOne == null || groupTwo == null)
            {
                throw new ArgumentNullException("You must set CombatGroups before simulating combat.");
            }

            //Variance to add variability to combat
            double varOne = RNG.NextDouble(0.9, 1.1);
            double varTwo = RNG.NextDouble(0.9, 1.1);

            double groupOneValue = groupOne.CombatValue;
            double groupTwoValue = groupTwo.CombatValue;

            groupOneValue *= varOne;
            groupTwoValue *= varTwo;

            double rng = RNG.NextDouble(-groupOneValue, groupTwoValue);

            //Determine winner/loser
            CombatGroup winner = (rng <= 0) ? groupOne : groupTwo;
            CombatGroup loser  = (rng > 0) ? groupOne : groupTwo;

            //If the player lost, send them to the end screen
            if (loser.IsPlayerGroup)
            {
                gameManager.LoseGame();
            }

            //Calculate and reward loot
            Inventory loot = getLoot(loser);

            winner.Ships[0].Inventory.AddInventoryList(loot.GetInventoryList());

            //Add loser ships to winner's faction
            foreach (Ship ship in loser.Ships)
            {
                ship.Faction.UnregisterShip(ship);
                winner.Ships[0].Faction.RegisterShip(ship);
            }

            groupOne = null;
            groupTwo = null;

            return(winner);
        }
Esempio n. 3
0
 public void SetCombatants(Ship one, Ship two)
 {
     groupOne = new CombatGroup(one);
     groupTwo = new CombatGroup(two);
 }
Esempio n. 4
0
 public void SetCombatants(CombatGroup one, CombatGroup two)
 {
     groupOne = one;
     groupTwo = two;
 }