public override void OnInspectorGUI()
        {
            base.OnInspectorGUI();

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

            GUI.changed = false;

            Undo.RecordObject(instance, "Collectible");

            EditorGUILayout.Space();


            //EditorGUILayout.HelpBox("Editing Collectible component using Inspector is not recommended.\nPlease use the editor window instead", MessageType.Info);
            if (GUILayout.Button("Collectible Editor Window"))
            {
                CollectibleEditorWindow.Init();
            }


            if (TDSEditor.IsPrefab(instance.gameObject))
            {
                if (!TDSEditor.ExistInDB(instance))
                {
                    EditorGUILayout.Space();

                    EditorGUILayout.HelpBox("This prefab hasn't been added to database hence it won't be accessible by other editor.", MessageType.Warning);
                    GUI.color = new Color(1f, 0.7f, .2f, 1f);
                    if (GUILayout.Button("Add Prefab to Database"))
                    {
                        CollectibleEditorWindow.Init();
                        CollectibleEditorWindow.NewItem(instance);
                        CollectibleEditorWindow.Init();                         //call again to select the instance in editor window
                    }
                    GUI.color = Color.white;
                }

                EditorGUILayout.Space();
            }

            EditorGUILayout.Space();

            DrawFullEditor();

            EditorGUILayout.Space();

            DefaultInspector();

            serializedObject.ApplyModifiedProperties();
            if (GUI.changed)
            {
                EditorUtility.SetDirty(instance);
            }
        }
        private float DrawAddWeapon(float startX, float startY, Perk perk)
        {
            startY += 35;

            int weaponIdx = perk.newWeaponID >= 0 ? TDSEditor.GetWeaponIndex(perk.newWeaponID) : 0;

            TDSEditorUtility.DrawSprite(new Rect(startX + spaceX + width - 40, startY + spaceY - 45, 40, 40), weaponIdx > 0 ? weaponDB.weaponList[weaponIdx - 1].icon : null);
            if (GUI.Button(new Rect(startX + spaceX, startY - 2, 40, height - 2), "Edit "))
            {
                WeaponEditorWindow.Init();
            }

            cont = new GUIContent("New Weapon:", "New weapon to be made available to player");
            EditorGUI.LabelField(new Rect(startX, startY += spaceY - 5, width, height), cont, headerStyle);

            weaponIdx = EditorGUI.Popup(new Rect(startX + spaceX, startY, width, height), weaponIdx, weaponLabel);
            if (weaponIdx > 0)
            {
                perk.newWeaponID = weaponDB.weaponList[weaponIdx - 1].ID;
            }
            else
            {
                perk.newWeaponID = -1;
            }


            cont = new GUIContent("Replace Existing:", "Check if the new weapon is to replace player's current weapon");
            EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
            perk.replaceExisting = EditorGUI.Toggle(new Rect(startX + spaceX, startY, widthS, height), perk.replaceExisting);


            if (!perk.replaceExisting)
            {
                weaponIdx = perk.replaceWeaponID >= 0 ? TDSEditor.GetWeaponIndex(perk.replaceWeaponID) : 0;

                cont = new GUIContent("Replacing:", "If the new weapon is to replace a existing player's weapon\n\nIf no matching weapon is found during runtime, the new weapon will simply be added");
                EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);

                weaponIdx = EditorGUI.Popup(new Rect(startX + spaceX, startY, width, height), weaponIdx, weaponLabel);
                if (weaponIdx > 0)
                {
                    perk.replaceWeaponID = weaponDB.weaponList[weaponIdx - 1].ID;
                }
                else
                {
                    perk.replaceWeaponID = -1;
                }
            }
            else
            {
                cont = new GUIContent("Replacing:", "If the new weapon is to replace a existing player's ability\n\nIf no matching weapon is found during runtime, the new weapon will simply be added");
                EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
                EditorGUI.LabelField(new Rect(startX + spaceX, startY, width, height), "-");
            }

            return(startY);
        }
        //not in used
        void ConfigureSpawnItemList()
        {
            EditorGUILayout.Space();

            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField(new GUIContent("Spawn Item List:", ""), GUILayout.MaxWidth(100), GUILayout.ExpandWidth(true));
            if (GUILayout.Button("+", GUILayout.Width(40), GUILayout.MaxHeight(14)))
            {
                instance.spawnItemList.Add(new CollectibleSpawnInfo());
            }
            if (GUILayout.Button("-", GUILayout.Width(40), GUILayout.MaxHeight(14)))
            {
                instance.spawnItemList.RemoveAt(instance.spawnItemList.Count - 1);
            }
            EditorGUILayout.EndHorizontal();

            //~ EditorGUILayout.BeginHorizontal();
            //~ SpaceH(20);
            //~ EditorGUILayout.LabelField("Item", GUILayout.Width(130));
            //~ EditorGUILayout.LabelField("chance", GUILayout.Width(50));
            //~ EditorGUILayout.LabelField("cd:", GUILayout.Width(30));
            //~ EditorGUILayout.EndHorizontal();

            for (int i = 0; i < instance.spawnItemList.Count; i++)
            {
                CollectibleSpawnInfo spInfo = instance.spawnItemList[i];

                EditorGUILayout.BeginHorizontal();
                //~ EditorGUILayout.LabelField("  -", GUILayout.MaxWidth(25));

                SpaceH(10);

                int itemIdx = spInfo.item != null?TDSEditor.GetCollectibleIndex(spInfo.item.ID) : 0;

                EditorGUILayout.LabelField("-", GUILayout.MaxWidth(10));
                itemIdx = EditorGUILayout.Popup(itemIdx, collectibleLabel, GUILayout.Width(130));
                if (itemIdx == 0)
                {
                    spInfo.item = null;
                }
                else if (itemIdx > 0)
                {
                    spInfo.item = collectibleDB.collectibleList[itemIdx - 1];
                }

                spInfo.chance = EditorGUILayout.FloatField(spInfo.chance, GUILayout.Width(30));
                //SpaceH(10);
                spInfo.cooldown = EditorGUILayout.FloatField(spInfo.cooldown, GUILayout.Width(30));
                //~ spInfo.currentCD=EditorGUILayout.FloatField(spInfo.currentCD, GUILayout.Width(30));

                EditorGUILayout.EndHorizontal();
            }
        }
        public static void Init(int prefabID = -1)
        {
            // Get existing open window or if none, make a new one:
            window         = (WeaponEditorWindow)EditorWindow.GetWindow(typeof(WeaponEditorWindow), false, "Weapon Editor");
            window.minSize = new Vector2(400, 300);
            //~ window.maxSize=new Vector2(375, 800);

            LoadDB();

            if (prefabID >= 0)
            {
                window.selectID = TDSEditor.GetWeaponIndex(prefabID) - 1;
            }

            window.SetupCallback();
        }
        private float DrawAddAbility(float startX, float startY, Perk perk)
        {
            startY += 45;

            int abilityIdx = perk.newAbilityID >= 0 ? TDSEditor.GetAbilityIndex(perk.newAbilityID) : 0;

            TDSEditorUtility.DrawSprite(new Rect(startX + spaceX + width - 40, startY + spaceY - 45, 40, 40), abilityIdx > 0 ? abilityDB.abilityList[abilityIdx - 1].icon : null);
            if (GUI.Button(new Rect(startX + spaceX, startY - 2, 40, height - 2), "Edit "))
            {
                AbilityEditorWindow.Init();
            }

            cont = new GUIContent("New Ability:", "New ability to be made available to player");
            EditorGUI.LabelField(new Rect(startX, startY += spaceY - 5, width, height), cont, headerStyle);

            abilityIdx = EditorGUI.Popup(new Rect(startX + spaceX, startY, width, height), abilityIdx, abilityLabel);
            if (abilityIdx > 0)
            {
                perk.newAbilityID = abilityDB.abilityList[abilityIdx - 1].ID;
            }
            else
            {
                perk.newAbilityID = -1;
            }


            abilityIdx = perk.replaceAbilityID >= 0 ? TDSEditor.GetAbilityIndex(perk.replaceAbilityID) : 0;

            cont = new GUIContent("Replace Existing:", "If the new ability is to replace a existing player's ability\n\nIf no matching ability is found during runtime, the new ability will simply be added");
            EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);

            abilityIdx = EditorGUI.Popup(new Rect(startX + spaceX, startY, width, height), abilityIdx, abilityLabel);
            if (abilityIdx > 0)
            {
                perk.replaceAbilityID = abilityDB.abilityList[abilityIdx - 1].ID;
            }
            else
            {
                perk.replaceAbilityID = -1;
            }

            return(startY);
        }
Exemple #6
0
 protected static void UpdateLabel_Ability()
 {
     TDSEditor.UpdateLabel_Ability();
 }
Exemple #7
0
 protected static void LoadAbility()
 {
     TDSEditor.LoadAbility();
 }
Exemple #8
0
 protected static void LoadDamageTable()
 {
     TDSEditor.LoadDamageTable();
 }
Exemple #9
0
 protected static void UpdateLabel_UnitPlayer()
 {
     TDSEditor.UpdateLabel_UnitPlayer();
 }
Exemple #10
0
 protected static void LoadUnitAI()
 {
     TDSEditor.LoadUnitAI();
 }
Exemple #11
0
 protected static void LoadCollectible()
 {
     TDSEditor.LoadCollectible();
 }
Exemple #12
0
 protected static void LoadWeapon()
 {
     TDSEditor.LoadWeapon();
 }
Exemple #13
0
 protected static void LoadPerk()
 {
     TDSEditor.LoadPerk();
 }
        void DrawFullEditor()
        {
            serializedObject.Update();

            cont = new GUIContent("Name:", "The collectible name to be displayed in game");
            PropertyFieldL(serializedObject.FindProperty("collectibleName"), cont);

            cont = new GUIContent("Icon:", "The collectible icon to be displayed in game and editor, must be a sprite");
            PropertyFieldL(serializedObject.FindProperty("icon"), cont);


            EditorGUILayout.Space();


            srlPpt = serializedObject.FindProperty("type");

            EditorGUILayout.BeginHorizontal();      EditorGUI.BeginChangeCheck();
            EditorGUI.showMixedValue = srlPpt.hasMultipleDifferentValues;

            cont = new GUIContent("Collectible Type:", "What does the specific collectible do when it's triggered");
            EditorGUILayout.LabelField(cont, GUILayout.MaxWidth(labelWidth));

            contL = new GUIContent[collectTypeLabel.Length];
            for (int i = 0; i < contL.Length; i++)
            {
                contL[i] = new GUIContent(collectTypeLabel[i], collectTypeTooltip[i]);
            }
            int type = EditorGUILayout.Popup(srlPpt.enumValueIndex, contL, GUILayout.MaxWidth(fieldWidthL));

            if (EditorGUI.EndChangeCheck())
            {
                srlPpt.enumValueIndex = type;
            }

            EditorGUI.showMixedValue = false; EditorGUILayout.EndHorizontal();


            EditorGUILayout.Space();

            if (instance.type == _CollectType.Ability)
            {
                EditorGUILayout.LabelField("Trigger Ability", headerStyle);

                srlPpt = serializedObject.FindProperty("abilityID");
                int abID = TDSEditor.GetAbilityIndex(srlPpt.intValue);

                EditorGUILayout.BeginHorizontal();      EditorGUI.BeginChangeCheck();
                EditorGUI.showMixedValue = srlPpt.hasMultipleDifferentValues;

                cont = new GUIContent(" - Trigger Ability:", "The ability to activate when triggered");
                EditorGUILayout.LabelField(cont, GUILayout.MaxWidth(labelWidth));

                contL = new GUIContent[abilityLabel.Length];
                for (int i = 0; i < contL.Length; i++)
                {
                    contL[i] = new GUIContent(abilityLabel[i]);
                }
                abID = EditorGUILayout.Popup(abID, contL, GUILayout.MaxWidth(fieldWidthL));
                if (EditorGUI.EndChangeCheck())
                {
                    srlPpt.intValue = abID - 1;
                }

                EditorGUI.showMixedValue = false; EditorGUILayout.EndHorizontal();
            }
            else
            {
                EditorGUILayout.LabelField("Instant Gain", headerStyle);

                srlPpt = serializedObject.FindProperty("life");

                EditorGUILayout.BeginHorizontal();      EditorGUI.BeginChangeCheck();
                EditorGUI.showMixedValue = srlPpt.hasMultipleDifferentValues;
                cont = new GUIContent("Life:", "The amount of respawn gained by the player");
                EditorGUILayout.LabelField(cont, GUILayout.MaxWidth(labelWidth));
                int life = EditorGUILayout.IntField(srlPpt.intValue, GUILayout.MaxWidth(fieldWidth));
                if (EditorGUI.EndChangeCheck())
                {
                    srlPpt.intValue = life;
                }
                EditorGUI.showMixedValue = false; EditorGUILayout.EndHorizontal();

                EditorGUILayout.Space();

                cont = new GUIContent("HitPoint:", "The amount of hit-point gained by the player");
                PropertyField(serializedObject.FindProperty("hitPoint"), cont);

                cont = new GUIContent("Energy:", "The amount of energy gained by the player");
                PropertyField(serializedObject.FindProperty("energy"), cont);

                EditorGUILayout.Space();

                cont = new GUIContent("Score:", "The amount of points gained by the player");
                PropertyField(serializedObject.FindProperty("score"), cont);

                EditorGUILayout.Space();

                cont = new GUIContent("Ammo:", "The amount of ammo gained by the player. If set as -1, the ammo count will be refilled to full");
                PropertyField(serializedObject.FindProperty("ammo"), cont);

                cont = new GUIContent("Weapon:", "The weapon in which the ammo gain of the collectible is intended for.");
                if (serializedObject.FindProperty("ammo").intValue != 0)
                {
                    weaponLabel[0] = "All Weapons";

                    srlPpt = serializedObject.FindProperty("ammoID");
                    int weaponIdx = TDSEditor.GetWeaponIndex(srlPpt.intValue);

                    //Weapon weapon=weaponIdx>0 ? weaponDB.weaponList[weaponIdx-1] : null ;
                    //if(weapon!=null)
                    //	TDSEditorUtility.DrawSprite(new Rect(startX+spaceX+width-40, startY+spaceY-45, 40, 40), weapon!=null ? weapon.icon : null);

                    EditorGUILayout.BeginHorizontal();      EditorGUI.BeginChangeCheck();
                    EditorGUI.showMixedValue = srlPpt.hasMultipleDifferentValues;
                    EditorGUILayout.LabelField(cont, GUILayout.MaxWidth(labelWidth));
                    weaponIdx = EditorGUILayout.Popup(weaponIdx, weaponLabel, GUILayout.MaxWidth(fieldWidthL));
                    if (EditorGUI.EndChangeCheck())
                    {
                        if (weaponIdx > 0)
                        {
                            srlPpt.intValue = weaponDB.weaponList[weaponIdx - 1].ID;
                        }
                        else
                        {
                            srlPpt.intValue = -1;
                        }
                    }
                    EditorGUI.showMixedValue = false; EditorGUILayout.EndHorizontal();

                    weaponLabel[0] = "Unassigned";
                }
                else
                {
                    InvalidField(cont);
                }


                EditorGUILayout.Space();

                cont = new GUIContent("Experience:", "The amount of experience gained by the player");
                PropertyField(serializedObject.FindProperty("exp"), cont);

                cont = new GUIContent("Perk Currency:", "The amount of perk currency gained by the player");
                PropertyField(serializedObject.FindProperty("perkCurrency"), cont);


                EditorGUILayout.Space();


                srlPpt = serializedObject.FindProperty("effectID");
                int effectIdx = srlPpt.intValue >= 0 ? TDSEditor.GetEffectIndex(srlPpt.intValue) : 0;

                EditorGUILayout.BeginHorizontal();      EditorGUI.BeginChangeCheck();
                EditorGUI.showMixedValue = srlPpt.hasMultipleDifferentValues;

                cont = new GUIContent("Triggered Effect:", "Special effect that applies on target when triggered (optional)");
                EditorGUILayout.LabelField(cont, GUILayout.MaxWidth(labelWidth));

                effectIdx = EditorGUILayout.Popup(effectIdx, effectLabel, GUILayout.MaxWidth(fieldWidthL));
                if (EditorGUI.EndChangeCheck())
                {
                    if (effectIdx > 0)
                    {
                        srlPpt.intValue = effectDB.effectList[effectIdx - 1].ID;
                    }
                    else
                    {
                        srlPpt.intValue = -1;
                    }
                }
                EditorGUI.showMixedValue = false; EditorGUILayout.EndHorizontal();


                EditorGUILayout.Space();


                srlPpt = serializedObject.FindProperty("gainWeapon");
                cont   = new GUIContent("Gain Weapon:", "Weapon gained by player upon triggered (optional)");
                PropertyField(srlPpt, cont);

                bool gainWeapon = srlPpt.boolValue;

                if (gainWeapon)
                {
                    srlPpt = serializedObject.FindProperty("weaponType");
                    int wType = TDSEditor.GetWeaponIndex(srlPpt.enumValueIndex);

                    EditorGUILayout.BeginHorizontal();      EditorGUI.BeginChangeCheck();
                    EditorGUI.showMixedValue = srlPpt.hasMultipleDifferentValues;

                    cont = new GUIContent(" - GainWeaponType:", "What the new weapon is for");
                    EditorGUILayout.LabelField(cont, GUILayout.MaxWidth(labelWidth));

                    contL = new GUIContent[weaponTypeLabel.Length];
                    for (int i = 0; i < contL.Length; i++)
                    {
                        contL[i] = new GUIContent(weaponTypeLabel[i], weaponTypeTooltip[i]);
                    }
                    wType = EditorGUILayout.Popup(wType, contL, GUILayout.MaxWidth(fieldWidthL));
                    if (EditorGUI.EndChangeCheck())
                    {
                        srlPpt.enumValueIndex = wType;
                    }

                    EditorGUI.showMixedValue = false; EditorGUILayout.EndHorizontal();


                    cont = new GUIContent(" - Duration:", "The duration of the temporary weapon. Set to -1 for not time limit (limit by weapon ammo instead)");
                    if (srlPpt.enumValueIndex == (int)Collectible._WeaponType.Temporary)
                    {
                        PropertyField(serializedObject.FindProperty("tempWeapDuration"), cont);
                    }
                    else
                    {
                        InvalidField(cont);
                    }


                    cont = new GUIContent(" - Random Weapon:", "Check if player will get random weapon out of a few potential candidates");
                    PropertyField(serializedObject.FindProperty("randomWeapon"), cont);

                    bool randWeapon = serializedObject.FindProperty("randomWeapon").boolValue;
                    if (randWeapon)
                    {
                        SerializedProperty enableAllWP = serializedObject.FindProperty("enableAllWeapon");
                        EditorGUILayout.BeginHorizontal();      EditorGUI.BeginChangeCheck();
                        EditorGUI.showMixedValue = enableAllWP.hasMultipleDifferentValues;

                        cont = new GUIContent(" - EnableAllWeapon:", "Check if all weapon in the database are to be added to the random pool");
                        EditorGUILayout.LabelField(cont, GUILayout.MaxWidth(labelWidth));

                        bool en = EditorGUILayout.Toggle(enableAllWP.boolValue, GUILayout.MaxWidth(fieldWidthS + 25));
                        if (EditorGUI.EndChangeCheck())
                        {
                            enableAllWP.boolValue = en;
                            if (en)
                            {
                                showWeaponList = true;
                            }
                        }
                        //~ PropertyField(serializedObject.FindProperty("enableAllWeapon"), cont);

                        GUIStyle notSelectedStyle = new GUIStyle("Label");
                        notSelectedStyle.normal.textColor = new Color(.2f, .2f, .2f, 1);

                        SpaceH(22);

                        bool enableAllWeapon = serializedObject.FindProperty("enableAllWeapon").boolValue;
                        if (enableAllWeapon)
                        {
                            showWeaponList = EditorGUILayout.Foldout(showWeaponList, "Show list");
                        }

                        EditorGUILayout.EndHorizontal();

                        if (enableAllWeapon && showWeaponList)
                        {
                            srlPpt = serializedObject.FindProperty("weaponList");

                            if (!serializedObject.isEditingMultipleObjects)
                            {
                                int enabledCount = 0;
                                for (int i = 0; i < weaponDB.weaponList.Count; i++)
                                {
                                    Weapon weapon  = weaponDB.weaponList[i];
                                    bool   enabled = false;
                                    for (int n = 0; n < srlPpt.arraySize; n++)
                                    {
                                        SerializedProperty elePpt = srlPpt.GetArrayElementAtIndex(n);
                                        if (elePpt.objectReferenceValue == (UnityEngine.Object)weapon)
                                        {
                                            enabled = true;
                                            break;
                                        }
                                    }

                                    bool enabledCached = enabled;

                                    EditorGUILayout.BeginHorizontal();
                                    cont = new GUIContent("    - " + weapon.weaponName, weapon.desp);
                                    if (enabled)
                                    {
                                        EditorGUILayout.LabelField(cont, GUILayout.MaxWidth(labelWidth + 50));
                                    }
                                    else
                                    {
                                        EditorGUILayout.LabelField(cont, notSelectedStyle, GUILayout.MaxWidth(labelWidth + 50));
                                    }

                                    enabled = EditorGUILayout.Toggle(enabled);
                                    EditorGUILayout.EndHorizontal();

                                    //TDSEditorUtility.DrawSprite(new Rect(startX+20, startY+=spaceY, 30, 30), weapon.icon, weapon.desp);
                                    //~ cont=new GUIContent(weapon.weaponName, weapon.desp);
                                    //~ EditorGUI.LabelField(new Rect(startX+65, startY+15, width, height), cont);
                                    //~ enabled=EditorGUI.Toggle(new Rect(startX+spaceX+width-15, startY+15, width, height), enabled);
                                    //~ startY+=14;

                                    if (enabled != enabledCached)
                                    {
                                        if (enabled)
                                        {
                                            srlPpt.InsertArrayElementAtIndex(enabledCount);
                                            SerializedProperty elePpt = srlPpt.GetArrayElementAtIndex(enabledCount);
                                            elePpt.objectReferenceValue = weapon;
                                        }
                                        else
                                        {
                                            srlPpt.DeleteArrayElementAtIndex(enabledCount);
                                        }
                                    }

                                    if (enabled)
                                    {
                                        enabledCount += 1;
                                    }
                                }
                            }
                            else
                            {
                                EditorGUILayout.LabelField("    - Cannot edit multiple instance");
                            }
                        }
                    }
                    else
                    {
                        srlPpt = serializedObject.FindProperty("weaponList");
                        while (srlPpt.arraySize > 1)
                        {
                            srlPpt.DeleteArrayElementAtIndex(srlPpt.arraySize - 1);
                        }
                        while (srlPpt.arraySize <= 0)
                        {
                            srlPpt.InsertArrayElementAtIndex(0);
                        }

                        SerializedProperty elePpt = srlPpt.GetArrayElementAtIndex(0);
                        int weapIdx = elePpt.objectReferenceValue != null?TDSEditor.GetWeaponIndex(((Weapon)elePpt.objectReferenceValue).ID) : 0;

                        EditorGUILayout.BeginHorizontal();      EditorGUI.BeginChangeCheck();
                        EditorGUI.showMixedValue = srlPpt.hasMultipleDifferentValues;

                        cont = new GUIContent(" - Gain Weapon:", "Weapon gained by player upon triggered (optional)");
                        EditorGUILayout.LabelField(cont, GUILayout.MaxWidth(labelWidth));

                        weapIdx = EditorGUILayout.Popup(weapIdx, weaponLabel, GUILayout.MaxWidth(fieldWidthL));
                        if (EditorGUI.EndChangeCheck())
                        {
                            if (weapIdx > 0)
                            {
                                elePpt.objectReferenceValue = weaponDB.weaponList[weapIdx - 1];
                            }
                            else
                            {
                                elePpt.objectReferenceValue = null;
                            }
                        }

                        EditorGUI.showMixedValue = false; EditorGUILayout.EndHorizontal();

                        //~ if(cItem.weaponList.Count!=1) cItem.weaponList=new List<Weapon>{ null };

                        //~ int weaponIdx1=cItem.weaponList[0]!=null ? TDSEditor.GetWeaponIndex(cItem.weaponList[0].ID) : 0;

                        //~ //if(cItem.weaponList[0]!=null)
                        //~ //	TDSEditorUtility.DrawSprite(new Rect(startX+spaceX+width-40, startY+spaceY-41, 40, 40), cItem.weaponList[0].icon);

                        //~ cont=new GUIContent("Gain Weapon:", "Weapon gained by player upon triggered (optional)");
                        //~ EditorGUI.LabelField(new Rect(startX, startY+=spaceY, width, height), cont);

                        //~ weaponIdx1=EditorGUI.Popup(new Rect(startX+spaceX, startY, width, height), weaponIdx1, weaponLabel);
                        //~ if(weaponIdx1>0) cItem.weaponList[0]=weaponDB.weaponList[weaponIdx1-1];
                        //~ else cItem.weaponList[0]=null;
                    }
                }
            }


            EditorGUILayout.Space();


            EditorGUILayout.LabelField("Miscellaneous", headerStyle);


            srlPpt = serializedObject.FindProperty("triggerEffectObj");

            EditorGUILayout.BeginHorizontal();      EditorGUI.BeginChangeCheck();
            EditorGUI.showMixedValue = srlPpt.hasMultipleDifferentValues;
            cont = new GUIContent("Triggered Effect Obj:", "The object to be spawned when the collectible is triggered (optional)");
            EditorGUILayout.LabelField(cont, GUILayout.MaxWidth(labelWidth));
            GameObject sObj = (GameObject)EditorGUILayout.ObjectField(srlPpt.objectReferenceValue, typeof(GameObject), false, GUILayout.MaxWidth(fieldWidthL));

            if (EditorGUI.EndChangeCheck())
            {
                srlPpt.objectReferenceValue = sObj;
            }
            EditorGUI.showMixedValue = false; EditorGUILayout.EndHorizontal();

            cont = new GUIContent("AutoDestroy Effect:", "Check if the effect object needs to be removed from the game");
            if (srlPpt.objectReferenceValue != null)
            {
                PropertyField(serializedObject.FindProperty("autoDestroyEffectObj"), cont);
            }
            else
            {
                InvalidField(cont);
            }

            cont = new GUIContent(" - Duration:", "The delay in seconds before the effect object is destroyed");
            if (srlPpt.objectReferenceValue != null && serializedObject.FindProperty("autoDestroyEffectObj").boolValue)
            {
                PropertyField(serializedObject.FindProperty("effectObjActiveDuration"), cont);
            }
            else
            {
                InvalidField(cont);
            }


            EditorGUILayout.Space();


            cont = new GUIContent("Triggered SFX:", "Audio clip to play when the collectible is triggered (optional)");
            PropertyFieldL(serializedObject.FindProperty("triggerSFX"), cont);


            EditorGUILayout.Space();


            cont   = new GUIContent("Self Destruct:", "Check if the item is to self-destruct if not collected in a set time frame");
            srlPpt = serializedObject.FindProperty("selfDestruct");
            PropertyField(srlPpt, cont);

            //~ EditorGUILayout.BeginHorizontal();	EditorGUI.BeginChangeCheck();
            //~ EditorGUI.showMixedValue=srlPpt.hasMultipleDifferentValues;

            //~ cont=new GUIContent("Self Destruct:", "Check if the item is to self-destruct if not collected in a set time frame");
            //~ EditorGUILayout.LabelField(cont);
            //~ bool flag=EditorGUILayout.Toggle(srlPpt.boolValue);
            //~ if(EditorGUI.EndChangeCheck()) srlPpt.boolValue=flag;
            //~ EditorGUI.showMixedValue=false; EditorGUILayout.EndHorizontal();

            //~ cont=new GUIContent("Active Duration:", "How long the item will stay active before it self destruct");
            //~ if(srlPpt.boolValue) PropertyField(serializedObject.FindProperty("selfDestructDuration"), cont);
            //~ else InvalidField(cont);


            EditorGUILayout.Space();


            cont = new GUIContent("BlinkBeforeDestruct:", "Blink to give player warning before the object self-destruct");
            if (srlPpt.boolValue)
            {
                PropertyField(serializedObject.FindProperty("blinkBeforeDestroy"), cont);
            }
            else
            {
                InvalidField(cont);
            }

            cont = new GUIContent("Blink Duration:", "The long the item is gong to blink for");
            if (srlPpt.boolValue && serializedObject.FindProperty("blinkBeforeDestroy").boolValue)
            {
                PropertyField(serializedObject.FindProperty("blinkDuration"), cont);
            }
            else
            {
                InvalidField(cont);
            }

            cont = new GUIContent("Blink Object: ", "The mesh object to blink (The system will deactivate/activate the blink object for blinking. we only need to deactivate the child object and contain the mesh, not the whole item)");
            if (srlPpt.boolValue && serializedObject.FindProperty("blinkBeforeDestroy").boolValue)
            {
                if (serializedObject.isEditingMultipleObjects)
                {
                    EditorGUILayout.LabelField(cont, new GUIContent("Cannot edit multiple instance"));
                }
                else
                {
                    EditorGUILayout.BeginHorizontal();
                    EditorGUILayout.LabelField(cont, GUILayout.MaxWidth(labelWidth));

                    int objID = GetObjectIDFromHList(instance.GetBlinkObjT(), objHList);
                    objID             = EditorGUILayout.Popup(objID, objHLabelList, GUILayout.MaxWidth(fieldWidthL));
                    instance.blinkObj = (objHList[objID] == null) ? null : objHList[objID];

                    EditorGUILayout.EndHorizontal();
                }
            }
            else
            {
                InvalidField(cont);
            }



            serializedObject.ApplyModifiedProperties();
        }
Exemple #15
0
        Vector2 DrawCollectibleConfigurator(float startX, float startY, Collectible cItem)
        {
            //float cachedX=startX;
            //float cachedY=startY;

            TDSEditorUtility.DrawSprite(new Rect(startX, startY, 60, 60), cItem.icon);
            startX += 65;

            float offsetY = TDSEditor.IsPrefab(cItem.gameObject) ? 5 : 0;

            cont = new GUIContent("Name:", "The collectible name to be displayed in game");
            EditorGUI.LabelField(new Rect(startX, startY += offsetY, width, height), cont);
            cItem.collectibleName = EditorGUI.TextField(new Rect(startX + spaceX - 65, startY, width - 5, height), cItem.collectibleName);

            cont = new GUIContent("Icon:", "The collectible icon to be displayed in game, must be a sprite");
            EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
            cItem.icon = (Sprite)EditorGUI.ObjectField(new Rect(startX + spaceX - 65, startY, width - 5, height), cItem.icon, typeof(Sprite), false);

            cont = new GUIContent("Prefab:", "The prefab object of the unit\nClick this to highlight it in the ProjectTab");
            EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
            EditorGUI.ObjectField(new Rect(startX + spaceX - 65, startY, width - 5, height), cItem.gameObject, typeof(GameObject), false);

            startX -= 65;
            startY += spaceY;           //cachedY=startY;


            int type = (int)cItem.type;

            cont = new GUIContent("Target Type:", "The target which the collectible affects when triggered");
            EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
            contL = new GUIContent[collectTypeLabel.Length];
            for (int i = 0; i < contL.Length; i++)
            {
                contL[i] = new GUIContent(collectTypeLabel[i], collectTypeTooltip[i]);
            }
            type       = EditorGUI.Popup(new Rect(startX + spaceX, startY, width, 15), new GUIContent(""), type, contL);
            cItem.type = (_CollectType)type;


            startY += 10;

            if (cItem.type == _CollectType.Ability)
            {
                int abID = (int)cItem.abilityID;
                cont = new GUIContent(" - Trigger Ability:", "The ability to activate when triggered");
                EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
                contL = new GUIContent[abilityLabel.Length];
                for (int i = 0; i < contL.Length; i++)
                {
                    contL[i] = new GUIContent(abilityLabel[i]);
                }
                abID            = EditorGUI.Popup(new Rect(startX + spaceX, startY, width, 15), new GUIContent(""), abID, contL);
                cItem.abilityID = abID;
            }
            else if (cItem.type == _CollectType.Self)
            {
                EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), "Instant Gain", headerStyle);

                cont = new GUIContent("Life:", "The amount of respawn gained by the player");
                EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
                cItem.life = EditorGUI.IntField(new Rect(startX + spaceX, startY, 40, height), cItem.life);

                startY += 10;

                cont = new GUIContent("HitPoint:", "The amount of hit-point gained by the player");
                EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
                cItem.hitPoint = EditorGUI.FloatField(new Rect(startX + spaceX, startY, 40, height), cItem.hitPoint);

                cont = new GUIContent("Energy:", "The amount of energy gained by the player");
                EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
                cItem.energy = EditorGUI.FloatField(new Rect(startX + spaceX, startY, 40, height), cItem.energy);

                startY += 10;

                //cont=new GUIContent("Credits:", "The amount of credist gained by the player");
                //EditorGUI.LabelField(new Rect(startX, startY+=spaceY, width, height), cont);
                //cItem.credit=EditorGUI.IntField(new Rect(startX+spaceX, startY, 40, height), cItem.credit);

                cont = new GUIContent("Score:", "The amount of points gained by the player");
                EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
                cItem.score = EditorGUI.IntField(new Rect(startX + spaceX, startY, 40, height), cItem.score);

                startY += 10;

                cont = new GUIContent("Ammo:", "The amount of ammo gained by the player. If set as -1, the ammo count will be refilled to full");
                EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
                cItem.ammo = EditorGUI.IntField(new Rect(startX + spaceX, startY, 40, height), cItem.ammo);


                if (cItem.ammo != 0)
                {
                    startY += 5;

                    weaponLabel[0] = "All Weapons";

                    int    weaponIdx = TDSEditor.GetWeaponIndex(cItem.ammoID);
                    Weapon weapon    = weaponIdx > 0 ? weaponDB.weaponList[weaponIdx - 1] : null;

                    if (weapon != null)
                    {
                        TDSEditorUtility.DrawSprite(new Rect(startX + spaceX + width - 40, startY + spaceY - 45, 40, 40), weapon != null ? weapon.icon : null);
                    }

                    cont = new GUIContent(" - Weapon:", "The weapon in which the ammo gain of the collectible is intended for.");
                    EditorGUI.LabelField(new Rect(startX, startY += spaceY - 5, width, height), cont);

                    weaponIdx = EditorGUI.Popup(new Rect(startX + spaceX, startY, width, height), weaponIdx, weaponLabel);
                    if (weaponIdx > 0)
                    {
                        cItem.ammoID = weaponDB.weaponList[weaponIdx - 1].ID;
                    }
                    else
                    {
                        cItem.ammoID = -1;
                    }

                    weaponLabel[0] = "Unassigned";
                }
                else
                {
                    cont = new GUIContent("Weapon:", "The weapon in which the ammo gain of the collectible is intended for.");
                    EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
                    EditorGUI.LabelField(new Rect(startX + spaceX, startY, width, height), "-");
                }


                startY += 10;

                cont = new GUIContent("Experience:", "The amount of experience gained by the player.");
                EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
                cItem.exp = EditorGUI.IntField(new Rect(startX + spaceX, startY, 40, height), cItem.exp);

                cont = new GUIContent("Perk Currency:", "The amount of perk currency gained by the player.");
                EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
                cItem.perkCurrency = EditorGUI.IntField(new Rect(startX + spaceX, startY, 40, height), cItem.perkCurrency);


                startY += 55;

                //int effectIdx=cItem.effect==null ? 0 : TDSEditor.GetEffectIndex(cItem.effect.ID);
                //if(effectIdx==0) cItem.effect=null;
                int effectIdx = cItem.effectID >= 0 ? TDSEditor.GetEffectIndex(cItem.effectID) : 0;

                TDSEditorUtility.DrawSprite(new Rect(startX + spaceX + width - 40, startY + spaceY - 45, 40, 40), effectIdx > 0 ? effectDB.effectList[effectIdx - 1].icon : null);
                if (GUI.Button(new Rect(startX + spaceX, startY - 2, 40, height - 2), "Edit "))
                {
                    EffectEditorWindow.Init();
                }

                cont = new GUIContent("Triggered Effect:", "Special effect that applies on target when triggered (optional)");
                EditorGUI.LabelField(new Rect(startX, startY += spaceY - 5, width, height), cont, headerStyle);

                effectIdx = EditorGUI.Popup(new Rect(startX + spaceX, startY, width, height), effectIdx, effectLabel);
                if (effectIdx > 0)
                {
                    cItem.effectID = effectDB.effectList[effectIdx - 1].ID;
                }
                else
                {
                    cItem.effectID = -1;
                }

                //if(effectIdx>0) cItem.effect=effectDB.effectList[effectIdx-1];
                //else cItem.effect=null;


                startY += 10;


                cont = new GUIContent("Gain Weapon:", "Weapon gained by player upon triggered (optional)");
                EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont, headerStyle);
                cItem.gainWeapon = EditorGUI.Toggle(new Rect(startX + spaceX, startY, 30, height), cItem.gainWeapon);

                if (cItem.gainWeapon)
                {
                    type = (int)cItem.weaponType;
                    cont = new GUIContent(" - GainWeaponType:", "What the new weapon is for");
                    EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
                    contL = new GUIContent[weaponTypeLabel.Length];
                    for (int i = 0; i < contL.Length; i++)
                    {
                        contL[i] = new GUIContent(weaponTypeLabel[i], weaponTypeTooltip[i]);
                    }
                    type             = EditorGUI.Popup(new Rect(startX + spaceX, startY, width, 15), new GUIContent(""), type, contL);
                    cItem.weaponType = (Collectible._WeaponType)type;


                    cont = new GUIContent(" - Duration:", "The duration of the temporary weapon. Set to -1 for not time limit (limit by weapon ammo instead)");
                    EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
                    if (cItem.weaponType == Collectible._WeaponType.Temporary)
                    {
                        cItem.tempWeapDuration = EditorGUI.FloatField(new Rect(startX + spaceX, startY, 40, height), cItem.tempWeapDuration);
                    }
                    else
                    {
                        EditorGUI.LabelField(new Rect(startX + spaceX, startY, 40, height), "-");
                    }

                    cont = new GUIContent(" - Random Weapon:", "Check if player will get random weapon out of a few potential candidates");
                    EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
                    cItem.randomWeapon = EditorGUI.Toggle(new Rect(startX + spaceX, startY, 30, height), cItem.randomWeapon);

                    if (cItem.randomWeapon)
                    {
                        cont = new GUIContent(" - EnableAllWeapon:", "Check if all weapon in the database are to be added to the random pool");
                        EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
                        cItem.enableAllWeapon = EditorGUI.Toggle(new Rect(startX + spaceX, startY, 30, height), cItem.enableAllWeapon);

                        if (!cItem.enableAllWeapon)
                        {
                            int enabledCount = 0;
                            for (int i = 0; i < weaponDB.weaponList.Count; i++)
                            {
                                Weapon weapon = weaponDB.weaponList[i];

                                bool enabled       = cItem.weaponList.Contains(weapon);
                                bool enabledCached = enabled;

                                TDSEditorUtility.DrawSprite(new Rect(startX + 20, startY += spaceY, 30, 30), weapon.icon, weapon.desp);
                                cont = new GUIContent(weapon.weaponName, weapon.desp);
                                EditorGUI.LabelField(new Rect(startX + 65, startY + 15, width, height), cont);
                                enabled = EditorGUI.Toggle(new Rect(startX + spaceX + width - 15, startY + 15, width, height), enabled);
                                startY += 14;

                                if (enabled != enabledCached)
                                {
                                    if (enabled)
                                    {
                                        cItem.weaponList.Insert(enabledCount, weapon);
                                    }
                                    else
                                    {
                                        cItem.weaponList.Remove(weapon);
                                    }
                                }

                                if (enabled)
                                {
                                    enabledCount += 1;
                                }
                            }
                        }
                    }
                    else
                    {
                        if (cItem.weaponList.Count != 1)
                        {
                            cItem.weaponList = new List <Weapon> {
                                null
                            }
                        }
                        ;

                        int weaponIdx1 = cItem.weaponList[0] != null?TDSEditor.GetWeaponIndex(cItem.weaponList[0].ID) : 0;

                        if (cItem.weaponList[0] != null)
                        {
                            TDSEditorUtility.DrawSprite(new Rect(startX + spaceX + width - 40, startY + spaceY - 41, 40, 40), cItem.weaponList[0].icon);
                        }

                        cont = new GUIContent(" - Weapon Gained:", "Weapon gained by player upon triggered (optional)");
                        EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);

                        weaponIdx1 = EditorGUI.Popup(new Rect(startX + spaceX, startY, width, height), weaponIdx1, weaponLabel);
                        if (weaponIdx1 > 0)
                        {
                            cItem.weaponList[0] = weaponDB.weaponList[weaponIdx1 - 1];
                        }
                        else
                        {
                            cItem.weaponList[0] = null;
                        }
                    }
                }
            }
            else
            {
                //if(cItem.type==_CollectType.AOEHostile){
                //cont=new GUIContent("AOE Range:", "");
                //EditorGUI.LabelField(new Rect(startX, startY+=spaceY, width, height), cont);
                //cItem.aoeRange=EditorGUI.FloatField(new Rect(startX+spaceX, startY, 40, height), cItem.aoeRange);
                //}

                Vector2 v2 = DrawAttackStats1(startX, startY + spaceY, cItem.aStats, cItem.type == _CollectType.AOEHostile, cItem.type == _CollectType.AOEHostile);
                startY = v2.y;
            }


            startY += 20;


            EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), "Miscellaneous", headerStyle);

            cont = new GUIContent("Triggered Effect Obj:", "The object to be spawned when the collectible is triggered (optional)");
            EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
            cItem.triggerEffectObj = (GameObject)EditorGUI.ObjectField(new Rect(startX + spaceX, startY, width, height), cItem.triggerEffectObj, typeof(GameObject), false);

            cont = new GUIContent("AutoDestroy Effect:", "Check if the effect object needs to be removed from the game");
            EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
            if (cItem.triggerEffectObj != null)
            {
                cItem.autoDestroyEffectObj = EditorGUI.Toggle(new Rect(startX + spaceX, startY, 40, height), cItem.autoDestroyEffectObj);

                if (cItem.autoDestroyEffectObj)
                {
                    cont = new GUIContent(" - Duration:", "The delay in seconds before the effect object is destroyed");
                    EditorGUI.LabelField(new Rect(startX + spaceX + 15, startY, width, height), cont);
                    cItem.effectObjActiveDuration = EditorGUI.FloatField(new Rect(startX + spaceX + width - 58, startY, 40, height), cItem.effectObjActiveDuration);
                }
            }
            else
            {
                EditorGUI.LabelField(new Rect(startX + spaceX, startY, 40, height), "-");
            }

            startY += 5;

            cont = new GUIContent("Triggered SFX:", "Audio clip to play when the collectible is triggered (optional)");
            EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
            cItem.triggerSFX = (AudioClip)EditorGUI.ObjectField(new Rect(startX + spaceX, startY, width, height), cItem.triggerSFX, typeof(AudioClip), false);


            startY += 10;

            cont = new GUIContent("Self Destruct:", "Check if the item is to self-destruct if not collected in a set time frame");
            EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
            cItem.selfDestruct = EditorGUI.Toggle(new Rect(startX + spaceX, startY, 40, height), cItem.selfDestruct);

            cont = new GUIContent("Active Duration:", "How long the item will stay active before it self destruct");
            EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
            if (cItem.selfDestruct)
            {
                cItem.selfDestructDuration = EditorGUI.FloatField(new Rect(startX + spaceX, startY, 40, height), cItem.selfDestructDuration);
            }
            else
            {
                EditorGUI.LabelField(new Rect(startX + spaceX, startY, 40, height), "-");
            }


            startY += 5;

            cont = new GUIContent("BlinkBeforeDestruct:", "Blink to give player warning before the object self-destruct");
            EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
            if (cItem.selfDestruct)
            {
                cItem.blinkBeforeDestroy = EditorGUI.Toggle(new Rect(startX + spaceX, startY, 40, height), cItem.blinkBeforeDestroy);
            }
            else
            {
                EditorGUI.LabelField(new Rect(startX + spaceX, startY, 40, height), "-");
            }

            cont = new GUIContent("Blink Duration:", "The long the item is gong to blink for");
            EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
            if (cItem.selfDestruct && cItem.blinkBeforeDestroy)
            {
                cItem.blinkDuration = EditorGUI.FloatField(new Rect(startX + spaceX, startY, 40, height), cItem.blinkDuration);
            }
            else
            {
                EditorGUI.LabelField(new Rect(startX + spaceX, startY, 40, height), "-");
            }

            int objID = cItem.blinkObj == null ? 0 : GetObjectIDFromHList(cItem.blinkObj.transform, objHList);

            cont = new GUIContent("Blink Object: ", "The mesh object to blink (The system will deactivate/activate the blink object for blinking. we only need to deactivate the child object and contain the mesh, not the whole item)");
            EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
            if (cItem.selfDestruct && cItem.blinkBeforeDestroy)
            {
                objID          = EditorGUI.Popup(new Rect(startX + spaceX, startY, width, height), objID, objHLabelList);
                cItem.blinkObj = (objHList[objID] == null) ? null : objHList[objID];
            }
            else
            {
                EditorGUI.LabelField(new Rect(startX + spaceX, startY, 40, height), "-");
            }


            startY += 15;

            GUIStyle style = new GUIStyle("TextArea");

            style.wordWrap = true;
            cont           = new GUIContent("Item description (to be used in runtime): ", "");
            EditorGUI.LabelField(new Rect(startX, startY += spaceY, 400, 20), cont);
            cItem.desp = EditorGUI.TextArea(new Rect(startX, startY + spaceY - 3, 270, 150), cItem.desp, style);


            return(new Vector2(startX, startY + 200));
        }
Exemple #16
0
        public override bool OnGUI()
        {
            if (!base.OnGUI())
            {
                return(true);
            }

            if (window == null)
            {
                Init();
            }

            List <Collectible> collectibleList = collectibleDB.collectibleList;

            Undo.RecordObject(this, "window");
            Undo.RecordObject(collectibleDB, "collectibleDB");
            if (collectibleList.Count > 0 && selectID >= 0)
            {
                Undo.RecordObject(collectibleList[selectID], "collectible");
            }

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


            EditorGUI.LabelField(new Rect(5, 7, 150, 17), "Add New Collectible:");
            Collectible newCollectible = null;

            newCollectible = (Collectible)EditorGUI.ObjectField(new Rect(125, 7, 140, 17), newCollectible, typeof(Collectible), false);
            if (newCollectible != null)
            {
                Select(NewItem(newCollectible));
            }


            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 = DrawCollectibleList(startX, startY, collectibleList);

            startX = v2.x + 25;

            if (collectibleList.Count == 0)
            {
                return(true);
            }


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


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

            if (srlObj.isEditingMultipleObjects)
            {
                EditorGUI.HelpBox(new Rect(startX, startY, width + spaceX, 40), "More than 1 Collectible instance is selected\nMulti-instance editing is not supported\nTry use Inspector instead", MessageType.Warning);
                startY += 55;
            }

            Collectible cltToEdit = selectedCltList.Count != 0 ? selectedCltList[0] : collectibleList[selectID];

            Undo.RecordObject(cltToEdit, "cltToEdit");

            v2            = DrawCollectibleConfigurator(startX, startY, cltToEdit);
            contentWidth  = v2.x + 35;
            contentHeight = v2.y - 55;

            srlObj.ApplyModifiedProperties();

            if (selectedCltList.Count > 0 && TDSEditor.IsPrefabInstance(selectedCltList[0].gameObject))
            {
                PrefabUtility.RecordPrefabInstancePropertyModifications(selectedCltList[0]);
            }

            GUI.EndScrollView();

            if (GUI.changed)
            {
                SetDirtyTDS();
                for (int i = 0; i < selectedCltList.Count; i++)
                {
                    EditorUtility.SetDirty(selectedCltList[i]);
                }
            }

            return(true);
        }
Exemple #17
0
 //protected static string[] damageTypeLabel;
 //protected static string[] armorTypeLabel;
 protected static void LoadProgressionStats()
 {
     TDSEditor.LoadProgressStats();
 }
Exemple #18
0
        //not in used, wip

        /*
         * protected Vector2 DrawAttackStats(string propertyName, float startX, float startY, SerializedObject aStats, bool showAOE=true, bool showPhysics=true, string label="Attack Stats"){
         *
         *      EditorGUI.LabelField(new Rect(startX, startY, width+50, height), label, headerStyle);	startY+=spaceY;
         *
         *      string pf="attackStats.";
         *      //SerializedProperty spas= aStats.FindProperty("attackStats");
         *      SerializedProperty spas= aStats.FindProperty(propertyName);
         *      string lbSp=" - ";
         *
         *      cont=new GUIContent(lbSp+"Damage Type:", "The damage type of the unit\nDamage type can be configured in Damage Armor Table Editor");
         *      EditorGUI.LabelField(new Rect(startX, startY, width, height), cont);
         *      if(damageTypeLabel.Length>0){
         *              srlPpt=spas.FindPropertyRelative("damageType");
         *              EditorGUI.showMixedValue=srlPpt.hasMultipleDifferentValues;
         *      //Debug.Log(srlPpt.intValue+"    "+srlPpt.hasMultipleDifferentValues);
         *              EditorGUI.BeginChangeCheck();
         *              int value=EditorGUI.Popup(new Rect(startX+spaceX, startY, width, height), srlPpt.intValue, damageTypeLabel);
         *              if(EditorGUI.EndChangeCheck()) srlPpt.intValue=value;
         *              EditorGUI.showMixedValue=false;
         *
         *              //aStats.damageType=EditorGUI.Popup(new Rect(startX+spaceX, startY, width, height), aStats.damageType, damageTypeLabel);
         *      }
         *      else{
         *              if(GUI.Button(new Rect(startX+spaceX, startY, 83, height-2), "Add Type")) DamageTableEditorWindow.Init();
         *      }
         *
         *      cont=new GUIContent(lbSp+"Damage (Min/Max):", "Damage value done to the target's hit-point.");
         *      EditorGUI.LabelField(new Rect(startX, startY+=spaceY, width, height), cont);
         *      EditorGUI.PropertyField(new Rect(startX+spaceX, startY, 40, height), aStats.FindProperty(pf+"damageMin"), contN);
         *      EditorGUI.PropertyField(new Rect(startX+spaceX+42, startY, 40, height), aStats.FindProperty(pf+"damageMax"), contN);
         *
         *      startY+=10;
         *
         *      if(showAOE){
         *              cont=new GUIContent(lbSp+"AOE Radius:", "Area of effect radius of the attack. Any hostile unit within the area is affected by the attack");
         *              EditorGUI.LabelField(new Rect(startX, startY+=spaceY, width, height), cont);
         *              EditorGUI.PropertyField(new Rect(startX+spaceX, startY, 40, height), aStats.FindProperty(pf+"aoeRadius"), contN);
         *
         *              cont=new GUIContent(lbSp+"Diminishing AOE22:", "Check if damage value diminished the further away the target is from the center of the aoe");
         *              EditorGUI.LabelField(new Rect(startX, startY+=spaceY, width, height), cont);
         *              if(aStats.FindProperty(pf+"aoeRadius").floatValue>0)
         *                      EditorGUI.PropertyField(new Rect(startX+spaceX, startY, 40, height), aStats.FindProperty(pf+"diminishingAOE"));
         *              else EditorGUI.LabelField(new Rect(startX+spaceX, startY, 40, height), "-");
         *
         *              startY+=10;
         *      }
         *
         *      cont=new GUIContent(lbSp+"Critical Chance:", "The chance of the attack to score a critical. Takes value from 0-1 with 0.3 being 30% to score a critical");
         *      EditorGUI.LabelField(new Rect(startX, startY+=spaceY, width, height), cont);
         *      EditorGUI.PropertyField(new Rect(startX+spaceX, startY, 40, height), aStats.FindProperty(pf+"critChance"), contN);
         *
         *      cont=new GUIContent(lbSp+"Critical Multiplier:", "The multiplier to be applied to damage if the attack scores a critical.\n - 1.5 for 150% of normal damage, 2 for 200% and so on");
         *      EditorGUI.LabelField(new Rect(startX, startY+=spaceY, width, height), cont);
         *      EditorGUI.PropertyField(new Rect(startX+spaceX, startY, 40, height), aStats.FindProperty(pf+"critChance"), contN);
         *      if(aStats.FindProperty(pf+"critChance").floatValue>0)
         *              EditorGUI.PropertyField(new Rect(startX+spaceX, startY, 40, height), aStats.FindProperty(pf+"critMultiplier"), contN);
         *      else EditorGUI.LabelField(new Rect(startX+spaceX, startY, 40, height), "-");
         *
         *      startY+=10;
         *
         *      if(showPhysics){
         *              cont=new GUIContent(lbSp+"Impact Force:", "If the attack will applies a knock back force to the target\nOnly applies if the attack is a direct hit from a shoot object");
         *              EditorGUI.LabelField(new Rect(startX, startY+=spaceY, width, height), cont);
         *              EditorGUI.PropertyField(new Rect(startX+spaceX, startY, 40, height), aStats.FindProperty(pf+"impactForce"), contN);
         *
         *              cont=new GUIContent(lbSp+"Explosion Radius:", "The radius in which all unit is affected by explosion force");
         *              EditorGUI.LabelField(new Rect(startX, startY+=spaceY, width, height), cont);
         *              EditorGUI.PropertyField(new Rect(startX+spaceX, startY, 40, height), aStats.FindProperty(pf+"explosionRadius"), contN);
         *
         *              cont=new GUIContent(lbSp+"Explosion Force:", "The force of the explosion which pushes all affect unit away from the impact point");
         *              EditorGUI.LabelField(new Rect(startX, startY+=spaceY, width, height), cont);
         *              if(aStats.FindProperty(pf+"explosionRadius").floatValue>0)
         *                      EditorGUI.PropertyField(new Rect(startX+spaceX, startY, 40, height), aStats.FindProperty(pf+"explosionRadius"), contN);
         *              else EditorGUI.LabelField(new Rect(startX+spaceX, startY, 40, height), "-");
         *      }
         *
         *      startY+=30;
         *
         *      srlPpt=aStats.FindProperty(pf+"effectID");
         *      EditorGUI.showMixedValue=srlPpt.hasMultipleDifferentValues;
         *      int effectIdx=srlPpt.intValue>=0 ? TDSEditor.GetEffectIndex(srlPpt.intValue) : 0 ;
         *
         *      if(!srlPpt.hasMultipleDifferentValues)
         *              TDSEditorUtility.DrawSprite(new Rect(startX+spaceX+width-40, startY+spaceY-45, 40, 40), effectIdx>0 ? effectDB.effectList[effectIdx-1].icon : null);
         *      if(GUI.Button(new Rect(startX+spaceX, startY-2, 40, height-2), "Edit")) EffectEditorWindow.Init();
         *
         *      cont=new GUIContent(lbSp+"Attack Effect:", "Special effect that applies with each hit (optional)");
         *      EditorGUI.LabelField(new Rect(startX, startY+=spaceY-5, width, height), cont);
         *
         *      EditorGUI.BeginChangeCheck();
         *      effectIdx=EditorGUI.Popup(new Rect(startX+spaceX, startY, width, height), effectIdx, effectLabel);
         *      if(EditorGUI.EndChangeCheck()){
         *              if(effectIdx>0) srlPpt.intValue=effectDB.effectList[effectIdx-1].ID;
         *              else srlPpt.intValue=-1;
         *      }
         *      EditorGUI.showMixedValue=false;
         *
         *      return new Vector2(startX, startY);
         * }
         */

        protected Vector2 DrawAttackStats1(float startX, float startY, AttackStats aStats, bool showAOE = true, bool showPhysics = true, string label = "Attack Stats")
        {
            EditorGUI.LabelField(new Rect(startX, startY, width + 50, height), label, headerStyle);   startY += spaceY;

            string lbSp = " - ";

            cont = new GUIContent(lbSp + "Damage Type:", "The damage type of the unit\nDamage type can be configured in Damage Armor Table Editor");
            EditorGUI.LabelField(new Rect(startX, startY, width, height), cont);
            if (damageTypeLabel.Length > 0)
            {
                aStats.damageType = EditorGUI.Popup(new Rect(startX + spaceX, startY, width, height), aStats.damageType, damageTypeLabel);
            }
            else
            {
                if (GUI.Button(new Rect(startX + spaceX, startY, 83, height - 2), "Add Type"))
                {
                    DamageTableEditorWindow.Init();
                }
            }

            cont = new GUIContent(lbSp + "Damage (Min/Max):", "Damage value done to the target's hit-point.");
            EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
            aStats.damageMin = EditorGUI.FloatField(new Rect(startX + spaceX, startY, 40, height), aStats.damageMin);
            aStats.damageMax = EditorGUI.FloatField(new Rect(startX + spaceX + 42, startY, 40, height), aStats.damageMax);

            startY += 10;

            if (showAOE)
            {
                cont = new GUIContent(lbSp + "AOE Radius:", "Area of effect radius of the attack. Any hostile unit within the area is affected by the attack");
                EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
                aStats.aoeRadius = EditorGUI.FloatField(new Rect(startX + spaceX, startY, 40, height), aStats.aoeRadius);

                //used in pre-version1.2, dimishingAOE is wrongly spelt
                //cont=new GUIContent(lbSp+"Diminishing AOE:", "Check if damage value diminished the further away the target is from the center of the aoe");
                //EditorGUI.LabelField(new Rect(startX, startY+=spaceY, width, height), cont);
                //if(aStats.aoeRadius>0) aStats.dimishingAOE=EditorGUI.Toggle(new Rect(startX+spaceX, startY, 40, height), aStats.dimishingAOE);
                //else EditorGUI.LabelField(new Rect(startX+spaceX, startY, 40, height), "-");

                cont = new GUIContent(lbSp + "Diminishing AOE:", "Check if damage value diminished the further away the target is from the center of the aoe");
                EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
                if (aStats.aoeRadius > 0)
                {
                    aStats.diminishingAOE = EditorGUI.Toggle(new Rect(startX + spaceX, startY, 40, height), aStats.diminishingAOE);
                }
                else
                {
                    EditorGUI.LabelField(new Rect(startX + spaceX, startY, 40, height), "-");
                }

                startY += 10;
            }

            cont = new GUIContent(lbSp + "Critical Chance:", "The chance of the attack to score a critical. Takes value from 0-1 with 0.3 being 30% to score a critical");
            EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
            aStats.critChance = EditorGUI.FloatField(new Rect(startX + spaceX, startY, 40, height), aStats.critChance);

            cont = new GUIContent(lbSp + "Critical Multiplier:", "The multiplier to be applied to damage if the attack scores a critical.\n - 1.5 for 150% of normal damage, 2 for 200% and so on");
            EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
            if (aStats.critChance > 0)
            {
                aStats.critMultiplier = EditorGUI.FloatField(new Rect(startX + spaceX, startY, 40, height), aStats.critMultiplier);
            }
            else
            {
                EditorGUI.LabelField(new Rect(startX + spaceX, startY, 40, height), "-");
            }

            startY += 10;

            if (showPhysics)
            {
                cont = new GUIContent(lbSp + "Impact Force:", "If the attack will applies a knock back force to the target\nOnly applies if the attack is a direct hit from a shoot object");
                EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
                aStats.impactForce = EditorGUI.FloatField(new Rect(startX + spaceX, startY, 40, height), aStats.impactForce);

                cont = new GUIContent(lbSp + "Explosion Radius:", "The radius in which all unit is affected by explosion force");
                EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
                aStats.explosionRadius = EditorGUI.FloatField(new Rect(startX + spaceX, startY, 40, height), aStats.explosionRadius);

                cont = new GUIContent(lbSp + "Explosion Force:", "The force of the explosion which pushes all affect unit away from the impact point");
                EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
                if (aStats.explosionRadius > 0)
                {
                    aStats.explosionForce = EditorGUI.FloatField(new Rect(startX + spaceX, startY, 40, height), aStats.explosionForce);
                }
                else
                {
                    EditorGUI.LabelField(new Rect(startX + spaceX, startY, 40, height), "-");
                }
            }

            startY += 30;



            int effectIdx = aStats.effectID >= 0 ? TDSEditor.GetEffectIndex(aStats.effectID) : 0;

            TDSEditorUtility.DrawSprite(new Rect(startX + spaceX + width - 40, startY + spaceY - 45, 40, 40), effectIdx > 0 ? effectDB.effectList[effectIdx - 1].icon : null);
            if (GUI.Button(new Rect(startX + spaceX, startY - 2, 40, height - 2), "Edit"))
            {
                EffectEditorWindow.Init();
            }

            cont = new GUIContent(lbSp + "Attack Effect:", "Special effect that applies with each hit (optional)");
            EditorGUI.LabelField(new Rect(startX, startY += spaceY - 5, width, height), cont);

            effectIdx = EditorGUI.Popup(new Rect(startX + spaceX, startY, width, height), effectIdx, effectLabel);
            if (effectIdx > 0)
            {
                aStats.effectID = effectDB.effectList[effectIdx - 1].ID;
            }
            else
            {
                aStats.effectID = -1;
            }


            return(new Vector2(startX, startY));
        }
Exemple #19
0
 protected static void UpdateLabel_Perk()
 {
     TDSEditor.UpdateLabel_Perk();
 }
Exemple #20
0
        void DrawObjective(ObjectiveTracker objective)
        {
            if (objective == null)
            {
                return;
            }


            EditorGUILayout.Space();


            //cont=new GUIContent("Main Objective:", "Check if this is the main objective of the level. Completing this will end the level");
            //objective.mainObjective=EditorGUILayout.Toggle(cont, objective.mainObjective);

            cont = new GUIContent("Wait For Timer:", "Enable to wait for the timer to run out before trigger a level complete state");
            objective.waitForTimer = EditorGUILayout.Toggle(cont, objective.waitForTimer);


            EditorGUILayout.Space();


            cont = new GUIContent("EnableTargetScore:", "Check if the objective is to gain a certain amount of score");
            objective.enableScoring = EditorGUILayout.Toggle(cont, objective.enableScoring);

            cont = new GUIContent("Target Score:", "The target score the player needs to gain to complete the objective");
            if (objective.enableScoring)
            {
                objective.targetScore = EditorGUILayout.FloatField(cont, objective.targetScore);
            }
            else
            {
                EditorGUILayout.LabelField(cont, new GUIContent("-", ""));
            }


            EditorGUILayout.Space();


            cont = new GUIContent("Clear All Hostile:", "Check if all active hostile unit in the level has to be destroyed before the objective is completed");
            objective.clearAllHostile = EditorGUILayout.Toggle(cont, objective.clearAllHostile);

            if (!objective.clearAllHostile)
            {
                cont         = new GUIContent("Unit List:", "Unit in the scene that need to be destroyed to complete the objective");
                showUnitList = EditorGUILayout.Foldout(showUnitList, cont);
                if (showUnitList)
                {
                    int count = objective.unitList.Count;

                    EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("", GUILayout.MaxWidth(15));
                    count = EditorGUILayout.IntField("Count", count);
                    EditorGUILayout.EndHorizontal();

                    while (count > objective.unitList.Count)
                    {
                        objective.unitList.Add(null);
                    }
                    while (count < objective.unitList.Count)
                    {
                        objective.unitList.RemoveAt(objective.unitList.Count - 1);
                    }

                    for (int i = 0; i < objective.unitList.Count; i++)
                    {
                        EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("", GUILayout.MaxWidth(20));
                        objective.unitList[i] = (Unit)EditorGUILayout.ObjectField("Element " + i, objective.unitList[i], typeof(Unit), true);
                        EditorGUILayout.EndHorizontal();
                    }
                }
            }


            EditorGUILayout.Space();


            //public List<Collectible> collectibleList=new List<Collectible>();	//collectible that exist in the scene
            cont = new GUIContent("Collectible List:", "Collectible item in the scene that need to be collected to complete the objective");
            showCollectibleList = EditorGUILayout.Foldout(showCollectibleList, cont);
            if (showCollectibleList)
            {
                int count = objective.collectibleList.Count;

                EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("", GUILayout.MaxWidth(15));
                count = EditorGUILayout.IntField("Count", count);
                EditorGUILayout.EndHorizontal();

                while (count > objective.collectibleList.Count)
                {
                    objective.collectibleList.Add(null);
                }
                while (count < objective.collectibleList.Count)
                {
                    objective.collectibleList.RemoveAt(objective.collectibleList.Count - 1);
                }

                for (int i = 0; i < objective.collectibleList.Count; i++)
                {
                    EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("", GUILayout.MaxWidth(20));
                    objective.collectibleList[i] = (Collectible)EditorGUILayout.ObjectField("Element " + i, objective.collectibleList[i], typeof(Collectible), true);
                    EditorGUILayout.EndHorizontal();
                }
            }


            EditorGUILayout.Space();


            cont = new GUIContent("Clear All Spawner:", "Check if all active unit spawner in the level has to be destroyed/cleared before the objective is completed");
            objective.clearAllSpawner = EditorGUILayout.Toggle(cont, objective.clearAllSpawner);

            if (!objective.clearAllSpawner)
            {
                cont            = new GUIContent("Unit Spawner List:", "Unit Spawner in the scene that need to be cleared to complete the objective");
                showSpawnerList = EditorGUILayout.Foldout(showSpawnerList, cont);
                if (showSpawnerList)
                {
                    int count = objective.spawnerList.Count;

                    EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("", GUILayout.MaxWidth(15));
                    count = EditorGUILayout.IntField("Count", count);
                    EditorGUILayout.EndHorizontal();

                    while (count > objective.spawnerList.Count)
                    {
                        objective.spawnerList.Add(null);
                    }
                    while (count < objective.spawnerList.Count)
                    {
                        objective.spawnerList.RemoveAt(objective.spawnerList.Count - 1);
                    }

                    for (int i = 0; i < objective.spawnerList.Count; i++)
                    {
                        EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("", GUILayout.MaxWidth(20));
                        objective.spawnerList[i] = (UnitSpawner)EditorGUILayout.ObjectField("Element " + i, objective.spawnerList[i], typeof(UnitSpawner), true);
                        EditorGUILayout.EndHorizontal();
                    }
                }
            }


            EditorGUILayout.Space();

            cont            = new GUIContent("Objective Trigger List:", "");
            showTriggerList = EditorGUILayout.Foldout(showTriggerList, cont);
            if (showTriggerList)
            {
                int count = objective.triggerList.Count;

                EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("", GUILayout.MaxWidth(15));
                count = EditorGUILayout.IntField("Count", count);
                EditorGUILayout.EndHorizontal();

                while (count > objective.triggerList.Count)
                {
                    objective.triggerList.Add(null);
                }
                while (count < objective.triggerList.Count)
                {
                    objective.triggerList.RemoveAt(objective.triggerList.Count - 1);
                }

                for (int i = 0; i < objective.triggerList.Count; i++)
                {
                    EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("", GUILayout.MaxWidth(20));
                    objective.triggerList[i] = (Trigger)EditorGUILayout.ObjectField("Element " + i, objective.triggerList[i], typeof(Trigger), true);
                    EditorGUILayout.EndHorizontal();
                }
            }

            EditorGUILayout.Space();


            cont = new GUIContent("Objective Targets:", "Specific numbers of any particular unit that needs to be destroyed before the level is cleared");
            EditorGUILayout.LabelField(cont);

            if (objective.prefabList.Count != objective.prefabCountList.Count)
            {
                //if(objective.targetUnitList.Count>objective.targetUnitCountList.Count)
                while (objective.prefabList.Count > objective.prefabCountList.Count)
                {
                    objective.prefabCountList.Add(1);
                }
                while (objective.prefabList.Count < objective.prefabCountList.Count)
                {
                    objective.prefabCountList.RemoveAt(objective.prefabCountList.Count - 1);
                }
            }


            for (int i = 0; i < objective.prefabList.Count + 1; i++)
            {
                if (i == objective.prefabList.Count && objective.prefabList.Count == unitAIDB.unitList.Count)
                {
                    continue;
                }

                int unitIdx = i < objective.prefabList.Count ? TDSEditor.GetUnitAIIndex(objective.prefabList[i].prefabID) : 0;

                EditorGUILayout.BeginHorizontal();

                EditorGUILayout.LabelField("  -  ", GUILayout.MaxWidth(20));                        //GUILayout.MaxWidth(115));
                unitIdx = EditorGUILayout.Popup(unitIdx, unitAILabel);

                if (i < objective.prefabList.Count)
                {
                    objective.prefabCountList[i] = EditorGUILayout.IntField(objective.prefabCountList[i], GUILayout.MaxWidth(40));
                    objective.prefabCountList[i] = Mathf.Max(1, objective.prefabCountList[i]);
                }
                else
                {
                    EditorGUILayout.LabelField("    ", GUILayout.MaxWidth(40));
                }

                EditorGUILayout.EndHorizontal();

                if (i < objective.prefabList.Count)
                {
                    if (unitIdx == 0)
                    {
                        objective.prefabList.RemoveAt(i);
                    }
                    else if (unitIdx > 0 && !objective.prefabList.Contains(unitAIDB.unitList[unitIdx - 1]))
                    {
                        objective.prefabList[i] = unitAIDB.unitList[unitIdx - 1];
                    }
                }
                else
                {
                    if (unitIdx > 0 && !objective.prefabList.Contains(unitAIDB.unitList[unitIdx - 1]))
                    {
                        objective.prefabList.Add(unitAIDB.unitList[unitIdx - 1]);
                    }
                }
            }


            EditorGUILayout.Space();


            cont = new GUIContent("Objective Collectibles:", "Specific numbers of any particular collectible that needs to be collectible before the level is cleared");
            EditorGUILayout.LabelField(cont);

            if (objective.colPrefabList.Count != objective.colPrefabCountList.Count)
            {
                while (objective.colPrefabList.Count > objective.colPrefabCountList.Count)
                {
                    objective.colPrefabCountList.Add(1);
                }
                while (objective.colPrefabList.Count < objective.colPrefabCountList.Count)
                {
                    objective.colPrefabCountList.RemoveAt(objective.colPrefabCountList.Count - 1);
                }
            }


            for (int i = 0; i < objective.colPrefabList.Count + 1; i++)
            {
                //if(i==objective.colPrefabList.Count && objective.prefabList.Count==unitAIDB.unitList.Count) continue;

                int itemIdx = i < objective.colPrefabList.Count ? TDSEditor.GetCollectibleIndex(objective.colPrefabList[i].ID) : 0;

                EditorGUILayout.BeginHorizontal();

                EditorGUILayout.LabelField("  -  ", GUILayout.MaxWidth(20));                        //GUILayout.MaxWidth(115));
                itemIdx = EditorGUILayout.Popup(itemIdx, collectibleLabel);

                if (i < objective.colPrefabList.Count)
                {
                    objective.colPrefabCountList[i] = EditorGUILayout.IntField(objective.colPrefabCountList[i], GUILayout.MaxWidth(40));
                    objective.colPrefabCountList[i] = Mathf.Max(1, objective.colPrefabCountList[i]);
                }
                else
                {
                    EditorGUILayout.LabelField("    ", GUILayout.MaxWidth(40));
                }

                EditorGUILayout.EndHorizontal();

                if (i < objective.colPrefabList.Count)
                {
                    if (itemIdx == 0)
                    {
                        objective.colPrefabList.RemoveAt(i);
                    }
                    else if (itemIdx > 0 && !objective.colPrefabList.Contains(collectibleDB.collectibleList[itemIdx - 1]))
                    {
                        objective.colPrefabList[i] = collectibleDB.collectibleList[itemIdx - 1];
                    }
                }
                else
                {
                    if (itemIdx > 0 && !objective.colPrefabList.Contains(collectibleDB.collectibleList[itemIdx - 1]))
                    {
                        objective.colPrefabList.Add(collectibleDB.collectibleList[itemIdx - 1]);
                    }
                }
            }

            //~ public List<Collectible> colPrefabList=new List<Collectible>();	//the collectible that need to be collect
            //~ public List<int> colPrefabCountList=new List<int>();		//the count required, editable in editor
        }
Exemple #21
0
 protected static void UpdateLabel_Weapon()
 {
     TDSEditor.UpdateLabel_Weapon();
 }
        Vector2 DrawUnitConfigurator(float startX, float startY, UnitAI unit)
        {
            Vector2 v2 = DrawUnitBaseStats(startX, startY, unit, false);

            startY = v2.y;

            startY += 10;


            //~ int type=(int)unit.behaviour;
            //~ cont=new GUIContent("Base Behaviour:", "Type of the behaviour which determine the how the unit respond to presence of hostile unit");
            //~ EditorGUI.LabelField(new Rect(startX, startY+=spaceY, width, height), cont);
            //~ contL=new GUIContent[behaviourLabel.Length];
            //~ for(int i=0; i<contL.Length; i++) contL[i]=new GUIContent(behaviourLabel[i], behaviourTooltip[i]);
            //~ type = EditorGUI.Popup(new Rect(startX+spaceX, startY, width, 15), new GUIContent(""), type, contL);
            //~ unit.behaviour=(_Behaviour)type;

            //~ cont=new GUIContent("Aggro Range:", "The range at which the unit will chasing down and attacking player\n\nUnit will not start attacking (shooting) until the target is within aggro range");
            //~ EditorGUI.LabelField(new Rect(startX, startY+=spaceY, width, height), cont);
            //~ if(unit.behaviour==_Behaviour.Aggressive_Trigger || unit.behaviour==_Behaviour.StandGuard)
            //~ unit.aggroRange=EditorGUI.DelayedFloatField(new Rect(startX+spaceX, startY, 40, height), unit.aggroRange);
            //~ else EditorGUI.LabelField(new Rect(startX+spaceX, startY, 40, height), "-");

            srlPpt = srlObj.FindProperty("behaviour");


            srlObj.Update();
            EditorGUI.BeginChangeCheck();
            cont = new GUIContent("Base Behaviour:", "Type of the behaviour which determine the how the unit respond to presence of hostile unit");
            EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
            contL = new GUIContent[behaviourLabel.Length];
            for (int i = 0; i < contL.Length; i++)
            {
                contL[i] = new GUIContent(behaviourLabel[i], behaviourTooltip[i]);
            }
            pptIntValue = EditorGUI.Popup(new Rect(startX + spaceX, startY, width, 15), EditorGUI.BeginProperty(new Rect(), contN, srlPpt), srlPpt.enumValueIndex, contL);    EditorGUI.EndProperty();
            if (EditorGUI.EndChangeCheck())
            {
                srlPpt.enumValueIndex = pptIntValue;
            }


            cont = new GUIContent("Aggro Range(P):", "The range at which the unit will chasing down and attacking player\n\nUnit will not start attacking (shooting) until the target is within aggro range");
            EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
            if (srlPpt.enumValueIndex == (int)_Behaviour.Aggressive_Trigger || srlPpt.enumValueIndex == (int)_Behaviour.StandGuard)
            {
                EditorGUI.PropertyField(new Rect(startX + spaceX, startY, 40, height), srlObj.FindProperty("aggroRange"), contN);
            }
            else
            {
                EditorGUI.LabelField(new Rect(startX + spaceX, startY, 40, height), "-");
            }
            srlObj.ApplyModifiedProperties();


            startY += 10;


            showMoveSetting = EditorGUI.Foldout(new Rect(startX, startY += spaceY, width, height), showMoveSetting, "Show Move Setting", foldoutStyle);
            if (showMoveSetting)
            {
                startX += 15; width -= 15;

                //~ cont=new GUIContent("Anchored To Point:", "Check if the unit is a static object. Means it will not moved and wont be affected by physics");
                //~ EditorGUI.LabelField(new Rect(startX, startY+=spaceY+5, width, height), cont);
                //~ unit.anchorDown=EditorGUI.Toggle(new Rect(startX+spaceX, startY, 40, height), unit.anchorDown);

                //~ cont=new GUIContent(" - Move Speed:", "The move speed of the unit");
                //~ EditorGUI.LabelField(new Rect(startX, startY+=spaceY, width, height), cont);
                //~ if(!unit.anchorDown) unit.moveSpeed=EditorGUI.DelayedFloatField(new Rect(startX+spaceX, startY, 40, height), unit.moveSpeed);
                //~ else EditorGUI.LabelField(new Rect(startX+spaceX, startY, 40, height), "-");

                //~ cont=new GUIContent(" - Rotate Speed:", "The rotate speed of the unit (degree per second)");
                //~ EditorGUI.LabelField(new Rect(startX, startY+=spaceY, width, height), cont);
                //~ if(!unit.anchorDown) unit.rotateSpeed=EditorGUI.DelayedFloatField(new Rect(startX+spaceX, startY, 40, height), unit.rotateSpeed);
                //~ else EditorGUI.LabelField(new Rect(startX+spaceX, startY, 40, height), "-");

                //~ cont=new GUIContent(" - Brake  Range:", "The range at which the unit will stop moving towards its target");
                //~ EditorGUI.LabelField(new Rect(startX, startY+=spaceY, width, height), cont);
                //~ if(!unit.anchorDown) unit.brakeRange=EditorGUI.DelayedFloatField(new Rect(startX+spaceX, startY, 40, height), unit.brakeRange);
                //~ else EditorGUI.LabelField(new Rect(startX+spaceX, startY, 40, height), "-");


                srlPpt = srlObj.FindProperty("anchorDown");

                EditorGUI.BeginChangeCheck();
                cont = new GUIContent("Anchored To Point:", "Check if the unit is a static object. Means it will not moved and wont be affected by physics");
                EditorGUI.LabelField(new Rect(startX, startY += spaceY + 5, width, height), cont);
                pptBoolValue = EditorGUI.Toggle(new Rect(startX + spaceX, startY, 40, height), EditorGUI.BeginProperty(new Rect(), contN, srlPpt), srlPpt.boolValue);       EditorGUI.EndProperty();
                if (EditorGUI.EndChangeCheck())
                {
                    srlPpt.boolValue = pptBoolValue;
                }

                showVar = !srlPpt.hasMultipleDifferentValues & !srlPpt.boolValue;

                cont = new GUIContent(" - Move Speed(P):", "The move speed of the unit");
                EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
                if (showVar)
                {
                    EditorGUI.PropertyField(new Rect(startX + spaceX, startY, 40, height), srlObj.FindProperty("moveSpeed"), contN);
                }
                else
                {
                    EditorGUI.LabelField(new Rect(startX + spaceX, startY, 40, height), "-");
                }

                cont = new GUIContent(" - Rotate Speed(P):", "The rotate speed of the unit (degree per second)");
                EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
                if (showVar)
                {
                    EditorGUI.PropertyField(new Rect(startX + spaceX, startY, 40, height), srlObj.FindProperty("rotateSpeed"), contN);
                }
                else
                {
                    EditorGUI.LabelField(new Rect(startX + spaceX, startY, 40, height), "-");
                }

                cont = new GUIContent(" - Brake  Range(P):", "The range at which the unit will stop moving towards its target");
                EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
                if (showVar)
                {
                    EditorGUI.PropertyField(new Rect(startX + spaceX, startY, 40, height), srlObj.FindProperty("brakeRange"), contN);
                }
                else
                {
                    EditorGUI.LabelField(new Rect(startX + spaceX, startY, 40, height), "-");
                }


                startY += 10;


                //~ cont=new GUIContent("Stop Ocassionally:", "Check to enable the target to stop every now and then when chasing the target");
                //~ EditorGUI.LabelField(new Rect(startX, startY+=spaceY, width, height), cont);
                //~ unit.stopOccasionally=EditorGUI.Toggle(new Rect(startX+spaceX, startY, 40, height), unit.stopOccasionally);

                //~ cont=new GUIContent("  - Stop Chance:", "Chance that determine how often the unit will stop. takes value from 0-1 with 0 as never and 1 as every cooldown");
                //~ EditorGUI.LabelField(new Rect(startX, startY+=spaceY, width, height), cont);
                //~ if(unit.stopOccasionally) unit.stopRate=EditorGUI.DelayedFloatField(new Rect(startX+spaceX, startY, 40, height), unit.stopRate);
                //~ else EditorGUI.LabelField(new Rect(startX+spaceX, startY, 40, height), "-");

                //~ cont=new GUIContent("  - Stop Duration:", "How long (in second) the unit will stop for");
                //~ EditorGUI.LabelField(new Rect(startX, startY+=spaceY, width, height), cont);
                //~ if(unit.stopOccasionally) unit.stopDuration=EditorGUI.DelayedFloatField(new Rect(startX+spaceX, startY, 40, height), unit.stopDuration);
                //~ else EditorGUI.LabelField(new Rect(startX+spaceX, startY, 40, height), "-");

                //~ cont=new GUIContent("  - Stop Cooldown:", "How long (in second) before the unit will try to stop after the last stop");
                //~ EditorGUI.LabelField(new Rect(startX, startY+=spaceY, width, height), cont);
                //~ if(unit.stopOccasionally) unit.stopCooldown=EditorGUI.DelayedFloatField(new Rect(startX+spaceX, startY, 40, height), unit.stopCooldown);
                //~ else EditorGUI.LabelField(new Rect(startX+spaceX, startY, 40, height), "-");


                srlPpt = srlObj.FindProperty("stopOccasionally");

                EditorGUI.BeginChangeCheck();
                cont = new GUIContent("Stop Ocassionally:", "Check to enable the target to stop every now and then when chasing the target");
                EditorGUI.LabelField(new Rect(startX, startY += spaceY + 5, width, height), cont);
                pptBoolValue = EditorGUI.Toggle(new Rect(startX + spaceX, startY, 40, height), EditorGUI.BeginProperty(new Rect(), contN, srlPpt), srlPpt.boolValue);       EditorGUI.EndProperty();
                if (EditorGUI.EndChangeCheck())
                {
                    srlPpt.boolValue = pptBoolValue;
                }

                showVar = !srlPpt.hasMultipleDifferentValues & pptBoolValue;

                cont = new GUIContent("  - Stop Chance:", "Chance that determine how often the unit will stop. takes value from 0-1 with 0 as never and 1 as every cooldown");
                EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
                if (showVar)
                {
                    EditorGUI.PropertyField(new Rect(startX + spaceX, startY, 40, height), srlObj.FindProperty("stopRate"), contN);
                }
                else
                {
                    EditorGUI.LabelField(new Rect(startX + spaceX, startY, 40, height), "-");
                }

                cont = new GUIContent("  - Stop Duration:", "How long (in second) the unit will stop for");
                EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
                if (showVar)
                {
                    EditorGUI.PropertyField(new Rect(startX + spaceX, startY, 40, height), srlObj.FindProperty("stopDuration"), contN);
                }
                else
                {
                    EditorGUI.LabelField(new Rect(startX + spaceX, startY, 40, height), "-");
                }

                cont = new GUIContent("  - Stop Cooldown:", "How long (in second) before the unit will try a stop maneuver after the last stop maneuver");
                EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
                if (showVar)
                {
                    EditorGUI.PropertyField(new Rect(startX + spaceX, startY, 40, height), srlObj.FindProperty("stopCooldown"), contN);
                }
                else
                {
                    EditorGUI.LabelField(new Rect(startX + spaceX, startY, 40, height), "-");
                }


                startY += 10;


                //~ cont=new GUIContent("Evade Ocassionally:", "Check to enable the target to perform a evade maneuver and then when chasing the target");
                //~ EditorGUI.LabelField(new Rect(startX, startY+=spaceY, width, height), cont);
                //~ unit.evadeOccasionally=EditorGUI.Toggle(new Rect(startX+spaceX, startY, 40, height), unit.evadeOccasionally);

                //~ cont=new GUIContent("  - Evade Chance:", "Chance that determine how often the unit will evade. takes value from 0-1 with 0 as never and 1 as every cooldown");
                //~ EditorGUI.LabelField(new Rect(startX, startY+=spaceY, width, height), cont);
                //~ if(unit.evadeOccasionally) unit.evadeRate=EditorGUI.DelayedFloatField(new Rect(startX+spaceX, startY, 40, height), unit.evadeRate);
                //~ else EditorGUI.LabelField(new Rect(startX+spaceX, startY, 40, height), "-");

                //~ cont=new GUIContent("  - Evade Duration:", "How long (in second) the unit will perform the maneuver for");
                //~ EditorGUI.LabelField(new Rect(startX, startY+=spaceY, width, height), cont);
                //~ if(unit.evadeOccasionally) unit.evadeDuration=EditorGUI.DelayedFloatField(new Rect(startX+spaceX, startY, 40, height), unit.evadeDuration);
                //~ else EditorGUI.LabelField(new Rect(startX+spaceX, startY, 40, height), "-");

                //~ cont=new GUIContent("  - Stop Cooldown:", "How long (in second) before the unit will try a evade maneuver after the last evade maneuver");
                //~ EditorGUI.LabelField(new Rect(startX, startY+=spaceY, width, height), cont);
                //~ if(unit.evadeOccasionally) unit.evadeCooldown=EditorGUI.DelayedFloatField(new Rect(startX+spaceX, startY, 40, height), unit.evadeCooldown);
                //~ else EditorGUI.LabelField(new Rect(startX+spaceX, startY, 40, height), "-");


                srlPpt = srlObj.FindProperty("evadeOccasionally");

                EditorGUI.BeginChangeCheck();
                cont = new GUIContent("Evade Ocassionally:", "Check to enable the target to perform a evade maneuver and then when chasing the target");
                EditorGUI.LabelField(new Rect(startX, startY += spaceY + 5, width, height), cont);
                pptBoolValue = EditorGUI.Toggle(new Rect(startX + spaceX, startY, 40, height), EditorGUI.BeginProperty(new Rect(), contN, srlPpt), srlPpt.boolValue);       EditorGUI.EndProperty();
                if (EditorGUI.EndChangeCheck())
                {
                    srlPpt.boolValue = pptBoolValue;
                }

                showVar = !srlPpt.hasMultipleDifferentValues & !pptBoolValue;

                cont = new GUIContent("  - Evade Chance:", "Chance that determine how often the unit will evade. takes value from 0-1 with 0 as never and 1 as every cooldown");
                EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
                if (showVar)
                {
                    EditorGUI.PropertyField(new Rect(startX + spaceX, startY, 40, height), srlObj.FindProperty("evadeRate"), contN);
                }
                else
                {
                    EditorGUI.LabelField(new Rect(startX + spaceX, startY, 40, height), "-");
                }

                cont = new GUIContent("  - Evade Duration:", "How long (in second) the unit will perform the maneuver for");
                EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
                if (showVar)
                {
                    EditorGUI.PropertyField(new Rect(startX + spaceX, startY, 40, height), srlObj.FindProperty("evadeDuration"), contN);
                }
                else
                {
                    EditorGUI.LabelField(new Rect(startX + spaceX, startY, 40, height), "-");
                }

                cont = new GUIContent("  - Evade Cooldown:", "How long (in second) before the unit will try a evade maneuver after the last evade maneuver");
                EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
                if (showVar)
                {
                    EditorGUI.PropertyField(new Rect(startX + spaceX, startY, 40, height), srlObj.FindProperty("evadeCooldown"), contN);
                }
                else
                {
                    EditorGUI.LabelField(new Rect(startX + spaceX, startY, 40, height), "-");
                }


                startX -= 15; width += 15;
            }

            startY += 10;

            showAttackSetting = EditorGUI.Foldout(new Rect(startX, startY += spaceY, width, height), showAttackSetting, "Show Attack Setting", foldoutStyle);
            if (showAttackSetting)
            {
                startX += 15; width -= 15; spaceX += 10;           //width-=20;

                startY += 5;

                //~ cont=new GUIContent("Range Attack:", "Check if the unit can perform any range attack");
                //~ EditorGUI.LabelField(new Rect(startX, startY+=spaceY, width, height), cont, headerStyle);
                //~ unit.enableAttack=EditorGUI.Toggle(new Rect(startX+spaceX, startY, 40, height), unit.enableAttack);

                srlPpt = srlObj.FindProperty("enableRangeAttack");

                EditorGUI.BeginChangeCheck();
                cont = new GUIContent("Range Attack:", "Check if the unit can perform any range attack");
                EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont, headerStyle);
                pptBoolValue = EditorGUI.Toggle(new Rect(startX + spaceX, startY, 40, height), EditorGUI.BeginProperty(new Rect(), contN, srlPpt), srlPpt.boolValue);       EditorGUI.EndProperty();
                if (EditorGUI.EndChangeCheck())
                {
                    srlPpt.boolValue = pptBoolValue;
                }

                bool enableRangeAttack = !srlPpt.hasMultipleDifferentValues & pptBoolValue;

                //if(unit.enableAttack){
                if (enableRangeAttack)
                {
                    string lbSp = " - ";

                    cont = new GUIContent(lbSp + "Shoot Periodically:", "Check to enable the target to shoot after every attack cooldown, regardless of existance or range of target");
                    EditorGUI.LabelField(new Rect(startX, startY += spaceY + 5, width, height), cont);
                    unit.shootPeriodically = EditorGUI.Toggle(new Rect(startX + spaceX, startY, 40, height), unit.shootPeriodically);

                    cont = new GUIContent(lbSp + "AlwaysOnTarget:", "Check to have the unit shoot object always fire towards target, regardless of aim direction");
                    EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
                    unit.alwaysShootTowardsTarget = EditorGUI.Toggle(new Rect(startX + spaceX, startY, 40, height), unit.alwaysShootTowardsTarget);


                    startY += 10;


                    cont = new GUIContent(lbSp + "Shoot Object:", "The prefab of the bullet/object fired by the unit\nMust be a prefab with ShootObject component attached on it\n\n*Required for range attack to work");
                    EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont, unit.shootObject != null ? new GUIStyle("Label") : conflictStyle);
                    unit.shootObject = (GameObject)EditorGUI.ObjectField(new Rect(startX + spaceX, startY, width, height), unit.shootObject, typeof(GameObject), false);

                    int objID = GetObjectIDFromHList(unit.turretObj, objHList);
                    cont = new GUIContent(lbSp + "Turret Object:", "The pivot transform on the unit to track the shoot direction");
                    EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
                    objID          = EditorGUI.Popup(new Rect(startX + spaceX, startY, width, height), objID, objHLabelList);
                    unit.turretObj = (objHList[objID] == null) ? null : objHList[objID].transform;

                    cont = new GUIContent(lbSp + "TurretTrackSpeed:", "The tracking speed of the turret. Slower turret will have a harder time keeping up with target.");
                    EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
                    if (unit.turretObj != null)
                    {
                        unit.turretTrackingSpeed = EditorGUI.DelayedFloatField(new Rect(startX + spaceX, startY, 40, height), unit.turretTrackingSpeed);
                    }
                    else
                    {
                        EditorGUI.LabelField(new Rect(startX + spaceX, startY, 40, height), "-");
                    }


                    startY += 10;


                    cont = new GUIContent("ShootPoint:", "The transform which indicate the position where the shootObject will be fired from (Optional)\nEach shootPoint assigned will fire a shootObject instance in each attack\nIf left empty, the weapon transform itself will be use as the shootPoint\nThe orientation of the shootPoint matter as they dictate the orientation of the firing direction.\n");
                    shootPointFoldout = EditorGUI.Foldout(new Rect(startX + 3, startY += spaceY, spaceX, height), shootPointFoldout, cont);
                    int shootPointCount = unit.shootPointList.Count;
                    shootPointCount = EditorGUI.DelayedIntField(new Rect(startX + spaceX, startY, 40, height), shootPointCount);

                    if (shootPointCount != unit.shootPointList.Count)
                    {
                        while (unit.shootPointList.Count < shootPointCount)
                        {
                            unit.shootPointList.Add(null);
                        }
                        while (unit.shootPointList.Count > shootPointCount)
                        {
                            unit.shootPointList.RemoveAt(unit.shootPointList.Count - 1);
                        }
                    }

                    if (shootPointFoldout)
                    {
                        for (int i = 0; i < unit.shootPointList.Count; i++)
                        {
                            objID = GetObjectIDFromHList(unit.shootPointList[i], objHList);
                            EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), "    - Element " + (i + 1));
                            objID = EditorGUI.Popup(new Rect(startX + spaceX, startY, width, height), objID, objHLabelList);
                            unit.shootPointList[i] = (objHList[objID] == null) ? null : objHList[objID].transform;
                        }
                    }

                    cont = new GUIContent(lbSp + "Shoot Point Delay:", "The delay in seconds between subsequent shot in each shoot point");
                    EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
                    if (unit.shootPointList.Count > 1)
                    {
                        unit.shootPointDelay = EditorGUI.DelayedFloatField(new Rect(startX + spaceX, startY, 40, height), unit.shootPointDelay);
                    }
                    else
                    {
                        EditorGUI.LabelField(new Rect(startX + spaceX, startY, 40, height), "-");
                    }


                    startY += 10;


                    cont = new GUIContent(lbSp + "Attack Range:", "The attack range of the unit");
                    EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
                    unit.range = EditorGUI.DelayedFloatField(new Rect(startX + spaceX, startY, 40, height), unit.range);

                    cont = new GUIContent(lbSp + "Attack Cooldown:", "The cooldown duration in seconds between each subsequent attack");
                    EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
                    unit.cooldown = EditorGUI.DelayedFloatField(new Rect(startX + spaceX, startY, 40, height), unit.cooldown);

                    startY += 5;

                    cont = new GUIContent(lbSp + "First Attack Delay:", "The delay in second before the unit can perform it's first attack. To prevent unit to fire immediately after being spawned or as soon as the game start");
                    EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
                    unit.firstAttackDelay = EditorGUI.DelayedFloatField(new Rect(startX + spaceX, startY, 40, height), unit.firstAttackDelay);

                    cont = new GUIContent("Randomize", "Randomize the first attack delay between 0 and the specified value");
                    unit.randFirstAttackDelay = EditorGUI.Toggle(new Rect(startX + spaceX + 45, startY, 20, height), unit.randFirstAttackDelay);
                    EditorGUI.LabelField(new Rect(startX + spaceX + 45 + 15, startY, width, height), cont);


                    startY += 10;


                    v2     = DrawAttackStats1(startX, startY + spaceY, unit.attackStats, true, false, "   Attack Stats (Range)");
                    startY = v2.y;
                }



                startY += 10;



                srlPpt = srlObj.FindProperty("enableContactAttack");

                EditorGUI.BeginChangeCheck();
                cont = new GUIContent("AttackOnContact:", "Check if the unit can attack when comes into contact with hostile unit");
                EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont, headerStyle);
                pptBoolValue = EditorGUI.Toggle(new Rect(startX + spaceX, startY, 40, height), EditorGUI.BeginProperty(new Rect(), contN, srlPpt), srlPpt.boolValue);       EditorGUI.EndProperty();
                if (EditorGUI.EndChangeCheck())
                {
                    srlPpt.boolValue = pptBoolValue;
                }

                bool enableContactAttack = !srlPpt.hasMultipleDifferentValues & pptBoolValue;

                if (enableContactAttack)
                {
                    string lbSp = " - ";

                    cont = new GUIContent(lbSp + "Attack Cooldown:", "The cooldown duration in seconds between each subsequent attack");
                    EditorGUI.LabelField(new Rect(startX, startY += spaceY + 5, width, height), cont);
                    unit.contactCooldown = EditorGUI.DelayedFloatField(new Rect(startX + spaceX, startY, 40, height), unit.contactCooldown);

                    startY += 10;

                    v2     = DrawAttackStats1(startX, startY + spaceY, unit.contactAttackStats, false, false, "   Attack Stats (On Contact)");
                    startY = v2.y;
                }


                startX -= 15; width += 15; spaceX -= 10;           //width+=20;
            }


            startY += 20;

            EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), "Misc", headerStyle);

            cont = new GUIContent("DestroyUponContact:", "Check to destroy unit upon coming into contact with a hostile");
            EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
            //unit.destroyUponPlayerContact=EditorGUI.Toggle(new Rect(startX+spaceX, startY, 40, height), unit.destroyUponPlayerContact);
            EditorGUI.PropertyField(new Rect(startX + spaceX, startY, 40, height), srlObj.FindProperty("destroyUponPlayerContact"), contN);

            startY += 10;

            cont = new GUIContent("Score On Destroy:", "Score gained by player when the unit is destroyed");
            EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
            //unit.valueScore=EditorGUI.DelayedIntField(new Rect(startX+spaceX, startY, 40, height), unit.valueScore);
            EditorGUI.PropertyField(new Rect(startX + spaceX, startY, 40, height), srlObj.FindProperty("valueScore"), contN);

            cont = new GUIContent("HitPoint On Destroy:", "Hit-Point gained by player when the unit is destroyed");
            EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
            //unit.valueHitPoint=EditorGUI.DelayedIntField(new Rect(startX+spaceX, startY, 40, height), unit.valueHitPoint);
            EditorGUI.PropertyField(new Rect(startX + spaceX, startY, 40, height), srlObj.FindProperty("valueHitPoint"), contN);

            cont = new GUIContent("Energy On Destroy:", "Energy gained by player when the unit is destroyed");
            EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
            //unit.valueEnergy=EditorGUI.DelayedIntField(new Rect(startX+spaceX, startY, 40, height), unit.valueEnergy);
            EditorGUI.PropertyField(new Rect(startX + spaceX, startY, 40, height), srlObj.FindProperty("valueEnergy"), contN);

            //cont=new GUIContent("Credit On Destroy:", "Credit gained by player when the unit is destroyed");
            //EditorGUI.LabelField(new Rect(startX, startY+=spaceY, width, height), cont);
            //unit.valueCredits=EditorGUI.DelayedIntField(new Rect(startX+spaceX, startY, 40, height), unit.valueCredits);

            startY += 10;


            //Vector2 v3=DrawDestroyEffectObj(startX, startY+spaceY, unit);
            Vector2 v3 = DrawDestroyEffectObj(startX, startY + spaceY, srlObj);

            startY = v3.y + 10;


            srlPpt = srlObj.FindProperty("useDropManager");

            EditorGUI.BeginChangeCheck();
            cont = new GUIContent("Use DropManager:", "Check to use DropManager to determine what the unit drops");
            EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
            pptBoolValue = EditorGUI.Toggle(new Rect(startX + spaceX, startY, 40, height), EditorGUI.BeginProperty(new Rect(), contN, srlPpt), srlPpt.boolValue);       EditorGUI.EndProperty();
            if (EditorGUI.EndChangeCheck())
            {
                srlPpt.boolValue = pptBoolValue;
            }

            showVar = !srlPpt.hasMultipleDifferentValues & !pptBoolValue;

            cont = new GUIContent("Drop Object:", "The game object to drop when the unit is destroyed");
            EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
            if (showVar)
            {
                //unit.dropObject=(GameObject)EditorGUI.ObjectField(new Rect(startX+spaceX, startY, width, height), unit.dropObject, typeof(GameObject), false);
                EditorGUI.PropertyField(new Rect(startX + spaceX, startY, width, height), srlObj.FindProperty("dropObject"), contN);
            }
            else
            {
                EditorGUI.LabelField(new Rect(startX + spaceX, startY, 40, height), "-");
            }

            cont = new GUIContent("Drop Chance:", "The chance for the object to drop. Takes value from 0-1 with 0.3 being 30% chance to drop");
            EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
            if (showVar)
            {
                //unit.dropChance=EditorGUI.DelayedFloatField(new Rect(startX+spaceX, startY, 40, height), unit.dropChance);
                EditorGUI.PropertyField(new Rect(startX + spaceX, startY, 40, height), srlObj.FindProperty("dropChance"), contN);
            }
            else
            {
                EditorGUI.LabelField(new Rect(startX + spaceX, startY, 40, height), "-");
            }


            startY += 10;



            EditorGUI.showMixedValue = srlObj.FindProperty("spawnUponDestroy").hasMultipleDifferentValues;
            int unitIdx = unit.spawnUponDestroy != null?TDSEditor.GetUnitAIIndex(unit.spawnUponDestroy.prefabID) : 0;

            cont = new GUIContent("SpawnUponDestroy:", "The unit to spawn when this unit is destroyed (optional)");
            EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);

            EditorGUI.BeginChangeCheck();
            unitIdx = EditorGUI.Popup(new Rect(startX + spaceX, startY, width, height), unitIdx, unitAILabel);
            if (EditorGUI.EndChangeCheck())
            {
                if (unitIdx == 0)
                {
                    unit.spawnUponDestroy = null;
                    srlObj.FindProperty("spawnUponDestroy").objectReferenceValue = null;
                }
                else if (unitIdx > 0)
                {
                    unit.spawnUponDestroy = unitAIDB.unitList[unitIdx - 1];
                    srlObj.FindProperty("spawnUponDestroy").objectReferenceValue = unitAIDB.unitList[unitIdx - 1];
                }
            }

            EditorGUI.showMixedValue = false;



            cont = new GUIContent("Spawn Count:", "Number of unit to spawn");
            EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
            if (unit.spawnUponDestroy != null)
            {
                EditorGUI.PropertyField(new Rect(startX + spaceX, startY, 40, height), srlObj.FindProperty("spawnUponDestroyCount"), contN);
            }
            else
            {
                EditorGUI.LabelField(new Rect(startX + spaceX, startY, 40, height), "-");
            }


            startY += 15;


            GUIStyle style = new GUIStyle("TextArea");

            style.wordWrap = true;
            cont           = new GUIContent("Unit description (to be used in runtime): ", "");
            EditorGUI.LabelField(new Rect(startX, startY += spaceY, 400, 20), cont);
            unit.desp = EditorGUI.DelayedTextField(new Rect(startX, startY + spaceY - 3, 270, 150), unit.desp, style);


            return(new Vector2(startX, startY + 200));
        }
Exemple #23
0
 protected static void UpdateLabel_Collectible()
 {
     TDSEditor.UpdateLabel_Collectible();
 }
        public override bool OnGUI()
        {
            if (!base.OnGUI())
            {
                return(true);
            }

            if (window == null)
            {
                Init();
            }

            List <UnitAI> unitList = unitAIDB.unitList;

            Undo.RecordObject(this, "window");
            Undo.RecordObject(unitAIDB, "unitAIDB");
            if (unitList.Count > 0 && selectID >= 0)
            {
                Undo.RecordObject(unitList[selectID], "unitAI");
            }


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

            if (!UnitAI_DB.UpdatedToPost_2018_3())
            {
                GUI.color = new Color(0, 1f, 1f, 1f);
                if (GUI.Button(new Rect(Math.Max(260, window.position.width - 230), 5, 100, 25), "Copy Old DB"))
                {
                    UnitAI_DB.CopyFromOldDB();              Select(0);
                }
                GUI.color = Color.white;
            }


            EditorGUI.LabelField(new Rect(5, 7, 150, 17), "Add New AI Unit:");
            UnitAI newUnit = null;

            newUnit = (UnitAI)EditorGUI.ObjectField(new Rect(125, 7, 140, 17), newUnit, typeof(UnitAI), false);
            if (newUnit != null)
            {
                Select(NewItem(newUnit));
            }

            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 = DrawUnitList(startX, startY, unitList);

            startX = v2.x + 25;

            if (unitList.Count == 0 || srlObj == null)
            {
                return(true);
            }


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


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

            srlObj.Update();

            if (srlObj.isEditingMultipleObjects)
            {
                EditorGUI.HelpBox(new Rect(startX, startY, width + spaceX, 40), "More than 1 UnitAI instance is selected\nMulti-instance editing is not supported\nTry use Inspector instead", MessageType.Warning);
                startY += 55;
            }

            UnitAI unitToEdit = selectedUnitList.Count != 0 ? selectedUnitList[0] : unitList[selectID];

            Undo.RecordObject(unitToEdit, "unitToEdit");

            EditorGUI.BeginChangeCheck();

            v2            = DrawUnitConfigurator(startX, startY, unitToEdit);
            contentWidth  = v2.x + 35;
            contentHeight = v2.y - 55;

            if (EditorGUI.EndChangeCheck() && selectID >= 0)
            {
                                        #if UNITY_2018_3_OR_NEWER
                //GameObject unitObj=PrefabUtility.LoadPrefabContents(AssetDatabase.GetAssetPath(unitList[selectID].gameObject));
                //UnitAI selectedUnit=unitObj.GetComponent<UnitAI>();
                //selectedUnit=unitList[selectID];
                //GameObject obj=PrefabUtility.SavePrefabAsset(selectedUnit.gameObject);

                string assetPath = AssetDatabase.GetAssetPath(unitList[selectID].gameObject);

                GameObject unitObj      = PrefabUtility.LoadPrefabContents(assetPath);
                UnitAI     selectedUnit = unitObj.GetComponent <UnitAI>();

                EditorUtility.CopySerialized(unitList[selectID], selectedUnit);

                PrefabUtility.SaveAsPrefabAsset(unitObj, assetPath);
                PrefabUtility.UnloadPrefabContents(unitObj);
                                        #endif
            }

            srlObj.ApplyModifiedProperties();

            if (selectedUnitList.Count > 0 && TDSEditor.IsPrefabInstance(selectedUnitList[0].gameObject))
            {
                PrefabUtility.RecordPrefabInstancePropertyModifications(selectedUnitList[0]);
            }

            GUI.EndScrollView();


            if (GUI.changed)
            {
                SetDirtyTDS();
                for (int i = 0; i < selectedUnitList.Count; i++)
                {
                    EditorUtility.SetDirty(selectedUnitList[i]);
                }
            }

            return(true);
        }
Exemple #25
0
 protected static void LoadUnitPlayer()
 {
     TDSEditor.LoadUnitPlayer();
 }
        void OnSelectionChange()
        {
            if (window == null)
            {
                return;
            }

            srlObj = null;

            selectedUnitList = new List <UnitAI>();

            UnityEngine.Object[] filtered = Selection.GetFiltered(typeof(UnitAI), SelectionMode.Editable);
            for (int i = 0; i < filtered.Length; i++)
            {
                selectedUnitList.Add((UnitAI)filtered[i]);
            }

            //if no no relevent object is selected
            if (selectedUnitList.Count == 0)
            {
                SelectItem();
                if (unitAIDB.unitList.Count > 0 && selectID >= 0)
                {
                    UpdateObjectHierarchyList(unitAIDB.unitList[selectID].gameObject);
                }
            }
            else
            {
                //only one relevent object is selected
                if (selectedUnitList.Count == 1)
                {
                    //if the selected object is a prefab and match the selected item in editor, do nothing
                    if (selectID > 0 && selectedUnitList[0] == unitAIDB.unitList[selectID])
                    {
                        UpdateObjectHierarchyList(selectedUnitList[0].gameObject);
                    }
                    //if the selected object doesnt match...
                    else
                    {
                        //if the selected object existed in DB
                        if (TDSEditor.ExistInDB(selectedUnitList[0]))
                        {
                            window.selectID = TDSEditor.GetUnitAIIndex(selectedUnitList[0].prefabID) - 1;
                            UpdateObjectHierarchyList(selectedUnitList[0].gameObject);
                            SelectItem();
                        }
                        //if the selected object is not in DB
                        else
                        {
                            selectID = -1;
                            UpdateObjectHierarchyList(selectedUnitList[0].gameObject);
                        }
                    }
                }
                //selected multiple editable object
                else
                {
                    selectID = -1;
                    UpdateObjectHierarchyList(selectedUnitList[0].gameObject);
                }

                srlObj = new SerializedObject(filtered);
            }

            Repaint();
        }
Exemple #27
0
        protected void DrawAttackStats(string propertyName, bool showAOE = true, bool showPhysics = true, string label = "Attack Stats")
        {
            string             lbSp    = " - ";
            SerializedProperty aStatsP = serializedObject.FindProperty(propertyName);

            EditorGUILayout.LabelField(label, headerStyle);


            srlPpt = aStatsP.FindPropertyRelative("damageType");
            EditorGUI.showMixedValue = srlPpt.hasMultipleDifferentValues;
            EditorGUI.BeginChangeCheck();
            cont  = new GUIContent(lbSp + "Damage Type:", "The damage type of the unit\nDamage type can be configured in Damage Armor Table Editor");
            contL = new GUIContent[damageTypeLabel.Length];
            for (int i = 0; i < contL.Length; i++)
            {
                contL[i] = new GUIContent(damageTypeLabel[i], "");
            }

            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField(cont, GUILayout.MaxWidth(labelWidth));
            int armorType = EditorGUILayout.Popup(srlPpt.intValue, contL, GUILayout.MaxWidth(fieldWidthL));

            EditorGUILayout.EndHorizontal();

            if (EditorGUI.EndChangeCheck())
            {
                srlPpt.intValue = armorType;
            }
            EditorGUI.showMixedValue = false;


            EditorGUILayout.BeginHorizontal();
            cont = new GUIContent(lbSp + "Damage(Min/Max):", "Damage value done to the target's hit-point.");
            EditorGUILayout.LabelField(cont, GUILayout.MaxWidth(labelWidth));
            EditorGUILayout.PropertyField(aStatsP.FindPropertyRelative("damageMin"), contN, GUILayout.MaxWidth(fieldWidth));
            EditorGUILayout.PropertyField(aStatsP.FindPropertyRelative("damageMax"), contN, GUILayout.MaxWidth(fieldWidth));
            EditorGUILayout.EndHorizontal();


            EditorGUILayout.Space();


            if (showAOE)
            {
                cont = new GUIContent(lbSp + "AOE Radius:", "Area of effect radius of the attack. Any hostile unit within the area is affected by the attack");
                PropertyField(aStatsP.FindPropertyRelative("aoeRadius"), cont);

                cont = new GUIContent(lbSp + "Diminishing AOE:", "Check if damage value diminished the further away the target is from the center of the aoe");
                if (aStatsP.FindPropertyRelative("aoeRadius").floatValue > 0)
                {
                    PropertyField(aStatsP.FindPropertyRelative("dimishingAOE"), cont);
                }
                else
                {
                    InvalidField(cont);
                }
            }


            EditorGUILayout.Space();


            cont = new GUIContent(lbSp + "Critical Chance:", "The chance of the attack to score a critical. Takes value from 0-1 with 0.3 being 30% to score a critical");
            PropertyField(aStatsP.FindPropertyRelative("critChance"), cont);

            cont = new GUIContent(lbSp + "Critical Multiplier:", "The multiplier to be applied to damage if the attack scores a critical.\n - 1.5 for 150% of normal damage, 2 for 200% and so on");
            if (aStatsP.FindPropertyRelative("critChance").floatValue > 0)
            {
                PropertyField(aStatsP.FindPropertyRelative("critMultiplier"), cont);
            }
            else
            {
                InvalidField(cont);
            }


            EditorGUILayout.Space();


            if (showPhysics)
            {
                cont = new GUIContent(lbSp + "Impact Force:", "If the attack will applies a knock back force to the target\nOnly applies if the attack is a direct hit from a shoot object");
                EditorGUI.BeginChangeCheck(); EditorGUILayout.BeginHorizontal();
                EditorGUILayout.LabelField(cont, GUILayout.MaxWidth(labelWidth));
                float impactForce = EditorGUILayout.FloatField(aStatsP.FindPropertyRelative("impactForce").floatValue, GUILayout.MaxWidth(fieldWidth));
                if (EditorGUI.EndChangeCheck())
                {
                    aStatsP.FindPropertyRelative("impactForce").floatValue = impactForce;
                }
                EditorGUILayout.EndHorizontal();

                cont = new GUIContent(lbSp + "Explosion Radius:", "The radius in which all unit is affected by explosion force");
                PropertyField(aStatsP.FindPropertyRelative("explosionRadius"), cont);

                cont = new GUIContent(lbSp + "Explosion Force:", "The force of the explosion which pushes all affect unit away from the impact point");
                if (aStatsP.FindPropertyRelative("explosionRadius").floatValue > 0)
                {
                    PropertyField(aStatsP.FindPropertyRelative("explosionForce"), cont);
                }
                else
                {
                    InvalidField(cont);
                }
            }


            EditorGUILayout.Space();



            srlPpt = aStatsP.FindPropertyRelative("effectID");
            EditorGUI.showMixedValue = srlPpt.hasMultipleDifferentValues;
            int effectIdx = srlPpt.intValue >= 0 ? TDSEditor.GetEffectIndex(srlPpt.intValue) : 0;

            //if(!srlPpt.hasMultipleDifferentValues)
            //TDSEditorUtility.DrawSprite(new Rect(startX+spaceX+width-40, startY+spaceY-45, 40, 40), effectIdx>0 ? effectDB.effectList[effectIdx-1].icon : null);
            //if(GUI.Button(new Rect(startX+spaceX, startY-2, 40, height-2), "Edit")) EffectEditorWindow.Init();

            EditorGUILayout.BeginHorizontal();      EditorGUI.BeginChangeCheck();

            cont = new GUIContent(lbSp + "Attack Effect:", "Special effect that applies with each hit (optional)");
            EditorGUILayout.LabelField(cont, GUILayout.MaxWidth(labelWidth));

            effectIdx = EditorGUILayout.Popup(effectIdx, effectLabel, GUILayout.MaxWidth(fieldWidthL));
            if (EditorGUI.EndChangeCheck())
            {
                if (effectIdx > 0)
                {
                    srlPpt.intValue = effectDB.effectList[effectIdx - 1].ID;
                }
                else
                {
                    srlPpt.intValue = -1;
                }
            }
            EditorGUI.showMixedValue = false;
            EditorGUILayout.EndHorizontal();
        }
Exemple #28
0
 protected static void LoadEffect()
 {
     TDSEditor.LoadEffect();
 }
Exemple #29
0
 protected static void UpdateLabel_DamageTable()
 {
     TDSEditor.UpdateLabel_DamageTable();
 }
Exemple #30
0
 protected static void UpdateLabel_Effect()
 {
     TDSEditor.UpdateLabel_Effect();
 }