Example #1
0
        public override void LoadDefaults()
        {
            SetupPlanets();

            List <PlanetSave> defaultSaves = new List <PlanetSave>();

            foreach (int planetId in PlanetConst.PlanetIds)
            {
                if (planetId == PlanetConst.EARTH_ID)
                {
                    defaultSaves.Add(new PlanetSave {
                        id = planetId, state = PlanetState.Opened, unlockTimer = 0
                    });
                }
                else
                {
                    defaultSaves.Add(new PlanetSave {
                        id = planetId, state = PlanetState.Closed, unlockTimer = 0
                    });
                }
            }

            LoadFromSaves(defaultSaves);

            currentPlanetId = PlanetConst.EARTH_ID;
            currentPlanet   = CurrentPlanet;
            StartCoroutine(SetEarthStartTime());

            IsLoaded = true;
        }
Example #2
0
 private void SetupPlanets()
 {
     planets.Clear();
     foreach (int planetId in PlanetConst.PlanetIds)
     {
         PlanetInfo planetInfo = new PlanetInfo(planetId, Services);
         planets.Add(planetId, planetInfo);
     }
 }
Example #3
0
 private void OnPlanetChanged(PlanetInfo oldPlanet, PlanetInfo newPlanet)
 {
     if (oldPlanet != null)
     {
         LogPlanetInterval(oldPlanet);
         if (Planets.PlanetOpenCounter > 0)
         {
             LogPlanetOpenCounter(Planets.PlanetOpenCounter);
         }
     }
 }
Example #4
0
 private void LogPlanetInterval(PlanetInfo planet)
 {
     FB.LogAppEvent("planet_interval", 1, new Dictionary <string, object> {
         ["planet_id"] = planet.Id,
         ["interval"]  = (planet.EndTime - planet.StartTime).ToTextMark()
     });
     InitSeparatePlanetLoggers();
     if (separatePlanetLoggers.ContainsKey(planet.Id))
     {
         separatePlanetLoggers[planet.Id](planet);
     }
 }
Example #5
0
        public void ChangeCurrentPlanet(int newPlanetId)
        {
            if (newPlanetId == NextPlanetId && HasNextPlanet)
            {
                if (GetPlanet(newPlanetId).State == PlanetState.Opened)
                {
                    PlanetInfo oldPlanet = CurrentPlanet;
                    oldPlanet.SetEndTime(TimeService.UnixTimeInt);

                    currentPlanetId = newPlanetId;
                    currentPlanet   = CurrentPlanet;
                    currentPlanet.SetStartTime(TimeService.UnixTimeInt);
                    Services.SetLoadingPlanet(CurrentPlanet.Id);
                    PlanetOpenCounter++;
                    GameEvents.OnCurrentPlanetChanged(oldPlanet, CurrentPlanet);
                }
            }
        }
Example #6
0
        public override void LoadSave(object obj)
        {
            PlanetServiceSave save = obj as PlanetServiceSave;

            if (save != null)
            {
                SetupPlanets();
                if (save.planets != null)
                {
                    LoadFromSaves(save.planets);
                }
                currentPlanetId   = save.currentPlanetId;
                currentPlanet     = CurrentPlanet;
                PlanetOpenCounter = save.planetOpenCounter;
                IsLoaded          = true;
            }
            else
            {
                LoadDefaults();
            }
        }
Example #7
0
 public static void OnCurrentPlanetChanged(PlanetInfo oldPlanet, PlanetInfo newPlanet)
 => CurrentPlanetChanged?.Invoke(oldPlanet, newPlanet);
Example #8
0
 private void OnPlanetStateChanged(PlanetState oldState, PlanetState newState, PlanetInfo planet)
 {
     if (IsLoaded)
     {
         if (planet.Id == PlanetConst.MARS_ID)
         {
             if (newState == PlanetState.Opened || newState == PlanetState.Opening || newState == PlanetState.ReadyToOpen)
             {
                 SkipState(TutorialStateName.Mars);
             }
         }
     }
 }
Example #9
0
 private void OnPlanetStateChanged(PlanetState oldState, PlanetState newState, PlanetInfo info)
 {
     if (newState == PlanetState.Opened && info.Id > PlanetConst.EARTH_ID)
     {
         UpdateIcon();
     }
 }
Example #10
0
 private void OnPlanetChanged(PlanetInfo planetOld, PlanetInfo planetNew)
 {
     UpdateBg();
 }
Example #11
0
 private void OnPlanetStateChanged(PlanetState oldState, PlanetState newState, PlanetInfo info)
 {
     UpdateButtonState();
 }
Example #12
0
 private void OnPlanetStateChanged(PlanetState oldState, PlanetState newState, PlanetInfo planet)
 {
     if (newState == PlanetState.Opened)
     {
         ChangeCurrentPlanet(planet.Id);
         ResetAfterOpenedPlanet();
     }
 }
Example #13
0
 private void OnPlanetStateChanged(PlanetState oldState, PlanetState newState, PlanetInfo planet)
 {
     if (newState == PlanetState.Opened)
     {
         MakeAvailableModuleForPlanet(planet.Data.Id);
     }
 }
Example #14
0
 private void LogTitanInterval(PlanetInfo planet)
 => FB.LogAppEvent("planet_interval_titan", 1, new Dictionary <string, object> {
     ["planet_id"] = 5,
     ["interval"]  = (planet.EndTime - planet.StartTime).ToTextMark()
 });
Example #15
0
 private void LogAsteroidsInterval(PlanetInfo planet)
 => FB.LogAppEvent("planet_interval_asteroidbelt", 1, new Dictionary <string, object> {
     ["planet_id"] = 3,
     ["interval"]  = (planet.EndTime - planet.StartTime).ToTextMark()
 });
Example #16
0
 public static void OnPlanetStateChanged(PlanetState oldState, PlanetState newState, PlanetInfo planet)
 => PlanetStateChanged?.Invoke(oldState, newState, planet);
Example #17
0
 private void OnPlanetStateChanged(PlanetState oldState, PlanetState newState, PlanetInfo planet)
 {
     if (IsLoaded)
     {
         if (newState == PlanetState.Opened && planet.Id != PlanetConst.EARTH_ID)
         {
             planetStartTime = Services.TimeService.UnixTimeInt;
             offerState      = SpecialOfferState.NotStarted;
         }
     }
 }
Example #18
0
 private void OnPlanetStateChanged(PlanetState oldState, PlanetState newState, PlanetInfo planet)
 {
     if (IsLoaded)
     {
         if (newState == PlanetState.Opened)
         {
             if (GameMode.IsGame)
             {
                 int countRemoved = RemoveBoosts(BoostSourceType.CoinUpgrade);
                 UDebug.Log($"count of boosts removed: {countRemoved}");
             }
             MakeGeneratorsManual();
         }
     }
 }