private void Update() { if (Input.GetKeyUp(KeyCode.F5)) { _data = DDA.GetGameData(); needReload = true; } if (needReload) { GameObject.Destroy(cached); cached = new GameObject("cache"); foreach (var obj in objects) { GameObject.Destroy(obj.Value); } objects = new Dictionary <int, GameObject>(); try { Debug.Log(_data.playerPosition); Game.Player.Reload(_data.playerPosition); Game.Camera.MoveTo(new Vector3(_data.playerPosition.x, 0, _data.playerPosition.z)); } catch (Exception ex) { Debug.LogError(ex); } try { Game.UI.SetUI(_data.weather, _data.calendar); } catch (Exception ex) { Debug.LogError(ex); } Debug.Log("reloading..."); GameObject.Destroy(frame); frame = new GameObject("frame"); frame.transform.parent = this.gameObject.transform; foreach (var tile in _data.map.tiles) { AddOrInstantiate(tile.loc, tile.ter, "t_unknown"); if (tile.furn != 0) { AddOrInstantiate(tile.loc, tile.furn, "f_unknown"); } // tyomalu: changed tile.ter to int } needReload = false; } }
private void Start() { cached = new GameObject("cache"); try { var sw = Stopwatch.StartNew(); sw.Stop(); Debug.Log(string.Format("Request sent in {0}ms", sw.ElapsedMilliseconds)); _data = DDA.GetGameData(); needReload = true; } catch (Exception) { Debug.Log("Map.json not created yet"); } }