public override void OnClientSceneChanged(NetworkConnection conn) { // Create message which stores our custom identifier IntegerMessage msg = new IntegerMessage(avatarIndex); // always become ready. ClientScene.Ready(conn); bool addPlayer = (ClientScene.localPlayers.Count == 0); bool foundPlayer = false; for (int i = 0; i < ClientScene.localPlayers.Count; i++) { if (ClientScene.localPlayers[i].gameObject != null) { Debug.Log("OnClientSceneChanged:: foundPlayer"); foundPlayer = true; break; } } if (!foundPlayer) { // there are players, but their game objects have all been deleted addPlayer = true; Debug.Log("OnClientSceneChanged:: !foundPlayer"); } if (addPlayer) { Debug.Log("OnClientSceneChanged:: addPlayer"); // Call Add player and pass the message ClientScene.AddPlayer(conn, 0, msg); } Debug.Log("OnClientSceneChanged:: done"); }
public override void OnClientConnect(NetworkConnection conn) { playerid++; IntegerMessage msg = new IntegerMessage(playerindex); ClientScene.AddPlayer(conn, isclient, msg); }
public override void OnClientSceneChanged(NetworkConnection conn) { IntegerMessage msg = new IntegerMessage(curPlayer); ClientScene.Ready(conn); ClientScene.AddPlayer(conn, 0, msg); }
static void Postfix(float ___m_refire_missile_time, Player ___c_player) { if (!GameplayManager.IsMultiplayerActive || !Server.IsActive() || !(___m_refire_missile_time == 1f && ___c_player.m_old_missile_type != MissileType.NUM && ___c_player.m_missile_ammo[(int)___c_player.m_old_missile_type] == 0)) // just switched? { return; } // make sure ammo is also zero on the client ___c_player.CallRpcSetMissileAmmo((int)___c_player.m_old_missile_type, 0); // workaround for not updating missle name in hud ___c_player.CallRpcSetMissileType(___c_player.m_missile_type); ___c_player.CallTargetUpdateCurrentMissileName(___c_player.connectionToClient); // make sure alternating missle fire is equal int connectionId = ___c_player.connectionToClient.connectionId; if (MPTweaks.ClientHasNetVersion(connectionId, MPCreeperSync.NET_VERSION_CREEPER_SYNC)) { var msg = new IntegerMessage(___c_player.c_player_ship.m_alternating_missile_fire ? 1 : 0); NetworkServer.SendToClient(connectionId, CreeperSyncMsg.MsgSetAlternatingMissleFire, msg); } }
public void ClientRcvStoryCard(NetworkMessage msg) { IntegerMessage data = msg.ReadMessage <IntegerMessage>(); Debug.Log("Got card " + data.value); spawnCard(data.value); }
public override void OnClientSceneChanged(NetworkConnection conn) { Debug.Log("didsdsdsdscks"); IntegerMessage msg = new IntegerMessage(characterSelected); ClientScene.AddPlayer(conn, playerControllerID, msg); }
public override void OnClientSceneChanged(NetworkConnection conn) { // always become ready. ClientScene.Ready(conn); if (!autoCreatePlayer) { return; } IntegerMessage msg = new IntegerMessage(avatarIndex); bool addPlayer = (ClientScene.localPlayers.Count == 0); bool foundPlayer = false; foreach (var playerController in ClientScene.localPlayers) { if (playerController.gameObject != null) { foundPlayer = true; break; } } if (!foundPlayer) { // there are players, but their game objects have all been deleted addPlayer = true; } if (addPlayer) { ClientScene.AddPlayer(conn, 0, msg); } }
/// Copied from Unity's original NetworkManager 'OnServerAddPlayerInternal' script except where noted /// Since OnServerAddPlayer calls OnServerAddPlayerInternal and needs to pass the message - just add it all into one. public override void OnServerAddPlayer(NetworkConnection conn, short playerControllerId, NetworkReader extraMessageReader) { /// *** additions /// I skipped all the debug messages... /// This is added to recieve the message from addPlayer()... /// int pci = Convert.ToInt32(playerControllerId) + pciOffset; playerControllerId = (short)pci; pciOffset++; Debug.Log(playerControllerId); int id = 0; if (extraMessageReader != null) { IntegerMessage i = extraMessageReader.ReadMessage <IntegerMessage>(); id = i.value; //Debug.Log(id); } /// using the sent message - pick the correct prefab GameObject playerPrefab = spawnPrefabs[id]; //Debug.Log(playerPrefab.name); /// *** end of additions GameObject player; player = (GameObject)Instantiate(playerPrefab, playerSpawnPosition[UnityEngine.Random.Range(0, playerSpawnCount)], Quaternion.identity); //player name 변경 //StartCoroutine(ChangeName(player)); NetworkServer.AddPlayerForConnection(conn, player, playerControllerId); }
public override void OnClientConnect(NetworkConnection conn) { if (TitleScreenData.Gender == "Female") { prefabIndx = spawnPrefabs.FindIndex( delegate(GameObject obj) { return(obj.name == "Player_Female"); }); } else { prefabIndx = spawnPrefabs.FindIndex( delegate(GameObject obj) { return(obj.name == "Player_Male"); }); } IntegerMessage msg = new IntegerMessage(prefabIndx); if (!clientLoadedScene) { ClientScene.AddPlayer(conn, 0, msg); } }
//Called on client when connect public override void OnClientConnect(NetworkConnection conn) { NetworkStartPosition[] spawnPositionArray = FindObjectsOfType <NetworkStartPosition>(); if (spawnPositionArray.Length > 1) { spawnPosition = new Transform[spawnPositionArray.Length]; int i = 0; foreach (var transform in spawnPositionArray) { spawnPosition[i] = spawnPositionArray[i++].transform; } } else { spawnPosition = new Transform[1]; Debug.Log("no spawn positions"); spawnPosition[0].position = new Vector3(0, 0, 0); } // Create message to set the player IntegerMessage msg = new IntegerMessage(curPlayer); // Call Add player and pass the message ClientScene.AddPlayer(conn, 0, msg); }
public void OnDieLockToggle(NetworkMessage msg) { if (msg.conn.connectionId == battle.currentTurn) { IntegerMessage actualMsg = msg.ReadMessage <IntegerMessage>(); int die = actualMsg.value; bool newLockState = !battle.locks[die]; if (newLockState) { int currentlyLocked = 0; for (int i = 0; i < battle.locks.Length; i++) { if (battle.locks[die]) { currentlyLocked++; } } int possibleLocks = (int)(battle.GetCurrentPawn() as PlayerPawn).LockCount.GetValue(battle.locks.Length); if (currentlyLocked >= possibleLocks) { string dieText = "more than @FFFFFF" + possibleLocks + ((possibleLocks == 1) ? " die" : " dice"); if (possibleLocks == 0) { dieText = "any dice"; } NetworkServer.SendToClient(msg.conn.connectionId, GameMsg.ShowMessage, new StringMessage("You can't lock " + dieText + " at the moment.")); return; } } battle.locks[die] = !battle.locks[die]; NetworkServer.SendToAll(GameMsg.ToggleDieLock, actualMsg); } }
/// Copied from Unity's original NetworkManager 'OnServerAddPlayerInternal' script except where noted /// Since OnServerAddPlayer calls OnServerAddPlayerInternal and needs to pass the message - just add it all into one. public override void OnServerAddPlayer(NetworkConnection conn, short playerControllerId, NetworkReader extraMessageReader) { /// *** additions /// I skipped all the debug messages... /// This is added to recieve the message from addPlayer()... int id = 0; if (extraMessageReader != null) { IntegerMessage i = extraMessageReader.ReadMessage <IntegerMessage>(); id = i.value; } /// using the sent message - pick the correct prefab GameObject playerPrefab = spawnPrefabs[id]; /// *** end of additions GameObject player; Transform startPos = GetStartPosition(); if (startPos != null) { player = (GameObject)Instantiate(playerPrefab, startPos.position, startPos.rotation); } else { player = (GameObject)Instantiate(playerPrefab, Vector3.zero, Quaternion.identity); } NetworkServer.AddPlayerForConnection(conn, player, playerControllerId); }
private void sendPlayerID(NetworkConnection conn) { IntegerMessage msg = new IntegerMessage(); if (!playersConnected.Contains(0)) { conn.Disconnect(); } else { for (int i = 0; i < 4; i++) { if (playersConnected[i] == 0) { msg.value = playerIDTest[i]; NetworkServer.SendToClient(conn.connectionId, 121, msg); readyClientsTest[i] = 0; // readyClientsTest.Add(false); //playerVehiclesTest.Add(1); playerConnectionID[i] = conn.connectionId; playersConnected[i] = 1; break; } } } }
void RecieveRemoveItem(NetworkMessage message) { IntegerMessage msg = message.ReadMessage <IntegerMessage>(); int itemCode = msg.value; GameManagerMobile.Instance.RemoveItemInInventory(itemCode); }
public override void OnClientConnect(NetworkConnection conn) { //Debug.Log("OnClientConnect is called -- now sending data about:"); //switch (index) //{ // case 0: Debug.Log("Default Player"); break; // case 1: Debug.Log("AR Player"); break; // case 2: Debug.Log("VR Player"); break; // case 3: Debug.Log("PC Player"); break; //} if (index != 1) { if (isVR) { index = 2; } else { index = 3; } } IntegerMessage msg = new IntegerMessage(index); ClientScene.AddPlayer(conn, 0, msg); }
void OnMessageReceivedUseItem(NetworkMessage networkMessage) { IntegerMessage message = networkMessage.ReadMessage <IntegerMessage>(); int itemCode = message.value; // if (GameManagerPC.Instance != null) // GameManagerPC.Instance.RequestUsingItem(itemCode, networkMessage.conn.connectionId); }
//public override void onClientConnect(NetworkConnection conn) //{ // characterSelectionCanvas.enabled = false; // IntegerMessage msg = new IntegerMessage(avatarIndex); // if (!clientLoadedScene) // { // ClientScene.Ready(conn); // if (autoCreatePlayer) // { // ClientScene.AddPlayer(conn, 0, msg); // } // } //} public override void OnServerAddPlayer(NetworkConnection conn, short playerControllerId, NetworkReader extraMessageReader) { int id = 0; if (extraMessageReader != null) { IntegerMessage i = extraMessageReader.ReadMessage <IntegerMessage> (); id = i.value; } GameObject playerPrefab = spawnPrefabs [id]; GameObject player; Transform startPos = GetStartPosition(); if (startPos != null) { player = (GameObject)Instantiate(playerPrefab, startPos.position, startPos.rotation); } else { player = (GameObject)Instantiate(playerPrefab, Vector3.zero, Quaternion.identity); } NetworkServer.AddPlayerForConnection(conn, player, playerControllerId); }
void CmdGenerateId() { this.id = this.gameManager.CreateNewId(); IntegerMessage idMessage = new IntegerMessage(this.id); connectionToClient.Send(2000, idMessage); }
public void sendJump() { IntegerMessage msg = new IntegerMessage(); msg.value = playerID; client.Send(137, msg); }
// OnMouseUpAsButton is only called when the mouse is released over the same GUIElement or Collider as it was pressed public void CreateObjectAndDisableMenu() { IntegerMessage msg = new IntegerMessage(1); ClientScene.AddPlayer(NetworkManager.singleton.client.connection, 0, msg); MainMenu.DeactivateMainMenu(); }
private static void OnMatchFound(GameServerInfo match, PlayerManagerClient pm) { print("match found " + match.ip + " " + match.port); NetworkClient gameClient = new NetworkClient(); gameClient.RegisterHandler(MsgType.Connect, x => { print("connected to gameServer"); gameClient.RegisterHandler((short)CustomMessageTypes.ApprovalResponse, netMsg => { IntegerMessage msg = netMsg.ReadMessage <IntegerMessage>(); bool isApproved = msg.value == 1; print("approval status " + isApproved); if (!isApproved) { gameClient.Disconnect(); } else { //Start playing , //Teel server i'm ready and addPlayerRequest if needed //ClientScene.AddPlayer() // or //ClientScene.Ready(); } }); gameClient.Send((short)CustomMessageTypes.RequestPlayerApproval, new IntegerMessage(pm.myInfo.gameServerID)); }); gameClient.Connect(match.ip, match.port); }
public override void OnClientSceneChanged(NetworkConnection conn) { IntegerMessage msg = new IntegerMessage(avatarIndex); ClientScene.AddPlayer(conn, 0, msg); Debug.Log("Changed"); }
///Daten an die Smartphones (Clients) senden //------------------------------------------------------------------------------- //Vibra Motor an den Smartphones auslösen public void SendMessageVibraToPlayer(int playerID = 1) { IntegerMessage msg = new IntegerMessage(); //Nachricht an alle Clients erstellen msg.value = playerID; //Von Server an den Client senden NetworkServer.SendToAll(networkController.msgIdVibraMotor, msg); }
//Called on client when connect public override void OnClientConnect(NetworkConnection conn) { // Create message to set the player IntegerMessage msg = new IntegerMessage(curPlayer); // Call Add player and pass the message ClientScene.AddPlayer(conn, 0, msg); }
//ask the server for the player ID after 2 seconds, will add 'loading icon' lets the client to connect to the server first private IEnumerator askPlayerID() { yield return(new WaitForSeconds(2.0f)); IntegerMessage msg = new IntegerMessage(); client.Send(132, msg); }
public override void OnClientConnect(NetworkConnection conn) { // Sending a message makes it call OnServerAddPlayer instead of // trying to do it itself. var msg = new IntegerMessage(0); ClientScene.AddPlayer(conn, 0, msg); }
/// <summary> /// saves host info if host succeeded /// </summary> /// <param name="msg"> an integer message which contains the result. 1 is success </param> private void OnClientReplyHostResult(NetworkMessage msg) { IntegerMessage resultMsg = msg.ReadMessage <IntegerMessage>(); Log("client reply host, game modeID: ", resultMsg.value); Log("save host info"); AddLobby(msg.conn.address, msg.conn.connectionId, resultMsg.value); }
int playerPrefabIndex; //0 HTC y 1 Ratón public override void OnClientConnect(NetworkConnection conn) //Cada vez que un cliente se conecte, se lee del fichero local con qué configuración quiere aparecer en escena (HTC ó Ratón) { SaveLoad.Load(); playerPrefabIndex = ControlOption.current.option; IntegerMessage msg = new IntegerMessage(playerPrefabIndex); //El cliente debe informar al server la configuración elegida ClientScene.AddPlayer(conn, 0, msg); }
public static void SendUpSkillMessage(int skillCode) { IntegerMessage msg = new IntegerMessage { value = skillCode }; client.Send(NetworkMessageNumber.msgUpSkill, msg); }
public void SendMessage(int stateID) { IntegerMessage myMessage = new IntegerMessage(); myMessage.value = stateID; //sending to server NetworkManager.singleton.client.Send(chatMessage, myMessage); }