private float DrawPerkConfigurator(float startX, float startY, Perk perk)
        {
            TDSEditorUtility.DrawSprite(new Rect(startX, startY, 60, 60), perk.icon);
            startX += 65;

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

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

            cont = new GUIContent("PerkID:", "The ID used to associate a perk item in perk menu to a perk when configuring perk menu manually");
            EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
            EditorGUI.LabelField(new Rect(startX + spaceX - 65, startY, width - 5, height), perk.ID.ToString());

            startX -= 65;
            startY += 15;          //+spaceY-spaceY/2;


            if (showTypeDesp)
            {
                EditorGUI.HelpBox(new Rect(startX, startY += spaceY, width + spaceX, 40), perkTypeTooltip[(int)perk.type], MessageType.Info);
                startY += 45 - height;
            }

            int type = (int)perk.type;

            cont = new GUIContent("Perk Type:", "What the perk does");
            EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont, headerStyle);
            contL = new GUIContent[perkTypeLabel.Length];
            for (int i = 0; i < contL.Length; i++)
            {
                contL[i] = new GUIContent(perkTypeLabel[i], perkTypeTooltip[i]);
            }
            type      = EditorGUI.Popup(new Rect(startX + spaceX, startY, width, 15), new GUIContent(""), type, contL);
            perk.type = (_PerkType)type;

            showTypeDesp = EditorGUI.ToggleLeft(new Rect(startX + spaceX + width + 2, startY, width, 20), "Show Description", showTypeDesp);

            startY += spaceY;

            startY = DrawPerkGeneralSetting(startX, startY + spaceY, perk);

            startY = DrawPerkStats(startX, startY + spaceY, perk);


            startY += 15;

            GUIStyle style = new GUIStyle("TextArea");

            style.wordWrap = true;
            cont           = new GUIContent("Perk description (for runtime and editor): ", "");
            EditorGUI.LabelField(new Rect(startX, startY, 400, 20), cont);
            perk.desp = EditorGUI.TextArea(new Rect(startX, startY + spaceY - 3, 270, 150), perk.desp, style);

            return(startY + 170);
        }
        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);
        }
        Vector2 DrawSpawnUnitList(float startX, float startY, UnitSpawner spawner)
        {
            for (int i = 0; i < spawner.spawnUnitList.Count; i++)
            {
                if (spawner.spawnUnitList[i] == null)
                {
                    spawner.spawnUnitList.RemoveAt(i); i -= 1;
                }
            }

            cont = new GUIContent("Spawn Unit:", "The potential unit prefab to be spawned, check to enable");
            EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont, headerStyle);

            int enabledCount = 0;

            for (int i = 0; i < unitAIDB.unitList.Count; i++)
            {
                UnitAI unit = unitAIDB.unitList[i];

                bool enabled       = spawner.spawnUnitList.Contains(unit);
                bool enabledCached = enabled;

                TDSEditorUtility.DrawSprite(new Rect(startX + 10, startY += spaceY, 30, 30), unit.icon, unit.desp);
                cont = new GUIContent(unit.unitName, unit.desp);
                EditorGUI.LabelField(new Rect(startX + 50, startY + 10, width, height), cont);
                enabled = EditorGUI.Toggle(new Rect(startX + spaceX + width - 15, startY + 10, width, height), enabled);
                startY += 14;

                if (enabled != enabledCached)
                {
                    if (enabled)
                    {
                        spawner.spawnUnitList.Insert(enabledCount, unit);
                    }
                    else
                    {
                        spawner.spawnUnitList.Remove(unit);
                    }
                }

                if (enabled)
                {
                    enabledCount += 1;
                }
            }

            return(new Vector2(startX, startY + spaceY));
        }
        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);
        }
Beispiel #5
0
 protected void UpdateObjectHierarchyList(GameObject obj)
 {
     TDSEditorUtility.GetObjectHierarchyList(obj, this.SetObjListCallback);
 }
Beispiel #6
0
        public override void OnInspectorGUI()
        {
            base.OnInspectorGUI();

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

            Undo.RecordObject(instance, "UIPerkTabList");

            //serializedObject.Update();


            //~ cont=new GUIContent("Manual Setup:", "");
            //~ instance.manuallySetupItem=EditorGUILayout.Toggle(cont, instance.manuallySetupItem);

            EditorGUILayout.Space();

            //if(!instance.manuallySetup){

            showPerkList = EditorGUILayout.Foldout(showPerkList, "Show Perk List");
            if (showPerkList)
            {
                EditorGUILayout.HelpBox("Choose perk that will shows up in the UI", MessageType.Info);

                EditorGUILayout.BeginHorizontal();
                if (GUILayout.Button("EnableAll"))
                {
                    EnableAllPerk();
                }
                if (GUILayout.Button("DisableAll"))
                {
                    DisableAllPerk();
                }
                EditorGUILayout.EndHorizontal();

                for (int i = 0; i < perkDB.perkList.Count; i++)
                {
                    Perk perk = perkDB.perkList[i];

                    GUILayout.BeginHorizontal();

                    GUILayout.Box("", GUILayout.Width(40), GUILayout.Height(40));
                    Rect rect = GUILayoutUtility.GetLastRect();
                    TDSEditorUtility.DrawSprite(rect, perk.icon, perk.desp, false);

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

                    GUILayout.BeginHorizontal();

                    EditorGUI.BeginChangeCheck();
                    bool flag = instance.perkIDList.Contains(perk.ID) ? true : false;
                    EditorGUILayout.LabelField(new GUIContent(" - enabled: ", "check to enable the perk in this level"), GUILayout.Width(70));
                    flag = EditorGUILayout.Toggle(flag);

                    if (!Application.isPlaying && EditorGUI.EndChangeCheck())
                    {
                        if (!flag && !instance.perkIDList.Contains(perk.ID))
                        {
                            instance.perkIDList.Remove(perk.ID);
                        }
                        else if (flag)
                        {
                            instance.perkIDList.Add(perk.ID);
                        }
                    }

                    GUILayout.EndHorizontal();

                    GUILayout.EndVertical();

                    GUILayout.EndHorizontal();
                }
            }

            EditorGUILayout.Space();
            EditorGUILayout.Space();
            //}



            //serializedObject.ApplyModifiedProperties();

            //DefaultInspector();

            DrawDefaultInspector();

            if (GUI.changed)
            {
                EditorUtility.SetDirty(instance);
            }
        }
        Vector2 DrawAbilityConfigurator(float startX, float startY, Ability ability)
        {
            //~ //float cachedX=startX;
            //~ //float cachedY=startY;

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

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

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

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


            EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), "Ability Type & Stats", headerStyle);

            int type = (int)ability.type;

            cont = new GUIContent("Ability Type:", "Type of the ability which determine the targeting mechanic and potential target");
            EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
            contL = new GUIContent[abilityTypeLabel.Length];
            for (int i = 0; i < contL.Length; i++)
            {
                contL[i] = new GUIContent(abilityTypeLabel[i], abilityTypeTooltip[i]);
            }
            type         = EditorGUI.Popup(new Rect(startX + spaceX, startY, width, 15), new GUIContent(""), type, contL);
            ability.type = (_AbilityType)type;

            startY += 5;

            cont = new GUIContent("Cost:", "The energy cost to launch the ability");
            EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
            ability.cost = EditorGUI.DelayedFloatField(new Rect(startX + spaceX, startY, 40, height), ability.cost);

            cont = new GUIContent("Cooldown:", "The cooldown in second for the ability before it can be used again after it's used");
            EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
            ability.cooldown = EditorGUI.DelayedFloatField(new Rect(startX + spaceX, startY, 40, height), ability.cooldown);

            startY += 10;


            if (ability.type == _AbilityType.Shoot)
            {
                cont = new GUIContent("Range:", "The shoot range of the ability");
                EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
                ability.range = EditorGUI.DelayedFloatField(new Rect(startX + spaceX, startY, 40, height), ability.range);

                cont = new GUIContent("Shoot Object:", "The prefab of the bullet/object fired by the weapon\nMust be a prefab with ShootObject component attached on it");
                EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
                ability.shootObject = (GameObject)EditorGUI.ObjectField(new Rect(startX + spaceX, startY, width, height), ability.shootObject, typeof(GameObject), false);

                cont = new GUIContent("Shoot Pos Offset:", "The relative shoot position to the position of the player transform, in player transform space");
                EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
                ability.shootPosOffset = EditorGUI.Vector3Field(new Rect(startX + spaceX, startY, width, height), "", ability.shootPosOffset);
            }


            if (ability.type != _AbilityType.Movement && ability.type != _AbilityType.Custom)
            {
                startY += 10;

                bool    showAOE = ability.type == _AbilityType.AOE | ability.type == _AbilityType.AOESelf | ability.type == _AbilityType.Shoot;
                Vector2 v2      = DrawAttackStats1(startX, startY + spaceY, ability.aStats, showAOE);
                startY = v2.y + 15;
            }


            if (ability.type == _AbilityType.Movement)
            {
                int mType = (int)ability.moveType;
                cont = new GUIContent("Move Type:", "Type of the move ability");
                EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
                contL = new GUIContent[moveTypeLabel.Length];
                for (int i = 0; i < contL.Length; i++)
                {
                    contL[i] = new GUIContent(moveTypeLabel[i], moveTypeTooltip[i]);
                }
                mType            = EditorGUI.Popup(new Rect(startX + spaceX, startY, width, 15), new GUIContent(""), mType, contL);
                ability.moveType = (_MoveType)mType;

                startY += 10;

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

                cont = new GUIContent("Duration:", "The duration of the dash");
                EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
                if (ability.moveType == _MoveType.Dash)
                {
                    ability.duration = EditorGUI.DelayedFloatField(new Rect(startX + spaceX, startY, 40, height), ability.duration);
                }
                else
                {
                    EditorGUI.LabelField(new Rect(startX + spaceX, startY, 40, height), "-");
                }

                startY += 15;
            }



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

            cont = new GUIContent("Launch Object:", "The object to be spawned when the ability is launched (optional)");
            EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
            ability.launchObj = (GameObject)EditorGUI.ObjectField(new Rect(startX + spaceX, startY, width, height), ability.launchObj, typeof(GameObject), false);

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

                if (ability.autoDestroyLaunchObj)
                {
                    cont = new GUIContent(" - Duration:", "The delay in seconds before the launch object is destroyed");
                    EditorGUI.LabelField(new Rect(startX + spaceX + 15, startY, width, height), cont);
                    ability.launchObjActiveDuration = EditorGUI.DelayedFloatField(new Rect(startX + spaceX + width - 58, startY, 40, height), ability.launchObjActiveDuration);
                }
            }
            else
            {
                EditorGUI.LabelField(new Rect(startX + spaceX, startY, 40, height), "-");
            }

            startY += 5;

            cont = new GUIContent("Launch SFX:", "Audio clip to play when the ability is launched (optional)");
            EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
            ability.launchSFX = (AudioClip)EditorGUI.ObjectField(new Rect(startX + spaceX, startY, width, height), ability.launchSFX, typeof(AudioClip), false);


            startY += 15;

            GUIStyle style = new GUIStyle("TextArea");

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


            return(new Vector2(startX, startY + 200));
        }
        public override void OnInspectorGUI()
        {
            base.OnInspectorGUI();

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

            GUI.changed = false;

            serializedObject.Update();


            EditorGUILayout.Space();
            cont = new GUIContent("Perk Currency:", "The amount of perk currency pocessed by the player unit.\nUsed to purchase perk");
            EditorGUILayout.PropertyField(serializedObject.FindProperty("perkCurrency"), cont);
            EditorGUILayout.Space();


            showPerkList = EditorGUILayout.Foldout(showPerkList, "Show Valid Perk List");
            if (showPerkList)
            {
                EditorGUILayout.BeginHorizontal();
                if (GUILayout.Button("EnableAll"))
                {
                    EnableAllPerkOnAll();
                }
                if (GUILayout.Button("DisableAll"))
                {
                    DisableAllPerkOnAll();
                }
                EditorGUILayout.EndHorizontal();

                for (int i = 0; i < perkDB.perkList.Count; i++)
                {
                    Perk perk = perkDB.perkList[i];

                    GUILayout.BeginHorizontal();

                    GUILayout.Box("", GUILayout.Width(40), GUILayout.Height(40));
                    Rect rect = GUILayoutUtility.GetLastRect();
                    TDSEditorUtility.DrawSprite(rect, perk.icon, perk.desp, false);

                    GUILayout.BeginVertical();

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


                    GUILayout.BeginHorizontal();

                    EditorGUI.showMixedValue = !UnavailableListSharesValue(perk.ID);

                    EditorGUI.BeginChangeCheck();
                    bool flag = !instance.unavailableIDList.Contains(perk.ID) ? true : false;
                    EditorGUILayout.LabelField(new GUIContent(" - enabled: ", "check to enable the perk in this level"), GUILayout.Width(70));
                    flag = EditorGUILayout.Toggle(flag);

                    if (!Application.isPlaying && EditorGUI.EndChangeCheck())
                    {
                        if (!flag)
                        {
                            RemoveIDFromAvaiList(perk.ID);
                        }
                        else
                        {
                            AddIDToAvaiList(perk.ID);
                        }
                    }

                    EditorGUI.showMixedValue = false;


                    EditorGUI.showMixedValue = !PurchasedListSharesValue(perk.ID);

                    if (!instance.unavailableIDList.Contains(perk.ID))
                    {
                        flag = instance.purchasedIDList.Contains(perk.ID);
                        EditorGUILayout.LabelField(new GUIContent(" - purchased: ", "check to set the perk as purchased right from the start"), GUILayout.Width(80));
                        flag = EditorGUILayout.Toggle(flag);

                        if (!Application.isPlaying)
                        {
                            if (!flag)
                            {
                                RemoveIDFromPurchasedList(perk.ID);
                            }
                            else
                            {
                                AddIDToPurchasedList(perk.ID);
                            }
                        }
                    }

                    EditorGUI.showMixedValue = false;

                    GUILayout.EndHorizontal();

                    GUILayout.EndVertical();

                    GUILayout.EndHorizontal();
                }
            }

            EditorGUILayout.Space();

            serializedObject.ApplyModifiedProperties();

            DefaultInspector();

            if (GUI.changed)
            {
                EditorUtility.SetDirty(instance);
            }
        }
Beispiel #9
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));
        }
Beispiel #10
0
        protected Vector2 DrawList(float startX, float startY, float winWidth, float winHeight, List <Item> list, bool drawRemove = true, bool shiftItem = true, bool clampSelectID = true)
        {
            float width = minimiseList ? 60 : 260;

            if (!minimiseList && shiftItem)
            {
                if (GUI.Button(new Rect(startX + 180, startY - 20, 40, 18), "up"))
                {
                    if (shiftItemUpCallback != null)
                    {
                        shiftItemUpCallback();
                    }
                    else
                    {
                        Debug.Log("call back is null");
                    }
                    if (selectID * 35 < scrollPosList.y)
                    {
                        scrollPosList.y = selectID * 35;
                    }
                }
                if (GUI.Button(new Rect(startX + 222, startY - 20, 40, 18), "down"))
                {
                    if (shiftItemDownCallback != null)
                    {
                        shiftItemDownCallback();
                    }
                    else
                    {
                        Debug.Log("call back is null");
                    }
                    if (visibleRectList.height - 35 < selectID * 35)
                    {
                        scrollPosList.y = (selectID + 1) * 35 - visibleRectList.height + 5;
                    }
                }
            }


            visibleRectList = new Rect(startX, startY, width + 15, winHeight - startY - 5);
            contentRectList = new Rect(startX, startY, width, list.Count * 35 + 5);

            GUI.color = new Color(.8f, .8f, .8f, 1f);
            GUI.Box(visibleRectList, "");
            GUI.color = Color.white;

            scrollPosList = GUI.BeginScrollView(visibleRectList, scrollPosList, contentRectList);

            startY += 5;      startX += 5;

            for (int i = 0; i < list.Count; i++)
            {
                TDSEditorUtility.DrawSprite(new Rect(startX, startY + (i * 35), 30, 30), list[i].icon);

                if (minimiseList)
                {
                    if (selectID == i)
                    {
                        GUI.color = new Color(0, 1f, 1f, 1f);
                    }
                    if (GUI.Button(new Rect(startX + 35, startY + (i * 35), 30, 30), ""))
                    {
                        Select(i);
                    }
                    GUI.color = Color.white;
                    continue;
                }

                if (selectID == i)
                {
                    GUI.color = new Color(0, 1f, 1f, 1f);
                }
                if (GUI.Button(new Rect(startX + 35, startY + (i * 35), 150 + (!drawRemove ? 60 : 0), 30), list[i].name))
                {
                    Select(i);
                }
                GUI.color = Color.white;

                if (!drawRemove)
                {
                    continue;
                }

                if (deleteID == i)
                {
                    if (GUI.Button(new Rect(startX + 190, startY + (i * 35), 60, 15), "cancel"))
                    {
                        deleteID = -1;
                    }

                    GUI.color = Color.red;
                    if (GUI.Button(new Rect(startX + 190, startY + (i * 35) + 15, 60, 15), "confirm"))
                    {
                        if (selectID >= deleteID)
                        {
                            Select(Mathf.Max(0, selectID - 1));
                        }
                        if (deleteItemCallback != null)
                        {
                            deleteItemCallback();
                        }
                        else
                        {
                            Debug.Log("callback is null");
                        }
                        deleteID = -1;
                    }
                    GUI.color = Color.white;
                }
                else
                {
                    if (GUI.Button(new Rect(startX + 190, startY + (i * 35), 60, 15), "remove"))
                    {
                        deleteID = i;
                    }
                }
            }

            GUI.EndScrollView();

            if (clampSelectID)
            {
                selectID = Mathf.Clamp(selectID, 0, list.Count - 1);
            }

            return(new Vector2(startX + width + 10, startY));
        }
Beispiel #11
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));
        }
Beispiel #12
0
        protected bool showVar;                         //temp bool value for variable depending on (enable/disable flag such as anchor-down, destroy effect)

        protected Vector2 DrawUnitBaseStats(float startX, float startY, Unit unit, bool isPlayer)
        {
            TDSEditorUtility.DrawSprite(new Rect(startX, startY, 60, 60), unit.icon);
            startX += 65;

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

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

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

            if (TDSEditor.IsPrefab(unit.gameObject))
            {
                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), unit.gameObject, typeof(GameObject), false);
            }
            else
            {
                EditorGUI.HelpBox(new Rect(startX, startY += spaceY, width + spaceX - 65, height + 5), "The unit being edited is not a prefab", MessageType.Warning);
                startY += 5;
            }

            startX -= 65;
            startY += spaceY;

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

            startY += 5;

            cont = new GUIContent("Hit Point:", "The hit-point capacity of the unit");
            EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
            unit.hitPointFull = EditorGUI.FloatField(new Rect(startX + spaceX, startY, 40, height), unit.hitPointFull);

            unit.startHitPointAtFull = EditorGUI.Toggle(new Rect(startX + spaceX + 50, startY, 40, height), unit.startHitPointAtFull);
            EditorGUI.LabelField(new Rect(startX + spaceX + 65, startY, width, height), " - start at full");

            cont = new GUIContent("Hit Point Regen:", "The amount of hit-point regenerated per second");
            EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
            unit.hpRegenRate = EditorGUI.FloatField(new Rect(startX + spaceX, startY, 40, height), unit.hpRegenRate);

            cont = new GUIContent("Hit Point Stagger:", "The duration in second in which the hit-point regen would stop after the unit being hit");
            EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
            if (unit.hpRegenRate > 0)
            {
                unit.hpRegenStagger = EditorGUI.FloatField(new Rect(startX + spaceX, startY, 40, height), unit.hpRegenStagger);
            }
            else
            {
                EditorGUI.LabelField(new Rect(startX + spaceX, startY, 40, height), "-");
            }

            if (isPlayer)
            {
                startY += 10;

                cont = new GUIContent("Energy:", "The energy capacity of the unit");
                EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
                unit.energyFull = EditorGUI.FloatField(new Rect(startX + spaceX, startY, 40, height), unit.energyFull);

                unit.startEnergyAtFull = EditorGUI.Toggle(new Rect(startX + spaceX + 50, startY, 40, height), unit.startEnergyAtFull);
                EditorGUI.LabelField(new Rect(startX + spaceX + 65, startY, width, height), " - start at full");

                cont = new GUIContent("Energy Rate:", "The rate (per second) in which the energy will recharge");
                EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
                unit.energyRate = EditorGUI.FloatField(new Rect(startX + spaceX, startY, 40, height), unit.energyRate);
            }

            startY += 10;

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

            return(new Vector2(startX, startY));
        }
        Vector2 DrawWeaponConfigurator(float startX, float startY, Weapon weapon)
        {
            //float cachedX=startX;
            //float cachedY=startY;

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

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

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

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

            cont = new GUIContent("Prefab:", "The prefab object of the weapon\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), weapon.gameObject, typeof(GameObject), false);

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


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

            cont = new GUIContent("Shoot Object:", "The prefab of the bullet/object fired by the weapon\nMust be a prefab with ShootObject component attached on it");
            EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
            weapon.shootObject = (GameObject)EditorGUI.ObjectField(new Rect(startX + spaceX, startY, width, height), weapon.shootObject, typeof(GameObject), false);

            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, startY += spaceY, spaceX, height), shootPointFoldout, cont);
            int shootPointCount = weapon.shootPointList.Count;

            shootPointCount = EditorGUI.DelayedIntField(new Rect(startX + spaceX, startY, 40, height), shootPointCount);

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

            if (shootPointFoldout)
            {
                for (int i = 0; i < weapon.shootPointList.Count; i++)
                {
                    int objID = GetObjectIDFromHList(weapon.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);
                    weapon.shootPointList[i] = (objHList[objID] == null) ? null : objHList[objID].transform;
                }
            }

            cont = new GUIContent("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 (weapon.shootPointList.Count > 1)
            {
                weapon.shootPointDelay = EditorGUI.DelayedFloatField(new Rect(startX + spaceX, startY, 40, height), weapon.shootPointDelay);
            }
            else
            {
                EditorGUI.LabelField(new Rect(startX + spaceX, startY, 40, height), "-");
            }


            startY += 5;

            cont = new GUIContent("Continous Fire:", "Check to enable continous firing on the weapon when holding down fire button");
            EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
            weapon.continousFire = EditorGUI.Toggle(new Rect(startX + spaceX, startY, 40, height), weapon.continousFire);

            startY += 5;

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

            cont = new GUIContent("Cooldown:", "The cooldown in seconds between subsequent shot");
            EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
            weapon.cooldown = EditorGUI.DelayedFloatField(new Rect(startX + spaceX, startY, 40, height), weapon.cooldown);

            startY += 5;

            cont = new GUIContent("UseEnergyAsAmmo:", "Check to use energy as ammunition");
            EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
            weapon.useEnergyAsAmmo = EditorGUI.Toggle(new Rect(startX + spaceX, startY, 40, height), weapon.useEnergyAsAmmo);

            cont = new GUIContent(" - Cost Per Shot:", "The energy cost per shot");
            EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
            if (!weapon.useEnergyAsAmmo)
            {
                EditorGUI.LabelField(new Rect(startX + spaceX, startY, 40, height), "-");
            }
            else
            {
                weapon.energyCost = EditorGUI.DelayedFloatField(new Rect(startX + spaceX, startY, 40, height), weapon.energyCost);
            }

            startY += 5;

            cont = new GUIContent("Clip Size:", "How many times the weapon can be fired before it needs a reload. Set to -1 if the weapon can be fired indefinitely without reloading");
            EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
            if (weapon.useEnergyAsAmmo)
            {
                EditorGUI.LabelField(new Rect(startX + spaceX, startY, 40, height), "-");
            }
            else
            {
                weapon.clipSize = EditorGUI.DelayedIntField(new Rect(startX + spaceX, startY, 40, height), weapon.clipSize);
            }

            cont = new GUIContent("Ammo Cap:", "How many ammo of the weapon the player can keep. Set to -1 if the weapon has unlimited ammo cap");
            EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
            if (weapon.useEnergyAsAmmo)
            {
                EditorGUI.LabelField(new Rect(startX + spaceX, startY, 40, height), "-");
            }
            else
            {
                weapon.ammoCap = EditorGUI.DelayedIntField(new Rect(startX + spaceX, startY, 40, height), weapon.ammoCap);
            }

            cont = new GUIContent("Reload Duration:", "The duration in seconds to reload the weapon");
            EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
            if (weapon.useEnergyAsAmmo)
            {
                EditorGUI.LabelField(new Rect(startX + spaceX, startY, 40, height), "-");
            }
            else
            {
                weapon.reloadDuration = EditorGUI.DelayedFloatField(new Rect(startX + spaceX, startY, 40, height), weapon.reloadDuration);
            }

            startY += 5;

            cont = new GUIContent("Recoil:", "The recoil magnitude of the weapon. The higher the value, the less accurate the weapon become when fired continously");
            EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
            weapon.recoilMagnitude = EditorGUI.DelayedFloatField(new Rect(startX + spaceX, startY, 40, height), weapon.recoilMagnitude);

            cont = new GUIContent("Recoil Cam Shake:", "The camera shake magnitude whenever the weapon is fired");
            EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
            weapon.recoilCamShake = EditorGUI.DelayedFloatField(new Rect(startX + spaceX, startY, 40, height), weapon.recoilCamShake);

            startY += 5;

            cont = new GUIContent("Spread:", "The number of shoot object split from each shoot point. This is to create a shotgun effect");
            EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
            weapon.spread = EditorGUI.DelayedIntField(new Rect(startX + spaceX, startY, 40, height), weapon.spread);
            weapon.spread = Mathf.Max(1, weapon.spread);

            cont = new GUIContent("Spread Angle:", "The angle (in degree) between each spread");
            EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
            if (weapon.spread > 1)
            {
                weapon.spreadAngle = EditorGUI.DelayedFloatField(new Rect(startX + spaceX, startY, 40, height), weapon.spreadAngle);
            }
            else
            {
                EditorGUI.LabelField(new Rect(startX + spaceX, startY, 40, height), "-");
            }

            startY += 10;

            Vector2 v2 = DrawAttackStats1(startX, startY + spaceY, weapon.aStats);

            startY = v2.y + 20;

            startY += 30;


            //int abilityIdx=weapon.ability==null ? 0 : TDSEditor.GetEffectIndex(weapon.ability.ID);
            //if(abilityIdx==0) weapon.ability=null;
            int abilityIdx = weapon.abilityID >= 0 ? TDSEditor.GetAbilityIndex(weapon.abilityID) : 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("AltAttack(Ability):", "Ability that is being used as the weapon alternate fire mode (optional)");
            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)
            {
                weapon.abilityID = abilityDB.abilityList[abilityIdx - 1].ID;
            }
            else
            {
                weapon.abilityID = -1;
            }

            //if(abilityIdx>0) weapon.ability=abilityDB.abilityList[abilityIdx-1];
            //else weapon.ability=null;


            startY += 15;


            cont = new GUIContent("Shoot SFX:", "Audio clip to play when the weapon fires (optional)");
            EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
            weapon.shootSFX = (AudioClip)EditorGUI.ObjectField(new Rect(startX + spaceX, startY, width, height), weapon.shootSFX, typeof(AudioClip), false);

            cont = new GUIContent("Reload SFX:", "Audio clip to play when the weapon reloads (optional)");
            EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
            weapon.reloadSFX = (AudioClip)EditorGUI.ObjectField(new Rect(startX + spaceX, startY, width, height), weapon.reloadSFX, typeof(AudioClip), false);


            startY += 15;

            GUIStyle style = new GUIStyle("TextArea");

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


            return(new Vector2(startX, startY + 200));
        }
Beispiel #14
0
        Vector2 DrawUnitConfigurator(float startX, float startY, UnitPlayer unit)
        {
            Vector2 v2 = DrawUnitBaseStats(startX, startY, unit, true);

            startY = v2.y;

            startY += 10;

            int objID = GetObjectIDFromHList(unit.turretObj, objHList);

            cont = new GUIContent("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;

            objID = GetObjectIDFromHList(unit.weaponMountPoint, objHList);
            cont  = new GUIContent("WeaponMount:", "The transform where the weapon object to be anchored to as child object");
            EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
            objID = EditorGUI.Popup(new Rect(startX + spaceX, startY, width, height), objID, objHLabelList);
            unit.weaponMountPoint = (objHList[objID] == null) ? null : objHList[objID].transform;

            startY += 10;

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

            cont = new GUIContent("Enable All   -  ", "Check to enable all weapons");
            EditorGUI.LabelField(new Rect(startX + spaceX + 50, startY, width, height), cont);
            unit.enableAllWeapons = EditorGUI.Toggle(new Rect(startX + spaceX + width - 15, startY, width, height), unit.enableAllWeapons);

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

                    bool enabled       = unit.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)
                        {
                            unit.weaponList.Insert(enabledCount, weapon);
                        }
                        else
                        {
                            unit.weaponList.Remove(weapon);
                        }
                    }

                    if (enabled)
                    {
                        enabledCount += 1;
                    }
                }

                startY += 10;
            }
            if (GUI.Button(new Rect(startX + spaceX + width - 100, startY += spaceY, 100, height - 2), "Weapon Editor"))
            {
                WeaponEditorWindow.Init();
            }


            startY += 20;


            unit.enableAbility = EditorGUI.Toggle(new Rect(startX, startY += spaceY, width, height), unit.enableAbility);
            EditorGUI.LabelField(new Rect(startX + 20, startY, width, height), "Abilities", headerStyle);

            if (unit.enableAbility)
            {
                cont = new GUIContent("Enable All   -  ", "Check to enable all abilities");
                EditorGUI.LabelField(new Rect(startX + spaceX + 50, startY, width, height), cont);
                unit.enableAllAbilities = EditorGUI.Toggle(new Rect(startX + spaceX + width - 15, startY, width, height), unit.enableAllAbilities);

                if (!unit.enableAllAbilities)
                {
                    int enabledCount = 0;
                    for (int i = 0; i < abilityDB.abilityList.Count; i++)
                    {
                        Ability ability = abilityDB.abilityList[i];

                        bool enabled       = unit.abilityIDList.Contains(ability.ID);
                        bool enabledCached = enabled;

                        TDSEditorUtility.DrawSprite(new Rect(startX + 20, startY += spaceY, 30, 30), ability.icon);
                        cont = new GUIContent(ability.name, ability.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)
                            {
                                unit.abilityIDList.Insert(enabledCount, ability.ID);
                            }
                            else
                            {
                                unit.abilityIDList.Remove(ability.ID);
                            }
                        }

                        if (enabled)
                        {
                            enabledCount += 1;
                        }
                    }

                    startY += 10;
                }
                if (GUI.Button(new Rect(startX + spaceX + width - 100, startY += spaceY, 100, height - 2), "Ability Editor"))
                {
                    AbilityEditorWindow.Init();
                }
            }

            startY += 10;


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

            cont = new GUIContent("EnableTurretAiming:", "Check to allow turret object to rotate and aim towards cursor position");
            EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
            unit.enableTurretRotate = EditorGUI.Toggle(new Rect(startX + spaceX, startY, width, height), unit.enableTurretRotate);

            cont = new GUIContent("Turret Aim Mode:", "The way in which the turret aim direction will be calculated");
            EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
            if (unit.enableTurretRotate)
            {
                int aimMode = (int)unit.turretAimMode;
                contL = new GUIContent[turretAimModeLabel.Length];
                for (int i = 0; i < contL.Length; i++)
                {
                    contL[i] = new GUIContent(turretAimModeLabel[i], turretAimModeTooltip[i]);
                }
                aimMode            = EditorGUI.Popup(new Rect(startX + spaceX, startY, width, 15), new GUIContent(""), aimMode, contL);
                unit.turretAimMode = (_TurretAimMode)aimMode;
            }
            else
            {
                EditorGUI.LabelField(new Rect(startX + spaceX, startY, width, height), "-");
            }

            cont = new GUIContent("Aim At Move Dir.:", "Check to have the unit's aim locked with it's move direction");
            EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
            if (unit.enableTurretRotate)
            {
                EditorGUI.LabelField(new Rect(startX + spaceX, startY, width, height), "-");
            }
            else
            {
                unit.aimAtTravelDirection = EditorGUI.Toggle(new Rect(startX + spaceX, startY, width, height), unit.aimAtTravelDirection);
            }

            startY += 10;

            cont = new GUIContent("FaceTravelDirection:", "Enable to have the unit's transform rotates to face its travel direction");
            EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
            unit.faceTravelDirection = EditorGUI.Toggle(new Rect(startX + spaceX, startY, width, height), unit.faceTravelDirection);

            cont = new GUIContent("x-axis movement:", "Check to enabled unit movement in x-axis");
            EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
            unit.enabledMovementX = EditorGUI.Toggle(new Rect(startX + spaceX, startY, width, height), unit.enabledMovementX);

            cont = new GUIContent("z-axis movement:", "Check to enabled unit movement in z-axis");
            EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
            unit.enabledMovementZ = EditorGUI.Toggle(new Rect(startX + spaceX, startY, width, height), unit.enabledMovementZ);

            startY += 10;

            int mode = (int)unit.movementMode;

            cont = new GUIContent("Movement Mode:", "The way in which the movement of the unit is handled with regard to the input");
            EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
            contL = new GUIContent[movementModeLabel.Length];
            for (int i = 0; i < contL.Length; i++)
            {
                contL[i] = new GUIContent(movementModeLabel[i], movementModeTooltip[i]);
            }
            mode = EditorGUI.Popup(new Rect(startX + spaceX, startY, width, 15), new GUIContent(""), mode, contL);
            unit.movementMode = (_MovementMode)mode;

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

            cont = new GUIContent("Boost Speed Mul:", "Speed-Multiplier(rigid mode)/Acceleration-Multiplier(free-form mode) when using boost (left-shift by default)");
            EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
            unit.boostMultiplier = EditorGUI.DelayedFloatField(new Rect(startX + spaceX, startY, 40, height), unit.boostMultiplier);

            cont = new GUIContent("Boost Energy Rate:", "Energy consumption rate (per second) when using boost (left-shift by default)\n0.3 being 30% of total energy per second");
            EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
            unit.boostEnergyRate = EditorGUI.DelayedFloatField(new Rect(startX + spaceX, startY, 40, height), unit.boostEnergyRate);

            if (unit.movementMode == _MovementMode.FreeForm)
            {
                cont = new GUIContent("Acceleration:", "The acceleration of the unit");
                EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
                unit.acceleration = EditorGUI.DelayedFloatField(new Rect(startX + spaceX, startY, 40, height), unit.acceleration);

                cont = new GUIContent("Decceleration:", "The rate of the unit losing it's speed");
                EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
                unit.decceleration = EditorGUI.DelayedFloatField(new Rect(startX + spaceX, startY, 40, height), unit.decceleration);

                cont = new GUIContent("Active Braking:", "Stopping power when using active braking (space by default)");
                EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
                unit.activeBrakingRate = EditorGUI.DelayedFloatField(new Rect(startX + spaceX, startY, 40, height), unit.activeBrakingRate);
            }

            startY += 10;


            cont = new GUIContent("Enable Limit ", "Check to limit player movement to a defined area");
            EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
            unit.useLimit = EditorGUI.Toggle(new Rect(startX + spaceX, startY, 30, height), unit.useLimit);

            if (unit.useLimit)
            {
                cont         = new GUIContent("Show", "");
                limitFoldout = EditorGUI.Foldout(new Rect(startX + spaceX + 40, startY, spaceX, height), limitFoldout, cont);

                if (limitFoldout)
                {
                    cont = new GUIContent("x-axis (min/max):", "Stopping power when using active braking (space by default)");
                    EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
                    unit.minPosX = EditorGUI.DelayedFloatField(new Rect(startX + spaceX, startY, 70, height), unit.minPosX);
                    unit.maxPosX = EditorGUI.DelayedFloatField(new Rect(startX + spaceX + 75, startY, 70, height), unit.maxPosX);

                    cont = new GUIContent("z-axis (min/max):", "Stopping power when using active braking (space by default)");
                    EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
                    unit.minPosZ = EditorGUI.DelayedFloatField(new Rect(startX + spaceX, startY, 70, height), unit.minPosZ);
                    unit.maxPosZ = EditorGUI.DelayedFloatField(new Rect(startX + spaceX + 75, startY, 70, height), unit.maxPosZ);
                }
            }

            startY += 10;

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

            startY = v3.y + 20;


            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));
        }
        Vector2 DrawSpawnerConfigurator(float startX, float startY, CollectibleSpawner spawner)
        {
            startY += 10;

            cont = new GUIContent("Spawn Area:", "The area which the unit should be spawn in\nIf unspecified, the unit will simply be spawned at the position of the spawner");
            EditorGUI.LabelField(new Rect(startX, startY, width, height), cont);
            spawner.spawnArea = (TDSArea)EditorGUI.ObjectField(new Rect(startX + spaceX, startY, width, height), spawner.spawnArea, typeof(TDSArea), true);

            startY += 10;

            if (GUI.Button(new Rect(startX + spaceX + width + 20, startY, 80, height), "Assign Self"))
            {
                TDSArea area = spawner.gameObject.GetComponent <TDSArea>();
                if (area == null)
                {
                    area = spawner.gameObject.AddComponent <TDSArea>();
                }
                spawner.spawnArea = area;
            }

            cont = new GUIContent("Spawn Upon Start:", "Check to have the spawner start spawning as soon as the game start");
            EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
            spawner.spawnUponStart = EditorGUI.Toggle(new Rect(startX + spaceX, startY, width, height), spawner.spawnUponStart);

            cont = new GUIContent("Start Delay:", "Delay (in second) before the spawning start");
            EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
            //if(spawner.spawnUponStart)
            spawner.startDelay = EditorGUI.DelayedFloatField(new Rect(startX + spaceX, startY, 40, height), spawner.startDelay);
            //else
            //	EditorGUI.LabelField(new Rect(startX+spaceX, startY, 40, height), "-");

            startY += 10;

            cont = new GUIContent("Spawn Cooldown:", "The cooldown between each spawn attempt");
            EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
            spawner.spawnCD = EditorGUI.DelayedFloatField(new Rect(startX + spaceX, startY, 40, height), spawner.spawnCD);

            cont = new GUIContent("Max Item Count:", "The maximum amount of active item in the game allowed by this spawner at any given item");
            EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
            spawner.maxItemCount = EditorGUI.DelayedIntField(new Rect(startX + spaceX, startY, 40, height), spawner.maxItemCount);

            cont = new GUIContent("Spawn Chance:", "The chance to successfully spawn an item during each cooldown cycle. Takes value from 0-1 with 0.3 being 30% to successfully spawn an item");
            EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
            spawner.spawnChance = EditorGUI.DelayedFloatField(new Rect(startX + spaceX, startY, 40, height), spawner.spawnChance);

            cont = new GUIContent("Fail Modifier:", "A modifier to the spawn chance should a spawn attempt fail (to prevent the attempt fail too many time in a row). ie if modifier is set as 0.1, each fail attempt will increase the spawn chance by 10%");
            EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
            spawner.failModifier = EditorGUI.DelayedFloatField(new Rect(startX + spaceX, startY, 40, height), spawner.failModifier);

            startY += 10;

            cont = new GUIContent("Spawn Item:", "The collectible item available to this spawner");
            EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont, headerStyle);

            int enabledCount = 0;

            for (int i = 0; i < collectibleDB.collectibleList.Count; i++)
            {
                Collectible colt = collectibleDB.collectibleList[i];


                CollectibleSpawnInfo spawnInfo = null;

                bool enabled = false;
                for (int n = 0; n < spawner.spawnItemList.Count; n++)
                {
                    enabled = spawner.spawnItemList[n].item == colt;
                    if (enabled)
                    {
                        spawnInfo = spawner.spawnItemList[n];
                        break;
                    }
                }
                bool enabledCached = enabled;

                float cachedX = startX;

                TDSEditorUtility.DrawSprite(new Rect(startX + 10, startY += spaceY, 30, 30), colt.icon, colt.desp);
                cont = new GUIContent(colt.collectibleName, colt.desp);
                EditorGUI.LabelField(new Rect(startX + 50, startY += 10, width, height), cont);
                enabled = EditorGUI.Toggle(new Rect(startX += (width), startY, 20, height), enabled);

                if (spawnInfo != null)
                {
                    cont = new GUIContent("Chance:", "Chance to spawn this item.\nThe way it works is a check against the individual item chance.\nA final candidate is then chosen over all item that pass the check.\nTakes value from 0-1 with 0.3 being 30% to pass the check");
                    EditorGUI.LabelField(new Rect(startX += 35, startY, width, height), cont);
                    spawnInfo.chance = EditorGUI.DelayedFloatField(new Rect(startX + 55, startY, 40, height), spawnInfo.chance);

                    cont = new GUIContent("Cooldown:", "The duration (in second) in which the item will be made unavailable after a successful spawn");
                    EditorGUI.LabelField(new Rect(startX += 120, startY, width, height), cont);
                    spawnInfo.cooldown = EditorGUI.DelayedFloatField(new Rect(startX + 65, startY, 40, height), spawnInfo.cooldown);
                }

                if (enabled != enabledCached)
                {
                    if (enabled)
                    {
                        spawnInfo      = new CollectibleSpawnInfo();
                        spawnInfo.item = colt;
                        spawner.spawnItemList.Insert(enabledCount, spawnInfo);
                    }
                    else
                    {
                        spawner.spawnItemList.Remove(spawnInfo);
                    }
                }

                if (enabled)
                {
                    enabledCount += 1;
                }

                startY += 4;

                startX = cachedX;
            }

            return(new Vector2(startX, startY + (1.5f * spaceY)));
        }
Beispiel #16
0
        Vector2 DrawEffectConfigurator(float startX, float startY, Effect effect)
        {
            //float cachedX=startX;
            //float cachedY=startY;

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

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

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

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


            cont = new GUIContent("Show On UI:", "Check to show the effect icon on UI when it's applied on player\nOnly applies to default UI");
            EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
            effect.showOnUI = EditorGUI.Toggle(new Rect(startX + spaceX, startY, 40, height), effect.showOnUI);

            startY += 10;

            cont = new GUIContent("Hit Chance:", "The chance of the effect being applied successfully. Takes value from 0-1 with 0.7 being 70%");
            EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
            effect.hitChance = EditorGUI.FloatField(new Rect(startX + spaceX, startY, 40, height), effect.hitChance);

            cont = new GUIContent("Duration:", "The active duration of the effect in seconds");
            EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
            effect.duration = EditorGUI.FloatField(new Rect(startX + spaceX, startY, 40, height), effect.duration);

            startY += 10;

            cont = new GUIContent("Restore HitPoint:", "Amount of hit-point to be restored to the unit per seconds while the effect is active");
            EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
            effect.restoreHitPoint = EditorGUI.FloatField(new Rect(startX + spaceX, startY, 40, height), effect.restoreHitPoint);

            cont = new GUIContent("Restore Energy:", "Amount of energy to be restored to the unit per seconds while the effect is active");
            EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
            effect.restoreEnergy = EditorGUI.FloatField(new Rect(startX + spaceX, startY, 40, height), effect.restoreEnergy);

            startY += 10;

            cont = new GUIContent("Speed Multiplier:", "The speed multiplier to be applied to the unit's speed. Stacks with other effects.\n - 0.7 means 70% of the default speed\n - 1.5 means 150% of the default speed");
            EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
            effect.speedMul = EditorGUI.FloatField(new Rect(startX + spaceX, startY, 40, height), effect.speedMul);

            cont = new GUIContent("Stun:", "Check if the effect stuns the target. Stunned unit cannot move or attack");
            EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
            effect.stun = EditorGUI.Toggle(new Rect(startX + spaceX, startY, 40, height), effect.stun);

            cont = new GUIContent("Invincible:", "Check if the effect makes the target invincible. Invincible unit are immuned to all damage and effect");
            EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
            effect.invincible = EditorGUI.Toggle(new Rect(startX + spaceX, startY, 40, height), effect.invincible);

            startY += 10;

            cont = new GUIContent("Damage Multiplier:", "The damage multiplier to be applied to the unit's damage. Stacks with other effects.\n - 0.7 means 70% of the default deamge\n - 1.5 means 150% of the default damage");
            EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
            effect.damageMul = EditorGUI.FloatField(new Rect(startX + spaceX, startY, 40, height), effect.damageMul);

            cont = new GUIContent("Crit Chance Mul.:", "The critical chance multiplier to be applied to the unit's critical chance. Stacks with other effects.\n - 0.7 means 70% of the default value\n - 1.5 means 150% of the default value");
            EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
            effect.critChanceMul = EditorGUI.FloatField(new Rect(startX + spaceX, startY, 40, height), effect.critChanceMul);

            cont = new GUIContent("Crit Multiplier Mul.:", "The critical multiplier to be applied to the unit's critical multiplier. Stacks with other effects.\n - 0.7 means 70% of the default value\n - 1.5 means 150% of the default value");
            EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
            effect.critMultiplierMul = EditorGUI.FloatField(new Rect(startX + spaceX, startY, 40, height), effect.critMultiplierMul);

            startY += 10;

            GUIStyle style = new GUIStyle("TextArea");

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


            return(new Vector2(startX, startY + 200));
        }