// Set BugID and save data // If BugID changes from -1 to nonnegative number, start bug timer // -1: don't exist, 0: ladybug, 1: butterfly, 2: bee public async void SetBugID(int bugID) { myClover.c_bug_ID = bugID; if (bugID != -1) { BugTimer.Getbugtimer().StartBugTimer(); CheckEnding(); // Check if ending conditions are met } await Task.Run(SetData); }
// Return BugTimer Object public static BugTimer Getbugtimer() { if (bugtimer == null) { bugtimer = FindObjectOfType <BugTimer>(); if (bugtimer == null) { GameObject container = new GameObject("BugTimer"); bugtimer = container.AddComponent <BugTimer>(); } } return(bugtimer); }
// Initialize clover data and corresponding UIs // And show name pop up to restart public async void Reset() { myClover.c_level = 1; myClover.c_sun_stat = 50; myClover.c_water_stat = 50; myClover.c_energy_stat = 20; myClover.c_name = string.Empty; myClover.c_weather_ID = 0; myClover.c_energy_requirement = 100; SetBugID(-1); SetBugTime(60); await Task.Run(SetData); UpdateStats(); BugTimer.Getbugtimer().UpdateBugTimer(-1); WeatherFunctionOn(false); await PopUp.GetInstance().ShowNamePopUp(); Debug.Log("Reset!"); }