Example #1
0
        public void OnSkillButtonClick(string skillName)
        {
            Debug.Log("Skill clicked " + skillName);

            UnitInfo unitInfo       = GetUnitInfo(selectedIndex);
            string   unitNameInCode = unitInfo.nameInCode;
            bool     haveSkillPoint = GetAvailableSkillPoint(unitNameInCode) > 0;
            bool     isLearned      = SkillDB.IsLearned(unitNameInCode, skillName);
            bool     isEnhanceable  = SkillDB.GetEnhanceLevel(unitNameInCode, skillName) < maxEnhanceLevel && haveSkillPoint;

            if (!isLearned)
            {
                SkillDB.Learn(unitNameInCode, skillName);
            }
            else if (isEnhanceable)
            {
                SkillDB.Enhance(unitNameInCode, skillName);
            }
            else
            {
                Debug.LogError("Cannot learn or enhance");
            }

            UpdateSkills(selectedIndex);
            UpdateDetail(selectedIndex);
        }
Example #2
0
    public void ApplySkillList(List <SkillInfo> skillInfoList, List <StatusEffectInfo> statusEffectInfoList)
    {
        float partyLevel = (float)FindObjectOfType <BattleManager>().GetPartyLevel();

        foreach (var skillInfo in skillInfoList)
        {
            if ((skillInfo.GetOwner() == this.nameInCode) &&
                (skillInfo.GetRequireLevel() <= partyLevel))
            {
                Skill skill = skillInfo.GetSkill();
                if (SkillDB.IsLearned(this.nameInCode, skill.GetName()))
                {
                    skill.SetLevel(SkillDB.GetEnhanceLevel(this.GetName(), skill.GetName()));
                    skill.ApplyStatusEffectList(statusEffectInfoList);
                    skillList.Add(skill);
                }
            }
        }
        // 비어있으면 디폴트 스킬로 채우도록.
        if (skillList.Count() == 0)
        {
            foreach (var skillInfo in skillInfoList)
            {
                if ((skillInfo.GetOwner() == "default") &&
                    (skillInfo.GetRequireLevel() <= partyLevel))
                {
                    skillList.Add(skillInfo.GetSkill());
                }
            }
        }
    }
Example #3
0
    public List <Skill> GetLearnedSkillList()
    {
        var learnedSkills =
            from skill in skillList
            where SkillDB.IsLearned(nameInCode, skill.GetName())
            select skill;

        Debug.LogWarning(GetNameInCode() + " Learnedskils" + learnedSkills.Count());
        return(learnedSkills.ToList());
    }
Example #4
0
        private void UpdateSkills(int selectedIndex)
        {
            InitializeSkillUI(column1Skills);
            InitializeSkillUI(column2Skills);
            InitializeSkillUI(column3Skills);

            SkillColumnInfo skillColumnInfo = GetSkillColumnInfo(selectedIndex);

            column1Text.GetComponent <Text>().text = skillColumnInfo.column1Name;
            column2Text.GetComponent <Text>().text = skillColumnInfo.column2Name;
            column3Text.GetComponent <Text>().text = skillColumnInfo.column3Name;

            UnitInfo unitInfo       = GetUnitInfo(selectedIndex);
            string   unitNameInCode = unitInfo.nameInCode;

            List <SkillInfo> unitSkills = new List <SkillInfo>();

            foreach (SkillInfo skillInfo in skillInfos)
            {
                if (skillInfo.owner == unitNameInCode)
                {
                    unitSkills.Add(skillInfo);
                }
            }

            foreach (SkillInfo unitSkillInfo in unitSkills)
            {
                GameObject skillGameObject = GetSkillGameObject(unitSkillInfo.column, unitSkillInfo.requireLevel);
                skillGameObject.GetComponent <SkillButton>().SetSkillInfo(unitSkillInfo);

                Skill skill          = unitSkillInfo.skill;
                bool  isLearned      = SkillDB.IsLearned(unitNameInCode, skill.GetName());
                bool  haveSkillPoint = GetAvailableSkillPoint(unitNameInCode) > 0;
                bool  isEnhanceable  = SkillDB.GetEnhanceLevel(unitNameInCode, skill.GetName()) < maxEnhanceLevel && haveSkillPoint;

                int  totalSkillPointUntilLevel = unitSkillInfo.requireLevel - 1;
                int  usedSkillPointUntilLevel  = GetUsedSkillPointUntilLevel(unitNameInCode, unitSkillInfo.requireLevel - 1);
                bool isLearnable = usedSkillPointUntilLevel >= totalSkillPointUntilLevel && haveSkillPoint;

                if (!isLearned && !isLearnable)
                {
                    skillGameObject.GetComponent <SkillButton>().ChangeState(this, SkillButtonState.NotLearnable);
                }
                else if (!isLearned && isLearnable)
                {
                    skillGameObject.GetComponent <SkillButton>().ChangeState(this, SkillButtonState.Learnable);
                }
                else if (isLearned && isEnhanceable)
                {
                    skillGameObject.GetComponent <SkillButton>().ChangeState(this, SkillButtonState.LearnedEnhanceable);
                }
                else if (isLearned && !isEnhanceable)
                {
                    skillGameObject.GetComponent <SkillButton>().ChangeState(this, SkillButtonState.LearnedMaxEnhanced);
                }
                else
                {
                    Debug.LogError("Invalid case");
                }
            }
            //  required level validation is needed
        }