示例#1
0
        /// <summary>
        /// Visual print out of requirements
        /// </summary>
        /// <returns>The requirements.</returns>
        virtual public string GetRequirements()
        {
            string            requirements = "";
            SkillCategoryBase category     = transform.parent.parent.GetComponent <SkillCategoryBase>();

            if (requiredLevel > 0)
            {
                requirements += string.Format("* {0} Skill Lv {1} \n", category.displayName, requiredLevel);
            }

            foreach (SkillBase skill in extraRequirements)
            {
                SkillCollectionBase collection = skill.transform.parent.GetComponent <SkillCollectionBase>();
                requirements += string.Format("* {0} Lv {1} \n", collection.displayName, skill.transform.GetSiblingIndex() + 1);
            }

            return(requirements);
        }
示例#2
0
        public SkillCollectionGrid GetGrid(SkillCategoryBase category)
        {
            SkillCollectionBase[] collect = category.GetComponentsInChildren <SkillCollectionBase>();
            Vector2 min = new Vector2(Mathf.Infinity, Mathf.Infinity);
            Vector2 max = new Vector2(Mathf.NegativeInfinity, Mathf.NegativeInfinity);

            // Find the min x, min y, max x, and max y
            foreach (SkillCollectionBase col in collect)
            {
                if (col.windowRect.x < min.x)
                {
                    min.x = col.windowRect.x;
                }
                if (col.windowRect.x > max.x)
                {
                    max.x = col.windowRect.x;
                }
                if (col.windowRect.y < min.y)
                {
                    min.y = col.windowRect.y;
                }
                if (col.windowRect.y > max.y)
                {
                    max.y = col.windowRect.y;
                }
            }

            int x, y;
            int width  = Mathf.CeilToInt(Mathf.Abs(min.x - max.x) / gridCellSize.x) + 1;
            int height = Mathf.CeilToInt(Mathf.Abs(min.y - max.y) / gridCellSize.y) + 1;

            SkillCollectionBase[,] grid = new SkillCollectionBase[width, height];
            foreach (SkillCollectionBase col in collect)
            {
                x          = Mathf.RoundToInt((col.windowRect.x - min.x) / gridCellSize.x);
                y          = Mathf.RoundToInt((col.windowRect.y - min.y) / gridCellSize.y);
                grid[x, y] = col;
            }

            return(new SkillCollectionGrid(grid));
        }
示例#3
0
        public void DrawSidebar(Rect rect, float padding, Color color)
        {
            float innerWidth  = rect.width - (padding * 2f);
            float innerHeight = rect.height - (padding * 2f);

            GUI.BeginGroup(rect);             // Container

            DrawBox(new Rect(0, 0, rect.width, rect.height), color);

            GUI.BeginGroup(new Rect(padding, padding, innerWidth, innerHeight));             // Padding

            if (target != null)
            {
                float y = 0f;
                foreach (Transform child in target.transform)
                {
                    SkillCategoryBase cat = child.GetComponent <SkillCategoryBase>();
                    GUI.BeginGroup(new Rect(0f, y, innerWidth, 300f));

                    if (GUI.Button(new Rect(0f, 0f, 22f, 20f), "X"))
                    {
                        if (EditorUtility.DisplayDialog("Delete Category?",
                                                        "Are you sure you want to delete this category? The delete action cannot be undone.",
                                                        "Delete Category",
                                                        "Cancel"))
                        {
                            if (target.currentCategory == cat)
                            {
                                target.currentCategory = null;
                            }

                            GameObject.DestroyImmediate(cat.gameObject);
                        }
                    }

                    if (GUI.Button(new Rect(24f, 0f, innerWidth - 82f, 20f), cat.displayName))
                    {
                        target.currentCategory     = cat;
                        Selection.activeGameObject = cat.gameObject;
                        GraphController.current.camera.Reset();
                    }

                    if (GUI.Button(new Rect(innerWidth - 56f, 0f, 27f, 20f), "UP"))
                    {
                        child.SetSiblingIndex(child.GetSiblingIndex() - 1);
                    }

                    if (GUI.Button(new Rect(innerWidth - 27f, 0f, 27f, 20f), "DN"))
                    {
                        child.SetSiblingIndex(child.GetSiblingIndex() + 1);
                    }

                    GUI.EndGroup();
                    y += 24f;
                }

                if (GUI.Button(new Rect(0f, y, innerWidth, 20f), "Create Category"))
                {
                    GameObject go = new GameObject();
                    go.name = "Category";
                    go.AddComponent(target.SkillCategory);
                    go.transform.SetParent(target.transform);
                }

                y += 25f;

                if (GUI.Button(new Rect(0f, y, innerWidth, 20f), "Snap All Nodes"))
                {
                    GraphController.current.SnapAllNodesToGrid();
                }

                y += 25f;

                GraphController.current.forceSnapping = GUI.Toggle(new Rect(0f, y, innerWidth, 20f), GraphController.current.forceSnapping, "Force Snapping");
            }

            GUI.EndGroup();

            GUI.EndGroup();             // Container
        }
		public SkillCollectionGrid GetGrid (SkillCategoryBase category) {
			SkillCollectionBase[] collect = category.GetComponentsInChildren<SkillCollectionBase>();
			Vector2 min = new Vector2(Mathf.Infinity, Mathf.Infinity);
			Vector2 max = new Vector2(Mathf.NegativeInfinity, Mathf.NegativeInfinity);

			// Find the min x, min y, max x, and max y
			foreach (SkillCollectionBase col in collect) {
				if (col.windowRect.x < min.x) min.x = col.windowRect.x;
				if (col.windowRect.x > max.x) max.x = col.windowRect.x;
				if (col.windowRect.y < min.y) min.y = col.windowRect.y;
				if (col.windowRect.y > max.y) max.y = col.windowRect.y;
			}

			int x, y;
			int width = Mathf.CeilToInt(Mathf.Abs(min.x - max.x) / gridCellSize.x) + 1;
			int height = Mathf.CeilToInt(Mathf.Abs(min.y - max.y) / gridCellSize.y) + 1;
			SkillCollectionBase[,] grid = new SkillCollectionBase[width, height];
			foreach (SkillCollectionBase col in collect) {
				x = Mathf.RoundToInt((col.windowRect.x - min.x) / gridCellSize.x);
				y = Mathf.RoundToInt((col.windowRect.y - min.y) / gridCellSize.y);
				grid[x, y] = col;
			}

			return new SkillCollectionGrid(grid);
		}
示例#5
0
        /// <summary>
        /// Declare the current level of a specific category
        /// </summary>
        /// <param name="categoryId">Category identifier.</param>
        /// <param name="lv">Lv.</param>
        public void SetCategoryLv(string categoryId, int lv)
        {
            SkillCategoryBase cat = GetCategory(categoryId);

            cat.skillLv = lv;
        }