Пример #1
0
    private TimeEffect EfffectOn(int time)
    {
        GameObject immortalityEffect = (GameObject)Resources.Load( "Prefabs/Particles/Immortality" );

        if ( time == 1 ) {
            immortalityEffect = null;
        }

        EffectsController effectsController = new EffectsController();

        TimeEffect effect = new TimeEffect( effectsController );
        effect.id = 99;
        effect.name = "Immortality";
        effect.visualPrefab = immortalityEffect;
        effect.duration = time;

        effect.characteristicsModifiers.armor = 1;
        effect.characteristicsModifiers.attack = 1;
        effect.characteristicsModifiers.attackRange = 1;
        effect.characteristicsModifiers.attackSpeed = 1;
        effect.characteristicsModifiers.speed = 1;
        effect.characteristicsModifiers.armor = 1;
        effect.characteristicsModifiers.hp = 1;

        return effect;
    }
Пример #2
0
        public void TimeEffectApplyOnRegenerationStat()
        {
            IEffect time = new TimeEffect(EffectTarget.Character, StatType.Health, -10, 3, 1);

            Assert.AreEqual(100f, hero.GetStat(StatType.Health).Value);
            hero.AddEffect(time);

            Assert.AreEqual(90f, hero.GetStat(StatType.Health).Value);
            //Assert.AreEqual(2, time.Stack);
            hero.Update();

            Assert.AreEqual(80f, hero.GetStat(StatType.Health).Value);
            //Assert.AreEqual(1, time.Stack);
            hero.Update();

            Assert.AreEqual(70f, hero.GetStat(StatType.Health).Value);
            //Assert.AreEqual(0, time.Stack);
            hero.Update();

            Assert.AreEqual(70f, hero.GetStat(StatType.Health).Value);
            //Assert.AreEqual(-1, time.Stack);
            hero.Update();

            Assert.AreEqual(70f, hero.GetStat(StatType.Health).Value);
        }
Пример #3
0
        public void UseConsumableItem_2()
        {
            IEffect insta = new InstantEffect(EffectTarget.Character, StatType.Health, -40f);

            Assert.AreEqual(100f, hero.GetStat(StatType.Health).Value);
            hero.AddEffect(insta);

            IEffect        restoreHealth = new TimeEffect(EffectTarget.Character, StatType.Health, +10f, 3, 1);
            ConsumableItem potion        = new ConsumableItem(99, "Health of Potion", "Get 40hp", restoreHealth);

            Assert.AreEqual(60f, hero.GetStat(StatType.Health).Value);

            hero.UseItem(potion); //+10hp/stack x3

            Assert.AreEqual(70f, hero.GetStat(StatType.Health).Value);
            hero.Update();
            Assert.AreEqual(80f, hero.GetStat(StatType.Health).Value);
            hero.Update();
            Assert.AreEqual(90f, hero.GetStat(StatType.Health).Value);
            hero.Update();
            Assert.AreEqual(90f, hero.GetStat(StatType.Health).Value);

            ((TimeEffect)potion.Effect).Refill();
            hero.UseItem(potion);
            Assert.AreEqual(100f, hero.GetStat(StatType.Health).Value);
            hero.Update();
            Assert.AreEqual(100f, hero.GetStat(StatType.Health).Value);
            hero.Update();
            Assert.AreEqual(100f, hero.GetStat(StatType.Health).Value);
        }
Пример #4
0
 public void DurationEffectStep(TimeEffect effect)
 {
     if (effect.Stack > 0)
     {
         AddModifier(effect);
     }
     effect.Used(); //init stack -1;
 }
Пример #5
0
 public int InvokeBuf( EffectsController.RemoveCoroutineEffect  removeEffect, TimeEffect timeEffect )
 {
     ++counter;
     IEnumerator tempIEnumerator = _InvokeBuf( removeEffect, timeEffect );
     currentCoroutines.Add( counter, tempIEnumerator );
     StartCoroutine( tempIEnumerator );
     return counter;
 }
Пример #6
0
    public List <Effet> getEffets(List <Effet> effects, TimeEffect timeEffect)
    {
        List <Effet> effets = new List <Effet>();

        foreach (Effet e in effects)
        {
            if (e.timeEffect == timeEffect)
            {
                effets.Add(e);
            }
        }
        return(effets);
    }
Пример #7
0
 public void DurationEffectStep(TimeEffect effect)
 {
     if (effect.Stack > 0)
     {
         if (value + effect.Value < MaxValue)
         {
             value += effect.Value;
         }
         else
         {
             this.value = MaxValue;
         }
     }
     effect.Used(); //init stack -1;
 }
Пример #8
0
 private static void CheckOldEffect(Unit targetUnit, TimeEffect nEffect)
 {
     TimeEffect oldEffect = targetUnit.efftcs.FirstOrDefault(x => x.EffectType == nEffect.EffectType);
     if (oldEffect != null)
     {
         var oldParamEffect = oldEffect as ParameterEffect;
         var nParamEffect = nEffect as ParameterEffect;
         if (oldParamEffect != null && nParamEffect != null)
         {
             if (oldParamEffect.Type == nParamEffect.Type)
             {
                 oldEffect.OnTimer();
             }
         }
         else
         {
             oldEffect.OnTimer();
         }
     }
     Debug.Log("Effect setted:" + nEffect);
 }
Пример #9
0
        public void TimeEffectApplyOnStat()
        {
            IEffect time = new TimeEffect(EffectTarget.Character, StatType.Intelligence, -3, 3, 1);

            Assert.AreEqual(30f, hero.GetStat(StatType.Intelligence).Value);
            hero.AddEffect(time);

            Assert.AreEqual(27f, hero.GetStat(StatType.Intelligence).Value);
            //Assert.AreEqual(2, time.Stack);
            hero.Update();

            Assert.AreEqual(24f, hero.GetStat(StatType.Intelligence).Value);
            //Assert.AreEqual(1, time.Stack);
            hero.Update();

            Assert.AreEqual(21f, hero.GetStat(StatType.Intelligence).Value);
            //Assert.AreEqual(0, time.Stack);
            hero.Update();

            Assert.AreEqual(30f, hero.GetStat(StatType.Intelligence).Value);
            //Assert.AreEqual(-1, time.Stack);
        }
Пример #10
0
    /// <summary>
    /// Добавить новый эффект к объекту
    /// </summary>
    /// <param name="effect">Эффект</param>
    /// <returns>Добавился ли эффект?</returns>
    public virtual bool AddEffect(TimeEffect effect)
    {
        TimeEffect activeEqualsEffect = timeEffects.Find(x => x.Name.Equals(effect.Name));

        LeveledEffect leveledEffect = activeEqualsEffect as LeveledEffect;

        if (leveledEffect != null && leveledEffect.Stackable)
        {
            leveledEffect.AddLevel(((LeveledEffect)effect).Level);
        }
        else if (activeEqualsEffect != null)
        {
            return(false);
        }

        effect.Handler = this;
        bool result = effect.OnAdded() && !GetEventSystem <AddEffectEvent>().CallListners(new AddEffectEvent(gameObject, effect)).IsCancel;

        if (result)
        {
            timeEffects.Add(effect);
        }
        return(result);
    }
Пример #11
0
 public void Init(Unit unit,TimeEffect timeEffect)
 {
     Init(unit, timeEffect.endEffect);
 }
    private Spell[] SpellInit( EffectsController effectsController )
    {
        GameObject freezeEffect = (GameObject)Resources.Load( "Prefabs/Particles/Freeze" );
        GameObject meteorShawer = (GameObject)Resources.Load( "Prefabs/Particles/MeteorShower" );

        Spell[] spells = new Spell[2];
        spells[0] = new Spell();

        TimeEffect effect = new TimeEffect( effectsController );
        effect.name = "Freeze";
        effect.characteristicsModifiers.attackSpeed = 0.1f;
        effect.characteristicsModifiers.speed = 0.1f;
        effect.visualPrefab = freezeEffect;
        effect.duration = 10;

        spells[0].aoeRadius = 0;
        spells[0].attackRange = 10;
        spells[0].damage = 15;
        spells[0].healing = 0;
        spells[0].needTarget = true;
        spells[0].effect = effect;
        spells[0].cdTime = 5;
        spells[0].cd = false;

        TimeEffect effect2 = new TimeEffect( effectsController );
        effect2.name = "MeteorShawer";
        effect2.visualPrefab = meteorShawer;
        effect2.duration = 0;

        spells[1] = new Spell();
        spells[1].aoeRadius = 10;
        spells[1].attackRange = 10;
        spells[1].damage = 50;
        spells[1].healing = 0;
        spells[1].needTarget = false;
        spells[1].effect = effect2;
        spells[1].cdTime = 5;
        spells[1].cd = false;

        return spells;
    }
Пример #13
0
 public void AddCoroutineToEffect( RemoveCoroutineEffect  removeEffect, TimeEffect timeEffect )
 {
     SceneManager.Instance.CoroutineManager.InvokeBuf(removeEffect,timeEffect);
 }
Пример #14
0
 public void DurationEffectEnd(TimeEffect effect)
 {
     modifiers.RemoveAll(x => x == effect);
 }
Пример #15
0
 public void DurationEffectEnd(TimeEffect effect)
 {
     // do nothing
 }
Пример #16
0
 private void RemoveEffect( TimeEffect effect )
 {
     Debug.Log( "RemoveEffect:" + effect.name );
     deleteVisualEffect();
     currentEffects.Remove( effect );
     UpdateAppliedEffects();
     Debug.Log( "baseCharacteristics.speed: " + baseCharacteristics.speed + " currentCharacteristics.speed: " + currentCharacteristics.speed );
 }
Пример #17
0
 private void ApplyEffect( TimeEffect timeEffect )
 {
     effectsController.AddCoroutineToEffect( RemoveEffect, timeEffect );
     UpdateAppliedEffects();
 }
Пример #18
0
    protected void AddEffect( TimeEffect timeEffect )
    {
        for ( int i = 0; i < currentEffects.Count; ++i ) {
            if ( currentEffects[i].id == timeEffect.id) {
                currentEffects.Remove( currentEffects[i] );
            }
        }
        currentEffects.Add( timeEffect );

        ApplyEffect( timeEffect );
    }
Пример #19
0
 public override bool AddEffect(TimeEffect effect)
 {
     return(!ListNames.Contains(effect.Name) && base.AddEffect(effect));
 }
Пример #20
0
 public AddEffectEvent(GameObject sender, TimeEffect effect) : base(sender, true)
 {
     Effect = effect;
 }
Пример #21
0
 private IEnumerator _InvokeBuf( EffectsController.RemoveCoroutineEffect  removeEffect, TimeEffect timeEffect )
 {
     yield return new WaitForSeconds( timeEffect.duration );
     removeEffect( timeEffect );
     yield return null;
 }
Пример #22
0
 public static void Creat(Unit targetUnit, TimeEffect Effect)
 {
     CheckOldEffect(targetUnit, Effect);
     targetUnit.efftcs.Add(Effect);
 }