Exemple #1
0
        public static void CB_COMP_PlayerNameBar(GameObject target, ref List <string> log)
        {
            if (log != null)
            {
                log.Add("Adding Player Name Bar");
            }
            GameObject playerNameBar = E_Helpers.CreatePrefabFromPath("InvectorMultiplayer/UI/PlayerNameBar.prefab");

            if (log != null)
            {
                log.Add(" * Positioning name bar above player head...");
            }
            Vector3 barPosition = target.GetComponent <Animator>().GetBoneTransform(HumanBodyBones.Head).position + (Vector3.up / 2);

            playerNameBar.transform.position = barPosition;
            playerNameBar.transform.SetParent(target.transform);

            if (!target.GetComponent <PlayerNameBar>())
            {
                if (log != null)
                {
                    log.Add("Adding PlayerNameBar component.");
                }
                target.AddComponent <PlayerNameBar>();
            }
            BindingFlags flags      = BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance;
            Text         playerName = playerNameBar.transform.Find("Background").Find("PlayerName").GetComponent <Text>();

            if (log != null)
            {
                log.Add("Adding name bar and player name to PlayerNameBar component.");
            }
            target.GetComponent <PlayerNameBar>().GetType().GetField("playerName", flags).SetValue(target.GetComponent <PlayerNameBar>(), playerName);
            target.GetComponent <PlayerNameBar>().GetType().GetField("playerBar", flags).SetValue(target.GetComponent <PlayerNameBar>(), playerNameBar);
        }
Exemple #2
0
 public static void CB_COMP_vBreakableObject(GameObject target)
 {
     if (target.GetComponent <vBreakableObject>())
     {
         if (!target.GetComponent <NetworkBreakObject>())
         {
             target.AddComponent <NetworkBreakObject>();
         }
         E_Helpers.SetObjectIcon(target, E_Core.h_genericIcon);
         if (!E_PlayerEvents.HasUnityEvent(target.GetComponent <vBreakableObject>().OnBroken, "BreakObject", target.GetComponent <NetworkBreakObject>()))
         {
             UnityEventTools.AddPersistentListener(target.GetComponent <vBreakableObject>().OnBroken, target.GetComponent <NetworkBreakObject>().BreakObject);
         }
     }
     if (target.GetComponentInChildren <vBreakableObject>())
     {
         foreach (vBreakableObject bo in target.GetComponentsInChildren <vBreakableObject>())
         {
             if (!bo.gameObject.GetComponent <NetworkBreakObject>())
             {
                 bo.gameObject.AddComponent <NetworkBreakObject>();
             }
             if (!E_PlayerEvents.HasUnityEvent(bo.OnBroken, "BreakObject", bo.gameObject.GetComponent <NetworkBreakObject>()))
             {
                 UnityEventTools.AddPersistentListener(bo.OnBroken, bo.gameObject.GetComponent <NetworkBreakObject>().BreakObject);
             }
             E_Helpers.SetObjectIcon(bo.gameObject, E_Core.h_genericIcon);
         }
     }
 }
Exemple #3
0
 public static void CB_AddGlobalVoiceChat()
 {
     if (!FindObjectOfType <NetworkManager>())
     {
         if (EditorUtility.DisplayDialog("Network Manager Not Found", "No NetworkManager was found in the scene. Please add a NetworkManager to the scene and try again.",
                                         "Okay"))
         {
             return;
         }
     }
     else
     {
         GameObject vc = E_Helpers.CreatePrefabFromPath("InvectorMultiplayer/UI/Voice/VoiceRecorder.prefab");
         vc.transform.SetParent(FindObjectOfType <NetworkManager>().transform);
         E_Helpers.SetObjectIcon(vc, E_Core.h_voiceIcon);
         if (EditorUtility.DisplayDialog("Added Voice Chat To Scene", "The \"VoiceRecorder\" has been successfully added to the scene. " +
                                         "Make sure that each spawnable player that you want to be able to transmit voice over the network also has the \"VoiceChat\" " +
                                         "component on them. This can be done when first setting up your player using the Convert Player menu. Read the help window " +
                                         "on this component for other needed items if doing this manually.",
                                         "Okay"))
         {
             Selection.activeGameObject = vc;
         }
     }
 }
Exemple #4
0
 public static void CB_COMP_vHealthController(GameObject target)
 {
     if (target.GetComponent <vHealthController>())
     {
         if (!target.GetComponent <SyncHealthController>())
         {
             target.AddComponent <SyncHealthController>();
         }
         E_Helpers.SetObjectIcon(target, E_Core.h_genericIcon);
         vHealthController hc = target.GetComponent <vHealthController>();
         if (!E_PlayerEvents.HasUnityEvent(hc.onReceiveDamage, "SendDamageOverNetwork", target.GetComponent <SyncHealthController>()))
         {
             UnityEventTools.AddPersistentListener(hc.onReceiveDamage, target.GetComponent <SyncHealthController>().SendDamageOverNetwork);
         }
     }
     if (target.GetComponentInChildren <vHealthController>())
     {
         foreach (vHealthController hc in target.GetComponentsInChildren <vHealthController>())
         {
             if (!hc.gameObject.GetComponent <SyncHealthController>())
             {
                 hc.gameObject.AddComponent <SyncHealthController>();
             }
             E_Helpers.SetObjectIcon(hc.gameObject, E_Core.h_genericIcon);
             if (!E_PlayerEvents.HasUnityEvent(hc.onReceiveDamage, "SendDamageOverNetwork", hc.gameObject.GetComponent <SyncHealthController>()))
             {
                 UnityEventTools.AddPersistentListener(hc.onReceiveDamage, hc.gameObject.GetComponent <SyncHealthController>().SendDamageOverNetwork);
             }
         }
     }
 }
Exemple #5
0
        public static void ConvertItemToMultiplayer(MenuCommand command)
        {
            GameObject prefab       = (GameObject)Selection.activeObject;
            string     saveLocation = string.Format("Assets{0}Resources{0}", Path.DirectorySeparatorChar);

            E_Helpers.CreateDirectory(E_Helpers.GetDirectoryPath(saveLocation));
            Debug.Log("Converting Prefab: " + prefab.name);
            try
            {
                CB_ConvertPrefabToMultiplayer(prefab.gameObject);
                if (EditorUtility.DisplayDialog("SUCCESS!",
                                                "You have successfully converted: " + prefab.name + ". " +
                                                "The multiplayer version can be found in the Assets/Resources folder.",
                                                "Great!"))
                {
                }
                Debug.Log("Successfully Converted Prefab: " + prefab.name);
            }
            catch (Exception ex)
            {
                Debug.Log(ex);
                if (EditorUtility.DisplayDialog("FAILURE!",
                                                "Failed to convert: " + prefab.name + " with error: \n\n " + ex.ToString(),
                                                "Okay"))
                {
                }
            }
        }
Exemple #6
0
        IEnumerator ScanProject()
        {
            _scanned  = false;
            _scanning = true;
            foundPaths.Clear();
            CB_prefabs.Clear();
            string[]   prefabPaths = E_Helpers.GetAllPrefabs(true, false);
            GameObject target;

            foreach (string prefabPath in prefabPaths)
            {
                Object prefab = AssetDatabase.LoadMainAssetAtPath(prefabPath);
                try
                {
                    target = (GameObject)prefab;
                    CB_CHECK_CORE_HasComp(target, _cItemCollection, _cvBreakableObjects, _cvHealthController, prefabPath);
                    CB_SHOOTER_HasShooterComp(target, _cvShooterWeapons, prefabPath);
                }
                catch
                {
                    Debug.LogWarning("Unable to cast: " + prefabPath + " to GameObject, skipping");
                }
            }
            _scrollHeight = CB_prefabs.Count * 39;
            _scanning     = false;
            _scanned      = true;
            yield return(null);
        }
Exemple #7
0
 void C_vBreakableObject(GameObject target)
 {
     if (_cvBreakableObjects == false)
     {
         return;
     }
     if (target.GetComponent <vBreakableObject>())
     {
         E_Helpers.SetObjectIcon(target, E_Core.h_genericIcon);
         if (!target.GetComponent <NetworkBreakObject>())
         {
             target.AddComponent <NetworkBreakObject>();
         }
         bool sync = !FindObjectOfType <NetworkManager>().syncScenes;
         target.GetComponent <NetworkBreakObject>().GetType().GetField("syncCrossScenes", E_Helpers.allBindings).SetValue(target.GetComponent <NetworkBreakObject>(), sync);
         if (sync == true)
         {
             target.GetComponent <NetworkBreakObject>().GetType().GetField("holder", E_Helpers.allBindings).SetValue(target.GetComponent <NetworkBreakObject>(), target.transform);
         }
         if (!E_PlayerEvents.HasUnityEvent(target.GetComponent <vBreakableObject>().OnBroken, "BreakObject", target.GetComponent <NetworkBreakObject>()))
         {
             UnityEventTools.AddPersistentListener(target.GetComponent <vBreakableObject>().OnBroken, target.GetComponent <NetworkBreakObject>().BreakObject);
         }
     }
 }
Exemple #8
0
 void C_Rigidbodies(GameObject target)
 {
     if (_cRigidbodies == false)
     {
         return;
     }
     if (target.GetComponent <Rigidbody>())
     {
         E_Helpers.SetObjectIcon(target, E_Core.h_genericIcon);
         if (target.GetComponent <vBreakableObject>())
         {
             return;
         }
         if (!target.GetComponent <PhotonRigidbodyView>())
         {
             target.AddComponent <PhotonRigidbodyView>();
         }
         if (!target.GetComponent <PhotonView>())
         {
             target.AddComponent <PhotonView>();
         }
         List <Component> observables = target.GetComponent <PhotonView>().ObservedComponents;
         if (observables == null || !observables.Contains(target.GetComponent <PhotonRigidbodyView>()))
         {
             observables = new List <Component>();
             observables.Add(target.GetComponent <PhotonRigidbodyView>());
         }
         target.GetComponent <PhotonView>().ObservedComponents = observables;
         target.GetComponent <PhotonView>().Synchronization    = ViewSynchronization.ReliableDeltaCompressed;
     }
 }
Exemple #9
0
        private void AddNetworkManagerToScene()
        {
            // Will add this new tag to the inspector if it doesn't already exist
            E_Helpers.AddInspectorTag("SpawnPoint");

            GameObject _target = null;

            if (FindObjectOfType <NetworkManager>())
            {
                _target = FindObjectOfType <NetworkManager>().gameObject;
            }
            if (!_target)
            {
                _target = new GameObject("Network Manager");
            }
            if (!_target.GetComponent <NetworkManager>())
            {
                _target.AddComponent <NetworkManager>();
            }
            if (_target.GetComponent <NetworkManager>().defaultSpawnPoint == null)
            {
                GameObject spawnPoints = (GameObject.Find("Spawn Points")) ? GameObject.Find("Spawn Points") : new GameObject("Spawn Points");
                GameObject spawnPoint  = (GameObject.Find("Player Spawn Point")) ? GameObject.Find("Player Spawn Point") : new GameObject("Player Spawn Point");
                E_Helpers.SetObjectIcon(spawnPoint, E_Core.h_spawnPointIcon);
                _target.GetComponent <NetworkManager>().defaultSpawnPoint = spawnPoint.transform;
                spawnPoints.layer = 2;
                spawnPoint.layer  = 2;
                spawnPoint.tag    = "SpawnPoint";
                spawnPoint.transform.SetParent(spawnPoints.transform);
            }
            if (_target.GetComponent <NetworkManager>().database == null)
            {
                if (System.IO.File.Exists("Assets/Resources/ScenesDatabase/ScenesDatabase.asset"))
                {
                    SceneDatabase database = AssetDatabase.LoadAssetAtPath <SceneDatabase>("Assets/Resources/ScenesDatabase/ScenesDatabase.asset");
                    if (database)
                    {
                        _target.GetComponent <NetworkManager>().database = database;
                    }
                }
                else
                {
                    Debug.LogWarning("Was unable to automatically add a \"SceneDatabase\" to the database entry on the NetworkManager. Remember to add one before making your final build!");
                }
            }
            E_Helpers.SetObjectIcon(_target, E_Core.h_networkIcon);
            Selection.activeGameObject = _target;
            _target.layer = 2; // Ignore Raycast Layer
            if (!_target.GetComponent <PlayerRespawn>())
            {
                _target.AddComponent <PlayerRespawn>();
            }
            _target.GetComponent <PlayerRespawn>().visualCountdown = AssetDatabase.LoadAssetAtPath <GameObject>("Assets/InvectorMultiplayer/UI/RespawnCounter.prefab");
            if (EditorUtility.DisplayDialog("Friendly Reminder", "Remember to adjust the spawn point to where you want it to be. \r\n" +
                                            "\r\n",
                                            "Okay"))
            {
                Debug.Log("Successfully added the \"Network Manager\" gameobject and assigned a Spawn Point.");
            }
        }
Exemple #10
0
        public static void CB_AddRespawnPoint()
        {
            // Will add this new tag to the inspector if it doesn't already exist
            E_Helpers.AddInspectorTag("RespawnPoint");

            GameObject respawnPoint = new GameObject("Respawn Point");

            respawnPoint.layer = 2;
            respawnPoint.tag   = "RespawnPoint";

            GameObject respawnPointParentGO = null;

            if (!GameObject.Find("Spawn Points"))
            {
                respawnPointParentGO       = new GameObject("Spawn Points");
                respawnPointParentGO.layer = 2;
                Debug.Log("Generated \"Spawn Points\" holder gameObject.");
            }
            else
            {
                respawnPointParentGO = GameObject.Find("Spawn Points");
            }
            respawnPoint.transform.SetParent(respawnPointParentGO.transform);
            respawnPoint.transform.position = E_Helpers.PositionInFrontOfEditorCamera();
            E_Helpers.SetObjectIcon(respawnPoint, E_Core.h_respawnPointIcon);
            Selection.activeGameObject = respawnPoint;
            Debug.Log("Added a new \"Respawn Point\" gameobject to the scene.");
        }
Exemple #11
0
 protected virtual void OnEnable()
 {
     if (!_skin)
     {
         _skin = E_Helpers.LoadSkin(E_Core.e_guiSkinPath);
     }
     _titleColor = E_Colors.e_c_blue_5;
     _skinHolder = new CBColorHolder(_skin.label);
 }
Exemple #12
0
 protected virtual void EndInspectorGUI(System.Type serializedType)
 {
     DrawPropertiesExcluding(serializedObject, E_Helpers.EditorGetVariables(serializedType));
     GUI.skin = _original;
     CBEditor.SetColorToEditorStyle(_originalHolder, _originalFoldout);
     serializedObject.ApplyModifiedProperties();
     GUILayout.EndHorizontal();
     GUILayout.EndVertical();
 }
Exemple #13
0
 private void OnEnable()
 {
     if (!_skin)
     {
         _skin = E_Helpers.LoadSkin(E_Core.e_guiSkinPath);
     }
     this.minSize = _minrect;
     this.maxSize = _maxrect;
     titleContent = new GUIContent("Welcome To The Invector Multiplayer Add-On");
 }
Exemple #14
0
        private void OnEnable()
        {
            if (!_skin)
            {
                _skin = E_Helpers.LoadSkin(E_Core.e_guiSkinPath);
            }

            //Make window title
            this.titleContent = new GUIContent("Convert Project Prefabs", null, "Converts all the prefabs in your project to support multiplayer.");
        }
Exemple #15
0
        private void OnEnable()
        {
            if (!_skin)
            {
                _skin = E_Helpers.LoadSkin(E_Core.e_guiSkinPath);
            }

            //Make window title
            this.titleContent = new GUIContent("Perform Scene Tests", null, "Perform a series of automated tests on this scene to make sure its ready for multiplayer.");
        }
Exemple #16
0
        private void OnEnable()
        {
            if (!_skin)
            {
                _skin = E_Helpers.LoadSkin(E_Core.e_guiSkinPath);
            }

            //Make window title
            this.titleContent = new GUIContent("Add Core Objects", null, "Adds the \"Core\" objects to the scene.");
        }
Exemple #17
0
        private void OnEnable()
        {
            if (!_skin)
            {
                _skin = E_Helpers.LoadSkin(E_Core.e_guiSkinPath);
            }

            //Make window title
            this.titleContent = new GUIContent("Main Menu", null, "Steps to setup multiplayer support.");
        }
Exemple #18
0
        private void OnEnable()
        {
            if (!_skin)
            {
                _skin = E_Helpers.LoadSkin(E_Core.e_guiSkinPath);
            }

            //Make window title
            this.titleContent = new GUIContent("Check File Status'", null, "What files have been modified and what add-ons are enabled.");
        }
Exemple #19
0
        public static void CB_COMP_vItemCollection(GameObject target)
        {
            //BindingFlags flags = BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance;
            GameObject      go = null;
            vItemCollection ic = null;

            if (target.GetComponent <vItemCollection>())
            {
                go = target;
                ic = target.GetComponent <vItemCollection>();
            }
            else if (target.GetComponentInChildren <vItemCollection>())
            {
                go = target.GetComponentInChildren <vItemCollection>().transform.gameObject;
                ic = target.GetComponentInChildren <vItemCollection>();
            }
            if (go)
            {
                if (!go.GetComponent <SyncItemCollection>())
                {
                    go.AddComponent <SyncItemCollection>();
                }
                go.GetComponent <SyncItemCollection>().OnPressActionInput           = ic.OnPressActionInput;
                go.GetComponent <SyncItemCollection>().onPressActionInputWithTarget = ic.onPressActionInputWithTarget;
                go.GetComponent <SyncItemCollection>().onPressActionDelay           = ic.onPressActionDelay;
                bool sync = !FindObjectOfType <NetworkManager>().syncScenes;
                if (sync == true)
                {
                    go.GetComponent <SyncItemCollection>().OnSceneEnterUpdate = ic.OnPressActionInput;
                    if (ic.transform.parent != null)
                    {
                        go.GetComponent <SyncItemCollection>().GetType().GetField("holder", E_Helpers.allBindings).SetValue(go.GetComponent <SyncItemCollection>(), ic.transform.parent);
                    }
                    else
                    {
                        go.GetComponent <SyncItemCollection>().GetType().GetField("holder", E_Helpers.allBindings).SetValue(go.GetComponent <SyncItemCollection>(), ic.transform);
                    }
                }
                go.GetComponent <SyncItemCollection>().GetType().GetField("syncCrossScenes", E_Helpers.allBindings).SetValue(go.GetComponent <SyncItemCollection>(), sync);
                //bool skipStart = (ic.items.Count > 0);
                go.GetComponent <SyncItemCollection>().GetType().GetField("skipStartCheck", E_Helpers.allBindings).SetValue(go.GetComponent <SyncItemCollection>(), false);
                go.GetComponent <SyncItemCollection>().GetType().GetField("syncCreateDestroy", E_Helpers.allBindings).SetValue(go.GetComponent <SyncItemCollection>(), true);
                go.GetComponent <SyncItemCollection>().GetType().GetField("resourcesPrefab", E_Helpers.allBindings).SetValue(go.GetComponent <SyncItemCollection>(), ic.transform.root.name);

                ic.OnPressActionInput           = new UnityEvent();
                ic.onPressActionInputWithTarget = new OnDoActionWithTarget();
                ic.onPressActionDelay           = 0;

                UnityEventTools.AddPersistentListener(ic.onPressActionInputWithTarget, go.GetComponent <SyncItemCollection>().Collect);

                E_Helpers.SetObjectIcon(go, E_Core.h_genericIcon);

                CB_COMP_SHOOTER_vItemCollection(ic, go);
            }
        }
Exemple #20
0
 protected virtual void DrawTitleBar(string title, string helpbox, string texturePath = null)
 {
     EditorGUI.DrawRect(new Rect(rect.x + 5, rect.y + 10, rect.width - 10, 40), _titleColor);
     if (!string.IsNullOrEmpty(texturePath))
     {
         GUI.DrawTexture(new Rect(rect.x + 10, rect.y + 15, 30, 30), E_Helpers.LoadTexture(texturePath, new Vector2(256, 256)));
     }
     GUILayout.Space(5);
     GUILayout.Label(title, _skin.label);
     GUILayout.Space(10);
     EditorGUILayout.HelpBox(helpbox, MessageType.Info);
 }
Exemple #21
0
        public static void CB_Scene_AddExit()
        {
            NetworkManager nm = GameObject.FindObjectOfType <NetworkManager>();

            if (!nm)
            {
                if (EditorUtility.DisplayDialog("No Found Network Manager", "The \"NetworkManager\" component doesn't exist in this scene. Please add it before continuing.",
                                                "Okay"))
                {
                }
                return;
            }
            GameObject sceneManager = GameObject.Find("SceneManager");

            if (!sceneManager)
            {
                sceneManager = new GameObject("SceneManager");
            }

            GameObject exitPoint = new GameObject("Exit Point");

            E_Helpers.SetObjectIcon(exitPoint, E_Core.h_sceneExitIcon);

            exitPoint.AddComponent <SceneTransition>();
            exitPoint.AddComponent <SetLoadingScreen>();

            SceneDatabase database = (SceneDatabase)AssetDatabase.LoadAssetAtPath(string.Format("Assets{0}Resources{0}ScenesDatabase{0}ScenesDatabase.asset", Path.DirectorySeparatorChar), typeof(SceneDatabase));

            exitPoint.GetComponent <SceneTransition>().SetDatabase(database);
            exitPoint.GetComponent <SceneTransition>().sendAllTogether = nm.syncScenes;

            UnityEvent beforeTravel = (UnityEvent)exitPoint.GetComponent <SceneTransition>().GetType().GetField("BeforeTravel", E_Helpers.allBindings).GetValue(exitPoint.GetComponent <SceneTransition>());

            if (beforeTravel == null)
            {
                exitPoint.GetComponent <SceneTransition>().GetType().GetField("BeforeTravel", E_Helpers.allBindings).SetValue(exitPoint.GetComponent <SceneTransition>(), new UnityEvent());
                beforeTravel = (UnityEvent)exitPoint.GetComponent <SceneTransition>().GetType().GetField("BeforeTravel", E_Helpers.allBindings).GetValue(exitPoint.GetComponent <SceneTransition>());
            }

            UnityEventTools.AddPersistentListener(beforeTravel, exitPoint.GetComponent <SetLoadingScreen>().EnableLoadingScreen);

            exitPoint.GetComponent <BoxCollider>().isTrigger = true;

            exitPoint.layer = 2;
            exitPoint.transform.SetParent(sceneManager.transform);
            exitPoint.transform.position = E_Helpers.PositionInFrontOfEditorCamera();
            Selection.activeGameObject   = exitPoint;

            Debug.Log("Successfully created scene exit point!");
        }
Exemple #22
0
 public static void CB_AddPlayersToExampleUI()
 {
     if (EditorUtility.DisplayDialog("About To Add Players",
                                     "This will scan all the prefabs in your root Resources folder and attempt to find all " +
                                     "of the player prefabs. Then it will assign these found prefabs to the \"players\" gameobject " +
                                     "array in the \"ExampleUI\" component. This will overwrite any settings currently there.\n\n" +
                                     "Do you want to continue?",
                                     "Continue", "Cancel"))
     {
         UICoreLogic ui = FindObjectOfType <UICoreLogic>();
         if (ui == null)
         {
             if (EditorUtility.DisplayDialog("Missing ExampleUI",
                                             "You are missing an example UI from the scene. Please add it before trying this again.",
                                             "Okay"))
             {
             }
         }
         else
         {
             string[]          prefabPaths = E_Helpers.GetAllPrefabs(false, true);
             GameObject        target;
             List <GameObject> foundPlayers = new List <GameObject>();
             foreach (string prefabPath in prefabPaths)
             {
                 try
                 {
                     UnityEngine.Object prefab = AssetDatabase.LoadMainAssetAtPath(prefabPath);
                     target = (GameObject)prefab;
                     if (target.GetComponent <vThirdPersonController>())
                     {
                         foundPlayers.Add(target);
                     }
                 }
                 catch
                 {
                     continue;
                 }
             }
             ui.selectablePlayers = foundPlayers.ToArray();
             if (EditorUtility.DisplayDialog("Completed!",
                                             "The found player prefabs of the resources folder have been added to the ExampleUI. \n\n" +
                                             "Remember to save this to the prefab otherwise it will be removed when you click play.",
                                             "Great!"))
             {
                 Selection.activeGameObject = ui.gameObject;
             }
         }
     }
 }
Exemple #23
0
        void ConvertPrefabsToMultiplayer()
        {
            _converted  = false;
            _converting = true;
            string saveLocation = string.Format("Assets{0}Resources{0}", Path.DirectorySeparatorChar);

            E_Helpers.CreateDirectory(E_Helpers.GetDirectoryPath(saveLocation));
            GameObject _copiedPrefab = null;

            foreach (KeyValuePair <GameObject, string> prefab in CB_prefabs)
            {
                _copiedPrefab      = GameObject.Instantiate(prefab.Key, Vector3.zero, Quaternion.identity) as GameObject;
                _copiedPrefab.name = "MP_" + _copiedPrefab.name.Replace("(Clone)", "");
                saveLocation       = string.Format("Assets{0}Resources{0}{1}.prefab", Path.DirectorySeparatorChar, _copiedPrefab.name);
                CB_COMP_vItemCollection(_copiedPrefab);
                CB_COMP_vBreakableObject(_copiedPrefab);
                CB_COMP_vHealthController(_copiedPrefab);

                CB_COMP_vProjectileControle(_copiedPrefab);
                CB_COMP_vShooterWeapon(_copiedPrefab);

                if (E_Helpers.FileExists(saveLocation))
                {
                    if (EditorUtility.DisplayDialog("Duplicate Detected!",
                                                    string.Format("Prefab \"{0}\" already exists, would you like to overwrite it or not copy it?", _copiedPrefab.name),
                                                    "Overwrite", "Not Copy"))
                    {
                        //Overwrite
                        E_Helpers.DeleteFile(saveLocation);
                        PrefabUtility.SaveAsPrefabAsset(_copiedPrefab, saveLocation);
                    }
                    else
                    {
                        Debug.Log("Skipped: " + _copiedPrefab.name);
                    }
                }
                else
                {
                    //Doesn't exist create it
                    saveLocation = AssetDatabase.GenerateUniqueAssetPath(saveLocation);
                    PrefabUtility.SaveAsPrefabAsset(_copiedPrefab, saveLocation);
                }
                DestroyImmediate(_copiedPrefab);
            }
            //AssetDatabase.SaveAssets();
            //AssetDatabase.Refresh();
            _converting = false;
            _converted  = true;
            Debug.Log("Finished converting CB_prefabs");
        }
Exemple #24
0
        public static void CB_AddStaminaBar()
        {
            GameObject target = Selection.activeGameObject;

            if (target == null)
            {
                if (EditorUtility.DisplayDialog("Select Valid Player",
                                                "You don't seem to have anything selected. Please select a valid player " +
                                                "before attempting to select this menu item.",
                                                "Okay"))
                {
                }
            }
            else if (!target.GetComponent <vThirdPersonController>())
            {
                if (EditorUtility.DisplayDialog("Select Valid Player",
                                                "The current selected object doesn't appear to be a player. Please select a player " +
                                                "then select this menu item again to add the stamina bar to the selected player.",
                                                "Okay"))
                {
                }
            }
            else
            {
                GameObject staminaBar = E_Helpers.CreatePrefabFromPath("InvectorMultiplayer/UI/FloatingStaminaBar.prefab");
                staminaBar.transform.SetParent(target.transform);
                staminaBar.GetComponent <FloatingBar>().controller = target.GetComponent <vThirdPersonController>();
                if (target.GetComponent <Animator>() && target.GetComponent <Animator>().GetBoneTransform(HumanBodyBones.Head))
                {
                    staminaBar.transform.position = target.GetComponent <Animator>().GetBoneTransform(HumanBodyBones.Head).position + Vector3.up / 2;
                    if (EditorUtility.DisplayDialog("Success!",
                                                    "Successfully added the health bar to your player.",
                                                    "Great!"))
                    {
                    }
                }
                else
                {
                    staminaBar.transform.localPosition = Vector3.zero;
                    if (EditorUtility.DisplayDialog("Partial Success",
                                                    "Successfully added the health bar to your player but was unable to determine where the head of your " +
                                                    "player was. You will need to manually position the floating bar where you want it to be.",
                                                    "Great!"))
                    {
                    }
                }
                Selection.activeGameObject = staminaBar;
            }
        }
Exemple #25
0
        public static void CB_COMP_SyncPlayer(GameObject target, ref List <string> log)
        {
            if (!target.GetComponent <SyncPlayer>())
            {
                E_Helpers.AddInspectorTag("OtherPlayer");
                E_Helpers.AddInspectorLayer("OtherPlayer");
                if (log != null)
                {
                    log.Add("Adding SyncPlayer Component to copied player");
                }
                target.AddComponent <SyncPlayer>();
            }

            E_CompHelper.AddCompToPhotonView(target, target.GetComponent <SyncPlayer>());
        }
Exemple #26
0
        private void OnEnable()
        {
            if (!_skin)
            {
                _skin = E_Helpers.LoadSkin(E_Core.e_guiSkinPath);
            }

            //Set title bar colors
            _lockColor           = new Color32(158, 158, 158, 200); //dark blue
            _convertBar          = new Color32(95, 165, 245, 255);  //dark blue
            _titleBoxColor       = new Color32(1, 16, 51, 255);     //Lighter Blue
            _convertColor        = new Color32(173, 127, 0, 255);   //Darker Yellow
            _convertSuccessColor = new Color32(8, 156, 0, 255);     //Light Green
            _convertErrorColor   = new Color32(222, 11, 0, 255);    //Red

            //Make window title
            this.titleContent = new GUIContent("Scene Conversion", null, "Convert a objects in the scene to support multiplayer.");

            GetSceneObjects();
            _scrollHeight = 35 * convertables.Count;
            _scrollPos    = new Vector2(0, _scrollHeight);

            //Set starting help text
            _help = "This is a list of objects that will be converted to support multiplayer. " +
                    "Select the object name button to see a preview of the target and what will be converted " +
                    "on that target. If you wish to remove an object from being converted click the 'X' " +
                    "button next to the object name to remove it from the list. Once you are satistfied with " +
                    "your selections click the 'CONVERT ALL' button to begin the conversion process.\n\n " +
                    "Found objects in this scene: " + convertables.Count;

            _target = null;
            if (_convertedGenericTriggers == true)
            {
                if (EditorUtility.DisplayDialog("Friendly Reminder",
                                                "You have converted some vTriggerGenericAction's in this scene. Not everything " +
                                                "is able to be auto converted by default. Look through these objects and make sure " +
                                                "the unity events that you want to be triggered over the network are being run by " +
                                                "the \"CallNetworkEvents\" component." +
                                                "",
                                                "Thanks For The Info"))
                {
                    _convertedGenericTriggers = false;
                }
            }
        }
Exemple #27
0
        public static void CB_CreatePlayerList()
        {
            PlayerList listComp = FindObjectOfType <PlayerList>();

            if (!listComp)
            {
                GameObject playerList = E_Helpers.CreatePrefabFromPath("InvectorMultiplayer/UI/PlayerList.prefab");
                playerList.transform.SetParent(FindObjectOfType <NetworkManager>().transform);
                listComp = playerList.GetComponent <PlayerList>();
            }

            //ChatBox Events
            ChatBox chatbox = FindObjectOfType <ChatBox>();

            if (!E_PlayerEvents.HasUnityEvent(chatbox.OnYouSubscribeToDataChannel, "SetPlayerList", listComp))
            {
                UnityEventTools.AddPersistentListener(chatbox.OnYouSubscribeToDataChannel, listComp.SetPlayerList);
            }
            if (!E_PlayerEvents.HasUnityEvent(chatbox.OnYouSubscribeToDataChannel, "UpdateLocationToCurrentScene", listComp))
            {
                UnityEventTools.AddPersistentListener(chatbox.OnYouSubscribeToDataChannel, listComp.UpdateLocationToCurrentScene);
            }
            if (!E_PlayerEvents.HasUnityEvent(chatbox.OnUserSubscribedToDataChannel, "AddPlayer", listComp))
            {
                UnityEventTools.AddPersistentListener(chatbox.OnUserSubscribedToDataChannel, listComp.AddPlayer);
            }
            if (!E_PlayerEvents.HasUnityEvent(chatbox.OnUserUnSubscribedToDataChannel, "RemovePlayer", listComp))
            {
                UnityEventTools.AddPersistentListener(chatbox.OnUserUnSubscribedToDataChannel, listComp.RemovePlayer);
            }

            //Network Manager Events
            NetworkManager nm = FindObjectOfType <NetworkManager>();

            if (!E_PlayerEvents.HasUnityEvent(nm.roomEvents._onJoinedRoom, "UpdateLocationToGoingToScene", listComp))
            {
                UnityEventTools.AddPersistentListener(nm.roomEvents._onJoinedRoom, listComp.UpdateLocationToGoingToScene);
            }
            if (!E_PlayerEvents.HasUnityEvent(nm.roomEvents._onJoinedRoom, "ClearPlayerList", listComp))
            {
                UnityEventTools.AddPersistentListener(nm.otherEvents._onDisconnected, listComp.ClearPlayerList);
            }

            E_Helpers.SetObjectIcon(listComp.gameObject, E_Core.h_playerlistIcon);
        }
Exemple #28
0
        private void OnEnable()
        {
            if (!_skin)
            {
                _skin = E_Helpers.LoadSkin(E_Core.e_guiSkinPath);
            }

            //Make window title
            this.titleContent = new GUIContent("Scenes Database", null, "List Of All Transition Scenes/Points.");

            SceneDatabase database = (SceneDatabase)AssetDatabase.LoadAssetAtPath("Assets/Resources/ScenesDatabase/ScenesDatabase.asset", typeof(SceneDatabase));

            databaseScenes.Clear();
            if (database)
            {
                databaseScenes = database.storedScenesData;
            }
        }
Exemple #29
0
        private void OnEnable()
        {
            if (!_skin)
            {
                _skin = E_Helpers.LoadSkin(E_Core.e_guiSkinPath);
            }

            //Set title bar colors
            _titleColor          = new Color32(1, 9, 28, 255);    //dark blue
            _titleBoxColor       = new Color32(1, 16, 51, 255);   //Lighter Blue
            _convertColor        = new Color32(173, 127, 0, 255); //Darker Yellow
            _convertSuccessColor = new Color32(8, 156, 0, 255);   //Light Green
            _convertErrorColor   = new Color32(222, 11, 0, 255);  //Red

            //Make window title
            this.titleContent = new GUIContent("Player Conversion", null, "Convert a player to support multiplayer.");
            FindAllPlayers();
        }
Exemple #30
0
 public static void CB_PreviewCamPoint()
 {
     if (!FindObjectOfType <PreviewCamera>())
     {
         if (EditorUtility.DisplayDialog("Missing \"PreviewCamera\" Component!", "Unable to find the \"PreviewCamera\" component in the scene. Please run \"CB Games/Add/Camera/Preview Camera Component\" before running this.",
                                         "Okay"))
         {
         }
     }
     else
     {
         PreviewCamera cam   = FindObjectOfType <PreviewCamera>();
         GameObject    point = new GameObject("CameraPoint");
         E_Helpers.SetObjectIcon(point, E_Core.h_cameraPath);
         point.transform.SetParent(cam.transform);
         cam.cameraPoints.Add(point.transform);
         Debug.Log("Successfully added camera point to the scene.");
     }
 }