Пример #1
0
        public override void OnInspectorGUI()
        {
            base.OnInspectorGUI();

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

            GUI.changed = false;

            Undo.RecordObject(instance, "Collectible");

            EditorGUILayout.Space();


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


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

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

                EditorGUILayout.Space();
            }

            EditorGUILayout.Space();

            DrawFullEditor();

            EditorGUILayout.Space();

            DefaultInspector();

            serializedObject.ApplyModifiedProperties();
            if (GUI.changed)
            {
                EditorUtility.SetDirty(instance);
            }
        }
Пример #2
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));
        }
Пример #3
0
        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));
        }
Пример #4
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));
        }
Пример #5
0
        public override void OnInspectorGUI()
        {
            base.OnInspectorGUI();

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

            GUI.changed = false;

            Undo.RecordObject(instance, "Player");

            serializedObject.Update();

            EditorGUILayout.Space();

            cont = new GUIContent("Load Progress:", "Check to enable loading of progress made in leveling and perk unlocking from previous save");
            instance.loadProgress = EditorGUILayout.Toggle(cont, instance.loadProgress);
            cont = new GUIContent("Save Progress:", "Check to enable saving of progress made in leveling and perk unlocking");
            instance.saveProgress = EditorGUILayout.Toggle(cont, instance.saveProgress);

            cont = new GUIContent("Save Upon Change:", "Check to enable instant save upon any changes made\nOtherwise saving is only done player hits a save trigger");
            if (instance.saveProgress)
            {
                instance.saveUponChange = EditorGUILayout.Toggle(cont, instance.saveUponChange);
            }
            else
            {
                EditorGUILayout.LabelField(cont, new GUIContent("-"));
            }

            EditorGUILayout.Space();

            EditorGUILayout.BeginHorizontal();
            bool saveExisted = PlayerPrefs.HasKey("p" + instance.playerID + "_progress") | PlayerPrefs.HasKey("p" + instance.playerID + "_perk");

            EditorGUILayout.LabelField("Save Existed: " + (saveExisted ? "Yes" : "No"));
            if (saveExisted && GUILayout.Button("Delete Save"))
            {
                instance.DeleteSave();
            }
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.Space();


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

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

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


            EditorGUILayout.Space();

            DefaultInspector();


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