// I have no idea if this actually works reliably or not, but it seems to // work in my testing. Semi-hack? I guess I could stall the application // until we know it's worked, but that's kind of jerky, too. public void OnApplicationQuit() { if (WasMine) { ServerNotifier.BecomeUnlisted(); } }
public void Update() { if (networkView.isMine) { ServerNotifier.Address = Relay.Instance.AddressFinder.ExternalAddress; ServerNotifier.CurrentMapName = Application.loadedLevelName; ServerNotifier.NumberOfPlayers = PlayerPresence.UnsafeAllPlayerPresences.Count; // In case our external address is still null, Update() in the // ServerNotifier won't actually send to the list server, so it's // fine to call it here. (It will send as soon as our address is not // null). ServerNotifier.Update(); } Leaderboard.Update(); // Update banner messages float yAccum = 0f; for (int i = BannerMessages.Count - 1; i >= 0; i--) { //BannerMessages[i].Index = displayIndex; BannerMessages[i].IndexY = yAccum; BannerMessages[i].Update(); if (BannerMessages[i].Active) { yAccum += BannerMessages[i].CalculatedHeight + 1f; } if (BannerMessages[i].Finished) { BannerMessages.RemoveAt(i); } } }
public void OnDestroy() { PlayerPresence.OnPlayerPresenceAdded -= ReceivePlayerPresenceAdd; PlayerPresence.OnPlayerPresenceRemoved -= ReceivePlayerPresenceRemove; Relay.Instance.MessageLog.OnCommandEntered -= ReceiveCommandEntered; if (CurrentGameMode != null) { Destroy(CurrentGameMode.gameObject); } // TODO not sure what to do about this stuff now foreach (var playerPresence in PlayerPresence.AllPlayerPresences) { Destroy(playerPresence.gameObject); } foreach (var playerScript in PlayerScript.AllEnabledPlayerScripts) { Destroy(playerScript.gameObject); } if (Relay.Instance.CurrentServer == this) { Relay.Instance.CurrentServer = null; } // FIXME dirty hack { //Screen.lockCursor = false; //Cursor.visible = true; if (Relay.Instance.MainCamera != null) { var indicator = Relay.Instance.MainCamera.GetComponent <WeaponIndicatorScript>(); if (indicator != null) { indicator.enabled = false; } } } // Will need to not dispose this if we're going to delist our server, // since we'll have to hand this off to the Relay for ownership. // TODO bit o' the old hack 'ere if (WasMine) { ServerNotifier.BecomeUnlisted(); } // Remove hooks for UPnP if (PortMapper != null) { PortMapper.Dispose(); } //ServerNotifier.Dispose(); }