Exemplo n.º 1
0
        public static SkillErrorInfo GetSkillErrorInfo(GameObject sender, GameObject skillObject)
        {
            SkillErrorInfo skillErrorInfo        = new SkillErrorInfo();
            BaseBehavior   baseBehaviorComponent = sender.GetComponent <BaseBehavior>();

            List <SkillCondition> skillConditions = null;
            SkillInfo             skillInfo       = null;
            BaseSkillScript       baseSkillScript = skillObject.GetComponent <BaseSkillScript>();

            if (baseSkillScript != null)
            {
                skillConditions = baseSkillScript.skillConditions;
                skillInfo       = baseSkillScript.skillInfo;
            }
            BaseBehavior senderBaseBehaviorComponent = skillObject.GetComponent <BaseBehavior>();

            if (senderBaseBehaviorComponent != null)
            {
                skillConditions = senderBaseBehaviorComponent.skillConditions;
                skillInfo       = senderBaseBehaviorComponent.skillInfo;
            }

            object[] errorInfo = GetSkillErrors(
                condList: skillConditions, team: baseBehaviorComponent.team,
                skillName: skillInfo.uniqueName, skillObject: skillObject, skillSender: sender);

            SkillCondition skillCondition = (SkillCondition)errorInfo[0];
            string         errorMessage   = (string)errorInfo[1];

            skillErrorInfo.errorMessage = errorMessage;

            if (errorMessage != "")
            {
                skillErrorInfo.isCanBeUsedAsSkill = false;
            }

            if (errorMessage != "" && skillCondition.notDisplayWhenFalse)
            {
                skillErrorInfo.isDisplayedAsSkill = false;
            }

            return(skillErrorInfo);
        }