Exemplo n.º 1
0
 /// <summary>
 /// Creates a copy of <see cref="ModifierModel"/>
 /// </summary>
 public ModifierModel(ModifierModel modifierModel)
 {
     _id               = modifierModel.ID;
     _text             = modifierModel.Text;
     _modifierCategory = modifierModel.ModifierCategory;
     _value            = modifierModel.Value;
     _ability          = modifierModel.Ability;
 }
Exemplo n.º 2
0
        /// <summary>
        /// Set a value without logging the change
        /// (used when an Updater makes an internal change and ensures to synchronizes the update itself)
        /// </summary>
        internal void SetValueUnlogged(ModifierCategory collectionType, ModifierType statType, double value)
        {
            m_changeLock.EnterWriteLock();

            try {
                m_modifiers[collectionType][statType] = value;
            }
            finally {
                m_changeLock.ExitWriteLock();
            }
        }
Exemplo n.º 3
0
        public Modifier(ModifierCategory category, ModifierTag tag)
        {
            Tag      = tag;
            Category = category;
            switch (Category)
            {
            case ModifierCategory.Domain:
                defineDomains(tag);
                break;

            case ModifierCategory.Province:
                defineProvincialModifiers(tag);
                break;
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// Sets a specific value for a specific <see cref="ModifierType" /> in a specific
        /// <see cref="ModifierCategory">collection</see>.
        /// </summary>
        /// <param name="collectionType">the collection type</param>
        /// <param name="statType">the stat type</param>
        /// <param name="value">the amount to set</param>
        public void SetValue(ModifierCategory collectionType, ModifierType statType, double value)
        {
            m_changeLock.EnterWriteLock();

            try {
                m_modifiers[collectionType][statType] = value;

                if (!IsChangeFlagged(statType))
                {
                    m_changes.AddLast(statType);
                }
            }
            finally {
                m_changeLock.ExitWriteLock();
            }
        }
Exemplo n.º 5
0
		/// <summary>
		/// Adds a given value to the existing value for a specific <see cref="ModifierType" /> in a
		/// specific <see cref="ModifierCategory">collection</see>. 
		/// </summary>
		/// <param name="collectionType">the collection type</param>
		/// <param name="statType">the stat type</param>
		/// <param name="value">the amount to add</param>
		public void AddToStat(ModifierCategory collectionType, ModifierType statType, double value)
		{
			m_changeLock.EnterWriteLock();

			try
			{
				m_modifiers[collectionType][statType] += value;

				if (!IsChangeFlagged(statType))
				{
					m_changes.AddLast(statType);
				}
			}
			finally
			{
				m_changeLock.ExitWriteLock();
			}
		}
Exemplo n.º 6
0
		/// <summary>
		/// Gets the value for a specific <see cref="ModifierType" /> and a specific <see cref="ModifierCategory" />. 
		/// </summary>
		/// <param name="collectionType">the collection type</param>
		/// <param name="statType">the stat type</param>
		/// <returns>the value for the given collection type/stat type</returns>
		public float GetValue(ModifierCategory collectionType, ModifierType statType)
		{
			return (float)m_modifiers[collectionType][statType];
		}
Exemplo n.º 7
0
		/// <summary>
		/// Sets a specific value for a specific <see cref="ModifierType" /> in a specific 
		/// <see cref="ModifierCategory">collection</see>.
		/// </summary>
		/// <param name="collectionType">the collection type</param>
		/// <param name="statType">the stat type</param>
		/// <param name="value">the amount to set</param>
		public void SetValue(ModifierCategory collectionType, ModifierType statType, int value)
		{
			SetValue(collectionType, statType, (double)value);
		}
Exemplo n.º 8
0
		/// <summary>
		/// Set a value without logging the change 
		/// (used when an Updater makes an internal change and ensures to synchronizes the update itself)
		/// </summary>
		internal void SetValueUnlogged(ModifierCategory collectionType, ModifierType statType, double value)
		{
			m_changeLock.EnterWriteLock();

			try {
				m_modifiers[collectionType][statType] = value;
			}
			finally {
				m_changeLock.ExitWriteLock();
			}
		}
Exemplo n.º 9
0
		/// <summary>
		/// Removes a given amount from the existing value for a specific <see cref="ModifierType" /> in a
		/// specific <see cref="ModifierCategory">collection</see>. 
		/// </summary>
		/// <param name="collectionType">the collection type</param>
		/// <param name="statType">the stat type</param>
		/// <param name="value">the amount to remove</param>
		public void RemoveFromStat(ModifierCategory collectionType, ModifierType statType, int value)
		{
			RemoveFromStat(collectionType, statType, (double)value);
		}
Exemplo n.º 10
0
 /// <summary>
 /// Adds a given value to the existing value for a specific <see cref="ModifierType" /> in a
 /// specific <see cref="ModifierCategory">collection</see>. 
 /// </summary>
 /// <param name="collectionType">the collection type</param>
 /// <param name="statType">the stat type</param>
 /// <param name="value">the amount to add</param>
 public void AddToStat(ModifierCategory collectionType, ModifierType statType, int value)
 {
     AddToStat(collectionType, statType, (double)value);
 }
Exemplo n.º 11
0
 /// <summary>
 /// Gets the value for a specific <see cref="ModifierType" /> and a specific <see cref="ModifierCategory" />.
 /// </summary>
 /// <param name="collectionType">the collection type</param>
 /// <param name="statType">the stat type</param>
 /// <returns>the value for the given collection type/stat type</returns>
 public float GetValue(ModifierCategory collectionType, ModifierType statType)
 {
     return((float)m_modifiers[collectionType][statType]);
 }
Exemplo n.º 12
0
 /// <summary>
 /// Sets a specific value for a specific <see cref="ModifierType" /> in a specific
 /// <see cref="ModifierCategory">collection</see>.
 /// </summary>
 /// <param name="collectionType">the collection type</param>
 /// <param name="statType">the stat type</param>
 /// <param name="value">the amount to set</param>
 public void SetValue(ModifierCategory collectionType, ModifierType statType, int value)
 {
     SetValue(collectionType, statType, (double)value);
 }
Exemplo n.º 13
0
 /// <summary>
 /// Removes a given amount from the existing value for a specific <see cref="ModifierType" /> in a
 /// specific <see cref="ModifierCategory">collection</see>.
 /// </summary>
 /// <param name="collectionType">the collection type</param>
 /// <param name="statType">the stat type</param>
 /// <param name="value">the amount to remove</param>
 public void RemoveFromStat(ModifierCategory collectionType, ModifierType statType, int value)
 {
     RemoveFromStat(collectionType, statType, (double)value);
 }
Exemplo n.º 14
0
 /// <summary>
 /// Adds a given value to the existing value for a specific <see cref="ModifierType" /> in a
 /// specific <see cref="ModifierCategory">collection</see>.
 /// </summary>
 /// <param name="collectionType">the collection type</param>
 /// <param name="statType">the stat type</param>
 /// <param name="value">the amount to add</param>
 public void AddToStat(ModifierCategory collectionType, ModifierType statType, int value)
 {
     AddToStat(collectionType, statType, (double)value);
 }
Exemplo n.º 15
0
    static void ApplyModifierToAttack_BlowbackFollowUp(ModifierData modifier, EntityData entity, ScenarioState gameState, Direction actionDirection, ModifierCategory blowbackOrFollowUp)
    {
        Direction forceDirection = actionDirection;

        if (blowbackOrFollowUp == ModifierCategory.Blowback)
        {
            forceDirection = ScenarioStateHelperFunctions.ReverseDirection(forceDirection);
        }
        int pushMagnitude = modifier.value;

        while (pushMagnitude > 0)
        {
            Tile currentEntityTile = BoardController
                                     .CurrentBoard
                                     .GetTileAtPosition(entity.Position);
            bool canPushTarget = currentEntityTile
                                 .ConnectsToNeighbor(forceDirection);

            if (canPushTarget)
            {
                Tile nextTile           = currentEntityTile.GetDirectionalNeighbor(forceDirection);
                bool isNextTileOccupied = nextTile.IsOccupied(gameState);

                if (isNextTileOccupied)
                {
                    ResolveBump(entity, gameState.GetTileOccupant(nextTile), forceDirection, gameState);
                    break;
                }
                else
                {
                    entity.SetPosition(currentEntityTile.GetDirectionalNeighbor(forceDirection).Position, gameState);
                    pushMagnitude--;
                }
            }
            else
            {
                entity.DealDamage(1, gameState);
                break;
            }
        }
    }
Exemplo n.º 16
0
    static void ApplyModifierToAttack_PushPull(EntityData target, ModifierData modifier, EntityData attacker, ScenarioState gameState, ModifierCategory pushOrPull)
    {
        if (attacker.Position == target.Position)
        {
            return;
        }
        // Default to push, check for pull.
        Direction forceDirection = BoardHelperFunctions.GetDirectionFromPosition(attacker.Position, target.Position);

        if (pushOrPull == ModifierCategory.Pull)
        {
            forceDirection = BoardHelperFunctions.GetDirectionFromPosition(target.Position, attacker.Position);
        }
        int pushMagnitude = modifier.value;

        while (pushMagnitude > 0)
        {
            Tile currentTargetTile = BoardController
                                     .CurrentBoard
                                     .GetTileAtPosition(target.Position);
            bool canPushTarget = currentTargetTile
                                 .ConnectsToNeighbor(forceDirection);

            if (canPushTarget)
            {
                Tile nextTile           = currentTargetTile.GetDirectionalNeighbor(forceDirection);
                bool isNextTileOccupied = nextTile.IsOccupied(gameState);

                if (isNextTileOccupied)
                {
                    ResolveBump(target, gameState.GetTileOccupant(nextTile), forceDirection, gameState);
                    break;
                }
                else
                {
                    target.SetPosition(currentTargetTile.GetDirectionalNeighbor(forceDirection).Position, gameState);
                    pushMagnitude--;
                }
            }
            else
            {
                target.DealDamage(1, gameState);
                break;
            }
        }
    }