コード例 #1
0
 public void startBuff(CharacterInstance c, Buff buff)
 {
     if (!c.IsDead)
     {
         if (buff.DurationSeconds <= 0f)
         {
             buff.DurationSeconds = 0.1f;
         }
         if (buff.Stuns)
         {
             CmdSetStunCondition.ExecuteStatic(c, true);
             if (!c.IsPlayerCharacter)
             {
                 float num = Mathf.Pow(2f, (float)(-Mathf.Min(c.StunnedCount, 3) + 1));
                 buff.DurationSeconds *= num;
             }
         }
         if (buff.Charms)
         {
             CmdSetCharmCondition.ExecuteStatic(c, true);
         }
         if (buff.Confuses)
         {
             CmdSetConfusedCondition.ExecuteStatic(c, true);
         }
         if (buff.TimeRemaining <= 0f)
         {
             buff.TimeRemaining = buff.DurationSeconds;
         }
         buff.Character = c;
         this.m_characterBuffLists[c].Add(buff);
         this.m_allBuffs.Add(buff);
         if ((buff.DamagePerSecond > 0.0) || (buff.HealingPerSecond > 0.0))
         {
             if ((buff.DurationSeconds % ConfigGameplay.BUFFS_TICK_INTERVAL) != 0f)
             {
                 Debug.LogWarning(string.Concat(new object[] { "Buff duration ", buff.DurationSeconds, " is not a multiple of the tick duration ", ConfigGameplay.BUFFS_TICK_INTERVAL }));
             }
             buff.TickTimer = new ManualTimer(ConfigGameplay.BUFFS_TICK_INTERVAL);
         }
         else if (buff.ModifierBuildupTick > 0f)
         {
             buff.TickTimer = new ManualTimer(buff.ModifierBuildupTick);
         }
         GameLogic.Binder.EventBus.BuffStarted(c, buff);
     }
 }
コード例 #2
0
        public void endBuff(Buff buff)
        {
            GameLogic.Binder.EventBus.BuffPreEnd(buff.Character, buff);
            CharacterInstance character = buff.Character;

            for (int i = this.m_characterBuffLists[character].Count - 1; i >= 0; i--)
            {
                if (this.m_characterBuffLists[character][i] == buff)
                {
                    this.m_characterBuffLists[character].Remove(buff);
                }
            }
            for (int j = this.m_allBuffs.Count - 1; j >= 0; j--)
            {
                if (this.m_allBuffs[j] == buff)
                {
                    this.m_allBuffs.Remove(buff);
                }
            }
            if (buff.Stuns)
            {
                bool flag = false;
                for (int k = this.m_characterBuffLists[character].Count - 1; k >= 0; k--)
                {
                    if (this.m_characterBuffLists[character][k].Stuns)
                    {
                        flag = true;
                        break;
                    }
                }
                if (!flag)
                {
                    CmdSetStunCondition.ExecuteStatic(character, false);
                }
            }
            if (buff.Charms)
            {
                bool flag2 = false;
                for (int m = this.m_characterBuffLists[character].Count - 1; m >= 0; m--)
                {
                    if (this.m_characterBuffLists[character][m].Charms)
                    {
                        flag2 = true;
                        break;
                    }
                }
                if (!flag2)
                {
                    CmdSetCharmCondition.ExecuteStatic(character, false);
                }
            }
            if (buff.Confuses)
            {
                bool flag3 = false;
                for (int n = this.m_characterBuffLists[character].Count - 1; n >= 0; n--)
                {
                    if (this.m_characterBuffLists[character][n].Confuses)
                    {
                        flag3 = true;
                        break;
                    }
                }
                if (!flag3)
                {
                    CmdSetConfusedCondition.ExecuteStatic(character, false);
                }
            }
            buff.Ended = true;
            GameLogic.Binder.EventBus.BuffEnded(buff.Character, buff);
        }