public void CmdRequestJoinAsPeer(string myName) { //A client has asked to become a new peer. hl.Peer peer = new hl.Peer(); hl.uIds++; peer.uId = hl.uIds; peer.myName = myName; peer.team = ServerSideLoop.DetermineBestTeam(peer.uId);//Only called on the server. Auto picks team 1 or 2 peer.teamPlayerNum = ServerSideLoop.DetermineTeamPlacement(peer.uId); Resources.InitResources(peer); hl.peers.Add(peer); RpcGrantJoinAsPeer(peer); //tell all the clients, including the one that just joined, all the peer info. hl.Peer[] list = new hl.Peer[hl.peers.Count]; for (int i = 0; i < list.Length; i++) { list[i] = hl.peers[i]; } RpcSendAllPeers(list); //Also update everyone's global info hl.globalInfo.currentPlayers++; RpcBroadcastGlobalInfo(hl.globalInfo); }
void Update() { if (isLocalPlayer) { if (Input.GetKeyDown(KeyCode.G)) { ChatScript.ChatLocally("G key pressed! " + hl.local_uId); } Cl_Orders.InputOrders(); //detect keyboard & mouse input, as orders, and send them to the server } if (isServer) { hl.svTime = Time.realtimeSinceStartup; //This is the server. Update this every frame ServerSideLoop.UpdateServer(); Ticks.HandleTicks(); //Send out ticks } if (isClient) { ClientSideLoop.UpdateClient(); } }