예제 #1
0
        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)));
            }
        }
예제 #2
0
    /// <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);
            }
        }
    }
예제 #3
0
 //Set a buff and return its unique name
 public string AddEffect(Effect effect)
 {
     CurrentEffects.Add(effect);
     return(CurrentEffects[CurrentEffects.Count - 1].Name);
 }
예제 #4
0
 //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);
 }