// Update is called once per frame void Update() { timer += Time.deltaTime; //check if everyone had been at the victory screen too long if (timer > MaxTimeWaiting) { //Application.LoadLevel("Prep"); mm.GetComponent <NetworkView>().RPC("ToPrepRoom", RPCMode.All); } }
// Update is called once per frame void Update() { if (isTimed && timerStarted) { timer -= Time.deltaTime; if (timer <= 0) { timer = 0; Debug.Log("Game Over! It's a DRAW! Time Ran Out!"); mm.GetComponent <NetworkView>().RPC("AssignDraw", RPCMode.All); } } }
private void Menu_Lobby() { //list all the players in the match and their wins scrollLobby = GUILayout.BeginScrollView(scrollLobby, GUILayout.MaxWidth(200)); foreach (MyPlayer pl in MultiplayerManager.instance.PlayerList) { if (pl.playerNetwork == Network.player) { GUI.color = Color.cyan; } if (MultiplayerManager.instance.allowTeams) { GUILayout.Box(pl.playerName + ": " + pl.wins + " wins | Team " + pl.team.ToString()); } else { GUILayout.Box(pl.playerName + ": " + pl.wins + " wins"); } GUI.color = Color.white; } GUILayout.EndScrollView(); GUI.Box(new Rect(250, 10, 200, 40), MultiplayerManager.instance.currentMap.mapName); GUI.Label(new Rect(250, 100, 200, 40), "Set Time"); GUI.Label(new Rect(290, 123, 100, 50), time.ToString()); GUI.Label(new Rect(250, 160, 200, 40), "Set Health"); GUI.Label(new Rect(295, 183, 100, 50), startHealth.ToString()); GUI.Label(new Rect(250, 220, 200, 40), "Set Ammo"); if (ammo == 11) { GUI.Label(new Rect(295, 243, 100, 50), "Unl."); } else { GUI.Label(new Rect(295, 243, 100, 50), ammo.ToString()); } if (Network.isServer) { if (GUI.Button(new Rect(250, 51, 200, 40), "Change Map")) { NavigateTo("SelMap"); } if (GUI.Button(new Rect(250, 120, 30, 30), "-")) { if (time > 0) { if (time == 1) { time = 0; } else if (time == 15) { time = 1; } else { time -= 15; } } MultiplayerManager.instance.GetComponent <NetworkView>().RPC("SetTime", RPCMode.All, time); } if (GUI.Button(new Rect(322, 120, 30, 30), "+")) { if (time < 300) { if (time == 0) { time = 1; } else if (time == 1) { time = 15; } else { time += 15; } } MultiplayerManager.instance.GetComponent <NetworkView>().RPC("SetTime", RPCMode.All, time); } if (GUI.Button(new Rect(250, 180, 30, 30), "-")) { if (startHealth > 1) { --startHealth; } MultiplayerManager.instance.GetComponent <NetworkView>().RPC("SetHealth", RPCMode.All, startHealth); } if (GUI.Button(new Rect(322, 180, 30, 30), "+")) { if (startHealth < 10) { ++startHealth; } MultiplayerManager.instance.GetComponent <NetworkView>().RPC("SetHealth", RPCMode.All, startHealth); } if (GUI.Button(new Rect(250, 243, 30, 30), "-")) { if (ammo > 1) { --ammo; } MultiplayerManager.instance.GetComponent <NetworkView>().RPC("SetAmmo", RPCMode.All, ammo); } if (GUI.Button(new Rect(322, 243, 30, 30), "+")) { if (ammo < 11) { ++ammo; } MultiplayerManager.instance.GetComponent <NetworkView>().RPC("SetAmmo", RPCMode.All, ammo); } } GUI.Label(new Rect(460, 10, 130, 30), "Choose Skin"); GUILayout.BeginArea(new Rect(460, 41, 150, Screen.height - 90)); for (int i = 0; i < skins.Length; ++i) { GameObject holdSkin = (GameObject)skins[i]; if (GUILayout.Button(holdSkin.GetComponent <ID>().skinName)) { MultiplayerManager.instance.GetComponent <NetworkView>().RPC("SetSkin", RPCMode.All, holdSkin.GetComponent <ID>().skinID, Network.player); } } GUILayout.EndArea(); if (Network.isServer) { if (GUI.Button(new Rect(621, 10, 130, 40), "Toggle Teams")) { MultiplayerManager.instance.GetComponent <NetworkView>().RPC("ToggleTeams", RPCMode.All); } if (AllReady) { if (GUI.Button(new Rect(Screen.width - 405, Screen.height - 40, 200, 40), "Start Match")) { MultiplayerManager.instance.GetComponent <NetworkView>().RPC("SetTime", RPCMode.All, time); MultiplayerManager.instance.GetComponent <NetworkView>().RPC("SetHealth", RPCMode.All, startHealth); MultiplayerManager.instance.GetComponent <NetworkView>().RPC("Client_LoadMultiplayerMap", RPCMode.All, MultiplayerManager.instance.currentMap.mapLoadName, MultiplayerManager.instance.oldPrefix + 1); MultiplayerManager.instance.oldPrefix += 1; MultiplayerManager.instance.isMatchStarted = true; } } } if (!hasLocked) { if (GUI.Button(new Rect(Screen.width - 405, Screen.height - 40, 200, 40), "Ready")) { hasLocked = true; mm.GetComponent <NetworkView>().RPC("PrepLockIn", RPCMode.All, Network.player); } } if (MultiplayerManager.instance.allowTeams) { for (int i = 0; i < 7; ++i) { if (GUI.Button(new Rect(621, 50 + 40 * i, 130, 40), "Team " + i.ToString())) { MultiplayerManager.instance.GetComponent <NetworkView>().RPC("SetTeam", RPCMode.All, Network.player, i); } } } if (GUI.Button(new Rect(Screen.width - 200, Screen.height - 40, 200, 40), "Disconnect")) { Network.Disconnect(); } }
// Kills the player public void Death() { playerInfo.solid = false; ghostTimer = 0f; // Disconnects all potential layers that are grabbing this one GetComponent <PlayerInfo>().DisconnectGrabbingPlayers(); GetComponent <PlayerStun>().UnStun(); GetComponent <PlayerPowerups>().ResetPlayerMass(); // Ignores collision between this player and the others for (int i = 0; i < myColliders.Length; i++) { for (int j = 0; j < otherColliders.Count; j++) { if (!myColliders[i].gameObject.name.Contains("Wrist")) { Physics.IgnoreCollision(myColliders[i], otherColliders[j]); } } } // Gets all spawnpoints within a radius Collider[] spawnPoints = Physics.OverlapSphere(transform.position, spawnPointSearchRad, layerMask, QueryTriggerInteraction.Collide); // Will be used to store the minimum distance to any spawn point float minDist = Mathf.Infinity; // Position to spawn at Vector3 spawnPos = Vector3.zero; // Goes through all found spawn points for (int i = 0; i < spawnPoints.Length; i++) { // Gets the distance between the player and a spawn point float dist = Vector3.Distance(transform.position, spawnPoints[i].transform.position); // If this distance is lesser that the previously minimum one if (dist < minDist) { minDist = dist; spawnPos = new Vector3(spawnPoints[i].transform.position.x, spawnPoints[i].transform.position.y, rootTrans.position.z); } } // Resets velocity for (int i = 0; i < rbs.Length; i++) { rbs[i].velocity = Vector3.zero; } // If a spawn point was found if (spawnPos != Vector3.zero) { // Teleports the player rootTrans.transform.position = spawnPos; for (int i = 0; i < transforms.Length; i++) { if (transforms[i].name != "Root_M") { transforms[i].localPosition = originPos[i]; } else { transforms[i].localPosition = new Vector3(transforms[i].localPosition.x, transforms[i].localPosition.y, originPos[i].z); } transforms[i].localRotation = originRot[i]; } } else { Debug.LogError("No spawn points were found!"); manager.GetComponent <DebugText>().AddText("ERROR!!! No spawn points were found!"); } ChangeMass(ghostMassMult); }