Exemplo n.º 1
0
        public void SetSlot(InventoryFairy fairy, int newSlotI)
        {
            if (fairy.slotIndex >= 0)
            {
                fairySlots[fairy.slotIndex] = null;
            }

            var swappedFairy = newSlotI < 0 ? null : fairySlots[newSlotI];

            if (swappedFairy != null)
            {
                SetSlotRaw(swappedFairy, fairy.slotIndex);
            }
            SetSlotRaw(fairy, newSlotI);

            void SetSlotRaw(InventoryFairy fairy, int newSlotI)
            {
                fairy.slotIndex = newSlotI;
                fairy.isInUse   = newSlotI >= 0;
                if (newSlotI >= 0)
                {
                    fairySlots[newSlotI] = fairy;
                }
            }
        }
Exemplo n.º 2
0
 public void FillMana(InventoryFairy fairy)
 {
     foreach (int spellIndex in fairy.spellIndices.Where(i => i >= 0))
     {
         FillMana((InventorySpell)cards[spellIndex] !);
     }
 }
Exemplo n.º 3
0
 private void Update(InventoryFairy fairy)
 {
     UpdateMaxMHP(fairy);
     UpdateMoveSpeed(fairy);
     UpdateJumpPower(fairy);
     UpdateCriticalHit(fairy);
 }
Exemplo n.º 4
0
        private void UpdateMaxMHP(InventoryFairy fairy)
        {
            var levelFactor  = GetLevelFactor(fairy);
            var reallyMaxMHP = mappedDB.GetFairy(fairy.dbUID).MHP;
            var oneTenth     = reallyMaxMHP / 10.0;

            fairy.maxMHP = (uint)(levelFactor * (reallyMaxMHP - oneTenth) + oneTenth);
        }
Exemplo n.º 5
0
 public void SetLevel(InventoryFairy fairy, int level)
 {
     fairy.levelChangeCount++;
     fairy.level = (uint)level;
     Update(fairy);
     fairy.currentMHP = fairy.maxMHP;
     FillManaAfterLevelup(fairy);
 }
Exemplo n.º 6
0
 private void FillManaAfterLevelup(InventoryFairy fairy)
 {
     foreach (int spellIndex in fairy.spellIndices.Where(i => i >= 0))
     {
         var spell   = (InventorySpell)cards[spellIndex] !;
         var maxMana = mappedDB.GetSpell(spell.dbUID).MaxMana;
         AddMana(spell, (int)(maxMana - spell.mana) / 2);
     }
 }
Exemplo n.º 7
0
        private void UpdateCriticalHit(InventoryFairy fairy)
        {
            var baseCrit    = mappedDB.GetFairy(fairy.dbUID).BaseCriticalHit;
            var levelFactor = Math.Max(0.001, GetLevelFactor(fairy));

            fairy.criticalHit = (float)(baseCrit * levelFactor);
            if (fairy.status == ZZPermSpellStatus.Burned)
            {
                fairy.criticalHit *= 0.5f;
            }
        }
Exemplo n.º 8
0
        public uint?GetLevelupXP(InventoryFairy fairy)
        {
            if (fairy.level >= MaxLevel - 1)
            {
                return(null);
            }
            var dbFairy = mappedDB.GetFairy(fairy.dbUID);
            var baseXP  = Math.Pow(MaxXP, dbFairy.LevelUp * XPExponentFactor);
            var exp     = 1 / (dbFairy.LevelUp * XPExponentFactor);

            return((uint)Math.Pow(baseXP * (fairy.level + 1) / MaxLevel, exp));
        }
Exemplo n.º 9
0
        private void UpdateJumpPower(InventoryFairy fairy)
        {
            var baseJumpPower = mappedDB.GetFairy(fairy.dbUID).BaseJumpPower;
            var levelFactor   = Math.Max(0.001, GetLevelFactor(fairy));

            fairy.jumpPower = (float)(
                baseJumpPower * 0.8 * levelFactor +
                baseJumpPower * 0.2);
            if (fairy.status == ZZPermSpellStatus.Burned)
            {
                fairy.jumpPower *= 0.7f;
            }
        }
Exemplo n.º 10
0
        private void UpdateMoveSpeed(InventoryFairy fairy)
        {
            var baseMoveSpeed = mappedDB.GetFairy(fairy.dbUID).BaseMoveSpeed;
            var levelFactor   = Math.Max(0.001, GetLevelFactor(fairy));

            fairy.moveSpeed = (float)(
                baseMoveSpeed / 2 * levelFactor +
                baseMoveSpeed / 2);
            if (fairy.status == ZZPermSpellStatus.Burned)
            {
                fairy.moveSpeed *= 0.7f;
            }
        }
Exemplo n.º 11
0
 public void AddXP(InventoryFairy fairy, int moreXP)
 {
     fairy.xpChangeCount += (uint)moreXP;
     while (moreXP-- >= 0)
     {
         fairy.xp = Math.Min(MaxXP, fairy.xp + 1);
         var newLevel = GetLevelByXP(fairy);
         if (newLevel <= fairy.level)
         {
             continue;
         }
         fairy.levelChangeCount++;
         fairy.level = newLevel;
     }
 }
Exemplo n.º 12
0
 private double GetLevelFactor(InventoryFairy fairy) => fairy.level / (double)MaxLevel;
Exemplo n.º 13
0
        private uint GetLevelByXP(InventoryFairy fairy)
        {
            var levelUpFactor = mappedDB.GetFairy(fairy.dbUID).LevelUp * 0.001;

            return((uint)(Math.Pow(fairy.xp, levelUpFactor) * MaxLevel / Math.Pow(MaxXP, levelUpFactor)));
        }