Exemplo n.º 1
0
 public void ChangeLeftOver(ShipStateChange change)
 {
     change.Health           = this.Health.ChangeValue(change.Health);
     change.Energy           = this.Energy.ChangeValue(change.Energy);
     change.HealthChangeRate = this.HealthChangeRate.ChangeValue(change.HealthChangeRate);
     change.EnergyChangeRate = this.EnergyChangeRate.ChangeValue(change.EnergyChangeRate);
 }
Exemplo n.º 2
0
        public ShipStateChange RemoveEffectTypes(EffectTypes types)
        {
            ShipStateChange removed = new ShipStateChange();

            if ((types & EffectTypes.Energy) == EffectTypes.Energy)
            {
                removed.Energy = Energy;
                this.Energy    = 0;
            }
            if ((types & EffectTypes.EnergyChangeRate) == EffectTypes.EnergyChangeRate)
            {
                removed.EnergyChangeRate = EnergyChangeRate;
                this.EnergyChangeRate    = 0;
            }
            if ((types & EffectTypes.Health) == EffectTypes.Health)
            {
                removed.Health = Health;
                this.Health    = 0;
            }
            if ((types & EffectTypes.HealthChangeRate) == EffectTypes.HealthChangeRate)
            {
                removed.HealthChangeRate = HealthChangeRate;
                this.HealthChangeRate    = 0;
            }
            return(removed);
        }
Exemplo n.º 3
0
 public void Change(ShipStateChange change)
 {
     this.Health.Value           += change.Health;
     this.Energy.Value           += change.Energy;
     this.HealthChangeRate.Value += change.HealthChangeRate;
     this.EnergyChangeRate.Value += change.EnergyChangeRate;
 }
Exemplo n.º 4
0
 public ShipStateChange(ShipStateChange copy)
 {
     this.Health           = copy.Health;
     this.Energy           = copy.Energy;
     this.HealthChangeRate = copy.HealthChangeRate;
     this.EnergyChangeRate = copy.EnergyChangeRate;
 }
Exemplo n.º 5
0
 public Costs(ShipStateChange ActivationCost,
              ShipStateChange RunningCost,
              ShipStateChange DeActivationCost)
 {
     this.ActivationCost   = ActivationCost;
     this.RunningCost      = RunningCost;
     this.DeActivationCost = DeActivationCost;
 }
Exemplo n.º 6
0
        public static ShipStateChange operator *(float s, ShipStateChange first)
        {
            ShipStateChange returnvalue = new ShipStateChange();

            returnvalue.Health           = first.Health * s;
            returnvalue.Energy           = first.Energy * s;
            returnvalue.HealthChangeRate = first.HealthChangeRate * s;
            returnvalue.EnergyChangeRate = first.EnergyChangeRate * s;
            return(returnvalue);
        }
Exemplo n.º 7
0
        public static ShipStateChange operator -(ShipStateChange first, ShipStateChange second)
        {
            ShipStateChange returnvalue = new ShipStateChange();

            returnvalue.Health           = first.Health - second.Health;
            returnvalue.Energy           = first.Energy - second.Energy;
            returnvalue.HealthChangeRate = first.HealthChangeRate - second.HealthChangeRate;
            returnvalue.EnergyChangeRate = first.EnergyChangeRate - second.EnergyChangeRate;
            return(returnvalue);
        }
Exemplo n.º 8
0
        public static ShipStateChange operator -(ShipStateChange source)
        {
            ShipStateChange returnvalue = new ShipStateChange();

            returnvalue.Health           = -source.Health;
            returnvalue.Energy           = -source.Energy;
            returnvalue.HealthChangeRate = -source.HealthChangeRate;
            returnvalue.EnergyChangeRate = -source.EnergyChangeRate;
            return(returnvalue);
        }
Exemplo n.º 9
0
        public static ShipStateChange Merge(ShipStateChange first, ShipStateChange second)
        {
            ShipStateChange returnvalue = new ShipStateChange();

            returnvalue.Health           = first.Health + second.Health;
            returnvalue.Energy           = first.Energy + second.Energy;
            returnvalue.HealthChangeRate = first.HealthChangeRate + second.HealthChangeRate;
            returnvalue.EnergyChangeRate = first.EnergyChangeRate + second.EnergyChangeRate;
            return(returnvalue);
        }
Exemplo n.º 10
0
 public void Merge(ShipStateChange other)
 {
     if (other != null)
     {
         this.Energy           += other.Energy;
         this.EnergyChangeRate += other.EnergyChangeRate;
         this.Health           += other.Health;
         this.HealthChangeRate += other.HealthChangeRate;
     }
 }
Exemplo n.º 11
0
 public Costs(Costs copy)
 {
     this.ActivationCost = new ShipStateChange(copy.ActivationCost);
     if (copy.RunningCost != null)
     {
         this.RunningCost = new ShipStateChange(copy.RunningCost);
     }
     if (copy.DeActivationCost != null)
     {
         this.DeActivationCost = new ShipStateChange(copy.DeActivationCost);
     }
 }
Exemplo n.º 12
0
        public bool MeetsCost(ShipStateChange cost)
        {
            float health = cost.Health;

            if (health != 0)
            {
                health -= 1;
            }
            return(this.Health.HasRoomFor(health) &&
                   this.Energy.HasRoomFor(cost.Energy) &&
                   this.HealthChangeRate.HasRoomFor(cost.HealthChangeRate) &&
                   this.EnergyChangeRate.HasRoomFor(cost.EnergyChangeRate));
        }
 public void Merge(GeneralChange other)
 {
     if (other != null)
     {
         if (other.MovementInfoChange != null)
         {
             if (MovementInfoChange == null)
             {
                 MovementInfoChange = other.MovementInfoChange;
             }
             else
             {
                 MovementInfoChange.Merge(other.MovementInfoChange);
             }
         }
         if (other.ShipStateChange != null)
         {
             if (ShipStateChange == null)
             {
                 ShipStateChange = other.ShipStateChange;
             }
             else
             {
                 ShipStateChange.Merge(other.ShipStateChange);
             }
         }
         if (other.PhysicsChange != null)
         {
             if (PhysicsChange == null)
             {
                 PhysicsChange = other.PhysicsChange;
             }
             else
             {
                 PhysicsChange.Velocity         += other.PhysicsChange.Velocity;
                 PhysicsChange.Position         += other.PhysicsChange.Position;
                 PhysicsChange.ForceAccumulator += other.PhysicsChange.ForceAccumulator;
                 PhysicsChange.Acceleration     += other.PhysicsChange.Acceleration;
             }
         }
     }
 }
Exemplo n.º 14
0
        public static EffectTypes CalcHarmfulEffectTypes(ShipStateChange ssc)
        {
            EffectTypes returnvalue = EffectTypes.None;

            if (ssc.Energy < 0)
            {
                returnvalue = returnvalue | EffectTypes.Energy;
            }
            if (ssc.EnergyChangeRate < 0)
            {
                returnvalue = returnvalue | EffectTypes.EnergyChangeRate;
            }
            if (ssc.Health < 0)
            {
                returnvalue = returnvalue | EffectTypes.Health;
            }
            if (ssc.HealthChangeRate < 0)
            {
                returnvalue = returnvalue | EffectTypes.HealthChangeRate;
            }
            return(returnvalue);
        }