Ejemplo n.º 1
0
 public static void CB_COMP_vLadderAction(GameObject target, ref List <string> log)
 {
     if (!target.GetComponent <vLadderAction>())
     {
         return;
     }
     if (!target.GetComponent <SyncPlayer>())
     {
         CB_COMP_SyncPlayer(target, ref log);
     }
     if (!E_PlayerEvents.HasUnityEvent(target.GetComponent <vLadderAction>().OnEnterLadder, "EnterLadder", target.GetComponent <SyncPlayer>()))
     {
         if (log != null)
         {
             log.Add("Adding 'EnterLadder' event to vLadderAction's 'OnEnterLadder' unityEvent.");
         }
         UnityEventTools.AddPersistentListener(target.GetComponent <vLadderAction>().OnEnterLadder, target.GetComponent <SyncPlayer>().EnterLadder);
     }
     if (!E_PlayerEvents.HasUnityEvent(target.GetComponent <vLadderAction>().OnExitLadder, "ExitLadder", target.GetComponent <SyncPlayer>()))
     {
         if (log != null)
         {
             log.Add("Adding 'ExitLadder' event to vLadderAction's 'OnExitLadder' unityEvent.");
         }
         UnityEventTools.AddPersistentListener(target.GetComponent <vLadderAction>().OnExitLadder, target.GetComponent <SyncPlayer>().ExitLadder);
     }
 }
Ejemplo n.º 2
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);
         }
     }
 }
Ejemplo n.º 3
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);
         }
     }
 }
Ejemplo n.º 4
0
 public static void CB_COMP_vItemManager(GameObject target, ref List <string> log)
 {
     if (!target.GetComponent <vItemManager>())
     {
         return;
     }
     if (!target.GetComponent <SyncPlayer>())
     {
         CB_COMP_SyncPlayer(target, ref log);
     }
     if (!E_PlayerEvents.HasUnityEvent(target.GetComponent <vItemManager>().onDropItem, "OnDropItem", target.GetComponent <SyncPlayer>()))
     {
         if (log != null)
         {
             log.Add(" * Adding OnDropItem Event to vItemManager");
         }
         UnityEventTools.AddPersistentListener(target.GetComponent <vItemManager>().onDropItem, target.GetComponent <SyncPlayer>().OnDropItem);
     }
     foreach (EquipPoint ep in target.GetComponent <vItemManager>().equipPoints)
     {
         CB_COMP_AddSyncObjComp(ep.handler.defaultHandler.gameObject, false, ep.equipPointName.ToLower().Contains("left"), false, false, false, true, ref log);
         foreach (Transform customHandler in ep.handler.customHandlers)
         {
             CB_COMP_AddSyncObjComp(customHandler.gameObject, false, ep.equipPointName.ToLower().Contains("left"), false, false, false, true, ref log);
         }
     }
 }
Ejemplo n.º 5
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);
             }
         }
     }
 }
Ejemplo n.º 6
0
 public static void CB_COMP_vThirdPersonController(GameObject target, ref List <string> log)
 {
     if (!target.GetComponent <vThirdPersonController>())
     {
         return;
     }
     if (log != null)
     {
         log.Add("Setting vThirdPersonController 'useInstance' to false");
     }
     //target.GetComponent<vThirdPersonController>().useInstance = false;
     if (log != null)
     {
         log.Add("Setting vThirdPersonController 'fillHealthOnStart' to false");
     }
     target.GetComponent <vThirdPersonController>().fillHealthOnStart = false;
     if (log != null)
     {
         log.Add("Setting vThirdPersonController health to max");
     }
     target.GetComponent <vThirdPersonController>().ResetHealth();
     if (!E_PlayerEvents.HasUnityEvent(target.GetComponent <vThirdPersonController>().onReceiveDamage, "OnReceiveDamage", target.GetComponent <SyncPlayer>()))
     {
         if (log != null)
         {
             log.Add("Setting vThirdPersonController onReceiveDamage event to use SyncPlayer");
         }
         UnityEventTools.AddPersistentListener(target.GetComponent <vThirdPersonController>().onReceiveDamage, target.GetComponent <SyncPlayer>().OnReceiveDamage);
     }
     if (!E_PlayerEvents.HasUnityEvent(target.GetComponent <vThirdPersonController>().onActiveRagdoll, "NetworkActiveRagdoll", target.GetComponent <SyncPlayer>()))
     {
         if (log != null)
         {
             log.Add("Setting vThirdPersonController onActiveRagdoll event to use SyncPlayer");
         }
         UnityEventTools.AddPersistentListener(target.GetComponent <vThirdPersonController>().onActiveRagdoll, target.GetComponent <SyncPlayer>().NetworkActiveRagdoll);
     }
     if (!E_PlayerEvents.HasUnityEvent(target.GetComponent <vThirdPersonController>().OnJump, "Jump", target.GetComponent <SyncPlayer>()))
     {
         if (log != null)
         {
             log.Add("Setting vThirdPersonController OnJump event to use SyncPlayer");
         }
         UnityEventTools.AddPersistentListener(target.GetComponent <vThirdPersonController>().OnJump, target.GetComponent <SyncPlayer>().Jump);
     }
     if (!E_PlayerEvents.HasUnityEvent(target.GetComponent <vThirdPersonController>().onDead, "Respawn", target.GetComponent <SyncPlayer>()))
     {
         if (log != null)
         {
             log.Add("Setting vThirdPersonController OnDead event to use SyncPlayer");
         }
         UnityEventTools.AddPersistentListener(target.GetComponent <vThirdPersonController>().onDead, target.GetComponent <SyncPlayer>().Respawn);
     }
 }
Ejemplo n.º 7
0
Archivo: E_UI.cs Proyecto: ZRace/ZRace
        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);
        }
Ejemplo n.º 8
0
 void C_vHealthController(GameObject target)
 {
     if (_cvHealthController == false)
     {
         return;
     }
     if (target.GetComponent <vHealthController>() && !target.GetComponent <vThirdPersonController>())
     {
         E_Helpers.SetObjectIcon(target, E_Core.h_genericIcon);
         if (!target.GetComponent <SyncHealthController>())
         {
             target.AddComponent <SyncHealthController>();
         }
         if (!E_PlayerEvents.HasUnityEvent(target.GetComponent <vHealthController>().onReceiveDamage, "SendDamageOverNetwork", target.GetComponent <SyncHealthController>()))
         {
             UnityEventTools.AddPersistentListener(target.GetComponent <vHealthController>().onReceiveDamage, target.GetComponent <SyncHealthController>().SendDamageOverNetwork);
         }
     }
 }
Ejemplo n.º 9
0
        public static void CB_AddDeathCamera()
        {
            GameObject     deathCam = E_Helpers.CreatePrefabFromPath("InvectorMultiplayer/DeathCamera.prefab");
            NetworkManager nm       = FindObjectOfType <NetworkManager>();

            if (nm == null)
            {
                if (EditorUtility.DisplayDialog("Missing Network Manager",
                                                "This component was added to the scene but there was not NetworkManager found in this scene. " +
                                                "It is highly suggested that you make this a child of the NetworkManager or of something " +
                                                "that is persistant between scenes.",
                                                "Okay"))
                {
                }
            }
            else
            {
                deathCam.transform.SetParent(nm.gameObject.transform);
                Selection.activeGameObject = deathCam;
                if (FindObjectOfType <SyncPlayer>())
                {
                    if (EditorUtility.DisplayDialog("Player Found In Scene",
                                                    "A convert multiplayer character was found in the scene do you want to add the unity events " +
                                                    "necessary to enable the death camera system on player death?",
                                                    "Yes", "No"))
                    {
                        foreach (SyncPlayer player in FindObjectsOfType <SyncPlayer>())
                        {
                            if (!E_PlayerEvents.HasUnityEvent(player.gameObject.GetComponent <vThirdPersonController>().onDead, "DeadEnableDeathCam", player))
                            {
                                UnityEventTools.AddPersistentListener(player.gameObject.GetComponent <vThirdPersonController>().onDead, player.DeadEnableDeathCam);
                            }
                        }
                        if (EditorUtility.DisplayDialog("Remember To Save!",
                                                        "Remember to save the changes back to the prefab on these converted players!",
                                                        "Okay Thanks!"))
                        {
                        }
                    }
                    else
                    {
                        DisplayEventRequirement();
                    }
                }
                else
                {
                    DisplayEventRequirement();
                }
            }

            void DisplayEventRequirement()
            {
                if (EditorUtility.DisplayDialog("Friendly Reminder For Missing Events",
                                                "This will not trigger by itself. You will be required to trigger it when you want to " +
                                                "allow the player to switch to targeting other players. A chain of events is available " +
                                                "for you to add if you would like:\n\n" +
                                                "vThirdPersonController (On Dead Event): Add SyncPlayer.DeadEnableDeathCam event",
                                                "Okay Thanks!"))
                {
                }
            }
        }
Ejemplo n.º 10
0
        void C_vTriggerGenericActions(GameObject target)
        {
            if (!target.GetComponent <vTriggerGenericAction>())
            {
                return;
            }
            if (target.GetComponent <vItemCollection>())
            {
                return;
            }

/*            #region Shooter Template
 *          if (target.GetComponent<vThrowCollectable>()) return;
 #endregion*/

            _convertedGenericTriggers = true;
            if (!target.GetComponent <CallNetworkEvents>())
            {
                target.AddComponent <CallNetworkEvents>();
            }
            target.GetComponent <CallNetworkEvents>().GetType().GetField("holder", E_Helpers.allBindings).SetValue(target.GetComponent <CallNetworkEvents>(), target.transform);

            //No Input UnityEvents
            if (!E_PlayerEvents.HasUnityEvent(target.GetComponent <vTriggerGenericAction>().OnPressActionInput, "CallNetworkInvoke1", target.GetComponent <CallNetworkEvents>()))
            {
                target.GetComponent <CallNetworkEvents>().GetType().GetField("NetworkInvoke1", E_Helpers.allBindings).SetValue(target.GetComponent <CallNetworkEvents>(), target.GetComponent <vTriggerGenericAction>().OnPressActionInput);
                target.GetComponent <vTriggerGenericAction>().OnPressActionInput = new UnityEvent();
                UnityEventTools.AddPersistentListener(target.GetComponent <vTriggerGenericAction>().OnPressActionInput, target.GetComponent <CallNetworkEvents>().CallNetworkInvoke1);
            }
            if (!E_PlayerEvents.HasUnityEvent(target.GetComponent <vTriggerGenericAction>().OnCancelActionInput, "CallNetworkInvoke2", target.GetComponent <CallNetworkEvents>()))
            {
                target.GetComponent <CallNetworkEvents>().GetType().GetField("NetworkInvoke2", E_Helpers.allBindings).SetValue(target.GetComponent <CallNetworkEvents>(), target.GetComponent <vTriggerGenericAction>().OnCancelActionInput);
                target.GetComponent <vTriggerGenericAction>().OnCancelActionInput = new UnityEvent();
                UnityEventTools.AddPersistentListener(target.GetComponent <vTriggerGenericAction>().OnCancelActionInput, target.GetComponent <CallNetworkEvents>().CallNetworkInvoke2);
            }
            if (!E_PlayerEvents.HasUnityEvent(target.GetComponent <vTriggerGenericAction>().OnFinishActionInput, "CallNetworkInvoke3", target.GetComponent <CallNetworkEvents>()))
            {
                target.GetComponent <CallNetworkEvents>().GetType().GetField("NetworkInvoke3", E_Helpers.allBindings).SetValue(target.GetComponent <CallNetworkEvents>(), target.GetComponent <vTriggerGenericAction>().OnFinishActionInput);
                target.GetComponent <vTriggerGenericAction>().OnFinishActionInput = new UnityEvent();
                UnityEventTools.AddPersistentListener(target.GetComponent <vTriggerGenericAction>().OnFinishActionInput, target.GetComponent <CallNetworkEvents>().CallNetworkInvoke3);
            }
            if (!E_PlayerEvents.HasUnityEvent(target.GetComponent <vTriggerGenericAction>().OnStartAnimation, "CallNetworkInvoke4", target.GetComponent <CallNetworkEvents>()))
            {
                target.GetComponent <CallNetworkEvents>().GetType().GetField("NetworkInvoke4", E_Helpers.allBindings).SetValue(target.GetComponent <CallNetworkEvents>(), target.GetComponent <vTriggerGenericAction>().OnStartAnimation);
                target.GetComponent <vTriggerGenericAction>().OnStartAnimation = new UnityEvent();
                UnityEventTools.AddPersistentListener(target.GetComponent <vTriggerGenericAction>().OnStartAnimation, target.GetComponent <CallNetworkEvents>().CallNetworkInvoke4);
            }
            if (!E_PlayerEvents.HasUnityEvent(target.GetComponent <vTriggerGenericAction>().OnEndAnimation, "CallNetworkInvoke5", target.GetComponent <CallNetworkEvents>()))
            {
                target.GetComponent <CallNetworkEvents>().GetType().GetField("NetworkInvoke5", E_Helpers.allBindings).SetValue(target.GetComponent <CallNetworkEvents>(), target.GetComponent <vTriggerGenericAction>().OnEndAnimation);
                target.GetComponent <vTriggerGenericAction>().OnEndAnimation = new UnityEvent();
                UnityEventTools.AddPersistentListener(target.GetComponent <vTriggerGenericAction>().OnEndAnimation, target.GetComponent <CallNetworkEvents>().CallNetworkInvoke5);
            }

            ////GameObject Input UnityEvents
            //if (!E_PlayerEvents.HasUnityEvent(target.GetComponent<vTriggerGenericAction>().onPressActionInputWithTarget, "CallGameObjectInvoke1", target.GetComponent<CallNetworkEvents>()))
            //{
            //    target.GetComponent<CallNetworkEvents>().GetType().GetField("NetworkGameObjectInvoke1", E_Helpers.allBindings).SetValue(target.GetComponent<CallNetworkEvents>(), target.GetComponent<vTriggerGenericAction>().onPressActionInputWithTarget);
            //    target.GetComponent<vTriggerGenericAction>().onPressActionInputWithTarget = new OnDoActionWithTarget();
            //    UnityEventTools.AddPersistentListener(target.GetComponent<vTriggerGenericAction>().onPressActionInputWithTarget, target.GetComponent<CallNetworkEvents>().CallGameObjectInvoke1);
            //}
            //if (!E_PlayerEvents.HasUnityEvent(target.GetComponent<vTriggerGenericAction>().OnPlayerEnter, "CallGameObjectInvoke2", target.GetComponent<CallNetworkEvents>()))
            //{
            //    target.GetComponent<CallNetworkEvents>().GetType().GetField("NetworkGameObjectInvoke2", E_Helpers.allBindings).SetValue(target.GetComponent<CallNetworkEvents>(), target.GetComponent<vTriggerGenericAction>().OnPlayerEnter);
            //    target.GetComponent<vTriggerGenericAction>().OnPlayerEnter = new OnDoActionWithTarget();
            //    UnityEventTools.AddPersistentListener(target.GetComponent<vTriggerGenericAction>().OnPlayerEnter, target.GetComponent<CallNetworkEvents>().CallGameObjectInvoke2);
            //}
            //if (!E_PlayerEvents.HasUnityEvent(target.GetComponent<vTriggerGenericAction>().OnPlayerStay, "CallGameObjectInvoke3", target.GetComponent<CallNetworkEvents>()))
            //{
            //    target.GetComponent<CallNetworkEvents>().GetType().GetField("NetworkGameObjectInvoke3", E_Helpers.allBindings).SetValue(target.GetComponent<CallNetworkEvents>(), target.GetComponent<vTriggerGenericAction>().OnPlayerStay);
            //    target.GetComponent<vTriggerGenericAction>().OnPlayerStay = new OnDoActionWithTarget();
            //    UnityEventTools.AddPersistentListener(target.GetComponent<vTriggerGenericAction>().OnPlayerStay, target.GetComponent<CallNetworkEvents>().CallGameObjectInvoke3);
            //}
            //if (!E_PlayerEvents.HasUnityEvent(target.GetComponent<vTriggerGenericAction>().OnPlayerExit, "CallGameObjectInvoke4", target.GetComponent<CallNetworkEvents>()))
            //{
            //    target.GetComponent<CallNetworkEvents>().GetType().GetField("NetworkGameObjectInvoke4", E_Helpers.allBindings).SetValue(target.GetComponent<CallNetworkEvents>(), target.GetComponent<vTriggerGenericAction>().OnPlayerExit);
            //    target.GetComponent<vTriggerGenericAction>().OnPlayerExit = new OnDoActionWithTarget();
            //    UnityEventTools.AddPersistentListener(target.GetComponent<vTriggerGenericAction>().OnPlayerExit, target.GetComponent<CallNetworkEvents>().CallGameObjectInvoke4);
            //}

            ////Float Input UnityEvents
            //if (!E_PlayerEvents.HasUnityEvent(target.GetComponent<vTriggerGenericAction>().OnUpdateButtonTimer, "CallFloatInvoke1", target.GetComponent<CallNetworkEvents>()))
            //{
            //    target.GetComponent<CallNetworkEvents>().GetType().GetField("NetworkSingleInvoke1", E_Helpers.allBindings).SetValue(target.GetComponent<CallNetworkEvents>(), target.GetComponent<vTriggerGenericAction>().OnUpdateButtonTimer);
            //    target.GetComponent<vTriggerGenericAction>().OnUpdateButtonTimer = new vTriggerGenericAction.OnUpdateValue();
            //    UnityEventTools.AddPersistentListener(target.GetComponent<vTriggerGenericAction>().OnUpdateButtonTimer, target.GetComponent<CallNetworkEvents>().CallFloatInvoke1);
            //}
        }
Ejemplo n.º 11
0
Archivo: E_UI.cs Proyecto: ZRace/ZRace
        public static void CB_AddFreeForAllModernUI()
        {
            if (EditorUtility.DisplayDialog("Are you sure?",
                                            "This will overwrite the settings for your teamName, initialTeamSpawnPointNames, " +
                                            "autoSpawnPlayer, and allowTeamDamaging options on your NetworkManager component. " +
                                            "Do you want to continue?",
                                            "Yes, Add ModernUI", "No"))
            {
                GameObject     ui = (GameObject.Find("ModernUI") != null) ? GameObject.Find("ModernUI") : E_Helpers.CreatePrefabFromPath("InvectorMultiplayer/UI/PreBuilt/ModernUI.prefab");
                NetworkManager nm = FindObjectOfType <NetworkManager>();
                ui.transform.SetParent(nm.transform);

                //Setup team settings
                nm.allowTeamDamaging = true;
                nm.teamName          = "";
                nm.initalTeamSpawnPointNames.Clear();
                nm.autoSpawnPlayer = false;

                //Capture Event Groups
                UnityEvent       joinRoomEvents           = nm.roomEvents._onJoinedRoom;
                UnityEvent       onLeftLobby              = nm.lobbyEvents._onLeftLobby;
                PlayerEvent      onPlayerEnter            = nm.playerEvents._onPlayerEnteredRoom;
                PlayerEvent      onPlayerLeft             = nm.playerEvents._onPlayerLeftRoom;
                StringUnityEvent joinRoomFailedEvents     = nm.roomEvents._onJoinRoomFailed;
                StringUnityEvent createRoomFailedEvents   = nm.roomEvents._onCreateRoomFailed;
                StringUnityEvent onDisconnected           = nm.otherEvents._onDisconnected;
                StringUnityEvent onConnectionFailedEvents = nm.otherEvents._onConnectionFail;
                StringUnityEvent photonFailedEvents       = nm.otherEvents._onFailedToConnectToPhoton;

                if (!E_PlayerEvents.HasUnityEvent(createRoomFailedEvents, "NetworkErrorOccured", ui.GetComponent <UICoreLogic>()))
                {
                    UnityEventTools.AddPersistentListener(createRoomFailedEvents, ui.GetComponent <UICoreLogic>().NetworkErrorOccured);
                }
                if (!E_PlayerEvents.HasUnityEvent(joinRoomFailedEvents, "NetworkErrorOccured", ui.GetComponent <UICoreLogic>()))
                {
                    UnityEventTools.AddPersistentListener(joinRoomFailedEvents, ui.GetComponent <UICoreLogic>().NetworkErrorOccured);
                }
                if (!E_PlayerEvents.HasUnityEvent(onDisconnected, "NetworkErrorOccured", ui.GetComponent <UICoreLogic>()))
                {
                    UnityEventTools.AddPersistentListener(onDisconnected, ui.GetComponent <UICoreLogic>().NetworkErrorOccured);
                }
                if (!E_PlayerEvents.HasUnityEvent(photonFailedEvents, "NetworkErrorOccured", ui.GetComponent <UICoreLogic>()))
                {
                    UnityEventTools.AddPersistentListener(photonFailedEvents, ui.GetComponent <UICoreLogic>().NetworkErrorOccured);
                }
                if (!E_PlayerEvents.HasUnityEvent(onConnectionFailedEvents, "NetworkErrorOccured", ui.GetComponent <UICoreLogic>()))
                {
                    UnityEventTools.AddPersistentListener(onConnectionFailedEvents, ui.GetComponent <UICoreLogic>().NetworkErrorOccured);
                }

                E_Helpers.SetObjectIcon(ui, E_Core.h_uiIcon);
                Debug.Log("Successfully added \"ModernUI\" and setup the UnityEvents in the \"Network Manager\" and the \"ModernUI\".");
                if (EditorUtility.DisplayDialog("Successfully Added ModernUI!",
                                                "The UICoreLogic has a \"selectablePlayers\" gameobject array that must be populated with your converted players that " +
                                                "are stored in the \"Resources\" folder. A helper menu option is available for you to automatically find " +
                                                "all of your converted players in the \"Resources\" folder and add it to this components array.\n\n" +
                                                "You can find this helper method under CB Games > UI > Add > All Player Prefabs To UICoreLogic.",
                                                "Thanks For The Tip!"))
                {
                    Selection.activeGameObject = ui.gameObject;
                }
            }
        }
Ejemplo n.º 12
0
        public static void CB_AddGlobalChatBox()
        {
            if (!FindObjectOfType <NetworkManager>())
            {
                if (EditorUtility.DisplayDialog("Missing Network Manager", "No NetworkManager object was found in this scene. In order for this component to work properly there must be a network manager in the scene. Please add a \"NetworkManager\" component to the scene.",
                                                "Okay"))
                {
                }
            }
            else if (FindObjectOfType <ChatBox>())
            {
                Selection.activeGameObject = FindObjectOfType <ChatBox>().gameObject;
                if (EditorUtility.DisplayDialog("Scene Already Has ChatBox", "This scene already contains a \"ChatBox\" component. You should never add more than one at a time to a scene.",
                                                "Okay"))
                {
                }
            }
            else
            {
                string     chatBoxPrefabPath = string.Format("Assets{0}InvectorMultiplayer{0}UI{0}ChatBox.prefab", Path.DirectorySeparatorChar);
                GameObject ChatBox           = E_Helpers.CreatePrefabFromPath(chatBoxPrefabPath);
                ChatBox.transform.SetParent(FindObjectOfType <NetworkManager>().transform);
                ChatBox.GetComponent <ChatBox>().nm = FindObjectOfType <NetworkManager>();
                ChatBox.GetComponent <ChatBox>().GetType().GetField("openChatWindowOnPress", E_Helpers.allBindings).SetValue(ChatBox.GetComponent <ChatBox>(), new List <string> {
                    "T"
                });
                ChatBox.GetComponent <ChatBox>().GetType().GetField("closeWindowOnPress", E_Helpers.allBindings).SetValue(ChatBox.GetComponent <ChatBox>(), new List <string> {
                    "Escape"
                });
                ChatBox.GetComponent <ChatBox>().GetType().GetField("sendChatOnPress", E_Helpers.allBindings).SetValue(ChatBox.GetComponent <ChatBox>(), new List <string> {
                    "KeypadEnter", "Return"
                });
                E_Helpers.SetObjectIcon(ChatBox, E_Core.h_textChatIcon);

                //Join Room Events
                if (!E_PlayerEvents.HasUnityEvent(FindObjectOfType <NetworkManager>().roomEvents._onJoinedRoom, "SetActiveRoomAsChannelName", ChatBox.GetComponent <ChatBox>()))
                {
                    UnityEventTools.AddPersistentListener(FindObjectOfType <NetworkManager>().roomEvents._onJoinedRoom, ChatBox.GetComponent <ChatBox>().SetActiveRoomAsChannelName);
                }
                if (!E_PlayerEvents.HasUnityEvent(FindObjectOfType <NetworkManager>().roomEvents._onJoinedRoom, "Connect", ChatBox.GetComponent <ChatBox>()))
                {
                    UnityEventTools.AddPersistentListener(FindObjectOfType <NetworkManager>().roomEvents._onJoinedRoom, ChatBox.GetComponent <ChatBox>().Connect);
                }
                if (E_PlayerEvents.HasUnityEvent(FindObjectOfType <NetworkManager>().roomEvents._onJoinedRoom, "EnableVisualBox", ChatBox.GetComponent <ChatBox>()))
                {
                    UnityEventTools.AddBoolPersistentListener(FindObjectOfType <NetworkManager>().roomEvents._onJoinedRoom, ChatBox.GetComponent <ChatBox>().EnableVisualBox, true);
                }

                //Left Room Events
                if (!E_PlayerEvents.HasUnityEvent(FindObjectOfType <NetworkManager>().roomEvents._onLeftRoom, "EnableVisualBox", ChatBox.GetComponent <ChatBox>()))
                {
                    UnityEventTools.AddBoolPersistentListener(FindObjectOfType <NetworkManager>().roomEvents._onLeftRoom, ChatBox.GetComponent <ChatBox>().EnableVisualBox, false);
                }

                //Joined Room Failed Events
                if (!E_PlayerEvents.HasUnityEvent(FindObjectOfType <NetworkManager>().roomEvents._onJoinRoomFailed, "SetActiveChannel", ChatBox.GetComponent <ChatBox>()))
                {
                    UnityEventTools.AddStringPersistentListener(FindObjectOfType <NetworkManager>().roomEvents._onJoinRoomFailed, ChatBox.GetComponent <ChatBox>().SetActiveChannel, "lobbyChat");
                }

                // Misc - OnDisconnect Events
                if (!E_PlayerEvents.HasUnityEvent(FindObjectOfType <NetworkManager>().otherEvents._onDisconnected, "Disconnect", ChatBox.GetComponent <ChatBox>()))
                {
                    UnityEventTools.AddStringPersistentListener(FindObjectOfType <NetworkManager>().otherEvents._onDisconnected, ChatBox.GetComponent <ChatBox>().Disconnect, "");
                }
                if (!E_PlayerEvents.HasUnityEvent(FindObjectOfType <NetworkManager>().otherEvents._onDisconnected, "EnableChat", ChatBox.GetComponent <ChatBox>()))
                {
                    UnityEventTools.AddBoolPersistentListener(FindObjectOfType <NetworkManager>().otherEvents._onDisconnected, ChatBox.GetComponent <ChatBox>().EnableChat, false);
                }
            }
        }