private void GameServiceDispose() { if (!_isInit) { return; } _isInit = false; FiroozehGameService.Core.GameService.Logout(); FiroozehGameService.Core.GameService.OnDebugReceived = null; Debug.Log("GameService Logout Called"); if (EnableSaveDebugLogs) { File.AppendAllText(_appPath + DebugPath + _logFile, EndLog); } if (!RealTimeUtilEnabled) { return; } GsLiveRealtime.Dispose(); Debug.Log("GsLiveRealtime Dispose Called"); }
private void Update() { NetworkDetails.text = null; NetworkDetails.text += "RTT : " + GsLiveRealtime.GetRoundTripTime() + "\r\n"; NetworkDetails.text += "Packet Lost : " + GsLiveRealtime.GetPacketLost() + "\r\n"; NetworkDetails.text += "SR : " + GsLiveRealtime.SerializationRate; }
public void FixedUpdate() { if (GsLiveRealtime.IsCurrentPlayerObserving(this)) { return; } _rBody.position = Vector3.MoveTowards(_rBody.position, _mNetworkPosition, _mDistance * (1.0f / GsLiveRealtime.SerializationRate)); _rBody.rotation = Quaternion.RotateTowards(_rBody.rotation, _mNetworkRotation, _mAngle * (1.0f / GsLiveRealtime.SerializationRate)); }
public void Update() { if (GsLiveRealtime.IsCurrentPlayerObserving(this)) { return; } _transform.position = Vector3.Lerp(_transform.position, _mNetworkPosition, Time.deltaTime * lerpRatePosition); _transform.rotation = Quaternion.Lerp(_transform.rotation, _mNetworkRotation, Time.deltaTime * lerpRateRotation); _transform.localScale = _mNetworkScale; }
public void OnGsLiveRead(GsReadStream readStream) { try { if (synchronizePosition) { _mNetworkPosition = (Vector3)readStream.ReadNext(); _mDirection = (Vector3)readStream.ReadNext(); if (_mFirstTake) { transform.position = _mNetworkPosition; _mDistance = 0f; } else { var lag = (float)GsLiveRealtime.GetPing() / 100; _mNetworkPosition += _mDirection * lag; _mDistance = Vector3.Distance(transform.position, _mNetworkPosition); } } if (synchronizeRotation) { _mNetworkRotation = (Quaternion)readStream.ReadNext(); if (_mFirstTake) { _mAngle = 0f; transform.rotation = _mNetworkRotation; } else { _mAngle = Quaternion.Angle(transform.rotation, _mNetworkRotation); } } if (synchronizeScale) { transform.localScale = (Vector3)readStream.ReadNext(); } if (_mFirstTake) { _mFirstTake = false; } } catch (Exception e) { Debug.LogError("GSLiveTransformObserver OnGsLiveRead Error : " + e); } }
private void OnDestroy() { FiroozehGameService.Core.GameService.Logout(); Debug.Log("GameService Logout Called"); if (!RealTimeUtilEnabled) { return; } GsLiveRealtime.Dispose(); Debug.Log("GsLiveRealtime Dispose Called"); }
private void OnDestroy() { FiroozehGameService.Core.GameService.Logout(); Debug.Log("GameService Logout Called"); if (!RealTimeUtilEnabled) { return; } GsLiveRealtime.Dispose(); Debug.Log("GsLiveRealtime Dispose Called"); if (EnableSaveDebugLogs) { File.AppendAllText(_appPath + DebugPath + _logFile, EndLog); } }
private void SpawnPlayer() { var randomX = Random.Range(-5f, 5f); var randomZ = Random.Range(-5f, 5f); var randomVector = new Vector3(randomX, .5f, randomZ); Debug.Log("Player Spawn in " + randomVector); mainCamera.gameObject.SetActive(false); SpawnButton.gameObject.SetActive(false); _me = GsLiveRealtime.Instantiate(mePrefab.name, randomVector, Quaternion.identity); // Enable Objects for current Player _me.GetComponent <PlayerObjectController>().SetActiveObjects(true); _me.SetActive(true); _me.GetComponent <Renderer>().material.color = Color.green; Debug.Log("Player Spawn Done!"); }
public void OnGsLiveRead(GsReadStream readStream) { try { _mNetworkPosition = (Vector2)readStream.ReadNext(); _mNetworkRotation = (float)readStream.ReadNext(); if (teleportEnabled) { if (Vector2.Distance(_rBody.position, _mNetworkPosition) > teleportIfDistanceGreaterThan) { _rBody.position = _mNetworkPosition; } } if (synchronizeVelocity || synchronizeAngularVelocity) { var lag = (float)GsLiveRealtime.GetPing() / 100; if (synchronizeVelocity) { _rBody.velocity = (Vector2)readStream.ReadNext(); _mNetworkPosition += _rBody.velocity * lag; _mDistance = Vector2.Distance(_rBody.position, _mNetworkPosition); } if (synchronizeAngularVelocity) { _rBody.angularVelocity = (float)readStream.ReadNext(); _mNetworkRotation += _rBody.angularVelocity * lag; _mAngle = Mathf.Abs(_rBody.rotation - _mNetworkRotation); } } } catch (Exception e) { Debug.LogError("RealtimeRigidbody2DObserver OnGsLiveRead Error : " + e); } }
private void OnEnable() { if (FiroozehGameService.Core.GameService.IsAuthenticated()) { return; } DontDestroyOnLoad(this); var systemInfo = new SystemInfo { DeviceUniqueId = UnityEngine.SystemInfo.deviceUniqueIdentifier, DeviceModel = UnityEngine.SystemInfo.deviceModel, DeviceName = UnityEngine.SystemInfo.deviceName, DeviceType = UnityEngine.SystemInfo.deviceType.ToString(), OperatingSystem = UnityEngine.SystemInfo.operatingSystem, NetworkType = Application.internetReachability.ToString(), ProcessorCount = UnityEngine.SystemInfo.processorCount, ProcessorFrequency = UnityEngine.SystemInfo.processorFrequency, ProcessorType = UnityEngine.SystemInfo.processorType, GraphicsDeviceName = UnityEngine.SystemInfo.graphicsDeviceName, GraphicsDeviceVendor = UnityEngine.SystemInfo.graphicsDeviceVendor, GraphicsMemorySize = UnityEngine.SystemInfo.graphicsMemorySize }; if (RealTimeUtilEnabled) { // set RealTime Helper Listener & Init GsLiveRealtime GsLiveRealtime.Init(); Debug.Log("GsLiveRealtime Version : " + GsLiveRealtime.Version + " Initialized"); } var config = new GameServiceClientConfiguration(ClientId, ClientSecret, systemInfo); FiroozehGameService.Core.GameService.ConfigurationInstance(config); Debug.Log("GameService Version : " + FiroozehGameService.Core.GameService.Version() + " Initialized"); }
private void OnEnable() { if (_isInit || FiroozehGameService.Core.GameService.IsAuthenticated()) { return; } var systemInfo = new SystemInfo { DeviceUniqueId = UnityEngine.SystemInfo.deviceUniqueIdentifier, DeviceModel = UnityEngine.SystemInfo.deviceModel, DeviceName = UnityEngine.SystemInfo.deviceName, DeviceType = UnityEngine.SystemInfo.deviceType.ToString(), OperatingSystem = UnityEngine.SystemInfo.operatingSystem, NetworkType = Application.internetReachability.ToString(), ProcessorCount = UnityEngine.SystemInfo.processorCount, ProcessorFrequency = UnityEngine.SystemInfo.processorFrequency, ProcessorType = UnityEngine.SystemInfo.processorType, GraphicsDeviceName = UnityEngine.SystemInfo.graphicsDeviceName, GraphicsDeviceVendor = UnityEngine.SystemInfo.graphicsDeviceVendor, GraphicsMemorySize = UnityEngine.SystemInfo.graphicsMemorySize }; if (RealTimeUtilEnabled) { // set RealTime Helper Listener & Init GsLiveRealtime GsLiveRealtime.Init(); Debug.Log("GsLiveRealtime Version : " + GsLiveRealtime.Version + " Initialized"); } if (DebugSystemEnabled) { var debugConfig = new GameServiceDebugConfiguration(EnableExceptionLogger, EnableErrorLogger, EnableDebugLogger, DebugLocations); FiroozehGameService.Core.GameService.OnDebugReceived += OnDebugReceived; FiroozehGameService.Core.GameService.ConfigurationDebug(debugConfig); if (EnableSaveDebugLogs) { if (!Directory.Exists(_appPath + DebugPath)) { Directory.CreateDirectory(_appPath + DebugPath); Debug.Log("GameService Debug Logs Directory Created. Path : " + _appPath + DebugPath); } else { Debug.Log("GameService Debug Logs Directory Path : " + _appPath + DebugPath); } File.AppendAllText(_appPath + DebugPath + _logFile, BeginLog); } Debug.Log("GameService Debug System Initialized"); } var config = new GameServiceClientConfiguration(ClientId.Trim(), ClientSecret.Trim(), systemInfo); FiroozehGameService.Core.GameService.ConfigurationInstance(config); _isInit = true; Debug.Log("GameService Version : " + FiroozehGameService.Core.GameService.Version() + " Initialized"); }