// Use this for initialization void Start() { SetChangeSailsPanel(); SetInventoryPanelItems(); MainGameController.instance.canGoBack = false; _route = MainGameController.instance.databaseController.connection.Table <Route>().Where(x => x.id == MainGameController.instance.player.CurrentRoute).First(); _timeSinceLastLogin = DateTime.Now - MainGameController.instance.player.GetLastInGame(); Vector2 playerposition = new Vector2(MainGameController.instance.player.CurrentLocationLat, MainGameController.instance.player.CurrentLocationLon); Location startLocation = MainGameController.instance.databaseController.connection.Table <Location>().Where(x => x.id == MainGameController.instance.player.CurrentLocation).First(); float totaldistance = _route.GetRouteDistanceFromPosition(playerposition, startLocation); float speed = MainGameController.instance.player.GetActiveBoat().GetSpeed(); if (useOfflineSpeed) { speed = MainGameController.instance.player.GetActiveBoat().GetOfflineSpeed(); } float distanceOffline = ((float)_timeSinceLastLogin.TotalHours * speed); MainGameController.instance.achievementManager.AddAchievementProperty(AchievementProperties.Distance, distanceOffline); float distance = totaldistance - distanceOffline; _route.SetDistanceLeft(distance); if (_route.GetDistanceLeft() <= 0) { ArrivedAtLocation(); } _currentSpeed = MainGameController.instance.player.GetActiveBoat().GetSpeed(); _isMoving = true; StartCoroutine(movement()); StartCoroutine(SpeedClickMultiplier()); if (_weatherController.GetCurrentData() != null) { if (_weatherController.GetCurrentData().getWindSpeed() > MainGameController.instance.player.GetActiveBoat().GetMaxWindSpeedSails() && !DamageCoroutineStarted) { float minutes = (float)_timeSinceLastLogin.TotalMinutes; MainGameController.instance.player.GetActiveBoat().Damage += minutes * 0.01f; #if UNITY_EDITOR Debug.Log("Received " + (minutes * 0.01f) + " damage"); #endif _receivedOfflineDamage = true; StartCoroutine(receiveDamage()); } } }
IEnumerator WaitForWeatherData() { _weatherData = _weatherController.GetCurrentData(); while (_weatherData == null) { yield return(new WaitForSeconds(1)); _weatherData = _weatherController.GetCurrentData(); } _currentWeatherSetting = FindWeatherSetting(_weatherData); DayNightAffected.FolowTime = !_currentWeatherSetting.Name.Equals("thunderstorm"); _mistImage.SetActive(_currentWeatherSetting.CloudFrequency < 0); _cloudMovement.SpawningClouds((_currentWeatherSetting.CloudFrequency > 0) ? true : false, _currentWeatherSetting.CloudFrequency, _currentWeatherSetting.AmountOfDrops, _currentWeatherSetting.Snow); if (_currentWeatherSetting.Name.Contains("thunder")) { _thunderFlash.StartFlashing(); } else { _thunderFlash.StopFlashing(); } }