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; } } }
public void FillMana(InventoryFairy fairy) { foreach (int spellIndex in fairy.spellIndices.Where(i => i >= 0)) { FillMana((InventorySpell)cards[spellIndex] !); } }
private void Update(InventoryFairy fairy) { UpdateMaxMHP(fairy); UpdateMoveSpeed(fairy); UpdateJumpPower(fairy); UpdateCriticalHit(fairy); }
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); }
public void SetLevel(InventoryFairy fairy, int level) { fairy.levelChangeCount++; fairy.level = (uint)level; Update(fairy); fairy.currentMHP = fairy.maxMHP; FillManaAfterLevelup(fairy); }
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); } }
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; } }
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)); }
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; } }
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; } }
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; } }
private double GetLevelFactor(InventoryFairy fairy) => fairy.level / (double)MaxLevel;
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))); }