private void Update() { if (jsonMode) { player.SetIsInteracting(true); } if (!jsonMode && player && (current == null || (!current.bounds.contains(player.transform.position) && !player.GetIsOscillating()))) { AttemptSectorLoad(); } // deadzone damage if (current && current.type == Sector.SectorType.DangerZone) { if (dangerZoneTimer >= 5 && !player.GetIsDead()) { dangerZoneTimer = 0; Instantiate(damagePrefab, player.transform.position, Quaternion.identity); player.TakeShellDamage(0.2F * player.GetMaxHealth()[0], 0, null); player.TakeCoreDamage(0.2F * player.GetMaxHealth()[1]); player.alerter.showMessage("WARNING: Leave Sector!", "clip_stationlost"); } else { dangerZoneTimer += Time.deltaTime; } } else { dangerZoneTimer = 0; } if (!DialogueSystem.isInCutscene) { bgSpawnTimer += Time.deltaTime; if (bgSpawnTimer >= 8 && bgSpawns.Count > 0) { bgSpawnTimer = 0; var key = bgSpawns[Random.Range(0, bgSpawns.Count)]; var spawnPoint = player.transform.position + Quaternion.Euler(0, 0, Random.Range(0, 360)) * new Vector3(key.Item4, 0, 0); key.Item2.position = spawnPoint; key.Item2.ID = ""; SpawnEntity(key.Item1, key.Item2); AudioManager.PlayClipByID("clip_respawn", spawnPoint); } } }
private void Update() { if (initialized) // check if it is safe to update { float[] currentHealth = player.GetHealth(); // grab the health values float[] maxHealth = player.GetMaxHealth(); for (int i = 0; i < currentHealth.Length; i++) // iterate through bar arrays { if (barsArray[i].fillAmount != 1) // check if the bar can gleam again to indicate full health { gleamed[i] = false; // ready bool value for another gleam } if (gleaming[i]) // check if gleaming { Gleam(i); // continue gleaming if so } // check if the bar is ready to gleam if (barsArray[i].fillAmount == 1 && !gleamed[i]) { gleamArray[i].color = Color.white; // reset gleam bar gleamed[i] = true; // update bool values if so gleaming[i] = true; } barsArray[i].fillAmount = UpdateBar(barsArray[i].fillAmount, currentHealth[i], maxHealth[i]); if (barsArray[i].GetComponentInChildren <Text>()) { var x = barsArray[i].GetComponentsInChildren <Text>(); x[0].text = (int)currentHealth[i] + "/" + maxHealth[i]; x[1].text = names[i]; } } } }
public void Save() { save.timePlayed += Time.timeSinceLevelLoad / 60; if (SaveMenuHandler.migratedTimePlayed != null) { save.timePlayed += (int)SaveMenuHandler.migratedTimePlayed; SaveMenuHandler.migratedTimePlayed = null; } string currentPath = File.ReadAllLines(Application.persistentDataPath + "\\CurrentSavePath")[0]; save.position = player.spawnPoint; save.currentHealths = player.currentHealth; if (player.currentHealth[1] <= 0) { save.currentHealths = player.GetMaxHealth(); } save.currentPlayerBlueprint = JsonUtility.ToJson(player.blueprint); save.credits = player.GetCredits(); save.abilityCaps = player.abilityCaps; save.shards = player.shards; if (save.resourcePath == "" || save.resourcePath.Contains("main")) { save.resourcePath = SectorManager.instance.resourcePath; } save.characters = SectorManager.instance.characters; save.version = VersionNumberScript.version; for (int i = 0; i < taskManager.traversers.Count; i++) { var traverser = taskManager.traversers[i]; var missionName = traverser.nodeCanvas.missionName; var lastCheckpoint = traverser.lastCheckpointName; save.missions.Find((m) => m.name == traverser.nodeCanvas.missionName).checkpoint = lastCheckpoint; } // Calculate the save episode by finding the maximal active mission's epsiode. save.episode = 0; foreach (var mission in save.missions) { if (mission.status != Mission.MissionStatus.Inactive) { if (save.episode < mission.episode) { save.episode = mission.episode; } } } Dictionary <string, int> variables = taskManager.taskVariables; string[] keys = new string[taskManager.taskVariables.Count]; int[] values = new int[taskManager.taskVariables.Count]; int index = 0; foreach (var pair in taskManager.taskVariables) { keys[index] = pair.Key; values[index] = pair.Value; index++; } save.taskVariableNames = keys; save.taskVariableValues = values; save.reputation = player.reputation; string saveJson = JsonUtility.ToJson(save); File.WriteAllText(currentPath, saveJson); }