示例#1
0
        protected override void UpdateUI()
        {
            var owningCharacter = BasePlayerCharacterController.OwningCharacter;

            if (owningCharacter != null &&
                Level < GuildSkill.GetMaxLevel() &&
                owningCharacter.GameManager.ClientGuild != null &&
                owningCharacter.GameManager.ClientGuild.IsLeader(owningCharacter) &&
                owningCharacter.GameManager.ClientGuild.skillPoint > 0)
            {
                onAbleToLevelUp.Invoke();
            }
            else
            {
                onUnableToLevelUp.Invoke();
            }

            if (owningCharacter != null &&
                Level > 1 &&
                GuildSkill.skillType == GuildSkillType.Active)
            {
                onAbleToUse.Invoke();
            }
            else
            {
                onUnableToUse.Invoke();
            }
        }
 public static bool IsBuff(this GuildSkill guildSkill)
 {
     if (guildSkill == null)
     {
         return(false);
     }
     return(guildSkill.skillType == GuildSkillType.Active);
 }
 public static int GetMaxLevel(this GuildSkill guildSkill)
 {
     if (guildSkill == null)
     {
         return(0);
     }
     return(guildSkill.maxLevel);
 }
示例#4
0
 protected virtual void ApplyGuildSkillBuff(GuildSkill guildSkill, short level)
 {
     if (IsDead() || !IsServer || guildSkill == null || level <= 0)
     {
         return;
     }
     ApplyBuff(guildSkill.DataId, BuffType.GuildSkillBuff, level);
 }
示例#5
0
        protected override void Update()
        {
            base.Update();

            if (coolDownRemainsDuration <= 0f)
            {
                BasePlayerCharacterEntity owningCharacter = BasePlayerCharacterController.OwningCharacter;
                if (owningCharacter != null && GuildSkill != null)
                {
                    int indexOfSkillUsage = owningCharacter.IndexOfSkillUsage(GuildSkill.DataId, SkillUsageType.GuildSkill);
                    if (indexOfSkillUsage >= 0)
                    {
                        coolDownRemainsDuration = owningCharacter.SkillUsages[indexOfSkillUsage].coolDownRemainsDuration;
                        if (coolDownRemainsDuration <= 1f)
                        {
                            coolDownRemainsDuration = 0f;
                        }
                    }
                }
            }

            if (coolDownRemainsDuration > 0f)
            {
                coolDownRemainsDuration -= Time.deltaTime;
                if (coolDownRemainsDuration <= 0f)
                {
                    coolDownRemainsDuration = 0f;
                }
            }
            else
            {
                coolDownRemainsDuration = 0f;
            }

            // Update UIs
            float coolDownDuration = GuildSkill.GetCoolDownDuration(Level);

            if (uiTextCoolDownDuration != null)
            {
                uiTextCoolDownDuration.text = string.Format(
                    LanguageManager.GetText(formatKeyCoolDownDuration),
                    coolDownDuration.ToString("N0"));
            }

            if (uiTextCoolDownRemainsDuration != null)
            {
                uiTextCoolDownRemainsDuration.text = string.Format(
                    LanguageManager.GetText(formatKeyCoolDownRemainsDuration),
                    coolDownRemainsDuration.ToString("N0"));
                uiTextCoolDownRemainsDuration.gameObject.SetActive(coolDownRemainsDuration > 0);
            }

            if (imageCoolDownGage != null)
            {
                imageCoolDownGage.fillAmount = coolDownDuration <= 0 ? 0 : coolDownRemainsDuration / coolDownDuration;
            }
        }
 public static short GetAdjustedLevel(this GuildSkill guildSkill, short level)
 {
     if (guildSkill == null)
     {
         return(0);
     }
     if (level > guildSkill.maxLevel)
     {
         level = guildSkill.maxLevel;
     }
     return(level);
 }
        public static float GetCoolDownDuration(this GuildSkill guildSkill, short level)
        {
            if (guildSkill == null)
            {
                return(0f);
            }
            level = guildSkill.GetAdjustedLevel(level);
            float duration = guildSkill.coolDownDuration.GetAmount(level);

            if (duration < 0f)
            {
                duration = 0f;
            }
            return(duration);
        }
示例#8
0
 protected override void SetFieldCondition()
 {
     if (cacheGuildSkill == null)
     {
         cacheGuildSkill = CreateInstance <GuildSkill>();
     }
     // Passive skill
     ShowOnEnum(cacheGuildSkill.GetMemberName(a => a.skillType), SkillType.Passive.ToString(), cacheGuildSkill.GetMemberName(a => a.increaseMaxMember));
     ShowOnEnum(cacheGuildSkill.GetMemberName(a => a.skillType), SkillType.Passive.ToString(), cacheGuildSkill.GetMemberName(a => a.increaseExpGainPercentage));
     ShowOnEnum(cacheGuildSkill.GetMemberName(a => a.skillType), SkillType.Passive.ToString(), cacheGuildSkill.GetMemberName(a => a.increaseGoldGainPercentage));
     ShowOnEnum(cacheGuildSkill.GetMemberName(a => a.skillType), SkillType.Passive.ToString(), cacheGuildSkill.GetMemberName(a => a.increaseShareExpGainPercentage));
     ShowOnEnum(cacheGuildSkill.GetMemberName(a => a.skillType), SkillType.Passive.ToString(), cacheGuildSkill.GetMemberName(a => a.increaseShareGoldGainPercentage));
     ShowOnEnum(cacheGuildSkill.GetMemberName(a => a.skillType), SkillType.Passive.ToString(), cacheGuildSkill.GetMemberName(a => a.decreaseExpLostPercentage));
     // Active skill
     ShowOnEnum(cacheGuildSkill.GetMemberName(a => a.skillType), SkillType.Active.ToString(), cacheGuildSkill.GetMemberName(a => a.coolDownDuration));
     ShowOnEnum(cacheGuildSkill.GetMemberName(a => a.skillType), SkillType.Active.ToString(), cacheGuildSkill.GetMemberName(a => a.buff));
 }
        public static bool CanUse(this GuildSkill guildSkill, ICharacterData character, short level)
        {
            if (guildSkill == null || character == null)
            {
                return(false);
            }
            if (level <= 0)
            {
                return(false);
            }
            int skillUsageIndex = character.IndexOfSkillUsage(guildSkill.DataId, SkillUsageType.GuildSkill);

            if (skillUsageIndex >= 0 && character.SkillUsages[skillUsageIndex].coolDownRemainsDuration > 0f)
            {
                return(false);
            }
            return(true);
        }
        public static bool CanLevelUp(this GuildSkill guildSkill, IPlayerCharacterData character, short level)
        {
            if (guildSkill == null || character == null)
            {
                return(false);
            }

            BaseGameNetworkManager gameManager = BaseGameNetworkManager.Singleton;

            if (gameManager == null)
            {
                return(false);
            }

            GuildData guildData = null;

            if (!gameManager.TryGetGuild(character.GuildId, out guildData))
            {
                return(false);
            }

            return(guildData.skillPoint > 0 && level < guildSkill.maxLevel);
        }
示例#11
0
        protected override void UpdateData()
        {
            if (Level <= 0)
            {
                onSetLevelZeroData.Invoke();
            }
            else
            {
                onSetNonLevelZeroData.Invoke();
            }

            if (uiTextTitle != null)
            {
                uiTextTitle.text = string.Format(titleFormat, GuildSkill == null ? "Unknow" : GuildSkill.title);
            }

            if (uiTextDescription != null)
            {
                uiTextDescription.text = string.Format(descriptionFormat, GuildSkill == null ? "N/A" : GuildSkill.description);
            }

            if (uiTextLevel != null)
            {
                uiTextLevel.text = string.Format(levelFormat, Level.ToString("N0"));
            }

            if (imageIcon != null)
            {
                var iconSprite = GuildSkill == null ? null : GuildSkill.icon;
                imageIcon.gameObject.SetActive(iconSprite != null);
                imageIcon.sprite = iconSprite;
            }

            if (uiTextSkillType != null)
            {
                switch (GuildSkill.skillType)
                {
                case GuildSkillType.Active:
                    uiTextSkillType.text = string.Format(skillTypeFormat, activeSkillType);
                    break;

                case GuildSkillType.Passive:
                    uiTextSkillType.text = string.Format(skillTypeFormat, passiveSkillType);
                    break;
                }
            }

            if (uiTextIncreaseMaxMember != null)
            {
                var amount = GuildSkill.increaseMaxMember.GetAmount(Level);
                uiTextIncreaseMaxMember.text = string.Format(increaseMaxMemberFormat, amount.ToString("N0"));
                uiTextIncreaseMaxMember.gameObject.SetActive(amount != 0);
            }

            if (uiTextIncreaseExpGainPercentage != null)
            {
                var amount = GuildSkill.increaseExpGainPercentage.GetAmount(Level);
                uiTextIncreaseExpGainPercentage.text = string.Format(increaseExpGainPercentageFormat, amount.ToString("N2"));
                uiTextIncreaseExpGainPercentage.gameObject.SetActive(amount != 0);
            }

            if (uiTextIncreaseGoldGainPercentage != null)
            {
                var amount = GuildSkill.increaseGoldGainPercentage.GetAmount(Level);
                uiTextIncreaseGoldGainPercentage.text = string.Format(increaseGoldGainPercentageFormat, amount.ToString("N2"));
                uiTextIncreaseGoldGainPercentage.gameObject.SetActive(amount != 0);
            }

            if (uiTextIncreaseShareExpGainPercentage != null)
            {
                var amount = GuildSkill.increaseShareExpGainPercentage.GetAmount(Level);
                uiTextIncreaseShareExpGainPercentage.text = string.Format(increaseShareExpGainPercentageFormat, amount.ToString("N2"));
                uiTextIncreaseShareExpGainPercentage.gameObject.SetActive(amount != 0);
            }

            if (uiTextIncreaseShareGoldGainPercentage != null)
            {
                var amount = GuildSkill.increaseShareGoldGainPercentage.GetAmount(Level);
                uiTextIncreaseShareGoldGainPercentage.text = string.Format(increaseShareGoldGainPercentageFormat, amount.ToString("N2"));
                uiTextIncreaseShareGoldGainPercentage.gameObject.SetActive(amount != 0);
            }

            if (uiTextDecreaseExpLostPercentage != null)
            {
                var amount = GuildSkill.decreaseExpLostPercentage.GetAmount(Level);
                uiTextDecreaseExpLostPercentage.text = string.Format(decreaseExpLostPercentageFormat, amount.ToString("N2"));
                uiTextDecreaseExpLostPercentage.gameObject.SetActive(amount != 0);
            }

            if (uiSkillBuff != null)
            {
                if (!GuildSkill.IsBuff())
                {
                    uiSkillBuff.Hide();
                }
                else
                {
                    uiSkillBuff.Show();
                    uiSkillBuff.Data = new BuffTuple(GuildSkill.buff, Level);
                }
            }

            if (uiNextLevelSkill != null)
            {
                if (Level + 1 > GuildSkill.maxLevel)
                {
                    uiNextLevelSkill.Hide();
                }
                else
                {
                    uiNextLevelSkill.Data = new GuildSkillTuple(GuildSkill, (short)(Level + 1));
                    uiNextLevelSkill.Show();
                }
            }
        }
示例#12
0
 public GuildSkillTuple(GuildSkill guildSkill, short targetLevel)
 {
     this.guildSkill  = guildSkill;
     this.targetLevel = targetLevel;
 }
示例#13
0
        protected override void UpdateData()
        {
            if (Level <= 0)
            {
                onSetLevelZeroData.Invoke();
            }
            else
            {
                onSetNonLevelZeroData.Invoke();
            }

            if (uiTextTitle != null)
            {
                uiTextTitle.text = string.Format(
                    LanguageManager.GetText(formatKeyTitle),
                    GuildSkill == null ? LanguageManager.GetUnknowTitle() : GuildSkill.Title);
            }

            if (uiTextDescription != null)
            {
                uiTextDescription.text = string.Format(
                    LanguageManager.GetText(formatKeyDescription),
                    GuildSkill == null ? LanguageManager.GetUnknowDescription() : GuildSkill.Description);
            }

            if (uiTextLevel != null)
            {
                uiTextLevel.text = string.Format(
                    LanguageManager.GetText(formatKeyLevel),
                    Level.ToString("N0"));
            }

            if (imageIcon != null)
            {
                Sprite iconSprite = GuildSkill == null ? null : GuildSkill.icon;
                imageIcon.gameObject.SetActive(iconSprite != null);
                imageIcon.sprite = iconSprite;
            }

            if (uiTextSkillType != null)
            {
                switch (GuildSkill.skillType)
                {
                case GuildSkillType.Active:
                    uiTextSkillType.text = string.Format(
                        LanguageManager.GetText(formatKeySkillType),
                        LanguageManager.GetText(UILocaleKeys.UI_SKILL_TYPE_ACTIVE.ToString()));
                    break;

                case GuildSkillType.Passive:
                    uiTextSkillType.text = string.Format(
                        LanguageManager.GetText(formatKeySkillType),
                        LanguageManager.GetText(UILocaleKeys.UI_SKILL_TYPE_PASSIVE.ToString()));
                    break;
                }
            }

            if (uiTextIncreaseMaxMember != null)
            {
                int amount = GuildSkill.increaseMaxMember.GetAmount(Level);
                uiTextIncreaseMaxMember.text = string.Format(
                    LanguageManager.GetText(UILocaleKeys.UI_FORMAT_INCREASE_MAX_MEMBER.ToString()),
                    amount.ToString("N0"));
                uiTextIncreaseMaxMember.gameObject.SetActive(amount != 0);
            }

            if (uiTextIncreaseExpGainPercentage != null)
            {
                float amount = GuildSkill.increaseExpGainPercentage.GetAmount(Level);
                uiTextIncreaseExpGainPercentage.text = string.Format(
                    LanguageManager.GetText(UILocaleKeys.UI_FORMAT_INCREASE_EXP_GAIN_PERCENTAGE.ToString()),
                    amount.ToString("N2"));
                uiTextIncreaseExpGainPercentage.gameObject.SetActive(amount != 0);
            }

            if (uiTextIncreaseGoldGainPercentage != null)
            {
                float amount = GuildSkill.increaseGoldGainPercentage.GetAmount(Level);
                uiTextIncreaseGoldGainPercentage.text = string.Format(
                    LanguageManager.GetText(UILocaleKeys.UI_FORMAT_INCREASE_GOLD_GAIN_PERCENTAGE.ToString()),
                    amount.ToString("N2"));
                uiTextIncreaseGoldGainPercentage.gameObject.SetActive(amount != 0);
            }

            if (uiTextIncreaseShareExpGainPercentage != null)
            {
                float amount = GuildSkill.increaseShareExpGainPercentage.GetAmount(Level);
                uiTextIncreaseShareExpGainPercentage.text = string.Format(
                    LanguageManager.GetText(UILocaleKeys.UI_FORMAT_INCREASE_SHARE_EXP_GAIN_PERCENTAGE.ToString()),
                    amount.ToString("N2"));
                uiTextIncreaseShareExpGainPercentage.gameObject.SetActive(amount != 0);
            }

            if (uiTextIncreaseShareGoldGainPercentage != null)
            {
                float amount = GuildSkill.increaseShareGoldGainPercentage.GetAmount(Level);
                uiTextIncreaseShareGoldGainPercentage.text = string.Format(
                    LanguageManager.GetText(UILocaleKeys.UI_FORMAT_INCREASE_SHARE_GOLD_GAIN_PERCENTAGE.ToString()),
                    amount.ToString("N2"));
                uiTextIncreaseShareGoldGainPercentage.gameObject.SetActive(amount != 0);
            }

            if (uiTextDecreaseExpLostPercentage != null)
            {
                float amount = GuildSkill.decreaseExpLostPercentage.GetAmount(Level);
                uiTextDecreaseExpLostPercentage.text = string.Format(
                    LanguageManager.GetText(UILocaleKeys.UI_FORMAT_DECREASE_EXP_PENALTY_PERCENTAGE.ToString()),
                    amount.ToString("N2"));
                uiTextDecreaseExpLostPercentage.gameObject.SetActive(amount != 0);
            }

            if (uiSkillBuff != null)
            {
                if (!GuildSkill.IsBuff())
                {
                    uiSkillBuff.Hide();
                }
                else
                {
                    uiSkillBuff.Show();
                    uiSkillBuff.Data = new BuffTuple(GuildSkill.buff, Level);
                }
            }

            if (uiNextLevelSkill != null)
            {
                if (Level + 1 > GuildSkill.maxLevel)
                {
                    uiNextLevelSkill.Hide();
                }
                else
                {
                    uiNextLevelSkill.Data = new GuildSkillTuple(GuildSkill, (short)(Level + 1));
                    uiNextLevelSkill.Show();
                }
            }
        }