A utility class to send simple network messages that only contain an integer.

Inheritance: UnityEngine.Networking.MessageBase
コード例 #1
0
 public static NetSystem.IntegerMessage GetIntegerMessage(int value)
 {
     if (_integerMessage == null)
     {
         _integerMessage = new NetSystem.IntegerMessage();
     }
     _integerMessage.value = value; return(_integerMessage);
 }
コード例 #2
0
 public void SendSceneLoadedMessage()
 {
     if (LogFilter.logDebug)
     {
         Debug.Log("NetworkLobbyPlayer SendSceneLoadedMessage");
     }
     NetworkLobbyManager singleton = NetworkManager.singleton as NetworkLobbyManager;
     if (singleton != null)
     {
         IntegerMessage msg = new IntegerMessage(base.playerControllerId);
         singleton.client.Send(0x2c, msg);
     }
 }
コード例 #3
0
    public void SendSceneLoadedMessage()
    {
        if (LogFilter.logDebug) { Debug.Log("NetworkLobbyPlayer SendSceneLoadedMessage"); }

        var lobby = NetworkManager.singleton as LobbyManager;
        if (lobby)
        {
            var msg = new IntegerMessage(playerControllerId);
            lobby.client.Send(MsgType.LobbySceneLoaded, msg);
        }
    }
コード例 #4
0
	IEnumerator RoundTimer(int seconds)
	{
		int currRoundsLeft = roundsToPlay;
		runningRound = true;
		while(--seconds > 0)
		{
			IntegerMessage msg = new IntegerMessage();
			msg.value = seconds;
			NetworkServer.SendToAll((short)MsgTypes.RoundStart, msg);
			if (currRoundsLeft == roundsToPlay)
				yield return new WaitForSeconds(1);
			else
				yield return null;
		}
		
		if (currRoundsLeft == roundsToPlay) //defenders won
			Win(attackingTeam.Enemy());
	}
コード例 #5
0
	IEnumerator PrepTimer(int seconds)
	{
		runningRound = false;
		while(--seconds > 0)
		{
			IntegerMessage msg = new IntegerMessage();
			msg.value = seconds;
			NetworkServer.SendToAll((short)MsgTypes.PrepTimeStart, msg);
			yield return new WaitForSeconds(1);
		}
		foreach (Player p in players)
		{
			p.waitingForRound = false;
			p.controller.controllable = true;
		}
		
		StartCoroutine(RoundTimer(roundSeconds));
	}
コード例 #6
0
        /// <summary>
        /// 
        /// <para>
        /// This is used on clients to tell the server that the client has switched from the lobby to the GameScene and is ready to play.
        /// </para>
        /// 
        /// </summary>
        public void SendSceneLoadedMessage()
        {
            if (LogFilter.logDebug)
            Debug.Log((object) "NetworkLobbyPlayer SendSceneLoadedMessage");

              NetworkLobbyManager networkLobbyManager = NetworkManager.singleton as NetworkLobbyManager;

              if (!(bool) ((Object) networkLobbyManager))
            return;

              IntegerMessage integerMessage = new IntegerMessage((int) this.playerControllerId);
              networkLobbyManager.client.Send((short) 44, (MessageBase) integerMessage);
        }
コード例 #7
0
        /// <summary>
        /// 
        /// <para>
        /// This is used on clients to tell the server that this player is ready for the game to begin.
        /// </para>
        /// 
        /// </summary>
        public void SendReadyToBeginMessage()
        {
            if (LogFilter.logDebug)
            Debug.Log((object) "NetworkLobbyPlayer SendReadyToBeginMessage");

              NetworkLobbyManager networkLobbyManager = NetworkManager.singleton as NetworkLobbyManager;

              if (!(bool) ((Object) networkLobbyManager))
            return;

              // Send the players controller id to server to signal this player as ready
              IntegerMessage integerMessage = new IntegerMessage((int) this.playerControllerId);
              networkLobbyManager.client.Send((short) 43, (MessageBase) integerMessage);
        }