예제 #1
0
    //////////////////////////////////////////
    /// ProcessAction()
    /// Processes the incoming action, doing
    /// whatever it's supposed to do.
    //////////////////////////////////////////
    private void ProcessAction(QueuedAction i_action)
    {
        // get the target the action affects
        CharacterModel modelTarget    = GetTargetModel(i_action.GetData().Target, i_action);
        CharacterModel modelAggressor = ModelManager.Instance.GetModel(i_action.GetOwnerID());

        //Debug.Log( "Processing " + i_action.GetData().Name + " on " + modelTarget.Name );

        // check to see if any effects on the aggressor contribute to increased power
        int nPowerBonus = modelAggressor.GetTotalModification("AllDamage");
        int nDamage     = i_action.GetData().Power + nPowerBonus;

        // check for valid bonus damage
        nDamage = CheckForBonuses(i_action.GetData(), nDamage, modelTarget, modelAggressor);

        // now do defenses -- for now, just handle one
        if (i_action.GetData().DamageTypes.Count > 0)
        {
            DamageTypes eDamageType = i_action.GetData().DamageTypes[0];
            int         nDefense    = modelTarget.GetTotalModification(eDamageType.ToString() + "Defense");

            if (nDamage > 0)
            {
                // something is reducing the defense
                nDamage = Mathf.Max(nDamage - nDefense, 0);
            }
            else
            {
                // something is augmenting the heal
                nDamage = nDamage + nDefense;
            }
        }

        // for now, we're just altering the hp of the target
        modelTarget.AlterHP(nDamage);

        // handle applied effects, if any
        foreach (AppliedEffectData effect in i_action.GetData().AppliedEffects)
        {
            // get the model the effect should apply to
            CharacterModel modelEffectTarget = GetTargetModel(effect.Target, i_action);

            // apply the effect!
            modelEffectTarget.ApplyEffect(effect);
        }

        // handle remove effects, if any
        foreach (RemovedEffectData removal in i_action.GetData().RemovedEffects)
        {
            // get the model the removal should apply to
            CharacterModel modelEffectRemoval = GetTargetModel(removal.Target, i_action);

            // remove the effect!
            modelEffectRemoval.RemoveEffect(removal);
        }
    }