Inheritance: ModelBase
Example #1
0
        internal Ship(RawShip rpRawData) : base(rpRawData)
        {
            Status        = new ShipStatus(this);
            CombatAbility = new ShipCombatAbility(this);

            OnRawDataUpdated();
        }
Example #2
0
        internal Ship(RawShip rpRawData) : base(rpRawData)
        {
            HP     = new ShipHP(this, 1, 1);
            Fuel   = new ClampedValue(1, 1);
            Bullet = new ClampedValue(1, 1);

            Status        = new ShipStatus(this);
            CombatAbility = new ShipCombatAbility(this);

            OnRawDataUpdated();
        }
Example #3
0
        internal Ship(RawShip rpRawData) : base(rpRawData)
        {
            HP     = new ClampedValue(1, 1);
            Fuel   = new ClampedValue(1, 1);
            Bullet = new ClampedValue(1, 1);

            HP.Subscribe(nameof(HP.Current), delegate
            {
                var rRate = HP.Current / (double)HP.Maximum;

                if (rRate <= .25)
                {
                    State      |= ShipState.HeavilyDamaged;
                    DamageState = ShipDamageState.HeavilyDamaged;
                }
                else
                {
                    State &= ~ShipState.HeavilyDamaged;

                    if (rRate <= .5)
                    {
                        DamageState = ShipDamageState.ModeratelyDamaged;
                    }
                    else if (rRate <= .75)
                    {
                        DamageState = ShipDamageState.LightlyDamaged;
                    }
                    else if (rRate < 1.0)
                    {
                        DamageState = ShipDamageState.Healthy;
                    }
                    else
                    {
                        DamageState = ShipDamageState.FullyHealthy;
                    }
                }
            });

            Status        = new ShipStatus(this);
            CombatAbility = new ShipCombatAbility(this);

            OnRawDataUpdated();
        }