コード例 #1
0
        public bool DisplayDescription(string className, List <SkillInfo> skillUIImages = null)
        {
            UnityEngine.Profiling.Profiler.BeginSample("p DisplayDescription"); // Profiler
            foreach (SkillInfo skillUIImage in checkedUIImages)
            {
                if (className.Contains(skillUIImage.uniqueName))
                {
                    if (descriptionActiveClass == skillUIImage.uniqueName)
                    {
                        return(true);
                    }

                    if (descriptionActiveClass != "" && descriptionActiveClass != skillUIImage.uniqueName)
                    {
                        DestroyDescription();
                    }

                    var         containerDescription = UI.document.getElementsByClassName("containerDescription")[0];
                    Dom.Element altInfo = UI.document.createElement("div");
                    altInfo.className = new StringBuilder(30).AppendFormat("content altInfo {0}", skillUIImage.uniqueName).ToString();
                    containerDescription.appendChild(altInfo);
                    DrawInfo("altInfo", skillUIImage, drawImage: false, detailInfo: true);
                    descriptionActiveClass = skillUIImage.uniqueName;
                    return(true);
                }
            }
            foreach (var skillElement in skillsCache)
            {
                unitBaseBehaviorComponent = skillElement.Key.GetComponent <BaseBehavior>();
                skillScript = skillElement.Key.GetComponent <BaseSkillScript>();

                SkillInfo skillInfo = null;
                if (unitBaseBehaviorComponent != null)
                {
                    skillInfo       = unitBaseBehaviorComponent.skillInfo;
                    costInfo        = unitBaseBehaviorComponent.GetCostInformation().ToArray();
                    tableStatistics = unitBaseBehaviorComponent.GetStatistics().ToArray();
                }
                if (skillScript != null)
                {
                    skillInfo       = skillScript.skillInfo;
                    costInfo        = skillScript.GetCostInformation().ToArray();
                    tableStatistics = skillScript.GetStatistics().ToArray();
                }

                if (className.Contains(skillInfo.uniqueName))
                {
                    if (descriptionActiveClass == skillInfo.uniqueName)
                    {
                        return(true);
                    }

                    if (descriptionActiveClass != "" && descriptionActiveClass != skillInfo.uniqueName)
                    {
                        DestroyDescription();
                    }

                    skillErrorInfo = BaseSkillScript.GetSkillErrorInfo(skillElement.Value, skillElement.Key);

                    var         containerDescription = UI.document.getElementsByClassName("containerDescription")[0];
                    Dom.Element altInfo = UI.document.createElement("div");
                    altInfo.className = "content altInfo";
                    containerDescription.appendChild(altInfo);

                    DrawInfo("altInfo", skillInfo, drawImage: false, detailInfo: true,
                             errorMessage: skillErrorInfo.errorMessage,
                             tableStatistics: tableStatistics,
                             costInfo: costInfo);

                    displayedNames.Add(skillInfo.uniqueName);
                    descriptionActiveClass = skillInfo.uniqueName;
                    return(true);
                }
            }
            UnityEngine.Profiling.Profiler.EndSample(); // Profiler
            return(false);
        }
コード例 #2
0
        public void DisplaySkillsInfo(List <GameObject> selectedObjects)
        {
            UnityEngine.Profiling.Profiler.BeginSample("p DisplayObjectsInfo"); // Profiler
            skillsCache.Clear();
            displayedNames.Clear();
            foreach (GameObject selectedObject in selectedObjects)
            {
                foreach (SkillType skillTypeFor in new SkillType[] { SkillType.Skill, SkillType.Upgrade })
                {
                    unitBaseBehaviorComponent = selectedObject.GetComponent <BaseBehavior>();
                    foreach (GameObject skillObject in unitBaseBehaviorComponent.skillList.Concat(unitBaseBehaviorComponent.producedUnits))
                    {
                        skillErrorInfo = BaseSkillScript.GetSkillErrorInfo(selectedObject, skillObject);
                        if (!skillErrorInfo.isDisplayedAsSkill)
                        {
                            continue;
                        }

                        SkillInfo skillInfo       = null;
                        string    blockImagesName = "";
                        skillObjectBaseBehaviorComponent = skillObject.GetComponent <BaseBehavior>();
                        skillScript = skillObject.GetComponent <BaseSkillScript>();
                        if (skillObjectBaseBehaviorComponent != null && !displayedNames.Contains(skillObjectBaseBehaviorComponent.skillInfo.uniqueName))
                        {
                            skillInfo       = skillObjectBaseBehaviorComponent.skillInfo;
                            costInfo        = skillObjectBaseBehaviorComponent.GetCostInformation().ToArray();
                            tableStatistics = skillObjectBaseBehaviorComponent.GetStatistics().ToArray();
                        }
                        else if (skillScript != null && !displayedNames.Contains(skillScript.skillInfo.uniqueName))
                        {
                            skillInfo       = skillScript.skillInfo;
                            costInfo        = skillScript.GetCostInformation().ToArray();
                            tableStatistics = skillScript.GetStatistics().ToArray();
                        }
                        else
                        {
                            continue;
                        }

                        if (skillTypeFor != skillInfo.skillType)
                        {
                            continue;
                        }

                        if (skillInfo.skillType == SkillType.Skill)
                        {
                            blockImagesName = "skills";
                        }
                        else if (skillInfo.skillType == SkillType.Upgrade)
                        {
                            blockImagesName = "upgrades";
                        }

                        if (skillInfo != null)
                        {
                            HtmlElement createdImage = DrawInfo("rblock", blockImagesName: blockImagesName, skillInfo: skillInfo, detailInfo: false,
                                                                costInfo: costInfo, tableStatistics: tableStatistics, hotkey: skillInfo.productionHotkey.ToString(), errorMessage: skillErrorInfo.errorMessage);
                            displayedNames.Add(skillInfo.uniqueName);
                            skillsCache.Add(skillObject, selectedObject);
                            createdImage.onmousedown = OnElementMouseDown;

                            // Description
                            createdImage.onmouseover = OnElementOnMouseOver;
                            createdImage.onmouseout  = OnElementOnMouseOut;

                            createdImage.onclick = OnElementOnClick;
                        }
                    }
                }
            }
            UnityEngine.Profiling.Profiler.EndSample(); // Profiler
        }