public void AddLives(int lives) { _health += lives; if (_health > _totalHealth) { _health = _totalHealth; } if (_health < 0) { _health = 0; } if (lives < 0) { CurrentEffects.Add(new Effect(EffectType.Damage, TimeSpan.FromMilliseconds(200))); CurrentEffects.Add(new Effect(EffectType.HealthChanged, TimeSpan.FromSeconds(2))); } }
/// <summary> /// Накладывает на персонажа заданный эффект <paramref name="effects"/>. /// </summary> /// <param name="effects">Массив накладываемых эффектов.</param> public void ApplyEffects(params Effect[] effects) { foreach (var effect in effects) { if (UnityEngine.Random.value <= effect.applicationChance) { var instance = Instantiate(effect); CurrentEffects.Add(instance); switch (instance.effectType) { case EffectType.Blindness: case EffectType.Weakness: case EffectType.Guard: instance.Apply(this); break; } OnEffectApplied?.Invoke(instance); } } }
//Set a buff and return its unique name public string AddEffect(Effect effect) { CurrentEffects.Add(effect); return(CurrentEffects[CurrentEffects.Count - 1].Name); }
//Set a buff and return its unique name public string AddEffect(string name, int value, string desc, string source, int ttl) { CurrentEffects.Add(new Effect(name, value, desc, source, ttl)); return(CurrentEffects[CurrentEffects.Count - 1].Name); }