// Server - when the client chooses to drop the flag (when they shoot a bullet) public void OnFlagDrop(NetworkMessage _networkMessage) { FlagDropMessage netMsg = _networkMessage.ReadMessage <FlagDropMessage>(); Debug.Log("On Flag Drop"); // update our flag this.gameFlag.StartCoroutine(this.gameFlag.DropFlag()); // Update our list for (int i = 0; i < this.numPlayers; i++) { if (this.playerInfoList[i].playerObjectId == netMsg.playerId) { PlayerInfo pInfo = this.playerInfoList[i]; pInfo.hasFlag = false; this.playerInfoList[i] = pInfo; } } // update client flags FlagInteractionMessage msg = new FlagInteractionMessage(); msg.playerId = netMsg.playerId; msg.flagId = this.flagId; msg.isHeld = false; NetworkServer.SendToAll(CustomMsgType.Flag, msg); }
// Local public void DropFlag() { if (this.hasFlag) { Debug.Log("Drop Flag"); this.hasFlag = false; // send msg to server FlagDropMessage msg = new FlagDropMessage(); msg.playerId = (int)this.netId.Value; NetworkManager.singleton.client.Send(CustomMsgType.DropFlag, msg); } }