public override bool IncreaseExp(BaseCharacterEntity character, int exp) { var monsterCharacter = character as BaseMonsterCharacterEntity; if (monsterCharacter != null && monsterCharacter.SummonType != SummonType.Pet) { // If it's monster and not pet, do not increase exp return(false); } var isLevelUp = false; character.Exp += exp; var playerCharacter = character as BasePlayerCharacterEntity; var nextLevelExp = character.GetNextLevelExp(); while (nextLevelExp > 0 && character.Exp >= nextLevelExp) { character.Exp = character.Exp - nextLevelExp; ++character.Level; nextLevelExp = character.GetNextLevelExp(); if (playerCharacter != null) { playerCharacter.StatPoint += increaseStatPointEachLevel; playerCharacter.SkillPoint += increaseSkillPointEachLevel; } isLevelUp = true; } return(isLevelUp); }
public override bool RewardExp(BaseCharacterEntity character, Reward reward, float multiplier, RewardGivenType rewardGivenType) { if ((character is BaseMonsterCharacterEntity) && (character as BaseMonsterCharacterEntity).SummonType != SummonType.Pet) { // If it's monster and not pet, do not increase exp return(false); } bool isLevelUp = false; int exp = Mathf.CeilToInt(reward.exp * multiplier); BasePlayerCharacterEntity playerCharacter = character as BasePlayerCharacterEntity; if (playerCharacter != null) { // Increase exp by guild's skills GuildData guildData; switch (rewardGivenType) { case RewardGivenType.KillMonster: if (playerCharacter.gameManager.TryGetGuild(playerCharacter.GuildId, out guildData)) { exp += (int)(exp * guildData.IncreaseExpGainPercentage * 0.01f); } break; case RewardGivenType.PartyShare: if (playerCharacter.gameManager.TryGetGuild(playerCharacter.GuildId, out guildData)) { exp += (int)(exp * guildData.IncreaseShareExpGainPercentage * 0.01f); } break; } } try { checked { character.Exp += exp; } } catch (System.OverflowException) { character.Exp = int.MaxValue; } int nextLevelExp = character.GetNextLevelExp(); while (nextLevelExp > 0 && character.Exp >= nextLevelExp) { character.Exp = character.Exp - nextLevelExp; ++character.Level; nextLevelExp = character.GetNextLevelExp(); if (playerCharacter != null) { try { checked { playerCharacter.StatPoint += increaseStatPointEachLevel; } } catch (System.OverflowException) { playerCharacter.StatPoint = short.MaxValue; } try { checked { playerCharacter.SkillPoint += increaseSkillPointEachLevel; } } catch (System.OverflowException) { playerCharacter.SkillPoint = short.MaxValue; } } isLevelUp = true; } return(isLevelUp); }