Пример #1
0
    public void AddToFeed(string killerName, string victimName, int weaponIndex, bool queued = false)
    {
        if (feedList.Count >= queueBuffer)
        {
            feedQueue.Add(new KillContainer(killerName, victimName, weaponIndex));
            return;
        }

        UILabel newFeedInstance = (UILabel)Instantiate(labelPrefab);

        newFeedInstance.transform.parent     = killFeedParent;
        newFeedInstance.transform.localScale = Vector3.one;
        newFeedInstance.fontSize             = fontSize;

        if (weaponIndex >= 0)
        {
            string killedBy = (weaponIndex >= 200) ? GrenadeDatabase.GetGrenadeByID(weaponIndex - 200).grenadeName : WeaponDatabase.GetWeaponByID(weaponIndex).gunName;
            newFeedInstance.text = killerName + " [" + killedBy + "] " + victimName;
        }
        else
        {
            newFeedInstance.text = killerName + " killed " + victimName;
        }

        KillFeedItem kfi = newFeedInstance.GetComponent <KillFeedItem>();

        kfi.manager   = this;
        kfi.targetPos = -Vector3.up * feedList.Count * feedSpacing;
        kfi.Initialize((queued) ? feedDuration * Random.Range(0.75f, 0.85f) : feedDuration); //yay for variety

        feedList.Add(newFeedInstance);
    }
Пример #2
0
    private void DrawGrenade(int grenadeID)
    {
        meleeObject.SetActive(false);

        GrenadeController toInstantiate = GrenadeDatabase.GetGrenadeByID(grenadeID);
        GrenadeController grenInstance  = (GrenadeController)Instantiate(toInstantiate);

        grenInstance.transform.parent        = weaponsParent;
        grenInstance.transform.localPosition = toInstantiate.thirdPersonPosition;
        grenInstance.transform.localRotation = toInstantiate.thirdPersonRotation;
        grenInstance.PrepareForMultiplayer();
        GetComponent <AudioSource>().PlayOneShot(drawSound, 0.7f);

        pullPinSound               = toInstantiate.pullPinSound;
        throwSound                 = toInstantiate.throwSound;
        currentGHP                 = grenInstance.GetComponent <GrenadeHandler_Proxy>();
        currentGHP.whp             = this;
        currentGHP.grenadePrefab   = grenInstance.grenadePrefab;
        currentGHP.displayMesh     = grenInstance.displayMesh;
        currentGHP.throwStr        = grenInstance.throwStrength;
        currentGHP.tossStr         = grenInstance.tossStrength;
        currentGHP.ignoreColliders = ignoreGrenades;
        baseDelay       = grenInstance.baseDelay;
        detonationDelay = grenInstance.detonationDelay;
        Destroy(grenInstance);

        currentGC      = null;
        currentVisuals = null;
    }
    public override void OnInspectorGUI()
    {
        GrenadeManager     gm  = target as GrenadeManager;
        GrenadeAmmoManager gam = gm.transform.parent.parent.GetComponent <GrenadeAmmoManager>();

        if (gm.nadeList == null)
        {
            gm.nadeList = (GrenadeList)EditorGUILayout.ObjectField("Grenade List Prefab:", gm.nadeList, typeof(GrenadeList), true);
            EditorGUILayout.HelpBox("Not assigning this variable will have a heavy performance cost!", MessageType.Warning);
        }

        GUILayout.Space(6);
        EditorGUILayout.LabelField(" To Be Instantiated:", EditorStyles.boldLabel);

        EditorGUI.indentLevel += 1;
        EditorGUILayout.ObjectField(" Grenade Slot #1:", GrenadeDatabase.GetGrenadeByID(gam.grenadeTypeOne), typeof(GrenadeController), false);
        EditorGUILayout.ObjectField(" Grenade Slot #2:", GrenadeDatabase.GetGrenadeByID(gam.grenadeTypeTwo), typeof(GrenadeController), false);
        EditorGUI.indentLevel -= 1;
    }
Пример #4
0
    public GrenadeController AddGrenadeToInventory(int targetID)
    {
        if (targetID < 0)
        {
            return(null);
        }

        GrenadeController instantiation = (GrenadeController)Instantiate(GrenadeDatabase.GetGrenadeByID(targetID));

        if (instantiation != null)
        {
            Transform tra = instantiation.transform;
            tra.parent        = transform;
            tra.localPosition = Vector3.zero;
            tra.localRotation = Quaternion.identity;
            instantiation.Initialize();
            instantiation.gameObject.SetActive(false);
        }

        return(instantiation);
    }
Пример #5
0
    public override void OnInspectorGUI()
    {
        GrenadeAmmoManager gam = target as GrenadeAmmoManager;

        GUILayout.Space(5);

        if (GrenadeDatabase.publicGrenadeControllers.Length <= 0)
        {
            GUILayout.Box("You must have at least 1 grenade in the database to enable this manager!");
            gam.grenadeTypeOne = -1;
            gam.grenadeTypeTwo = -1;
            return;
        }

        int typeOneValue = Mathf.Clamp(gam.grenadeTypeOne, -1, GrenadeDatabase.publicGrenadeControllers.Length - 1);

        EditorGUILayout.LabelField("Grenade Slot #1 (" + ((typeOneValue == -1) ? "None" : GrenadeDatabase.GetGrenadeByID(typeOneValue).name) + ")", EditorStyles.boldLabel);
        EditorGUI.indentLevel += 1;
        gam.grenadeTypeOne     = EditorGUILayout.IntField("Grenade ID:", typeOneValue);

        if (gam.grenadeTypeOne == -1)
        {
            GUI.enabled = false;
        }

        gam.typeOneGrenades    = EditorGUILayout.IntSlider("  Grenade Amount:", gam.typeOneGrenades, 0, gam.typeOneMaxGrenades);
        gam.typeOneMaxGrenades = EditorGUILayout.IntField("  Max Grenades:", gam.typeOneMaxGrenades);
        GUI.enabled            = true;
        EditorGUI.indentLevel -= 1;

        DarkRef.GUISeparator();

        int typeTwoValue = Mathf.Clamp(gam.grenadeTypeTwo, -1, GrenadeDatabase.publicGrenadeControllers.Length - 1);

        if (typeTwoValue == typeOneValue && typeOneValue > -1)
        {
            if (typeTwoValue < GrenadeDatabase.publicGrenadeControllers.Length - 1)
            {
                typeTwoValue++;
            }
            else
            {
                typeTwoValue--;
            }
        }

        if (GrenadeDatabase.publicGrenadeControllers.Length < 2)
        {
            GUILayout.Box("You must have at least 2 grenades in the database in order to enable the second slot!");
            GUI.enabled = false;
        }
        else
        {
            EditorGUILayout.LabelField("Grenade Slot #2 (" + ((typeTwoValue == -1) ? "None" : GrenadeDatabase.GetGrenadeByID(typeTwoValue).name) + ")", EditorStyles.boldLabel);
            EditorGUI.indentLevel += 1;
            gam.grenadeTypeTwo     = EditorGUILayout.IntField("Grenade ID:", typeTwoValue);

            if (gam.grenadeTypeTwo == -1)
            {
                GUI.enabled = false;
            }

            gam.typeTwoGrenades    = EditorGUILayout.IntSlider("  Grenade Amount:", gam.typeTwoGrenades, 0, gam.typeTwoMaxGrenades);
            gam.typeTwoMaxGrenades = EditorGUILayout.IntField("  Max Grenades:", gam.typeTwoMaxGrenades);
            EditorGUI.indentLevel -= 1;
        }

        if (GUI.changed)
        {
            EditorUtility.SetDirty(gam);
        }
    }
Пример #6
0
    public override void OnInspectorGUI()
    {
        GrenadeController gc = target as GrenadeController;

        GUI.color      = new Color(1f, 0.8f, 0.6f, 1f);
        gc.grenadeName = EditorGUILayout.TextField("Grenade Name:", gc.grenadeName);
        GUI.color      = new Color(0.8f, 0.8f, 0.8f, 1f);
        EditorGUIUtility.labelWidth = 140f;
        gc.grenadeIcon = (Texture2D)EditorGUILayout.ObjectField("  Icon Texture:", gc.grenadeIcon, typeof(Texture2D));
        EditorGUIUtility.LookLikeControls();
        GUI.color = Color.white;

        GUILayout.Space(10);

        gc.isDetonatable = EditorGUILayout.Toggle(" Is Detonatable:", gc.isDetonatable);

        if (gc.isDetonatable)
        {
            gc.baseDelay       = EditorGUILayout.FloatField(" Initial Delay:", Mathf.Clamp(gc.baseDelay, 0f, 5f));
            gc.detonationDelay = EditorGUILayout.FloatField(" Detonation Interval:", Mathf.Clamp(gc.detonationDelay, 0f, 5f));
        }

        GUILayout.Space(10);

        gc.throwPos      = (Transform)EditorGUILayout.ObjectField(" Throw Position:", gc.throwPos, typeof(Transform), true);
        gc.grenadePrefab = (Rigidbody)EditorGUILayout.ObjectField((gc.isDetonatable) ? " Explosive Prefab:" : " Grenade Prefab:", gc.grenadePrefab, typeof(Rigidbody), true);
        gc.displayMesh   = (MeshRenderer)EditorGUILayout.ObjectField(" Display Mesh:", gc.displayMesh, typeof(MeshRenderer), true);

        GUILayout.Space(10);

        EditorGUIUtility.labelWidth = 150f;
        gc.throwThreshold           = EditorGUILayout.FloatField(" Throw Threshold:", Mathf.Clamp(gc.throwThreshold, 0f, 5f));
        gc.cookingThreshold         = EditorGUILayout.FloatField(" Cooking Threshold:", Mathf.Clamp(gc.cookingThreshold, 0f, 10f));
        GUILayout.Space(5);
        gc.throwStrength = EditorGUILayout.FloatField(" Throw Strength:", Mathf.Clamp(gc.throwStrength, 0f, 1000f));

        if (!gc.isDetonatable)
        {
            gc.tossStrength = EditorGUILayout.FloatField(" Toss Strength:", Mathf.Clamp(gc.tossStrength, 0f, 1000f));
        }

        EditorGUIUtility.LookLikeControls();

        GUILayout.Space(10);

        EditorGUILayout.LabelField("Sounds", EditorStyles.boldLabel);
        EditorGUI.indentLevel += 1;

        gc.pullPinSound = (AudioClip)EditorGUILayout.ObjectField((gc.isDetonatable) ? "Detonation Sound:" : "Pull Pin Sound:", gc.pullPinSound, typeof(AudioClip), true);

        gc.throwSound          = (AudioClip)EditorGUILayout.ObjectField("Throw Sound:", gc.throwSound, typeof(AudioClip), true);
        EditorGUI.indentLevel -= 1;

        GUILayout.Space(6);

        EditorGUILayout.LabelField("Third Person Variables (MP)", EditorStyles.boldLabel);
        EditorGUI.indentLevel += 1;
        EditorGUILayout.LabelField("Local Position: " + DarkRef.PreciseStringVector3(gc.thirdPersonPosition));
        EditorGUILayout.LabelField("Local Rotation: " + DarkRef.PreciseStringVector3(gc.thirdPersonRotation.eulerAngles));

        GUILayout.Space(8f);

        if (gc.transform.parent != null && gc.transform.parent.name == "WeaponsParent" && GUILayout.Button("Preview Transform Info"))
        {
            gc.transform.localPosition = gc.thirdPersonPosition;
            gc.transform.localRotation = gc.thirdPersonRotation;
        }

        if (GUILayout.Button("Set Transform Info"))
        {
            GrenadeController prefab = GrenadeDatabase.GetGrenadeByID(gc.grenadeID);
            prefab.thirdPersonPosition = gc.transform.localPosition;
            prefab.thirdPersonRotation = gc.transform.localRotation;

            gc.thirdPersonPosition = gc.transform.localPosition;
            gc.thirdPersonRotation = gc.transform.localRotation;
        }

        EditorGUI.indentLevel -= 1;

        DarkRef.GUISeparator(8f);

        GUI.color = new Color(0.7f, 0.7f, 0.7f, 1f);
        EditorGUIUtility.labelWidth = 210f;
        EditorGUILayout.IntField("Grenade ID:", gc.grenadeID);
        EditorGUIUtility.LookLikeControls();

        if (GUI.changed)
        {
            EditorUtility.SetDirty(gc);
        }
    }
Пример #7
0
    void OnGUI()
    {
        if (settingsPrefab == null)
        {
            GUI.enabled = false;
        }

        if (GUILayout.Button("Initialize Assignment of Grenade IDs"))
        {
            GrenadeDatabase.Initialize();
        }
        if (GUILayout.Button("Clear Grenade IDs"))
        {
            GrenadeDatabase.customGrenadeList = new GrenadeController[0];
            GrenadeList temp = (GrenadeList)Instantiate(settingsPrefab);
            temp.savedGrenades = new GrenadeController[0];
            GrenadeDatabase.RefreshIDs();
            PrefabUtility.ReplacePrefab(temp.gameObject, settingsPrefab, ReplacePrefabOptions.Default);
            DestroyImmediate(temp.gameObject);
            GrenadeDatabase.Initialize();
        }
        if (GUILayout.Button("Auto-fill Grenade IDs"))
        {
            Object[] resourcesGC = Resources.LoadAll("Explosive Controllers", typeof(GrenadeController));
            GrenadeDatabase.customGrenadeList = new GrenadeController[resourcesGC.Length];

            for (int i = 0; i < resourcesGC.Length; i++)
            {
                GrenadeDatabase.customGrenadeList[i] = (GrenadeController)resourcesGC[i];
            }

            GrenadeList temp = (GrenadeList)Instantiate(settingsPrefab);
            temp.savedGrenades = GrenadeDatabase.customGrenadeList;

            GrenadeDatabase.RefreshIDs();
            PrefabUtility.ReplacePrefab(temp.gameObject, settingsPrefab, ReplacePrefabOptions.Default);
            DestroyImmediate(temp.gameObject);
            WeaponDatabase.Initialize();
        }

        GUI.enabled = true;

        GUILayout.Space(10);

        EditorGUIUtility.labelWidth = 120f;
        GUILayout.Box("Prefab Directory:   MAIN - Blackraze/Resources/Static Prefabs", GUILayout.MaxWidth(500), GUILayout.Height(20));

        if (settingsPrefab)
        {
            EditorGUILayout.ObjectField("Settings Prefab:", settingsPrefab, typeof(GrenadeList), false, GUILayout.MaxWidth(350));
        }
        else
        {
            GrenadeList savedGL = (GrenadeList)Resources.Load("Static Prefabs/Grenade List", typeof(GrenadeList));
            if (savedGL)
            {
                settingsPrefab = savedGL;
                GrenadeDatabase.customGrenadeList = savedGL.savedGrenades;
            }
            else
            {
                GUI.color = new Color(1f, 0.2f, 0f, 1f);
                if (GUILayout.Button("Generate Prefab", GUILayout.MaxWidth(120)))
                {
                    if (settingsPrefab == null)
                    {
                        GameObject go = new GameObject("Grenade List");
                        go.AddComponent <GrenadeList>();

                        settingsPrefab = PrefabUtility.CreatePrefab("Assets/MAIN - Blackraze/Resources/Static Prefabs/Grenade List.prefab", go, ReplacePrefabOptions.ConnectToPrefab).GetComponent <GrenadeList>();
                        DestroyImmediate(go);
                    }
                }
                GUI.color = Color.white;
            }
        }

        EditorGUIUtility.LookLikeControls();

        if (settingsPrefab == null)
        {
            GUI.color   = Color.gray;
            GUI.enabled = false;
        }
        else if (!settingsPrefab.GetComponent <GrenadeList>())
        {
            GUI.color   = Color.gray;
            GUI.enabled = false;
        }

        DarkRef.GUISeparator(10f);

        if (GUILayout.Button((inEditMode) ? "DONE" : "EDIT", GUILayout.MaxWidth(80)))
        {
            inEditMode = !inEditMode;

            if (!inEditMode)
            {
                GrenadeDatabase.RefreshIDs();
            }
        }

        EditorGUILayout.LabelField("Grenade ID List", EditorStyles.boldLabel);

        EditorGUILayout.BeginHorizontal();

        EditorGUI.indentLevel += 1;
        if (inEditMode)
        {
            int length = GrenadeDatabase.customGrenadeList.Length;
            GrenadeController[] tempStorage = GrenadeDatabase.customGrenadeList;
            EditorGUIUtility.labelWidth = 90f;
            length = EditorGUILayout.IntField("Length:", Mathf.Clamp(length, 0, 100), GUILayout.MaxWidth(150));
            EditorGUIUtility.LookLikeControls();
            if (length != GrenadeDatabase.customGrenadeList.Length)
            {
                GrenadeDatabase.customGrenadeList = new GrenadeController[length];
                for (int i = 0; i < tempStorage.Length; i++)
                {
                    if (i < GrenadeDatabase.customGrenadeList.Length)
                    {
                        GrenadeDatabase.customGrenadeList[i] = tempStorage[i];
                    }
                }
            }

            scrollPos              = EditorGUILayout.BeginScrollView(scrollPos, GUILayout.Width(Screen.width - 10), GUILayout.Height(Mathf.Clamp(Screen.height - 210, 1, Screen.height)));
            EditorGUI.indentLevel += 1;
            for (int i = 0; i < length; i++)
            {
                EditorGUIUtility.labelWidth          = 90f;
                GrenadeDatabase.customGrenadeList[i] = (GrenadeController)EditorGUILayout.ObjectField("Element #" + i.ToString(), GrenadeDatabase.customGrenadeList[i], typeof(GrenadeController), false, GUILayout.MaxWidth(330));
                EditorGUIUtility.LookLikeControls();
            }
            EditorGUI.indentLevel -= 1;
            EditorGUILayout.EndScrollView();

            if (GrenadeDatabase.customGrenadeList != settingsPrefab.savedGrenades)
            {
                settingsPrefab.savedGrenades = new GrenadeController[length];
                for (int i = 0; i < GrenadeDatabase.customGrenadeList.Length; i++)
                {
                    if (i < settingsPrefab.savedGrenades.Length)
                    {
                        settingsPrefab.savedGrenades[i] = GrenadeDatabase.customGrenadeList[i];
                    }
                }
            }
        }
        else
        {
            if (GrenadeDatabase.publicGrenadeControllers.Length <= 0)
            {
                EditorGUILayout.LabelField("[Press the 'EDIT' button above to get started]");
            }
            else
            {
                scrollPos = EditorGUILayout.BeginScrollView(scrollPos, GUILayout.Width(Screen.width - 10), GUILayout.Height(Mathf.Clamp(Screen.height - 210, 1, Screen.height)));
                for (int i = 0; i < GrenadeDatabase.publicGrenadeControllers.Length; i++)
                {
                    GrenadeController gc = GrenadeDatabase.publicGrenadeControllers[i];

                    if (gc != null)
                    {
                        if (gc.grenadeID <= -1)
                        {
                            EditorGUILayout.LabelField(i + " - (UNASSIGNED)");
                        }
                        else
                        {
                            EditorGUILayout.LabelField(i + " - " + gc.name);
                        }
                    }
                    else
                    {
                        EditorGUILayout.LabelField(i + " - (NULL)");
                    }
                }
                EditorGUILayout.EndScrollView();
            }
        }

        EditorGUILayout.EndHorizontal();

        EditorGUI.indentLevel -= 1;
    }