コード例 #1
0
        public override void OnInspectorGUI()
        {
            script     = (bl_Customizer)target;
            weaponName = script.WeaponName;

            GUILayout.BeginVertical("box");
            EditorGUI.BeginChangeCheck();
            GUILayout.BeginHorizontal("box");
            script.WeaponID = EditorGUILayout.Popup("Customizer ID", script.WeaponID, bl_CustomizerData.Instance.GetWeaponStringArray(), EditorStyles.toolbarDropDown);
            GUILayout.Space(5);
            if (GUILayout.Button("Refresh", EditorStyles.toolbarButton, GUILayout.Width(100)))
            {
                script.RefreshAttachments();
            }
            GUILayout.EndHorizontal();
            if (customizerManager != null && !customizerManager.AllCustom.Exists(x => x.WeaponID == script.WeaponID))
            {
                if (GUILayout.Button("Listed Customizer Weapon"))
                {
                    customizerManager.AllCustom.Add(script);
                    EditorUtility.SetDirty(customizerManager);
                }
            }
            if (GUI.changed)
            {
                script.WeaponName = bl_CustomizerData.Instance.Weapons[script.WeaponID].WeaponName;
                if (script.WeaponName != weaponName)
                {
                    script.BuildAttachments();
                    weaponName = script.WeaponName;
                }
            }

            serializedObject.Update();
            GUILayout.BeginHorizontal("box");
            GUILayout.Space(10);
            EditorGUILayout.PropertyField(camor, true);
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal("box");
            GUILayout.Space(10);
            EditorGUILayout.PropertyField(attac, true);
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal("box");
            GUILayout.Space(10);
            EditorGUILayout.PropertyField(positions, true);
            GUILayout.EndHorizontal();
            serializedObject.ApplyModifiedProperties();
            GUILayout.EndVertical();
            script.SeparateCurve      = EditorGUILayout.CurveField("Separate Curve", script.SeparateCurve);
            script.ChangeMovementPath = EditorGUILayout.CurveField("Change Movement Path", script.ChangeMovementPath);
            EditorGUI.EndChangeCheck();
            if (GUI.changed)
            {
                EditorUtility.SetDirty(target);
            }
        }
コード例 #2
0
        /// <summary>
        /// activate the object in the list with the name of the information
        /// </summary>
        /// <param name="t_active"></param>
        public void showCustomizerWeapon(bl_Customizer weaponToShow)
        {
            currentCustomizer = weaponToShow;
            RootAnim.Play("Change", 0, 0);
            isSave = false;
            float t = RootAnim.GetCurrentAnimatorStateInfo(0).length / 2;

            Invoke("ActiveInvoke", t);
        }
コード例 #3
0
 /// <summary>
 ///
 /// </summary>
 void ActiveInvoke()
 {
     foreach (bl_Customizer c in AllCustom)
     {
         c.gameObject.SetActive(false);
         if (c.WeaponID == currentCustomizer.WeaponID)
         {
             c.gameObject.SetActive(true);
             CurrentCustomizer = c;
             SeparateText.text = (CurrentCustomizer.Customize) ? "UNITE" : "SEPARATE";
         }
     }
 }
コード例 #4
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="c"></param>
        /// <returns></returns>
        private bool ActualSelect(bl_Customizer c)
        {
            bool b = false;

            foreach (bl_Customizer custom in AllCustom)
            {
                if (c == custom)
                {
                    if (custom.gameObject.activeSelf)
                    {
                        b = true;
                    }
                }
            }
            return(b);
        }
コード例 #5
0
        void SetupPlayerWeapons()
        {
            bl_Gun gun = script.GetComponent <bl_Gun>();

            if (gun != null)
            {
                int gunID = gun.GunID;
                script.WeaponID   = bl_CustomizerData.Instance.GetCustomizerID(gunID);
                script.WeaponName = bl_CustomizerData.Instance.Weapons[script.WeaponID].WeaponName;
                bl_CustomizerManager cm = FindObjectOfType <bl_CustomizerManager>();
                if (cm != null)
                {
                    bl_Customizer[] all = cm.transform.GetComponentsInChildren <bl_Customizer>(true);
                    for (int i = 0; i < all.Length; i++)
                    {
                        if (all[i].WeaponID == script.WeaponID)
                        {
                            _CustomizerWeapon  = all[i];
                            customizerSelected = i;
                        }
                    }
                    if (_CustomizerWeapon != null)
                    {
                        script.BuildAttachments();
                        script.CamoRender.MaterialID = _CustomizerWeapon.CamoRender.MaterialID;
                        Mesh         mesh = _CustomizerWeapon.CamoRender.Render.GetComponent <MeshFilter>().sharedMesh;
                        MeshFilter[] allm = script.transform.GetComponentsInChildren <MeshFilter>(true);
                        for (int i = 0; i < allm.Length; i++)
                        {
                            if (allm[i].sharedMesh == mesh)
                            {
                                script.CamoRender.Render = allm[i].GetComponent <MeshRenderer>();
                                _TargetMesh = script.CamoRender.Render.transform;
                            }
                        }
                    }
                    else
                    {
                        Debug.LogWarning("Can't find the Customizer weapon with GunID: " + gunID);
                    }
                }
            }
            else
            {
                Debug.LogWarning("You only can setup customizer weapon from the FPWeapon");
            }
        }
コード例 #6
0
        private void OnSceneGUI()
        {
            script = (bl_Customizer)target;

            if (editOpen)
            {
                script.Positions.BarrelPosition.position   = Handles.PositionHandle(script.Positions.BarrelPosition.position, Quaternion.identity);
                script.Positions.OpticPosition.position    = Handles.PositionHandle(script.Positions.OpticPosition.position, Quaternion.identity);
                script.Positions.FeederPosition.position   = Handles.PositionHandle(script.Positions.FeederPosition.position, Quaternion.identity);
                script.Positions.CylinderPosition.position = Handles.PositionHandle(script.Positions.CylinderPosition.position, Quaternion.identity);

                if (GUI.changed)
                {
                    EditorUtility.SetDirty(target);
                }
            }
            if (Handles.Button(script.transform.position, Quaternion.identity, 0.05f, 0.1f, Handles.RectangleHandleCap))
            {
                editOpen = !editOpen;
            }
        }
コード例 #7
0
        public void Init(bl_Customizer weapon)
        {
            lockedStatus     = 0;
            customizerWeapon = weapon;
            bl_GunInfo info = customizerWeapon.GetWeaponInfo();

            m_Text.text       = customizerWeapon.WeaponName;
            weaponIcon.sprite = info.GunIcon;

#if SHOP && ULSP
            if (info.Price > 0 && bl_DataBase.Instance != null)
            {
                if (bl_DataBase.Instance.LocalUser.ShopData.isItemPurchase(ShopItemType.Weapon, customizerWeapon.GunID()))
                {
                    lockedStatus = bl_ShopData.Instance.purchaseOverrideLevelLock ? 3 : 0;
                }
                else
                {
                    lockedStatus        = 1;
                    lockedText.text     = "PRICE: $" + info.Price;
                    button.interactable = false;
                }
            }
#endif
#if LM
            if (bl_GameData.Instance.LockWeaponsByLevel && (lockedStatus == 0 || lockedStatus == 3))
            {
                int  al     = bl_LevelManager.Instance.GetLevelID();
                bool UnLock = (al >= info.LevelUnlock);
                lockedStatus = UnLock ? lockedStatus : 2;
                if (!UnLock)
                {
                    lockedText.text     = "REQUIRES LEVEL: " + info.LevelUnlock;
                    button.interactable = false;
                }
            }
#endif

            lockedUI.SetActive(lockedStatus != 0 && lockedStatus != 3);
        }
コード例 #8
0
        void UpdateAttachemtns()
        {
            bl_Customizer[] all = customizerManager.transform.GetComponentsInChildren <bl_Customizer>(true);
            for (int i = 0; i < all.Length; i++)
            {
                if (all[i].WeaponID == script.WeaponID)
                {
                    _CustomizerWeapon  = all[i];
                    customizerSelected = i;
                }
            }
            int                 gunID         = script.GetComponent <bl_Gun>().GunID;
            bl_NetworkGun       ngun          = script.transform.root.GetComponentInChildren <bl_PlayerNetwork>().NetworkGuns.Find(x => x.LocalGun.GunID == gunID);
            bl_CustomizerWeapon networkScript = ngun.GetComponent <bl_CustomizerWeapon>();

            CompareLists(_CustomizerWeapon.Attachments.Foregrips, ref script.Attachments.Foregrips, ref networkScript.Attachments.Foregrips);
            CompareLists(_CustomizerWeapon.Attachments.Magazines, ref script.Attachments.Magazines, ref networkScript.Attachments.Magazines);
            CompareLists(_CustomizerWeapon.Attachments.Sights, ref script.Attachments.Sights, ref networkScript.Attachments.Sights);
            CompareLists(_CustomizerWeapon.Attachments.Suppressers, ref script.Attachments.Suppressers, ref networkScript.Attachments.Suppressers);
            EditorUtility.SetDirty(networkScript);
            EditorUtility.SetDirty(target);
        }
コード例 #9
0
        public void Init(bl_Customizer customizer)
        {
            cacheCustomizer = customizer;
            if (Barrel != null && cacheCustomizer.Positions.BarrelPosition != null)
            {
                Barrel.transform.position = cacheCustomizer.Positions.BarrelPosition.position;
            }
            if (Optics != null && cacheCustomizer.Positions.OpticPosition != null)
            {
                Optics.transform.position = cacheCustomizer.Positions.OpticPosition.position;
            }
            if (Feeder != null && cacheCustomizer.Positions.FeederPosition != null)
            {
                Feeder.transform.position = cacheCustomizer.Positions.FeederPosition.position;
            }
            if (Cylinder != null && cacheCustomizer.Positions.CylinderPosition != null)
            {
                Cylinder.transform.position = cacheCustomizer.Positions.CylinderPosition.position;
            }

            Feeder.gameObject.SetActive(customizer.Attachments.Foregrips.Count > 0);

            Active(false);
        }
コード例 #10
0
        public override void OnInspectorGUI()
        {
            GUILayout.BeginVertical("box");
            EditorGUI.BeginChangeCheck();
            GUILayout.BeginHorizontal("box");
            script.WeaponID = EditorGUILayout.Popup("Customizer ID", script.WeaponID, bl_CustomizerData.Instance.GetWeaponStringArray(), EditorStyles.toolbarDropDown);
            GUILayout.Space(5);
            if (GUILayout.Button("Refresh", EditorStyles.toolbarButton, GUILayout.Width(100)))
            {
                script.RefreshAttachments();
            }
            GUILayout.EndHorizontal();
            script.isFPWeapon   = EditorGUILayout.ToggleLeft("is First Person Weapon", script.isFPWeapon, EditorStyles.toolbarButton);
            script.ApplyOnStart = EditorGUILayout.ToggleLeft("Apply On Start", script.ApplyOnStart, EditorStyles.toolbarButton);
            if (GUI.changed)
            {
                script.WeaponName = bl_CustomizerData.Instance.Weapons[script.WeaponID].WeaponName;
                if (script.WeaponName != weaponName)
                {
                    script.BuildAttachments();
                    weaponName = script.WeaponName;
                }
            }

            serializedObject.Update();
            GUILayout.BeginHorizontal("box");
            GUILayout.Space(10);
            EditorGUILayout.PropertyField(camor, true);
            GUILayout.EndHorizontal();
            GUILayout.BeginHorizontal("box");
            GUILayout.Space(10);
            EditorGUILayout.PropertyField(attac, true);
            GUILayout.EndHorizontal();
            serializedObject.ApplyModifiedProperties();
            GUILayout.EndVertical();

            GUILayout.BeginHorizontal("box");
            GUI.enabled = customizerManager != null && script.isFPWeapon;
            if (GUILayout.Button("Import", EditorStyles.toolbarButton, GUILayout.Width(100)))
            {
                openImportMenu = !openImportMenu;
                if (openImportMenu)
                {
                    //ActiveEditorTracker.sharedTracker.isLocked = openImportMenu;

                    allCustomizers.Clear();
                    bl_CustomizerManager cm = FindObjectOfType <bl_CustomizerManager>();
                    if (cm != null)
                    {
                        bl_Customizer[] all = cm.transform.GetComponentsInChildren <bl_Customizer>(true);
                        for (int i = 0; i < all.Length; i++)
                        {
                            allCustomizers.Add(all[i].gameObject.name, all[i]);
                            if (all[i].WeaponID == script.WeaponID)
                            {
                                _CustomizerWeapon  = all[i];
                                customizerSelected = i;
                            }
                        }
                        if (script.CamoRender.Render == null)
                        {
                            SetupPlayerWeapons();
                        }
                    }
                }
            }
            GUILayout.Space(5);
            if (GUILayout.Button("Update Attachments", EditorStyles.toolbarButton, GUILayout.Width(200)))
            {
                UpdateAttachemtns();
            }
            GUILayout.EndHorizontal();
            GUI.enabled = true;

            if (openImportMenu)
            {
                GUILayout.BeginVertical("box");
                if (script.CamoRender.Render == null)
                {
                    if (allCustomizers.Count > 0)
                    {
                        if (GUILayout.Button("Setup FP and TP Weapons"))
                        {
                            SetupPlayerWeapons();
                        }
                    }
                    else
                    {
                        EditorGUILayout.HelpBox("Can't find any customizer weapon in the scene, be sure you're in the Customizer scene", MessageType.Warning);
                    }
                }
                else
                {
                    if (allCustomizers.Count > 0)
                    {
                        customizerSelected = EditorGUILayout.Popup("Customizer Weapon", customizerSelected, allCustomizers.Keys.ToArray());
                        _CustomizerWeapon  = allCustomizers.Values.ElementAt(customizerSelected);
                    }
                    else
                    {
                        EditorGUILayout.HelpBox("Can't find any customizer weapon in the scene, be sure you're in the Customizer scene", MessageType.Warning);
                    }
                    if (_CustomizerWeapon != null && _CustomizerWeapon.gameObject.name != "***TEMPLATE***")
                    {
                        if (allCustomizersMeshs.Count <= 0)
                        {
                            MeshRenderer[] all = _CustomizerWeapon.Positions.ModelParent.GetComponentsInChildren <MeshRenderer>(true);
                            for (int i = 0; i < all.Length; i++)
                            {
                                allCustomizersMeshs.Add(all[i].name, all[i].transform);
                            }
                        }
                        else
                        {
                            _CustomizerMesh = _CustomizerWeapon.CamoRender.Render.transform;
                            _CustomizerMesh = EditorGUILayout.ObjectField("Customizer Mesh", _CustomizerMesh, typeof(Transform), true) as Transform;
                            if (_CustomizerMesh != null)
                            {
                                if (_TargetMesh == null)
                                {
                                    if (script.CamoRender.Render != null)
                                    {
                                        _TargetMesh = script.CamoRender.Render.transform;
                                    }
                                    else
                                    {
                                        if (GUILayout.Button("Search Mesh"))
                                        {
                                            MeshFilter[] all = script.transform.GetComponentsInChildren <MeshFilter>(true);
                                            Mesh         m   = _CustomizerMesh.GetComponent <MeshFilter>().sharedMesh;
                                            for (int i = 0; i < all.Length; i++)
                                            {
                                                if (all[i].sharedMesh == m)
                                                {
                                                    _TargetMesh = all[i].transform;
                                                }
                                            }
                                        }
                                    }
                                }
                                else
                                {
                                    _TargetMesh = EditorGUILayout.ObjectField("Target Weapon Mesh", _TargetMesh, typeof(Transform), true) as Transform;
                                }
                            }
                        }
                    }

                    GUI.enabled = (_CustomizerMesh != null && _CustomizerWeapon != null && _TargetMesh != null);
                    if (GUILayout.Button("Transfer", EditorStyles.toolbarButton, GUILayout.Width(100)))
                    {
                        Transfer();
                    }
                    GUI.enabled = true;
                }
                GUILayout.EndVertical();
            }

            EditorGUI.EndChangeCheck();
            if (GUI.changed)
            {
                EditorUtility.SetDirty(target);
            }
        }