Example #1
0
    public override void Apply(GameObject target)
    {
        base.Apply(target);

        //if (!CheckForSpecificTarget(target))
        //    return;

        switch (statusType)
        {
        case Constants.StatusEffectType.None:
            //Status newStatus = target.AddComponent<Status>();
            Status newStatus = new Status();


            newStatus.Initialize(target, duration, interval, statusType, parentAbility);

            StatusManager.AddStatus(target.GetComponent <Entity>(), newStatus, this, parentAbility);
            break;

        case Constants.StatusEffectType.AffectMovement:
            //AffectMovement newAffectMovement = target.AddComponent<AffectMovement>();
            AffectMovement newAffectMovement = new AffectMovement();

            //knockbackVector = TargetingUtilities.DegreeToVector2(knocbackAngle);
            knockbackVector = TargetingUtilities.DirectionFromAngle(knocbackAngle, false);

            if (Source.Facing == Constants.EntityFacing.Left)
            {
                knockbackVector = new Vector2(-knockbackVector.x, knockbackVector.y);
            }

            //Debug.Log(knockbackVector + " is the knockback vector");

            newAffectMovement.Initialize(target, duration, interval, statusType, parentAbility, maxStack, onCompleteEffect);
            newAffectMovement.InitializeAffectMovement(affectMoveType, affectMoveValue, knockbackVector);

            StatusManager.AddStatus(target.GetComponent <Entity>(), newAffectMovement, this, parentAbility);
            break;

        case Constants.StatusEffectType.Stun:
            Stun newStun = new Stun();

            newStun.Initialize(target, duration, interval, statusType, parentAbility);
            newStun.InitializeStun();

            StatusManager.AddStatus(target.GetComponent <Entity>(), newStun, this, parentAbility);
            break;

        case Constants.StatusEffectType.DamageOverTime:


            float damage;
            if (scaleFromBaseDamage)
            {
                damage = damagePerInterval + (parentAbility.source.stats.GetStatModifiedValue(StatCollection.BaseStat.BaseStatType.BaseDamage) * percentOfBaseDamage);
            }
            else
            {
                damage = damagePerInterval;
            }

            //DamageOverTime newDot = target.AddComponent<DamageOverTime>();
            DamageOverTime newDot = new DamageOverTime();
            newDot.Initialize(target, duration, interval, statusType, parentAbility, maxStack);
            newDot.InitializeDamageOverTime(damage, parentAbility.source);

            StatusManager.AddStatus(target.GetComponent <Entity>(), newDot, this, parentAbility);

            Debug.Log("Applying " + damage + " over time");

            break;

        case Constants.StatusEffectType.StaticStatAdjustment:
            StatCollection.StatModifer modStatic = new StatCollection.StatModifer(statAdjustmentValue, modType);

            Debug.Log("Stat " + statType + " is being adjusted by " + statAdjustmentValue);

            StatAdjustmentManager.ApplyTrackedStatMod(Source, target.GetComponent <Entity>(), statType, modStatic);

            break;

        case Constants.StatusEffectType.DurationalStatAdjustment:
            //StatCollection.StatModifer modDur = new StatCollection.StatModifer(statAdjustmentValue, modType);

            Debug.Log("Setting durational stuff");

            DurationalStatChange newDurationalStatChange = new DurationalStatChange();
            newDurationalStatChange.Initialize(target, duration, interval, statusType, parentAbility, maxStack);
            newDurationalStatChange.InitializeDurationalStatChange(statType, modType, statAdjustmentValue);

            StatusManager.AddStatus(target.GetComponent <Entity>(), newDurationalStatChange, this, parentAbility);

            break;
        }
    }