Example #1
0
        private void InputManager_Update(On.InputManager.orig_Update orig, InputManager self)
        {
            KeyCode key = (KeyCode)Enum.Parse(typeof(KeyCode), (mod.settings as PingSettings).Key);

            if (Input.GetKeyDown(key))
            {
                // First, find the mouse position as a unity vector
                // Next, spawn something there that lasts for x seconds
                // Finally, remove it after those seconds pass
                IGameCameraService gameCameraManager = Services.GetService <IGameCameraService>();
                GameNetworkManager net    = GameObject.FindObjectOfType <GameNetworkManager>();
                IMessageBox        msgBox = new DynData <GameNetworkManager>(net).Get <IMessageBox>("messageBox");

                RaycastHit[] array = Physics.RaycastAll(gameCameraManager.ScreenPointToRay(Input.mousePosition), float.PositiveInfinity);
                Array.Sort <RaycastHit>(array, (RaycastHit hitInfo1, RaycastHit hitInfo2) => hitInfo1.distance.CompareTo(hitInfo2.distance));

                // In theory the first raycast hit should be the best?
                // Not sure if this is the case...
                Vector3 mousePos = array[0].point;

                mod.Log("Raycast hits:");
                foreach (RaycastHit ra in array)
                {
                    mod.Log("Dist: " + ra.distance + " with pos: " + ra.point);
                }

                mod.Log("Mouse pos: " + mousePos.ToString());

                bool assert = (bool)typeof(GameNetworkManager).GetMethod("AssertMessageBoxIsSet", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance).Invoke(net, new object[0]);
                if (assert && msgBox != null && net != null)
                {
                    PingMessage pm = new PingMessage();
                    pm.SetPos(mousePos);
                    Message m = pm as Message;

                    mod.Log("Assertion: " + assert);
                    mod.Log("Net: " + net.name);
                    mod.Log("MSG BOX: " + msgBox.ToString());

                    EP2PSend temp = msgBox.SteamNetworkingSendMode;
                    msgBox.SteamNetworkingSendMode = EP2PSend.k_EP2PSendReliable;
                    msgBox.SendMessage(ref m, net.GetLobbyPlayerIDs());
                    msgBox.SteamNetworkingSendMode = temp;

                    mod.Log("Attempting to display!");
                }
                else
                {
                    GameObject obj = new GameObject("PING OBJECT");
                    PingScript p   = obj.AddComponent <PingScript>();
                    p.pos = mousePos;
                    mod.Log("It seems the game is not in multiplayer, attempting to create a local ping!");
                }
            }
            orig(self);
        }
Example #2
0
            public void CreatePingObject()
            {
                mod.Log("Creating a ping object!");
                Dungeon    d    = SingletonManager.Get <Dungeon>(false);
                GameObject obj  = new GameObject("PING OBJECT");
                PingScript ping = obj.AddComponent <PingScript>();

                ping.pos = pos;
                new DynData <Dungeon>(d).Get <IAudioEventService>("audioEventManager").Play2DEvent("Master/Jingles/Exit");
            }
Example #3
0
    public void UpdatePing()
    {
        int index = 0;

        equiposContent.GetComponent <RectTransform>().localPosition = new Vector2(0, -1585);
        foreach (Ping pin in clientes[idClienteSelected].sucursales[idSucursalSelected].ping)
        {
            GameObject a    = Instantiate(pingPrefab) as GameObject;
            PingScript temp = a.GetComponent <PingScript>();
            temp.nombreText.text = clientes [idClienteSelected].sucursales[idSucursalSelected].ping[index].nombre;
            temp.fechaText.text  = clientes [idClienteSelected].sucursales[idSucursalSelected].ping[index].fecha;
            a.transform.SetParent(equiposContent.transform, false);
            index++;
        }
    }