Ejemplo n.º 1
0
        private void DeltaVitalInternal(CreatureVital vital, long delta)
        {
            uint absVal;

            if (delta < 0 && Math.Abs(delta) > vital.Current)
            {
                absVal = (uint)(-1 * vital.Current);
            }
            else if (delta + vital.Current > vital.MaxValue)
            {
                absVal = (uint)(vital.MaxValue - vital.Current);
            }
            else
            {
                absVal = (uint)(vital.Current + delta);
            }

            UpdateVitalInternal(vital, absVal);
        }
Ejemplo n.º 2
0
        private void VitalTick(CreatureVital vital)
        {
            double tickTime = vital.NextTickTime;

            if (double.IsNegativeInfinity(tickTime))
            {
                tickTime = vital.RegenRate;
            }
            else
            {
                tickTime -= WorldManager.PortalYearTicks;
            }

            // Set up our next tick
            ActionChain tickChain = new ActionChain();

            tickChain.AddDelayTicks(tickTime);
            tickChain.AddAction(this, () => VitalTickInternal(vital));
            tickChain.EnqueueChain();
        }
Ejemplo n.º 3
0
        private Character()
        {
            StrengthAbility     = new CreatureAbility(Enum.Ability.Strength);
            EnduranceAbility    = new CreatureAbility(Enum.Ability.Endurance);
            CoordinationAbility = new CreatureAbility(Enum.Ability.Coordination);
            QuicknessAbility    = new CreatureAbility(Enum.Ability.Quickness);
            FocusAbility        = new CreatureAbility(Enum.Ability.Focus);
            SelfAbility         = new CreatureAbility(Enum.Ability.Self);

            // TODO: Real regen rates?
            Health  = new CreatureVital(this, Enum.Ability.Health, .5);
            Stamina = new CreatureVital(this, Enum.Ability.Stamina, 1.0);
            Mana    = new CreatureVital(this, Enum.Ability.Mana, .7);

            abilities.Add(Enum.Ability.Strength, StrengthAbility);
            abilities.Add(Enum.Ability.Endurance, EnduranceAbility);
            abilities.Add(Enum.Ability.Coordination, CoordinationAbility);
            abilities.Add(Enum.Ability.Quickness, QuicknessAbility);
            abilities.Add(Enum.Ability.Focus, FocusAbility);
            abilities.Add(Enum.Ability.Self, SelfAbility);

            abilities.Add(Enum.Ability.Health, Health);
            abilities.Add(Enum.Ability.Stamina, Stamina);
            abilities.Add(Enum.Ability.Mana, Mana);

            Abilities = new ReadOnlyDictionary <Enum.Ability, CreatureAbility>(abilities);

            // initialize properties collections to reasonable defaults
            InitializeProperties(typeof(Character));

            friends = new List <Friend>();
            Friends = new ReadOnlyCollection <Friend>(friends);

            InitializeCharacterOptions();
            CharacterOptions = new ReadOnlyDictionary <CharacterOption, bool>(characterOptions);

            // initialize the blank character positions
            InitializeCharacterPositions();
            Positions = new ReadOnlyDictionary <PositionType, Position>(positions);
        }
Ejemplo n.º 4
0
 public void DeltaVital(CreatureVital vital, long delta)
 {
     EnqueueAction(new ActionEventDelegate(() => DeltaVitalInternal(vital, delta)));
 }
Ejemplo n.º 5
0
 /// <summary>
 /// Updates a vital, returns true if vital is now < max
 /// </summary>
 /// <param name="vital"></param>
 /// <param name="quantity"></param>
 /// <returns></returns>
 public void UpdateVital(CreatureVital vital, uint newVal)
 {
     EnqueueAction(new ActionEventDelegate(() => UpdateVitalInternal(vital, newVal)));
 }