protected override void Activate(UnitData data)
        {
            if (!ResourceCollection.Instance)
            {
                return;
            }
            UnitModifier modifier = ResourceCollection.GetModifier(NumModifier);

            if (modifier == null)
            {
                return;
            }
            if (OnlyForMe)
            {
                var mod = Instantiate(modifier, data.transform);
                mod.transform.localPosition = Vector3.zero;
                mod.transform.localRotation = Quaternion.identity;
                mod.source = data as MoveUnitData;
            }
            else
            {
                if (GameLogic.Instance)
                {
                    GameLogic.Instance.ApplyModifiers(data, modifier);
                }
            }
        }
Example #2
0
        public void ApplyModifiers(UnitData getter, UnitModifier modifier)
        {
            if (!getter || !modifier)
            {
                return;
            }
            Type targetType = null;

            if (getter is CharacterData)
            {
                targetType = typeof(EnemyData);
            }
            else if (getter is EnemyData)
            {
                targetType = typeof(CharacterData);
            }

            if (targetType != null)
            {
                foreach (var unit in units)
                {
                    if (targetType.IsInstanceOfType(unit))
                    {
                        var mod = Instantiate(modifier, unit.transform);
                        mod.transform.localPosition = Vector3.zero;
                        mod.transform.localRotation = Quaternion.identity;
                    }
                }
            }
        }
Example #3
0
        private void OnDamage(TakeDamage taken)
        {
            if (taken)
            {
                taken.GetDamage(DamagePower, DamageMethod, source);
                if (SetDamage != null)
                {
                    SetDamage(DamagePower, DamageMethod);
                }

                if (!ResourceCollection.Instance)
                {
                    return;
                }
                UnitModifier modifier = ResourceCollection.GetModifier(NumModifier);
                if (modifier == null)
                {
                    return;
                }
                UnitData data = taken.GetComponentInParent <UnitData>();
                if (data == null)
                {
                    return;
                }
                if (OnlyForOne)
                {
                    var mod = Instantiate(modifier, data.transform);
                    mod.transform.localPosition = Vector3.zero;
                    mod.transform.localRotation = Quaternion.identity;
                    mod.source = source;
                }
                else
                {
                    if (GameLogic.Instance)
                    {
                        GameLogic.Instance.ApplyModifiers(source, modifier);
                    }
                }
            }
        }