public void UpdateForDay(bool restoreFromSave) { template_day day = GameManager.instance.GetCurrentDay(); template_day_task task = day.Template.day.day_task_slot as template_day_task; PlayerState player = SaveManager.instance.GetCurrentPlayerState(); if (!restoreFromSave) { player.LetterTextIndex = Random.Range(0, DailyLetterFrontText.Count); player.LetterOpenSpriteIndex = Random.Range(0, DailyLetterSpritesOpen.Count); player.LetterClosedSpriteIndex = Random.Range(0, DailyLetterSpritesClosed.Count); if (IsInDrawer()) { HandleDragOutOfDrawer(); } gameObject.transform.localPosition = LetterMarker.localPosition; } else { } TextLetterFront.text = DailyLetterFrontText[player.LetterTextIndex]; DailyOpenSprite = DailyLetterSpritesOpen[player.LetterOpenSpriteIndex]; DailyClosedSprite = DailyLetterSpritesClosed[player.LetterClosedSpriteIndex]; TextLetterTop.text = task.Template.task.task_description_top; TextLetterBottom.text = task.Template.task.task_description_bottom; CloseLetter(); }
public void SetCurrentDay(template_day day) { if (day == null) { Debug.LogError("NULL DAY BEING SET"); } CurrentDay = day; }
public template_day ProgressDay(template_day currentDay) { if (currentDay.OutputPins.Count == 0 || currentDay.OutputPins[0].Connections.Count == 0) { Debug.LogError("Broken day! No connection! " + currentDay.DisplayName); return(null); } template_day day = currentDay.OutputPins[0].Connections[0].Target as template_day; //Hub hub = currentDay.OutputPins[0].Connections[0].Target as Hub; Condition condition = currentDay.OutputPins[0].Connections[0].Target as Condition; currentDay.OutputPins[0].Evaluate(); //Debug.Log("fate absent: " + ArticyGlobalVariables.Default.game.fate_absent); //Debug.Log("thirteen no profiles: " + ArticyGlobalVariables.Default.day.thirteen_no_profiles); while (condition != null) { bool conditionResult = condition.Evaluate(); if (conditionResult) { condition.OutputPins[0].Evaluate(); day = condition.OutputPins[0].Connections[0].Target as template_day; //hub = condition.OutputPins[0].Connections[0].Target as Hub; condition = condition.OutputPins[0].Connections[0].Target as Condition; } else { condition.OutputPins[1].Evaluate(); day = condition.OutputPins[1].Connections[0].Target as template_day; //hub = condition.OutputPins[1].Connections[0].Target as Hub; condition = condition.OutputPins[1].Connections[0].Target as Condition; } } SaveManager.instance.MarkSavegameDirty(); if (day != null) { return(day); } //if (hub != null) //{ // return hub; //} Debug.LogError("No day found! Ott fix pls"); return(null); }
public void RollDay(bool restoreFromSave) { List <template_profile> profiles = new List <template_profile>(); int currentDayIndex = SaveManager.instance.GetCurrentPlayerState().GetCurrentDayIndex(); if (restoreFromSave) { List <ProfileState> profileStates = SaveManager.instance.GetCurrentPlayerState().GetCurrentDayProfiles(); for (int i = 0; i < profileStates.Count; ++i) { template_profile profile = ArticyDatabase.GetObject(profileStates[i].ProfileID) as template_profile; if (profile != null) { profiles.Add(profile); } else { Debug.LogError("Invalid Profile ID: " + profileStates[i].ProfileID.ToString() + " saved for day: " + (currentDayIndex + 1)); } } } else { template_day day = GameManager.instance.GetCurrentDay(); if (day == null) { Debug.LogError("DAY NOT FOUND; PROBABLY GOING TO EXPLODE"); } template_day_task dayTask = day.Template.day.day_task_slot as template_day_task; if (dayTask == null) { Debug.LogError("DAY TASK NOT FOUND; PROBABLY GOING TO EXPLODE"); } dayTask.Template.task.task_profile_count.CallScript(); Debug.Log("Getting " + ArticyGlobalVariables.Default.day.profile_count + " profiles for day " + (currentDayIndex + 1) + "; Day Name: " + day.DisplayName); List <ArticyObject> dailyProfileTemplates = new List <ArticyObject>(dayTask.Template.task.task_daily_profiles); for (int j = 0; j < ArticyGlobalVariables.Default.day.profile_count; ++j) { int index = j; if (dayTask.Template.task.task_profile_shuffler) { index = UnityEngine.Random.Range(0, dailyProfileTemplates.Count); } else { } template_profile dailyProfile = dailyProfileTemplates[index] as template_profile; template_random_profile dailyRandomProfile = dailyProfileTemplates[index] as template_random_profile; if (dayTask.Template.task.task_profile_shuffler) { dailyProfileTemplates.RemoveAt(index); } if (dailyRandomProfile != null) { dailyProfile = ProfileManager.instance.RollProfileByRandoDefinition(dailyRandomProfile); } if (dailyProfile == null) { Debug.LogError("Rolled null profile for day " + (currentDayIndex + 1) + "!"); continue; } else if (!dailyProfile.Template.profile_basic_data.profile_is_enabled) { Debug.Log("Skipping un-enabled profile: " + dailyProfile.Template.profile_basic_data.profile_name + " for day: " + (currentDayIndex + 1) + "!"); } else { profiles.Add(dailyProfile); AllProfiles.Add(dailyProfile); } } int profileDelta = ArticyGlobalVariables.Default.day.profile_count - profiles.Count; for (int i = 0; i < profileDelta; ++i) { template_profile dailyProfile = null; dailyProfile = ProfileManager.instance.RollProfileByRandoDefinition(ProfileManager.instance.AnyRandomTemplate); if (dailyProfile == null) { Debug.LogError("Rolled null profile for day " + (currentDayIndex + 1) + "!"); continue; } else { profiles.Add(dailyProfile); AllProfiles.Add(dailyProfile); } } SaveManager.instance.GetCurrentPlayerState().SetCurrentDayProfiles(profiles); // grab only its general properties } List <ulong> profileIDs = new List <ulong>(); for (int i = 0; i < profiles.Count; ++i) { profileIDs.Add(profiles[i].Id); if (!restoreFromSave) { Phone.instance.AddNewsText(profiles[i].Template.profile_basic_data.profile_appearance_news_first); Phone.instance.AddNewsText(profiles[i].Template.profile_basic_data.profile_appearance_news_second); } } Debug.Log("Found " + profiles.Count + " profiles for day " + (currentDayIndex + 1)); if (!restoreFromSave) { SaveManager.instance.GetCurrentPlayerState().AddDailyProfiles(currentDayIndex + 1, profileIDs); } DailyProfiles.Add(currentDayIndex + 1, profiles); }