public virtual void RewardGold(int gold, RewardGivenType rewardGivenType)
        {
            if (!IsServer)
            {
                return;
            }
            GuildData guildData;

            switch (rewardGivenType)
            {
            case RewardGivenType.KillMonster:
                if (GameManager.TryGetGuild(GuildId, out guildData))
                {
                    gold += (int)(gold * guildData.IncreaseGoldGainPercentage / 100f);
                }
                break;

            case RewardGivenType.PartyShare:
                if (GameManager.TryGetGuild(GuildId, out guildData))
                {
                    gold += (int)(gold * guildData.IncreaseShareGoldGainPercentage / 100f);
                }
                break;
            }
            Gold += gold;
        }
        public override void RewardExp(int exp, RewardGivenType rewardGivenType)
        {
            if (!IsServer)
            {
                return;
            }

            GuildData guildData;

            switch (rewardGivenType)
            {
            case RewardGivenType.KillMonster:
                if (GameManager.TryGetGuild(GuildId, out guildData))
                {
                    exp += (int)(exp * guildData.IncreaseExpGainPercentage / 100f);
                }
                break;

            case RewardGivenType.PartyShare:
                if (GameManager.TryGetGuild(GuildId, out guildData))
                {
                    exp += (int)(exp * guildData.IncreaseShareExpGainPercentage / 100f);
                }
                break;
            }
            base.RewardExp(exp, rewardGivenType);
        }
        public override void RewardCurrencies(BaseCharacterEntity character, Reward reward, float multiplier, RewardGivenType rewardGivenType)
        {
            if (character is BaseMonsterCharacterEntity)
            {
                // Don't give reward currencies to monsters
                return;
            }

            int gold = Mathf.CeilToInt(reward.gold * 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))
                    {
                        gold += (int)(gold * guildData.IncreaseGoldGainPercentage * 0.01f);
                    }
                    break;

                case RewardGivenType.PartyShare:
                    if (playerCharacter.gameManager.TryGetGuild(playerCharacter.GuildId, out guildData))
                    {
                        gold += (int)(gold * guildData.IncreaseShareGoldGainPercentage * 0.01f);
                    }
                    break;
                }

                try
                {
                    checked
                    {
                        playerCharacter.Gold += gold;
                    }
                }
                catch (System.OverflowException)
                {
                    playerCharacter.Gold += int.MaxValue;
                }
            }
        }
        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);
        }
Exemplo n.º 5
0
 public abstract void RewardCurrencies(BaseCharacterEntity character, Reward reward, float multiplier, RewardGivenType rewardGivenType);
Exemplo n.º 6
0
 public abstract bool RewardExp(BaseCharacterEntity character, Reward reward, float multiplier, RewardGivenType rewardGivenType);