Example #1
0
 //private void UpdateIsOpen() {
 //    bool isOpen =
 //    SetIsOpen(isOpen);
 //}
 private void SetIsOpen(bool _isOpen)
 {
     isOpen = _isOpen;
     SaveStorage.SetBool(SaveKeys.IsProgressGateOpen(MyRoom, myIndex), isOpen);
     UpdateIsReadyToOpen();
     UpdateOpennessVisuals();
 }
Example #2
0
    private static IBData LoadIBData(DateTime date, int index)
    {
        string saveKey        = SaveKeys.IBEntry(CustomDate.FromDateTime(date), index);
        string saveDataString = SaveStorage.GetString(saveKey);

        return(JsonUtility.FromJson <IBData>(saveDataString));
    }
    private void StartLevel(LevelData ld)
    {
        if (ld == null)           // Safety check.
        {
            Debug.LogError("Can't load the requested level! Can't find its LevelData.");
            if (CurrLevel == null)               // If there's no currentLevel, yikes! Default us to something.
            {
                ld = dataManager.GetLevelData(0, 0);
            }
            else
            {
                return;
            }                            // If there IS a currentLevel, then don't leave it.
        }

        // Reset some values
        DestroyCurrentLevel();

        // Instantiate the Level from the provided LevelData!
        CurrLevel = Instantiate(ResourcesHandler.Instance.Level).GetComponent <Level>();
        CurrLevel.Initialize(this, MainCanvas.Canvas.transform, rt_boardArea, ld);
        SaveStorage.SetInt(SaveKeys.LastPlayedLevelInPack(currAddress.pack), currAddress.level);
        SaveStorage.SetString(SaveKeys.LastPlayedLevelAddress, currAddress.ToString());
        ExpandLevelHierarchy();

        // Dispatch event!
        GameManagers.Instance.EventManager.OnStartLevel(CurrLevel);
    }
    //public void RefreshTotalEdiblesEaten() {
    //    NumSnacksEaten = 0;
    //    for (int w=0; w<worldDatas.Count; w++) {
    //        for (int c=0; c<worldDatas[w].clusters.Count; c++) {
    //            NumSnacksEaten += worldDatas[w].clusters[c].NumSnacksEaten;
    //        }
    //    }
    //    if (!GameManagers.IsInitializing) {
    //        GameManagers.Instance.EventManager.OnNumSnacksEatenChanged();
    //    }
    //}
    //public void IncrementNumSnacksEaten() {
    //    NumSnacksEaten ++;
    //    GameManagers.Instance.EventManager.OnNumSnacksEatenChanged();
    //}


    // ----------------------------------------------------------------
    //  Deleting / Resetting
    // ----------------------------------------------------------------
    public void ClearAllSaveData()
    {
        // NOOK IT
        SaveStorage.DeleteAll();
        Reset();
        Debug.Log("All SaveStorage CLEARED!");
    }
    private void StartPack(int packIndex)
    {
        int levelIndex = SaveStorage.GetInt(SaveKeys.LastPlayedLevelInPack(packIndex));

        levelIndex = 0;//QQQ
        StartLevel(new LevelAddress(packIndex, levelIndex));
    }
 public void SetCoinsCollected(int value)
 {
     CoinsCollected = value;
     SaveStorage.SetInt(SaveKeys.NumCoinsCollected, CoinsCollected);
     // Dispatch event!
     GameManagers.Instance.EventManager.OnCoinsCollectedChanged();
 }
Example #7
0
        //string returnString = ROOM_PROPERTIES + " ";
        //returnString += "pos:" + rd.PosGlobal;
        //returnString += ";size:" + rd.Size;
        //returnString += ";camBoundsPos:" + rd.CameraBoundsPos;
        //returnString += ";designerFlag:" + rd.DesignerFlag;

        private void SetCurrWorld(int _worldIndex)
        {
            if (_worldIndex >= GameProperties.NUM_WORLDS)
            {
                return;
            }                                                             // Don't crash da game, bruddah.

            // Deselect any tiles that might be selected!
            DeselectAllRoomTiles();

            // Tell all the tiles in the world we already were to hide their stuff!
            if (currWorldIndex != -1)
            {
                for (int i = 0; i < CurrWorldRoomTiles.Count; i++)
                {
                    CurrWorldRoomTiles[i].Hide();
                }
            }
            currWorldIndex = _worldIndex;
            SaveStorage.SetInt(SaveKeys.LastPlayedWorldIndex, currWorldIndex);

            // Tell all the tiles in the NEW world to show their stuff!
            for (int i = 0; i < CurrWorldRoomTiles.Count; i++)
            {
                CurrWorldRoomTiles[i].Show();
            }

            // Dispatch heevent!
            GameManagers.Instance.EventManager.OnMapEditorSetCurrWorld(currWorldIndex);
        }
    // ================================================================
    //  Start / Destroy
    // ================================================================
    void Start()
    {
        // Open the last panel that was open!
        PanelTypes lastPanelOpenType = (PanelTypes)SaveStorage.GetInt(SaveKeys.LastPanelOpen);
        string     lastSetName       = SaveStorage.GetString(SaveKeys.LastStudySetOpenName);
        StudySet   lastSet           = dm.library.GetSetByName(lastSetName);

        if (lastSet != null && lastPanelOpenType == PanelTypes.EditSet)
        {
            OpenPanel_EditSet(lastSet);
        }
        else if (lastSet != null && lastPanelOpenType == PanelTypes.StudyFlashcards)
        {
            OpenPanel_StudyFlashcards(lastSet);
        }
        else
        {
            OpenPanel_ChooseSet();
        }

        // Add event listeners.
        GameManagers.Instance.EventManager.OpenPanelEditSetEvent         += OpenPanel_EditSet;
        GameManagers.Instance.EventManager.OpenPanelChooseSetEvent       += OpenPanel_ChooseSet;
        GameManagers.Instance.EventManager.OpenPanelStudyFlashcardsEvent += OpenPanel_StudyFlashcards;
    }
    public void StartGameAtRoom(RoomData rd, PlayerData playerData)
    {
        // Wipe everything totally clean.
        DestroyPlayer();
        DestroyRoom();

        dm.currRoomData = rd;

        // Make Room and Player!
        CurrRoom = Instantiate(ResourcesHandler.Instance.Room).GetComponent <Room>();
        CurrRoom.Initialize(this, tf_world, rd);
        MakePlayer(playerData);
        // Tell the RoomData it's on!
        rd.OnPlayerEnterMe();

        // Reset things!
        dm.ResetRoomEnterValues();

        // Save what's up!
        SaveStorage.SetInt(SaveKeys.LastPlayedWorldIndex, rd.WorldIndex);
        SaveStorage.SetString(SaveKeys.LastPlayedRoomKey(rd.WorldIndex), rd.RoomKey);
        SaveStorage.SetFloat(SaveKeys.MapEditor_CameraPosX, rd.PosGlobal.x);
        SaveStorage.SetFloat(SaveKeys.MapEditor_CameraPosY, rd.PosGlobal.y);

        //// Use this opportunity to call SAVE with SaveStorage, yo! (This causes a brief stutter, so I'm opting to call it when the game is already loading.)
        //SaveStorage.Save();
        // Dispatch the post-function event!
        eventManager.OnStartRoom(CurrRoom);
    }
    private void Debug_ToggleIgnoreColorTheme()
    {
        bool val = SaveStorage.GetBool(SaveKeys.Debug_IgnoreColorTheme);

        SaveStorage.SetBool(SaveKeys.Debug_IgnoreColorTheme, !val);
        SceneHelper.ReloadScene();
    }
Example #11
0
    static private int GetTheme(int worldIndex)
    {
        // Debug ignore theme? Return TestingGreen theme.
        if (SaveStorage.GetBool(SaveKeys.Debug_IgnoreColorTheme))
        {
            return(TestingGreen);
        }
        // Otherwise, return the theme for this world!
        switch (worldIndex)
        {
        case 0: return(TestingGreen);

        case 1: return(BasicGreen);

        case 2: return(MyYachtBlue);

        case 3: return(MrKakhi);

        case 4: return(Hungaria);

        case 5: return(GrayClicks);

        case 6: return(NoirDark);

        case 7: return(NoirLight);

        default: return(TestingGreen);
        }
    }
    // Properties
    //private PackData[] packDatas;


    //// ----------------------------------------------------------------
    ////  Getters
    //// ----------------------------------------------------------------
    //   public PackData GetPackData (LevelAddress address) {
    //       return GetPackData (address.pack);
    //   }
    //   public PackData GetPackData (int pack) {
    //       if (pack<0 || pack>=packDatas.Length) { return null; } // Safety check.
    //       return packDatas[pack];
    //   }
    //   public LevelData GetLevelData(int pack, int level) {
    //       PackData packData = GetPackData(pack);
    //       if (packData == null) { return null; } // Safety check.
    //       return packData.GetLevelData(level);
    //   }
    //public LevelData GetLevelData (LevelAddress address) {
    //	return GetLevelData (address.pack, address.level);
    //}

    //   public bool DidCompleteLevel (int packIndex, int levelIndex) {
    //       LevelData levelData = GetLevelData (packIndex, levelIndex);
    //       if (levelData == null) { return false; } // Safety check.
    //       return levelData.DidCompleteLevel;
    //   }

    //public LevelAddress GetLastPlayedLevelAddress() {
    //	// Save data? Use it!
    //	if (SaveStorage.HasKey (SaveKeys.LastPlayedLevelAddress)) {
    //		return LevelAddress.FromString (SaveStorage.GetString (SaveKeys.LastPlayedLevelAddress));
    //	}
    //	// No save data. Default to the first level, I guess.
    //	else {
    //		return new LevelAddress(0, 0);
    //	}
    //}
    //   public LevelAddress PrevLevelAddress(LevelAddress addr) {
    //       if (addr==LevelAddress.zero) { return addr; } // Safety check; can't go before 0,0.
    //       addr.level --;
    //       if (addr.level < 0) { // Wrap back to previous pack.
    //           addr.pack --;
    //           addr.level = GetPackData(addr.pack).NumLevels-1;
    //       }
    //       return addr;
    //   }
    //   public LevelAddress NextLevelAddress(LevelAddress addr) {
    //       PackData pack = GetPackData(addr.pack);
    //       if (pack == null) { return LevelAddress.undefined; } // Safety check.
    //       addr.level ++;
    //       if (addr.level >= pack.NumLevels) { // Wrap over to next pack.
    //           addr.pack ++;
    //           addr.level = 0;
    //       }
    //       return addr;
    //   }


    //// ----------------------------------------------------------------
    ////  Initialize
    //// ----------------------------------------------------------------
    //public DataManager() {
    //       ReloadLevels ();
    //}

    //public void ReloadLevels () {
    //       // Read Levels.xml file.
    //       PackCollectionDataXML collectionXML;
    //       TextAsset levelsXML = Resources.Load<TextAsset>("Levels/Levels");
    //       if (levelsXML != null) {
    //           XmlSerializer serializer = new XmlSerializer(typeof(PackCollectionDataXML));
    //           StringReader reader = new StringReader(levelsXML.text);
    //           collectionXML = serializer.Deserialize(reader) as PackCollectionDataXML;
    //       }
    //       else {
    //           Debug.LogError("Can't find Levels.xml file!");
    //           collectionXML = new PackCollectionDataXML();
    //       }

    //       // Make those PackDatas from the XML!
    //       int numPacks = collectionXML.packDataXMLs.Count;
    //       packDatas = new PackData[numPacks];
    //       for (int i=0; i<numPacks; i++) {
    //           LevelAddress packAddress = new LevelAddress(i, -1);
    //           packDatas[i] = new PackData (packAddress, collectionXML.packDataXMLs[i]);
    //       }
    //   }


    // ----------------------------------------------------------------
    //  Events
    // ----------------------------------------------------------------
    //public void OnCompleteLevel (LevelAddress levelAddress) {
    //  PackData packData = GetPackData (levelAddress);
    //  packData.OnCompleteLevel (levelAddress);
    //}


    // ----------------------------------------------------------------
    //  Doers
    // ----------------------------------------------------------------
    public void ClearAllSaveData()
    {
        // NOOK IT
        SaveStorage.DeleteAll();
        //ReloadLevels ();
        Debug.Log("All SaveStorage CLEARED!");
    }
Example #13
0
    public void ReloadStudySetLibrary()
    {
        string libSaveKey = SaveKeys.StudySetLibrary(SettingsManager.Instance.CurrForeignCode);

        //// QQQ if we can't find the correct key, use the OLD one. Should just be for ONE push to my phone.
        //if (SettingsManager.Instance.CurrForeignCode=="da" && !SaveStorage.HasKey(libSaveKey)) {
        //    if (SaveStorage.HasKey("StudySetLibrary")) {
        //        libSaveKey = "StudySetLibrary";
        //    }
        //}

        // NO save data?! Ok, default to Quizlet hardcoded ones! :)
        if (!SaveStorage.HasKey(libSaveKey))
        {
            //ReplaceAllStudySetsWithPremadeHardcodedOnes();
            library = new StudySetLibrary();
        }
        // Otherwise, YES load what's been saved!
        else
        {
            string jsonString = SaveStorage.GetString(libSaveKey);
            library = JsonUtility.FromJson <StudySetLibrary>(jsonString);
            // Convert the unpacked term list to our efficient dictionary.
            library.RemakeTermsDictionaryFromList();

            // Reaffiliate all terms with their sets.
            foreach (StudySet set in library.GetMainAndBenchedSetsList())
            {
                set.SetMyLibraryAndGiveMyTermsRefToMe(library);
            }
        }

        // Hardcoded. Set some properties manually.
        //library.setToughies.isRemixSet = true;
        //library.setSourdough.isRemixSet = true;
        //library.setAced.canIncludeMeInRemixes = false;
        //library.setInQueue.canIncludeMeInRemixes = false;
        //library.setShelved.canIncludeMeInRemixes = false;
        //library.setToValidate.canIncludeMeInRemixes = false;
        //library.setWantRecording.canIncludeMeInRemixes = false;
        //foreach (StudySet set in library.sets) {
        //    set.canIncludeMeInRemixes = true;
        //}

        // DEBUG. Print any terms that don't belong to the set they're in.
        foreach (StudySet set in library.sets)
        {
            for (int i = set.allTermGs.Count - 1; i >= 0; --i)
            {
                string termG = set.allTermGs[i];
                Term   term  = library.GetTerm(termG);
                if (term.mySet != set)
                {
                    AppDebugLog.LogError("MISMATCH BETWEEN SETS: " + set.name + ", " + term.MySetName() + ",   " + term.native);
                    set.RemoveTerm(termG); // Remove it from this set! ONLY trust the Term's set.
                }
            }
        }
    }
Example #14
0
 // ----------------------------------------------------------------
 //  Events
 // ----------------------------------------------------------------
 override public void GetEaten()
 {
     base.GetEaten();
     // Save the value!
     SaveStorage.SetBool(SaveKeys.DidEatGem(MyRoom, myIndex), true);
     // Particle bursttt
     ps_collectedBurst.Emit(16);
 }
 public void OnPlayerExitMyRoom()
 {
     // Save when the Player EXITS this Room.
     if (doSaveIsUnlocked)
     {
         SaveStorage.SetBool(SaveKeys.IsGateUnlocked(myRoom, channelID), IsUnlocked);
     }
 }
Example #16
0
 // ----------------------------------------------------------------
 //  Doers
 // ----------------------------------------------------------------
 public void ClearAllSaveData()
 {
     // NOOK IT
     SaveStorage.DeleteAll();
     Debug.Log("All SaveStorage CLEARED!");
     ReloadStudySetLibrary();
     SceneHelper.ReloadScene();
 }
Example #17
0
 // ----------------------------------------------------------------
 //  Doers
 // ----------------------------------------------------------------
 public void SetDidCompleteLevel(bool _didCompleteLevel)
 {
     if (DidCompleteLevel != _didCompleteLevel)
     {
         DidCompleteLevel = _didCompleteLevel;
         SaveStorage.SetBool(SaveKeys.DidCompleteLevel(myAddress), DidCompleteLevel);
     }
 }
Example #18
0
    public float GetHoursUntilNextSourdoughRefill()
    {
        DateTime timeLastRefilled = SaveStorage.GetDateTime(SaveKeys.SourdoughTimeLastRefilled);
        DateTime timeToNextRefill = timeLastRefilled.AddHours(SourdoughHoursBetweenRefill);
        TimeSpan timeSpan         = timeToNextRefill - DateTime.Now;

        return((float)timeSpan.TotalHours);
    }
Example #19
0
    public void SaveStudySetLibrary()
    {
        string jsonString = JsonUtility.ToJson(library);
        string libSaveKey = SaveKeys.StudySetLibrary(SettingsManager.Instance.CurrForeignCode);

        SaveStorage.SetString(libSaveKey, jsonString);
        Debug.Log("SAVED STUDYSET LIBRARY: " + jsonString);
    }
    private void Reset()
    {
        CoinsCollected = SaveStorage.GetInt(SaveKeys.NumCoinsCollected);
//		highestWorldEndEverReached = SaveStorage.GetInt (SaveKeys.HIGHEST_WORLD_END_EVER_REACHED);

        ReloadCharLineup();
        ReloadWorldDatas();
        RefreshSnackCountGame();
    }
Example #21
0
 public void OnPlayerEnterMe()
 {
     // First time in room?? Update hasPlayerBeenHere!!
     if (!HasPlayerBeenHere)
     {
         HasPlayerBeenHere = true;
         SaveStorage.SetBool(SaveKeys.HasPlayerBeenInRoom(this), HasPlayerBeenHere);
     }
 }
Example #22
0
 public MapEditorSettings()
 {
     DoMaskRoomContents  = SaveStorage.GetBool(SaveKeys.MapEditor_DoMaskRoomContents, true);
     DoShowClusters      = SaveStorage.GetBool(SaveKeys.MapEditor_DoShowClusters, true);
     DoShowDesignerFlags = SaveStorage.GetBool(SaveKeys.MapEditor_DoShowDesignerFlags, false);
     DoShowInstructions  = SaveStorage.GetBool(SaveKeys.MapEditor_DoShowInstructions, true);
     DoShowRoomEdibles   = SaveStorage.GetBool(SaveKeys.MapEditor_DoShowRoomEdibles, true);
     DoShowRoomNames     = SaveStorage.GetBool(SaveKeys.MapEditor_DoShowRoomNames, true);
     DoShowRoomProps     = SaveStorage.GetBool(SaveKeys.MapEditor_DoShowRoomProps, true);
 }
Example #23
0
    // ----------------------------------------------------------------
    //  Initialize
    // ----------------------------------------------------------------
    public LevelData(LevelAddress myAddress, LevelDataXML ldxml)
    {
        // Basic properties
        this.myAddress = myAddress;
        boardData      = new BoardData(ldxml);
        startingZoom   = ldxml.zoom;

        // LOAD up stats!
        DidCompleteLevel = SaveStorage.GetBool(SaveKeys.DidCompleteLevel(myAddress));
    }
Example #24
0
 public void SaveAll()
 {
     SaveStorage.SetBool(SaveKeys.MapEditor_DoMaskRoomContents, DoMaskRoomContents);
     SaveStorage.SetBool(SaveKeys.MapEditor_DoShowClusters, DoShowClusters);
     SaveStorage.SetBool(SaveKeys.MapEditor_DoShowDesignerFlags, DoShowDesignerFlags);
     SaveStorage.SetBool(SaveKeys.MapEditor_DoShowInstructions, DoShowInstructions);
     SaveStorage.SetBool(SaveKeys.MapEditor_DoShowRoomEdibles, DoShowRoomEdibles);
     SaveStorage.SetBool(SaveKeys.MapEditor_DoShowRoomNames, DoShowRoomNames);
     SaveStorage.SetBool(SaveKeys.MapEditor_DoShowRoomProps, DoShowRoomProps);
 }
Example #25
0
 override public void GetEaten()
 {
     base.GetEaten();
     // Save the value!
     SaveStorage.SetBool(SaveKeys.DidEatSnack(MyRoom, myIndex), true);
     // Particle bursttt and visuals
     sr_aura.enabled = false;
     ps_collectedBurst.Emit(4);
     // Tell my WorldData!
     MyRoom.MyWorldData.OnPlayerEatSnack(MyRoom);
 }
Example #26
0
    // ----------------------------------------------------------------
    //  Save / Load
    // ----------------------------------------------------------------
    public void LoadFromSaveData()
    {
        string str = SaveStorage.GetString(SaveKeys.PlayerLineup, PlayerTypes.Neutrala.ToString());

        string[] strs = str.Split(',');
        Lineup = new List <PlayerTypes>();
        for (int i = 0; i < strs.Length; i++)
        {
            Lineup.Add(PlayerTypeHelper.TypeFromString(strs[i]));
        }
    }
Example #27
0
    // ================================================================
    //  Initialize
    // ================================================================
    public RoomData(WorldData _worldData, string _key)
    {
        MyWorldData       = _worldData;
        MyAddress         = new RoomAddress(MyWorldData.worldIndex, -1, _key);
        IsSecret          = false;
        HasPlayerBeenHere = SaveStorage.GetBool(SaveKeys.HasPlayerBeenInRoom(this), false);

        // Initialize all my PropData lists.
        ClearAllPropDataLists();
        Openings = new List <RoomOpening>();
    }
    // ----------------------------------------------------------------
    //  Initialize
    // ----------------------------------------------------------------
    public GateChannel(Room myRoom, int channelID)
    {
        this.myRoom           = myRoom;
        this.channelID        = channelID;
        this.doSaveIsUnlocked = channelID < 3; // Hacky: We don't wanna save gate-unlockedness for Channels 3 and up.

        if (doSaveIsUnlocked)
        {
            IsUnlocked = SaveStorage.GetBool(SaveKeys.IsGateUnlocked(myRoom, channelID));
        }
    }
Example #29
0
 public SettingsManager()
 {
     currForeignCode       = SaveStorage.GetString(SaveKeys.CurrForeignCode, "da");
     doShowCardDots        = SaveStorage.GetBool(SaveKeys.DoShowCardDots, true);
     doShowCardStats       = SaveStorage.GetBool(SaveKeys.DoShowCardStats, true);
     doTrimAudioClips      = SaveStorage.GetBool(SaveKeys.DoTrimAudioClips, true);
     doNormalizeAudioClips = SaveStorage.GetBool(SaveKeys.DoNormalizeAudioClips, true);
     isTTSOn       = SaveStorage.GetBool(SaveKeys.IsTTSOn, true);
     ttsSpeechRate = SaveStorage.GetFloat(SaveKeys.TTSSpeechRate, 1);
     UpdateForeignCodeValues();
 }
Example #30
0
    // ----------------------------------------------------------------
    //  Initialize
    // ----------------------------------------------------------------
    public void Initialize(Room _myRoom, ProgressGateData data, int myIndex)
    {
        this.myIndex = myIndex;
        base.BaseGroundInitialize(_myRoom, data);

        numSnacksReq = data.numSnacksReq;
        UpdateText();
        // Load openness!
        isOpen = SaveStorage.GetBool(SaveKeys.IsProgressGateOpen(MyRoom, myIndex));
        UpdateIsReadyToOpen();
        UpdateOpennessVisuals();
    }