public void RemoveStatusEffect()
 {
     if (instance != null)
     {
         target.RemoveStatusEffect(instance);
         instance = null;
     }
 }
 private void RemoveIcon(StatusEffectBase statusEffect)
 {
     if (statusEffect.effectIcon != null && IconDictionary.ContainsKey(statusEffect) == true)
     {
         StatusEffectIcon icon = IconDictionary[statusEffect];
         icon.OnStatusRemoved();
         Destroy(icon.gameObject);
         IconDictionary.Remove(statusEffect);
     }
 }
Exemple #3
0
        public void RemoveStatusEffect(StatusEffectBase statusEffectInstance)
        {
            if (statusEffects.Contains(statusEffectInstance))
            {
                statusEffects.Remove(statusEffectInstance);
                OnStatusEffectRemoved(statusEffectInstance);

                // Called last because it might be destroyed.
                statusEffectInstance.OnStatusRemoved();
            }
        }
        private void AddIcon(StatusEffectBase statusEffect)
        {
            if (statusEffect.effectIcon != null && IconDictionary.ContainsKey(statusEffect) == false)
            {
                Debug.Log("Adding Status Effect Icon");
                GameObject       iconGo = GameObject.Instantiate(statusEffect.effectIcon, iconGroupRoot);
                StatusEffectIcon icon   = iconGo.GetComponent <StatusEffectIcon>();
                IconDictionary.Add(statusEffect, icon);

                icon.Initialize(statusEffect);
            }
        }
Exemple #5
0
        public StatusEffectBase AddStatusEffect(StatusEffectBase statusEffectAsset)
        {
            // ToDo: Check if asset file ref

            var instance = statusEffectAsset.CreateRuntimeInstance();

            statusEffects.Add(instance);
            instance.Initialize(this);
            instance.OnStatusApplied();
            OnStatusEffectAdded(instance);
            return(instance);
        }
        public void Initialize(StatusEffectBase statEffect)
        {
            if (statusEffect != null)
            {
                Debug.LogWarning("Status Effect was already assigned!");
            }
            statusEffect = statEffect;

            // Attach meters
            if (meters.Length > 0 && typeof(IMeterable).IsAssignableFrom(statusEffect.GetType()))
            {
                IMeterable m = statusEffect as IMeterable;
                foreach (MeterBase meter in meters)
                {
                    meter.SetMeterable(m);
                }
            }

            OnInitialized();
        }
 public void ApplyStatusEffect()
 {
     instance = target.AddStatusEffect(statusEffectAsset);
 }
 private void Start()
 {
     instance = null;
 }
        public virtual StatusEffectBase CreateRuntimeInstance()
        {
            StatusEffectBase instance = Object.Instantiate(this);

            return(instance);
        }