Exemplo n.º 1
0
 protected override void ShiftItemDown()
 {
     if (selectID < AbilityDB.GetList().Count - 1)
     {
         ShiftItem(1);
     }
 }
Exemplo n.º 2
0
        private void ShiftItem(int dir)
        {
            Ability item = AbilityDB.GetList()[selectID];

            AbilityDB.GetList()[selectID]       = AbilityDB.GetList()[selectID + dir];
            AbilityDB.GetList()[selectID + dir] = item;
            selectID += dir;
        }
Exemplo n.º 3
0
 private void SelectItem(int newID)
 {
     selectID = newID;
     if (AbilityDB.GetList().Count <= 0)
     {
         return;
     }
     selectID = Mathf.Clamp(selectID, 0, AbilityDB.GetList().Count - 1);
 }
Exemplo n.º 4
0
        private int _NewItem(int idx = -1)
        {
            Ability item = null;

            if (idx < 0)
            {
                item = new Ability(); item.stats.ResetAsBaseStat();
            }
            if (idx >= 0)
            {
                item = AbilityDB.GetList()[idx].Clone();
            }

            item.prefabID = TDE.GenerateNewID(AbilityDB.GetPrefabIDList());

            AbilityDB.GetList().Add(item);
            AbilityDB.UpdateLabel();

            return(AbilityDB.GetList().Count - 1);
        }
Exemplo n.º 5
0
        void Awake()
        {
            instance = this;

            List <Ability> dbList = AbilityDB.GetList();

            for (int i = 0; i < dbList.Count; i++)
            {
                if (!unavailablePrefabIDList.Contains(dbList[i].prefabID) && !dbList[i].hideInInspector)
                {
                    abilityList.Add(dbList[i].Clone());
                }
            }

            tgtSelectIndicator        = Instantiate(tgtSelectIndicator.gameObject).transform;
            tgtSelectIndicator.parent = transform;
            tgtSelectIndicator.gameObject.SetActive(false);

            pendingTgtAbilityIdx = -1;
        }
Exemplo n.º 6
0
        public void OnGUI()
        {
            TDE.InitGUIStyle();

            if (!CheckIsPlaying())
            {
                return;
            }
            if (window == null)
            {
                Init();
            }


            List <Ability> abilityList = AbilityDB.GetList();

            Undo.RecordObject(this, "window");
            Undo.RecordObject(AbilityDB.GetDB(), "abilityDB");


            if (GUI.Button(new Rect(Math.Max(260, window.position.width - 120), 5, 100, 25), "Save"))
            {
                TDE.SetDirty();
            }


            if (GUI.Button(new Rect(5, 5, 120, 25), "Create New"))
            {
                Select(NewItem());
            }
            if (abilityList.Count > 0 && GUI.Button(new Rect(130, 5, 100, 25), "Clone Selected"))
            {
                Select(NewItem(selectID));
            }


            float startX = 5; float startY = 55;

            if (minimiseList)
            {
                if (GUI.Button(new Rect(startX, startY - 20, 30, 18), ">>"))
                {
                    minimiseList = false;
                }
            }
            else
            {
                if (GUI.Button(new Rect(startX, startY - 20, 30, 18), "<<"))
                {
                    minimiseList = true;
                }
            }

            Vector2 v2 = DrawAbilityList(startX, startY, abilityList);

            startX = v2.x + 25;

            if (abilityList.Count == 0)
            {
                return;
            }


            Rect visibleRect = new Rect(startX, startY, window.position.width - startX, window.position.height - startY);
            Rect contentRect = new Rect(startX, startY, contentWidth, contentHeight);

            scrollPos = GUI.BeginScrollView(visibleRect, scrollPos, contentRect);

            v2            = DrawAbilityConfigurator(startX, startY, abilityList[selectID]);
            contentWidth  = v2.x - startX;
            contentHeight = v2.y - 55;

            GUI.EndScrollView();


            if (GUI.changed)
            {
                TDE.SetDirty();
            }
        }
Exemplo n.º 7
0
 protected override void DeleteItem()
 {
     AbilityDB.GetList().RemoveAt(deleteID);
     AbilityDB.UpdateLabel();
 }
Exemplo n.º 8
0
        public override void OnInspectorGUI()
        {
            base.OnInspectorGUI();

            if (instance == null)
            {
                Awake(); return;
            }

            GUI.changed = false;

            Undo.RecordObject(instance, "AbilityManager");

            EditorGUILayout.Space();

            EditorGUIUtility.labelWidth += 35;
            cont = new GUIContent("Use RscManager For Cost:", "Check use the resources in RscManager for ability cost");
            instance.useRscManagerForCost = EditorGUILayout.Toggle(cont, instance.useRscManagerForCost);
            EditorGUIUtility.labelWidth  -= 35;

            EditorGUILayout.Space();

            if (!instance.useRscManagerForCost)
            {
                GUILayout.BeginHorizontal();

                GUILayout.BeginVertical();
                EditorGUIUtility.labelWidth += 35;
                cont = new GUIContent("Full Resource On Start:", "Check to have the resource start at full\nOtherwise it will start at whatever value specified");
                instance.startWithFullRsc    = EditorGUILayout.Toggle(cont, instance.startWithFullRsc);
                EditorGUIUtility.labelWidth -= 35;

                cont         = new GUIContent("Resource:", "The resource used  to cast ability");
                instance.rsc = EditorGUILayout.IntField(cont, instance.rsc);

                cont            = new GUIContent("Resource Cap:", "The resource capacity. Resource cannot exceed this value");
                instance.rscCap = EditorGUILayout.IntField(cont, instance.rscCap);
                if (!Application.isPlaying && instance.startWithFullRsc)
                {
                    instance.rsc = instance.rscCap;
                }

                cont = new GUIContent("Resource Regen Rate:", "The rate at which the resource regenerate (per second)");
                instance.rscRegenRate = EditorGUILayout.FloatField(cont, instance.rscRegenRate);
                GUILayout.EndVertical();

                GUILayout.BeginVertical();
                EditorGUILayout.Space();
                EditorGUILayout.Space();
                EditorGUILayout.Space();

                if (!instance.useRscManagerForCost)
                {
                    Sprite icon = AbilityDB.GetRscIcon();
                    icon = (Sprite)EditorGUILayout.ObjectField(icon, typeof(Sprite), true, GUILayout.Width(40), GUILayout.Height(40));
                    AbilityDB.SetRscIcon(icon);
                }
                GUILayout.EndVertical();

                GUILayout.EndHorizontal();
            }
            else
            {
                EditorGUILayout.LabelField("Full Rsc On Start:", "-");
                EditorGUILayout.LabelField("Resource:", "-");
                EditorGUILayout.LabelField("Resource Cap:", "-");
                EditorGUILayout.LabelField("Resource Regen Rate:", "-");
            }

            EditorGUILayout.Space();

            cont = new GUIContent("Target Select Indicator:", "the object used to indicate selected position during target selection phase");
            instance.tgtSelectIndicator = (Transform)EditorGUILayout.ObjectField(cont, instance.tgtSelectIndicator, typeof(Transform), true);


            EditorGUILayout.Space();


            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("", GUILayout.MaxWidth(10));
            showList = EditorGUILayout.Foldout(showList, "Show Ability List");
            EditorGUILayout.EndHorizontal();
            if (showList)
            {
                EditorGUILayout.BeginHorizontal();
                EditorGUILayout.Space();
                if (GUILayout.Button("EnableAll") && !Application.isPlaying)
                {
                    instance.unavailablePrefabIDList = new List <int>();
                }
                if (GUILayout.Button("DisableAll") && !Application.isPlaying)
                {
                    instance.unavailablePrefabIDList = AbilityDB.GetPrefabIDList();
                }
                EditorGUILayout.Space();
                EditorGUILayout.EndHorizontal();

                EditorGUILayout.Space();


                List <Ability> abilityList = AbilityDB.GetList();
                for (int i = 0; i < abilityList.Count; i++)
                {
                    if (abilityList[i].hideInInspector)
                    {
                        continue;
                    }

                    Ability ability = abilityList[i];

                    GUILayout.BeginHorizontal();

                    EditorGUILayout.Space();

                    GUILayout.Box("", GUILayout.Width(40), GUILayout.Height(40));
                    TDE.DrawSprite(GUILayoutUtility.GetLastRect(), ability.icon, ability.desp, false);

                    GUILayout.BeginVertical();
                    EditorGUILayout.Space();
                    GUILayout.Label(ability.name, GUILayout.ExpandWidth(false));

                    EditorGUI.BeginChangeCheck();
                    bool flag = !instance.unavailablePrefabIDList.Contains(ability.prefabID) ? true : false;
                    flag = EditorGUILayout.Toggle(new GUIContent(" - enabled: ", "check to enable the ability in this level"), flag);

                    if (!Application.isPlaying && EditorGUI.EndChangeCheck())
                    {
                        if (!flag && !instance.unavailablePrefabIDList.Contains(ability.prefabID))
                        {
                            instance.unavailablePrefabIDList.Add(ability.prefabID);
                        }
                        else if (flag)
                        {
                            instance.unavailablePrefabIDList.Remove(ability.prefabID);
                        }
                    }

                    GUILayout.EndVertical();

                    GUILayout.EndHorizontal();
                }
            }

            EditorGUILayout.Space();

            DefaultInspector();

            if (GUI.changed)
            {
                EditorUtility.SetDirty(instance);
            }
        }