// Use this for initialization void Start () { controlScript = GameObject.FindGameObjectWithTag(StateManager.CONTROL_SCRIPT_TAG); loadAssetBundle = controlScript.GetComponent<LoadAssetBundle>(); saveProgress = controlScript.GetComponent<SaveProgress>(); loadProgress = controlScript.GetComponent<LoadProgress>(); stateManager = controlScript.GetComponent<StateManager>(); }
IEnumerator loadinformation() { _loaddata = false; yield return(new WaitForSeconds(3)); SaveProgress.loadplayerdata(); _loaddata = true; }
public void SaveAll() { if (saveProgress != null) { return; } saveProgress = new SaveProgress(Voxelmetric.SaveAll(world)); }
public static SaveProgress LoadProgressFromJSON(string file, SaveProgress progress) { if (File.Exists(Application.persistentDataPath + file)) { string jsonData = File.ReadAllText(Application.persistentDataPath + file); progress = JsonUtility.FromJson <SaveProgress>(jsonData); } return(progress); }
IEnumerator saveandloadprogress() { savetime = false; yield return(new WaitForSeconds(60)); SaveProgress.saveplayedata(Player.player); SaveProgress.loadplayerdata(); savetime = false; }
private void SaveProgressNow() { for (int i = 0; i < numLevelsProgress.Length; i++) { progress.levels[i] = numLevelsProgress[i]; } progress.hints = hints; progress.ads = ads; SaveProgress.SaveProgressToJSON(progress, saveFile); }
private void Awake() { if (instance == null) { instance = this; } else { Destroy(gameObject); } }
private void Start() { Script_GoldManager = GetComponent <GoldManager>(); Script_SaveProgress = GetComponent <SaveProgress>(); // If we haven't set up the Unity Purchasing reference if (m_StoreController == null) { // Begin to configure our connection to Purchasing InitializePurchasing(); } }
private void JsonSave() { #if UNITY_ANDROID && !UNITY_EDITOR path = Path.Combine(Application.persistentDataPath, "SaveProgress.json"); #else path = Path.Combine(Application.dataPath, "SaveProgress.json"); #endif if (File.Exists(path)) { save = JsonUtility.FromJson <SaveProgress>(File.ReadAllText(path)); } }
private void Start() { SaveProgress.loadplayerdata(); for (int i = 0; i < Buttons.Length; i++) { Buttons[i].interactable = false; } for (int i = 0; i < levelunlocked; i++) { Buttons[i].interactable = true; } }
// Use this for initialization void Start() { freeClass = new FreeClass(); freeClass.mode = true; #if UNITY_ANDROID && !UNITY_EDITOR path = Path.Combine(Application.persistentDataPath, "SaveProgress.json"); #else path = Path.Combine(Application.dataPath, "SaveProgress.json"); #endif if (File.Exists(path)) { save = JsonUtility.FromJson <SaveProgress>(File.ReadAllText(path)); } Awake(); }
// Use this for initialization void Start() { SelectLevel.SetActive(false); SelectPlayer.SetActive(false); SetActiveInfo(); #if UNITY_ANDROID && !UNITY_EDITOR path = Path.Combine(Application.persistentDataPath, "SaveProgress.json"); #else path = Path.Combine(Application.dataPath, "SaveProgress.json"); #endif if (File.Exists(path)) { save = JsonUtility.FromJson <SaveProgress>(File.ReadAllText(path)); } ActiveLevel(); }
private void Start() { if (_instance != null) { _instance.levelManager = levelManager; if (levelManager != null) { _instance.levelManager.levelPackage = _instance.currentPackage; _instance.levelManager.numHints = _instance.hints; } _instance.grid = grid; _instance.canvas = canvas; _instance.StartNewScene(); DestroyImmediate(gameObject); return; } // Resto de la incializacion del GameManager _instance = this; DontDestroyOnLoad(gameObject); progress = new SaveProgress(); progress.ads = true; progress.levels = new List <int>(); progress.hints = hints; progress = SaveProgress.LoadProgressFromJSON(saveFile, progress); if (progress.levels.Count == 0) { for (int i = 0; i < levelPackages.Length; i++) { progress.levels.Add(0); } } numLevelsProgress = new int[levelPackages.Length]; hints = progress.hints; for (int i = 0; i < numLevelsProgress.Length; i++) { numLevelsProgress[i] = progress.levels[i]; } ads = progress.ads; StartNewScene(); }
/// <summary> /// Saves all chunks currently loaded, if UseMultiThreading is enabled it saves the chunks /// asynchronously and the SaveProgress object returned will show the progress /// </summary> /// <param name="world">Optional parameter for the world to save chunks for, if left /// empty it will use the world Singleton instead</param> /// <returns>A SaveProgress object to monitor the save.</returns> public static SaveProgress SaveAll(World world = null) { if (!world) { world = World.instance; } //Create a saveprogress object with positions of all the chunks in the world //Then save each chunk and update the saveprogress's percentage for each save SaveProgress saveProgress = new SaveProgress(world.chunks.Keys); List <Chunk> chunksToSave = new List <Chunk>(); chunksToSave.AddRange(world.chunks.Values); if (Config.Toggle.UseMultiThreading) { Thread thread = new Thread(() => { foreach (var chunk in chunksToSave) { while (!chunk.GetFlag(Chunk.Flag.terrainGenerated) || chunk.GetFlag(Chunk.Flag.busy)) { Thread.Sleep(0); } Serialization.SaveChunk(chunk); saveProgress.SaveCompleteForChunk(chunk.pos); } }); thread.Start(); } else { foreach (var chunk in chunksToSave) { Serialization.SaveChunk(chunk); saveProgress.SaveCompleteForChunk(chunk.pos); } } return(saveProgress); }
/// <summary> /// Implementation of the ITrackableEventHandler function called when the /// tracking state changes. /// </summary> public void OnTrackableStateChanged( TrackableBehaviour.Status previousStatus, TrackableBehaviour.Status newStatus) { m_PreviousStatus = previousStatus; m_NewStatus = newStatus; Debug.Log("Trackable " + mTrackableBehaviour.TrackableName + " " + mTrackableBehaviour.CurrentStatus + " -- " + mTrackableBehaviour.CurrentStatusInfo); if (newStatus == TrackableBehaviour.Status.DETECTED || newStatus == TrackableBehaviour.Status.TRACKED || newStatus == TrackableBehaviour.Status.EXTENDED_TRACKED) { if (SaveProgress.flag >= 2) { if (SaveProgress.flag == 2) { SaveProgress.flag = 3; SaveProgress.Save(); } OnTrackingFound(); } else { OnTrackingLost(); } } else if (previousStatus == TrackableBehaviour.Status.TRACKED && newStatus == TrackableBehaviour.Status.NO_POSE) { OnTrackingLost(); } else { // For combo of previousStatus=UNKNOWN + newStatus=UNKNOWN|NOT_FOUND // Vuforia is starting, but tracking has not been lost or found yet // Call OnTrackingLost() to hide the augmentations OnTrackingLost(); } }
/// <summary> /// Saves all chunks currently loaded, if UseMultiThreading is enabled it saves the chunks /// asynchronously and the SaveProgress object returned will show the progress /// </summary> /// <param name="world">Optional parameter for the world to save chunks for, if left /// empty it will use the world Singleton instead</param> /// <returns>A SaveProgress object to monitor the save.</returns> public static SaveProgress SaveAll(World world = null) { if (!world) world = World.instance; //Create a saveprogress object with positions of all the chunks in the world //Then save each chunk and update the saveprogress's percentage for each save SaveProgress saveProgress = new SaveProgress(world.chunks.Keys); List<Chunk> chunksToSave = new List<Chunk>(); chunksToSave.AddRange(world.chunks.Values); if (Config.Toggle.UseMultiThreading) { Thread thread = new Thread(() => { foreach (var chunk in chunksToSave) { while (!chunk.terrainGenerated || chunk.busy) { Thread.Sleep(0); } Serialization.SaveChunk(chunk); saveProgress.SaveCompleteForChunk(chunk.pos); } }); thread.Start(); } else { foreach (var chunk in chunksToSave) { Serialization.SaveChunk(chunk); saveProgress.SaveCompleteForChunk(chunk.pos); } } return saveProgress; }
private void OnCrystalDestroyed() { GameObject crystal = GameObject.Find("Crystal"); if (crystal) { WaveGenerator waveGen = crystal.GetComponent <WaveGenerator>(); if (waveGen) { int currentScore = waveGen.CurrentScore; SaveProgress saver = new SaveProgress(); saver.SaveInfo(currentScore); } } StartCoroutine(DelayEndGame()); }
public static SaveProgress SaveAll(World world = null) { if (!world) { world = World.instance; } SaveProgress saveProgress = new SaveProgress(world.chunks.Keys); List <Chunk> chunksToSave = new List <Chunk>(); chunksToSave.AddRange(world.chunks.Values); if (Config.Toggle.UseMultiThreading) { Thread thread = new Thread(() => { foreach (var chunk in chunksToSave) { while (!chunk.terrainGenerated || chunk.busy) { Thread.Sleep(0); } Serialization.SaveChunk(chunk); saveProgress.SaveCompleteForChunk(chunk.pos); } }); thread.Start(); } else { foreach (var chunk in chunksToSave) { Serialization.SaveChunk(chunk); saveProgress.SaveCompleteForChunk(chunk.pos); } } return(saveProgress); }
public static SaveProgress SaveAll(World world = null) { if (!world) world = World.instance; SaveProgress saveProgress = new SaveProgress(world.chunks.Keys); List<Chunk> chunksToSave = new List<Chunk>(); chunksToSave.AddRange(world.chunks.Values); if (Config.Toggle.UseMultiThreading) { Thread thread = new Thread(() => { foreach (var chunk in chunksToSave) { while (!chunk.terrainGenerated || chunk.busy) { Thread.Sleep(0); } Serialization.SaveChunk(chunk); saveProgress.SaveCompleteForChunk(chunk.pos); } }); thread.Start(); } else { foreach (var chunk in chunksToSave) { Serialization.SaveChunk(chunk); saveProgress.SaveCompleteForChunk(chunk.pos); } } return saveProgress; }
public static void SaveProgressToJSON(SaveProgress progress, string file) { string progressToString = JsonUtility.ToJson(progress); File.WriteAllText(Application.persistentDataPath + file, progressToString); }
// Start is called before the first frame update protected virtual void Awake() { print("Loaded SaveProgress"); SaveProgress.Load(); }
public void SaveAll() { saveProgress = Voxelmetric.SaveAll(); }
private void Awake() { LM = this; SaveProgress.saveplayedata(Player.player); }
private void onSaveProgress(int progress, int speed) { SaveProgress?.Invoke(progress, speed); }
protected override void handleOnKeyPressed(ConsoleKeyInfo keyInfo) { if (keyInfo.Key == ConsoleKey.F9) { FrameLogger.Toggle(); } else if (keyInfo.Key == ConsoleKey.F1) { m_OptimizedMode = !m_OptimizedMode; } if (State == GameState.Menu) { if (keyInfo.Key == ConsoleKey.Escape) { IsRunning = false; } else if (keyInfo.Key == ConsoleKey.UpArrow) { m_CurrentMenuSelection = (m_CurrentMenuSelection - 1 < 0) ? c_OptionTexts.Count - 1 : m_CurrentMenuSelection - 1; selectOption(m_CurrentMenuSelection); } else if (keyInfo.Key == ConsoleKey.DownArrow) { m_CurrentMenuSelection = (m_CurrentMenuSelection + 1 > c_OptionTexts.Count - 1) ? 0 : m_CurrentMenuSelection + 1; selectOption(m_CurrentMenuSelection); } else if (keyInfo.Key == ConsoleKey.Enter) { confirmOption(m_CurrentMenuSelection); } } else if (State == GameState.InGame) { for (int i = 0; i < World.Characters.Count; i++) { var character = World.Characters[i]; if (keyInfo.Key == c_InputTable[i, 0]) { character.TurnRight(); } else if (keyInfo.Key == c_InputTable[i, 1]) { character.TurnLeft(); } } if (keyInfo.Key == ConsoleKey.F1) { World.BackgroundImageNode.IsActive = !m_OptimizedMode; } else if (keyInfo.Key == ConsoleKey.Escape) { loadScene(enterMainMenu, delegate { }); } if (IsFinished) { if (keyInfo.Key == ConsoleKey.Enter) { if (m_InputName.Length <= 0) { m_InputName = new StringBuilder("SOMEONE"); } switch (Mode) { case GameMode.SinglePlayer: SaveProgress.AddRecord(GameMode.SinglePlayer, m_InputName.ToString(), World.TotalLevelCounter); break; case GameMode.TwoPlayers: SaveProgress.AddRecord(GameMode.TwoPlayers, m_InputName.ToString(), World.TotalLevelCounter); break; } loadScene(enterMainMenu, delegate { }); } else if (keyInfo.Key == ConsoleKey.Backspace) { if (m_InputName.Length > 0) { m_InputName.Length--; AudioManager.Instance.BeepMusic(80, 20); m_InputText.text = m_InputName.ToString(); } } else if (keyInfo.Key != ConsoleKey.RightArrow && keyInfo.Key != ConsoleKey.LeftArrow) { if (m_InputName.Length < 12) { m_InputName.Append(keyInfo.KeyChar); AudioManager.Instance.BeepMusic(150, 20); m_InputText.text = m_InputName.ToString(); } } } else { if (keyInfo.Key == ConsoleKey.F2) { if (IsPaused) { Resume(); } else { Pause(); } } } } else if (State == GameState.Tutorial) { if (keyInfo.Key == ConsoleKey.Escape) { loadScene(enterMainMenu, delegate { }); } } else if (State == GameState.Leaderboard) { if (keyInfo.Key == ConsoleKey.Escape) { loadScene(enterMainMenu, delegate { }); } } }
void Update() { if (saveProgress != null && saveProgress.GetProgress() >= 100) { saveProgress = null; } // Roatation if (Input.GetMouseButton(1)) { rot = new Vector2( rot.x + Input.GetAxis("Mouse X") * 3, rot.y + Input.GetAxis("Mouse Y") * 3 ); cam.transform.localRotation = Quaternion.AngleAxis(rot.x, Vector3.up); cam.transform.localRotation *= Quaternion.AngleAxis(rot.y, Vector3.left); } // Movement float speedModificator = 1f; if (Input.GetKey(KeyCode.LeftShift) || Input.GetKey(KeyCode.RightShift)) { speedModificator = 2f; } else if (Input.GetKey(KeyCode.LeftControl) || Input.GetKey(KeyCode.RightControl)) { speedModificator = 0.25f; } cam.transform.position += cam.transform.forward * 40f * speedModificator * Input.GetAxis("Vertical") * Time.deltaTime; cam.transform.position += cam.transform.right * 40f * speedModificator * Input.GetAxis("Horizontal") * Time.deltaTime; // Screenspace mouse cursor coordinates var mousePos = cam.ScreenToWorldPoint(new Vector3(Input.mousePosition.x, Input.mousePosition.y, 10)); if (world != null) { Block block = world.blockProvider.GetBlock(blockToPlace); VmRaycastHit hit = VmRaycast.Raycast( new Ray(cam.transform.position, mousePos - cam.transform.position), world, 100, block.Type == BlockProvider.AirType ); // Display the type of the selected block if (selectedBlockText != null) { selectedBlockText.text = Code.Voxelmetric.GetBlock(world, ref hit.vector3Int).DisplayName; } // Save current world status if (saveProgressText != null) { saveProgressText.text = saveProgress != null?SaveStatus() : "Save"; } if (eventSystem != null && !eventSystem.IsPointerOverGameObject()) { if (hit.block.Type != BlockProvider.AirType) { bool adjacent = block.Type != BlockProvider.AirType; Vector3Int blockPos = adjacent ? hit.adjacentPos : hit.vector3Int; Debug.DrawLine(cam.transform.position, blockPos, Color.red); } // Clicking voxel blocks if (Input.GetMouseButtonDown(0)) { if (hit.block.Type != BlockProvider.AirType) { bool adjacent = block.Type != BlockProvider.AirType; Vector3Int blockPos = adjacent ? hit.adjacentPos : hit.vector3Int; Code.Voxelmetric.SetBlockData(world, ref blockPos, new BlockData(block.Type, block.Solid)); } } // Pathfinding if (Input.GetKeyDown(KeyCode.I)) { if (hit.block.Type != BlockProvider.AirType) { bool adjacent = block.Type != BlockProvider.AirType; pfStart = adjacent ? hit.adjacentPos : hit.vector3Int; } } if (Input.GetKeyDown(KeyCode.O)) { if (hit.block.Type != BlockProvider.AirType) { bool adjacent = block.Type != BlockProvider.AirType; pfStop = adjacent ? hit.adjacentPos : hit.vector3Int; } } if (Input.GetKeyDown(KeyCode.P)) { pf = new PathFinder(pfStart, pfStop, world, 0); } if (pf != null && pf.path.Count != 0) { for (int i = 0; i < pf.path.Count - 1; i++) { Vector3 p0 = (Vector3)pf.path[i] + Env.HalfBlockOffset; Vector3 p1 = (Vector3)pf.path[i + 1] + Env.HalfBlockOffset; Debug.DrawLine(p0, p1, Color.red); } } } // Test of ranged block setting if (Input.GetKeyDown(KeyCode.T)) { Action <ModifyBlockContext> action = context => { Debug.Log("Action performed"); }; Vector3Int fromPos = new Vector3Int(-44, -44, -44); Vector3Int toPos = new Vector3Int(44, 44, 44); Code.Voxelmetric.SetBlockData(world, ref fromPos, ref toPos, BlockProvider.AirBlock, action); } } }
/// <summary> /// Reference to the "GoldManager" and "SaveProgress" scripts to get access to the necessary variables/functions. /// </summary> void Start() { Script_GoldManager = GetComponent <GoldManager>(); Script_SaveProgress = GetComponent <SaveProgress>(); }
public void SaveAll() { var chunksToSave = Code.Voxelmetric.SaveAll(world); saveProgress = new SaveProgress(chunksToSave); }