Esempio n. 1
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());
 }
Esempio n. 2
0
 private void spendPower()
 {
     // currently the only thing that this does is regen the shields or not.
     // change to for loop so we have more control owver what gets power when and what happens if there isn't enough power.
     Power -= (Reactors.Select(x => x.GetUpkeepCost()).Sum() +
               Shields.Select(x => x.GetUpkeepCost()).Sum() +
               Weapons.Select(x => x.GetUpkeepCost()).Sum() +
               Engines.Select(x => x.GetUpkeepCost()).Sum() +
               CrewDecks.Select(x => x.GetUpkeepCost()).Sum());
     if (Power < 0)
     {
         Power = 0;
     }
     foreach (var shield in Shields)
     {
         Power = shield.Regen(Power);
     }
 }
Esempio n. 3
0
        public override string ToString()
        {
            var result = "Ship:" + Name +
                         " Crew:" + CrewDecks.Select(x => (int)x.GetCrew()).Sum() +
                         " Mass: " + Mass +
                         " Power:" + Power +
                         " Position:[X:" + Position.X + " Y:" + Position.Y + " Heading:" + Orientation + "° Velocity: X:" + Velocity.X + " Y:" + Velocity.Y + " Mag:" + Velocity.Magnitude + "]\n";

            result += string.Join(" ", Reactors.Select(x => x.ToString())) + "\n";
            result += string.Join(" ", Shields.Select(x => x.ToString())) + "\n";
            result += string.Join(" ", Weapons.Select(x => x.ToString())) + "\n";
            result += string.Join(" ", Engines.Select(x => x.ToString())) + "Max :" + GetMaxAcceleration() + "\n";
            result += string.Join(" ", CrewDecks.Select(x => x.ToString())) + "\n";
            if (IsDestroyed())
            {
                result += "(Destroyed)\n";
            }
            return(result);
        }
Esempio n. 4
0
        public override bool IsDestroyed()
        {
            if (CrewDecks.Select(x => (int)x.GetCrew()).Sum() == 0)
            {
                return(true); // probably not exactly what we want. We will probably want a difference betweeen destroyed and derelict.
            }
            foreach (var part in Reactors)
            {
                if (!part.IsDestroyed())
                {
                    return(false);
                }
            }
            foreach (var part in Shields)
            {
                if (!part.IsDestroyed())
                {
                    return(false);
                }
            }
            foreach (var part in Weapons)
            {
                if (!part.IsDestroyed())
                {
                    return(false);
                }
            }
            foreach (var part in Engines)
            {
                if (!part.IsDestroyed())
                {
                    return(false);
                }
            }

            return(true);
        }