Inheritance: NetworkManager
Esempio n. 1
0
        private void MyNetworkManager_OnReceiveNetMessageClient(MyNetworkManager.NetMessage obj)
        {
            if (!obj.IsSameReceiverID(UID))
            {
                return;
            }

            switch (obj.MsgType)
            {
            case MyNetworkManager.NET_GAME_MESSAGE.MSG_SYNC_PULL_VALUE:
                if (!MyNetworkManager.IsMyID(obj.SenderID))
                {
                    obj.Sub(out float newPullValue);
                    m_fPrevPulledvalue = m_fPulledValue;
                    m_fPulledValue     = newPullValue;
                    m_comunicationData.Receive();

                    if (!m_GrabData.IsGrabbing)
                    {
                        TranslatePullingTarget(m_fPulledValue);
                    }
                }
                break;
            }
        }
Esempio n. 2
0
    /*
     * IEnumerator LoadDevice(string newDevice)
     * {
     *  if (String.Compare(XRSettings.loadedDeviceName, newDevice, true) != 0)
     *  {
     *      XRSettings.LoadDeviceByName(newDevice);
     *      yield return null;
     *      XRSettings.enabled = true;
     *  }
     * }
     *
     *
     * //http://talesfromtherift.com/googlevr-cardboard-switch-between-normal-mode-and-vr-mode-at-run-time/
     * // https://docs.unity3d.com/ScriptReference/XR.XRSettings.LoadDeviceByName.html
     * void ToggleVR()
     * {
     *
     *  if (XRSettings.loadedDeviceName == "Cardboard")
     *  {
     *    //  XRSettings.enabled = false;
     *      StartCoroutine(LoadDevice("None"));
     *  }
     *  else
     *  {
     *      XRSettings.enabled = true;
     *      Screen.orientation = ScreenOrientation.AutoRotation;
     *      StartCoroutine(LoadDevice("Cardboard"));
     *  }
     *
     *  Debug.Log("XR Settings are: " + XRSettings.enabled);
     *  Debug.Log("active: " + XRSettings.isDeviceActive);
     *  Debug.Log("supported: " + XRSettings.supportedDevices);
     * }
     */
    public void ChangeSceneToServer()
    {
        Debug.Log("Hello serverbutton");
        // Debug.Log("XR Settings are: " + XRSettings.enabled);
        notificationText.text = "Initialising Server";
        if (GameObject.FindWithTag("ClientButton") != null)
        {
            Debug.Log("Client Button found and set false.");
            GameObject.FindWithTag("ClientButton").SetActive(false);
        }
        if (networkManager == null)
        {
            networkManager = MyNetworkManager.getInstance();
            Debug.Log("Networkmanager is null.");
            notificationText.text = "Networkmanager null";
            return;
        }


        TextMeshProUGUI networkAdressText = GameObject.Find("AdressInput_Text").GetComponent <TextMeshProUGUI>();

        networkManager.InitServer();

        // bool waiting = networkManager.GetUDPChat().ConnectAsServer(notificationText.text);
        //  SceneManager.LoadScene("SampleScene");

        Debug.Log("Waiting for Client ...");
        notificationText.text = "Waiting for Client ...";
        networkManager.GetUDPChat().StartListening();


        //    Debug.Log("Address: " + networkManager.GetServerNetworkAdress());
    }
Esempio n. 3
0
 // Use this for initialization
 void Start()
 {
     netManager = GameObject.Find ("NetManager").GetComponent<MyNetworkManager>();
     if (netManager.isHost) {
         isHider = true;
     }
 }
Esempio n. 4
0
 public void Construct(ServiceProvider provider, ConnectionStateMachine connMachine, UIManager uiManager)
 {
     _netManager   = provider.networkManager;
     _netDiscovery = provider.networkDiscovery;
     _connMachine  = connMachine;
     _uiManager    = uiManager;
 }
Esempio n. 5
0
        private void TriggerUp(stExternalInteractData _externalInteractData)
        {
            //Debug.Log("Trigger Up : " + name + " " + _externalInteractData.HandType);
            if (isRequestedGrabMessage)
            {
                return;
            }

            bool isGrab = VRHandEventHandler.IsGrab(_externalInteractData.HandType, this);

            if (isGrab)
            {
                isRequestedGrabMessage = true;
                Vector3    pos      = Pivot.position;
                Quaternion rot      = Pivot.rotation;
                Vector3    velocity = VRInputManager.GetVelocity(_externalInteractData.HandType, VRInputManager.PositionType.CONTROLLER);

                if (m_bIsOnlyLocalObject)
                {
                    m_GrabData.SetUnGrabData(_externalInteractData.HandType, pos, rot, velocity, Time.time);
                    UnGrabSomething();
                }
                else
                {
                    //Debug.Log("Send UnGrab : " + name + " " + _externalInteractData.HandType);
                    MyNetworkManager.SendToServer_UnGrab(UID, _externalInteractData.HandType, pos, rot, velocity);
                }
            }
        }
Esempio n. 6
0
        private void TriggerDown(stExternalInteractData _externalInteractData)
        {
            Debug.Log("Trigger Down : " + name + " " + _externalInteractData.HandType);

            if (isRequestedGrabMessage)
            {
                return;
            }
            isRequestedGrabMessage = true;
            Transform  grabTm = VRHandEventHandler.GetHandGrabPivot(_externalInteractData.HandType);
            Vector3    pos    = grabTm.InverseTransformPoint(Pivot.position);
            Quaternion rot    = Quaternion.Inverse(grabTm.rotation) * Pivot.rotation;

            if (m_GrabData.AmIGrabbing && m_GrabData.HandType != _externalInteractData.HandType)
            {
                VRHandEventHandler.UnGrabInteractObject(m_GrabData.HandType, this);
            }

            if (m_bIsOnlyLocalObject)
            {
                m_GrabData.SetGrabData(MyNetworkManager.MyNetID, _externalInteractData.HandType, pos, rot, Time.time);
                GrabSomething();
            }
            else
            {
                //Debug.Log("Send Grab : " + name + " " + _externalInteractData.HandType);
                MyNetworkManager.SendToServer_Grab(UID, _externalInteractData.HandType, pos, rot);
            }
        }
Esempio n. 7
0
    public void DisconnectHost()
    {
        this.Display(false);
        MyNetworkManager Manager = GameObject.FindGameObjectWithTag("NetworkManager").GetComponent <MyNetworkManager>();

        Manager.StopHost();
    }
Esempio n. 8
0
    public void HandlePressEvent()
    {
        Transform parent = transform.parent;

        while (!parent.GetComponent <Canvas>())
        {
            parent = parent.transform.parent;
        }

        Canvas     parentCanvas  = parent.gameObject.GetComponent <Canvas>();
        InputField fieldToModify = null;

        for (int i = 0; i < parentCanvas.transform.childCount; i++)
        {
            InputField field = parentCanvas.transform.GetChild(i).GetComponent <InputField>();
            if (field)
            {
                fieldToModify = field;
                break;
            }
        }

        string matchName = fieldToModify.text;

        if (!stop && matchName.Length > 0)
        {
            MyNetworkManager myNetwork = GameObject.Find("NetworkManager").GetComponent <MyNetworkManager>();
            myNetwork.StartGame(matchName);
            stop = true;
        }
        else
        {
            fieldToModify.image.color = Color.red;
        }
    }
Esempio n. 9
0
    // Use this for initialization
    void Start()
    {
        ChatCanvas.enabled = false;
        RealChannelName rn = new RealChannelName();

        rn.userName    = "******";
        rn.channelName = GameChannels[0];
        RealChannelsNames.Add(rn);
        RefreshChannelsList();

        if (NetworkManager == null && GameObject.Find("NetworkManager") != null)
        {
            NetworkManager = GameObject.Find("NetworkManager").GetComponent <MyNetworkManager> ();
        }

        if (MessageNotifyComponent == null && GameObject.Find("MessageNotify-Canvas") != null)
        {
            MessageNotifyComponent = GameObject.Find("MessageNotify-Canvas").GetComponent <MessageNotify> ();
        }

        if (POPUPWindowComponent == null && GameObject.Find("POPUP-Canvas") != null)
        {
            POPUPWindowComponent = GameObject.Find("POPUP-Canvas").GetComponent <MainMenuPOPUP> ();
        }
    }
Esempio n. 10
0
 /* Awake(): de esta clase crea las esferas que sirven para determinar la posición del coche en relación al circuito
  * También se encarga de inicializar variables y establecer las referencias de los scripts necesarios
  */
 private void Awake()
 {
     if (networkManager == null)
     {
         networkManager = FindObjectOfType <NetworkManager>();
     }
     if (m_CircuitController == null)
     {
         m_CircuitController = FindObjectOfType <CircuitController>();
     }
     m_DebuggingSpheres = new GameObject[networkManager.maxConnections];
     for (int i = 0; i < networkManager.maxConnections; ++i)
     {
         m_DebuggingSpheres[i] = GameObject.CreatePrimitive(PrimitiveType.Sphere);
         m_DebuggingSpheres[i].GetComponent <SphereCollider>().enabled = false;
         m_DebuggingSpheres[i].GetComponent <MeshRenderer>().enabled   = false;
     }
     m_UIManager = FindObjectOfType <UIManager>();
     m_UIManager.m_polePositionManager = this; //de esta forma sabemos la relacion de cada poleposition con ui manager de cada player
     if (isServer)
     {
         started = false;
         full    = false;
     }
     m_MyNetworkManager = FindObjectOfType <MyNetworkManager>();
     numVueltas         = 3;
     m_UIManager.InitLaps();
 }
Esempio n. 11
0
    // Update is called once per frame
    void Update()
    {
        Cursor.lockState = CursorLockMode.None;
        Cursor.visible   = true;
        if (mnm == null)
        {
            mnm = GameObject.Find("NetworkManager").GetComponent <MyNetworkManager>();
        }

        if (Input.GetKeyDown("k"))
        {
            if (matchNameColumn != null)
            {
                //matchNameColumn.AddRow(0);
            }
        }

        if (mnm != null && MyNetworkManager.singleton.matchMaker != null)
        {
            MyNetworkManager.singleton.matchMaker.ListMatches(0, 20, "", MyNetworkManager.singleton.OnMatchList);
            if (mnm.AreMatches())
            {
                if (matchsCount < mnm.matches.Count)
                {
                    for (int run = matchsCount; run < mnm.matches.Count; run++)
                    {
                        matchNameColumn.AddRow(run);
                    }
                    matchsCount = mnm.matches.Count;
                }
            }
        }
    }
Esempio n. 12
0
    private IEnumerator WaitForDataAndBackToGame(string RoomName, string gameMode)
    {
        MyNetworkManager    netManager = GameObject.Find("NetworkManager").GetComponent <MyNetworkManager> ();
        DeckTableController deckTable  = GameObject.Find("DeckSelect-Canvas").GetComponent <DeckTableController> ();

        if (netManager != null)
        {
            while (DataSaved)
            {
                yield return(new WaitForSeconds(0.5f));
            }

            netManager.GameMode = (MyNetworkManager.gameModeEnum)Enum.Parse(typeof(MyNetworkManager.gameModeEnum), gameMode);
            GameObject deck = deckTable.SpawnDeck(FromPrevGame.DeckName,
                                                  FromPrevGame.HeroName, FromPrevGame.CardsNames);
            //deck.GetComponent<Deck> ().SpawnReverses (Deck.deckSize);
            deck.transform.localScale = new Vector3(0, 0, 0);
            netManager.PrevRoomName   = RoomName;
            netManager.MainMenuComponent.SetupPlayButtonReconnect();
            netManager.SetDeckToPlay(deck);
            if (netManager.AutoRejoin)
            {
                netManager.RejoinGame();
            }
        }
        yield return(null);
    }
Esempio n. 13
0
    public void JoinGameClick()
    {
        MyNetworkManager nm = MyNetworkManager.singleton;

        nm.networkAddress = ipAddressText.text;
        nm.StartClient();
    }
Esempio n. 14
0
 protected override void OnUnGrab()
 {
     if (m_GrabData.WasIGrabbing)
     {
         MyNetworkManager.SendToServer_FloatValue(MyNetworkManager.NET_GAME_MESSAGE.MSG_SYNC_PULL_VALUE, UID, m_fPulledValue);
         m_comunicationData.Send();
     }
 }
Esempio n. 15
0
    // Start is called before the first frame update
    void Start()
    {
        //networkManager = GameObject.Find("/Network").GetComponent<MyNetworkManager>();
        networkManager = MyNetworkManager.getInstance();

        //  clientButton = GetComponent<Button>();
        //  clientButton.onClick.AddListener(ChangeSceneToClient);
    }
Esempio n. 16
0
 void Start()
 {
     networkManager = NetworkHandler.GetComponent <MyNetworkManager>();
     _drawStates    = new DrawState[_pinchDetectors.Length];
     for (int i = 0; i < _pinchDetectors.Length; i++)
     {
         _drawStates[i] = new DrawState(this);
     }
 }
Esempio n. 17
0
 void TargetsendFood(NetworkConnection conn, int fd)
 {
     if (nm == null)
     {
         nm = GameObject.Find("Network Manager").GetComponent <MyNetworkManager>();
     }
     Debug.Log("FOOD TRPC");
     nm.transform.GetChild(3).GetChild(2).GetComponent <Text>().text = "Food: " + fd;
 }
Esempio n. 18
0
    public void JoinHost()
    {
        this.Display(true);
        MyNetworkManager Manager = GameObject.FindGameObjectWithTag("NetworkManager").GetComponent <MyNetworkManager>();

        Manager.networkAddress = IP.text;
        Manager.networkPort    = Port;
        Manager.StartClient();
    }
Esempio n. 19
0
 void TargetsendPoints(NetworkConnection conn, int pts)
 {
     if (nm == null)
     {
         nm = GameObject.Find("Network Manager").GetComponent <MyNetworkManager>();
     }
     Debug.Log("POINTS TRPC");
     nm.transform.GetChild(3).GetChild(1).GetComponent <Text>().text = "Gold: " + pts;
 }
Esempio n. 20
0
    public void StartHost(bool solo)
    {
        this.solo = solo;
        this.Display(true);
        MyNetworkManager Manager = GameObject.FindGameObjectWithTag("NetworkManager").GetComponent <MyNetworkManager>();

        Manager.networkPort = Port;
        Manager.StartHost();
    }
Esempio n. 21
0
 // Use this for initialization
 void Start()
 {
     //canvasA = GameObject.Find("HUD").GetComponent<Canvas>();
     //canvasA.enabled = false;
     //playerList = FindObjectsOfType<networkPlayer>();
     //if (isServer)
     //{
     manager = GameObject.Find("Network Manager").GetComponent <MyNetworkManager>();
 }
Esempio n. 22
0
    //Called in create level scene to start the game
    public void CreateGame(Text matchName)
    {
        MyNetworkManager myNetwork = GameObject.Find("NetworkManager").GetComponent <MyNetworkManager>();;

        myNetwork.matchName = matchName.text;
        myNetwork.matchSize = 2;
        MyNetworkManager.singleton.matchName = matchName.text;
        myNetwork.StartGame(matchName.text);
    }
Esempio n. 23
0
    private void Start()
    {
        _networkManager  = MyNetworkManager.Instance;
        _mainMenuManager = MainMenuManager.Instance;
        _gameController  = GameController.Instance;

        _playerName = _mainMenuManager.PlayerNametInput.text;
        //_networkManager.playerJoined += InstantiatePlayerList;
    }
Esempio n. 24
0
    void RemoveDelegate()
    {
        MyNetworkManager nm = MyNetworkManager.singleton;

        nm.delegateOnStartHost             -= OnStartHost;
        nm.delegateOnStartClient           -= OnStartClient;
        nm.delegateOnStopHost              -= OnDisconnected;
        nm.delegateOnStopClient            -= OnDisconnected;
        GameManager.delegateOnStateChanged -= OnGameStateChanged;
    }
Esempio n. 25
0
 /* Awake(): establece las relaciones de esta clase con el resto de las necesarias.
  * Para ello o bien las busca en el componente o bien las busca en el proyecto.
  * También inicializa el valor de la referencia de m_MyNetworkManager con esta clase.
  */
 private void Awake()
 {
     m_PlayerInfo                     = GetComponent <PlayerInfo>();
     m_PlayerController               = GetComponent <PlayerController>();
     m_NetworkManager                 = FindObjectOfType <NetworkManager>();
     m_PolePositionManager            = FindObjectOfType <PolePositionManager>();
     m_UIManager                      = FindObjectOfType <UIManager>();
     m_MyNetworkManager               = FindObjectOfType <MyNetworkManager>();
     m_MyNetworkManager.m_SetUpPlayer = this;
 }
Esempio n. 26
0
    //void OnLeftRoom() {
    //Application.LoadLevel("Main_Menu");
    //SceneManager.LoadScene(ExitScene);
    //}

    public void AddCurrentPlayerToFriends()
    {
        if (GameObject.Find("NetworkManager") != null)
        {
            MyNetworkManager netManager = GameObject.Find("NetworkManager").GetComponent <MyNetworkManager> ();
            netManager.ChatHandler.LocalFriendListComponent.AddFriend(OnlinePlayersNameComponent.enemyPlayerName);
            AddFriendBtn.interactable = false;
        }
        CloseSubmenu();
    }
Esempio n. 27
0
    void resolveGame()
    {
        GameObject[] players = GameObject.FindGameObjectsWithTag("Player");
        Debug.Log("Player " + players[0].name + " wins yo!");
        DestroyObject(players [0].gameObject);
        DestroyObject(this.gameObject);
        MyNetworkManager networkManager = GameObject.Find("Network").GetComponent <MyNetworkManager>();

        networkManager.reset();
    }
Esempio n. 28
0
    // Use this for initialization
    void Start()
    {
        PlayerReadySignal.color = TextNotReadyColor;
        FriendReadySignal.color = TextNotReadyColor;

        if (NetworkManager == null && GameObject.Find("NetworkManager") != null)
        {
            NetworkManager = GameObject.Find("NetworkManager").GetComponent <MyNetworkManager> ();
        }
    }
Esempio n. 29
0
    //----------------------------------------------------------------------------------------------------
    /// <summary>
    /// 初期
    /// </summary>
    void Start()
    {
        m_netManager = FindObjectOfType <MyNetworkManager>();
        m_netManager.IsStandbyState = false;
        m_countMatchingTime         = 0;

        //Sound
        MySoundManager.Instance.Play(BgmCollection.Matching);
        MySoundManager.Instance.Play(SeCollection.CrossShip, true, true, Vector3.zero);
    }
Esempio n. 30
0
 void Awake()
 {
     networkManager = FindObjectOfType <MyNetworkManager>();
     lobbyUI        = FindObjectOfType <LobbyUI>();
     hostButton.onClick.AddListener(StartHostingCreation);
     createLanButton.onClick.AddListener(StartLANCreation);
     joinLanButton.onClick.AddListener(StartClient);
     startButton.onClick.AddListener(StartGame);
     quitButton.onClick.AddListener(LastState);
     ActiveGameLobby();
 }
 public void Awake()
 {
     if (!instance)
     {
         instance = this;
     }
     else if (instance != this)
     {
         Destroy(gameObject);
     }
 }
Esempio n. 32
0
 // Use this for initialization
 void Start()
 {
     IsNetworkUp = true;
     instance = this;
 }
 void OnEnable()
 {
     manager = GameObject.Find("NetworkManager").GetComponent<MyNetworkManager>();
     manager.EventConnectPlayer += Listener;
     manager.EventDisconnectPlayer += Listener;
 }
 // Use this for initialization
 void Start()
 {
     if (!isServer) return;
     if (terrainParent != null)
         terrainParentInfo = terrainParent.GetComponent<TerrainInfo>();
     manager = GameObject.Find("NetworkManager").GetComponent<MyNetworkManager>();
     StartCoroutine(GetCollectableAreas());
 }
Esempio n. 35
0
    void Awake()
    {
        longIntro = GameObject.Find("LongIntro");
        fadingText = longIntro.GetComponent<FadeObjectInOut>();
        introBackground = GameObject.Find("IntroBackground");
        introBackground.SetActive(false);
        introText = GameObject.Find ("IntroText");
        introText.SetActive(false);
        winText = (GameObject)Instantiate (winTextPrefab, new Vector3 (0f, -1f, 33f), Quaternion.identity);
        winText.SetActive (false);
        scoreText = GameObject.Find ("ScoreText").GetComponent<Text> ();
        highScoreText = GameObject.Find ("HighScore").GetComponent<Text> ();
        timeText = GameObject.Find ("TimeText").GetComponent<Text> ();
        rotServer = GameObject.Find("RotationServer").GetComponent<RotationServer>();
        networkManager = GameObject.Find ("MyNetworkManager").GetComponent<MyNetworkManager> ();
        _usedDevice = Device.Android;

        _gameState = State.NetworkSetup;
        OnStateEntering ();
    }
Esempio n. 36
0
	void Start (){
		manager = GameObject.FindWithTag ("NetworkManager").GetComponent<MyNetworkManager> ();
		UpdateNames ();
		//Debug.Log ("Player: " + gameObject.name + "   PCID: " + playerControllerId);
	}
Esempio n. 37
0
	void Start (){
		manager = GameObject.FindWithTag ("NetworkManager").GetComponent<MyNetworkManager> ();
		//Invoke ("UpdateNames", 0.2f);
	}