Beispiel #1
0
    protected virtual void ApplyContinuousEffect(BaseAgent triggeringComponent, float timeStep)
    {
        int applicableEffect = 0;

        if (triggeringComponent != null)
        {
            switch (effectCode)
            {
            case EFFECT_CODE_HP_DAMAGE:
                accumulatedEffect += timeStep * effectIntensity;
                applicableEffect   = (int)accumulatedEffect;
                if (applicableEffect > 0)
                {
                    accumulatedEffect -= applicableEffect;
                    triggeringComponent.SufferHPDamage(applicableEffect, gameObject, triggerSourceComponent);
                }
                break;

            case EFFECT_CODE_HP_RECOVERY:
                accumulatedEffect += timeStep * effectIntensity;
                applicableEffect   = (int)accumulatedEffect;
                if (applicableEffect > 0)
                {
                    accumulatedEffect -= applicableEffect;
                    triggeringComponent.AddToCurrentHP(applicableEffect, false);
                }
                break;
            }
        }
    }
Beispiel #2
0
    protected virtual void OnCollisionEnter2D(Collision2D collision)
    {
        GameObject adversaryObject    = null;
        BaseAgent  adversaryComponent = null;

        if ((collision != null) && (adversaryObjects != null) && (adversaryComponents != null))
        {
            if (collision.gameObject != null)
            {
                /*halmeida - this is the invader's object.*/
                for (int i = 0; i < adversaryObjects.Length; i++)
                {
                    adversaryObject = adversaryObjects[i];
                    if (adversaryObject == collision.gameObject)
                    {
                        adversaryComponent = adversaryComponents[i];
                        if (adversaryComponent != null)
                        {
                            adversaryComponent.SufferHPDamage((int)finalAttack, gameObject, this);
                            adversaryComponent.SufferPush((Vector2)transform.position, finalAttack);
                        }
                        break;
                    }
                }
            }
        }
    }
Beispiel #3
0
    /*halmeida - this function receives an index that is valid across all relevant arrays and denotes
     * an element that is not null across all relevant arrays.*/
    protected override void Trigger(int triggerIndex)
    {
        BaseAgent agentComponent = null;

        agentComponent = triggerComponents[triggerIndex];
        if (!continuousEffect)
        {
            switch (effectCode)
            {
            case EFFECT_CODE_HP_DAMAGE:
                agentComponent.SufferHPDamage((int)effectIntensity, gameObject, triggerSourceComponent);
                break;

            case EFFECT_CODE_HP_RECOVERY:
                agentComponent.AddToCurrentHP((int)effectIntensity, false);
                break;
            }
            Deactivate();
        }
        base.Trigger(triggerIndex);
    }