コード例 #1
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));
    }
コード例 #2
0
    public static void SaveSettings()
    {
        //SavableSettings sets = new SavableSettings();
        //List<FieldInfo> savableprops = typeof(SavableSettings).GetFields().ToList();
        //PropertyInfo[] settingsprops = typeof(InputMap).GetProperties();
        //int i = 0;
        ////sets,settingsprops[i].GetValue(this,null),null
        //foreach (var propertyInfo in savableprops)
        //{
        //    propertyInfo.SetValue(sets, settingsprops[i].GetValue(null, null));
        //    i++;
        //}

        SaveKeys save = new SaveKeys();

        save.keys   = new List <string>(KeyBinds.Keys);
        save.values = new List <KeyCode>(KeyBinds.Values);
        //Dictionary<string, KeyCode> Kb = new Dictionary<string, KeyCode>(KeyBinds);

        //save.binds = KeyBinds;
        string Json = JsonUtility.ToJson(save, true);
        //string codesJson = JsonUtility.ToJson(keyCodes, true);


        string path = Application.persistentDataPath;

        path = Application.dataPath + "/bin";

        if (!File.Exists(path))
        {
            Directory.CreateDirectory(path);
        }
        File.WriteAllText(path + "/settings" + ".json", Json);
    }
コード例 #3
0
    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);
    }
コード例 #4
0
 //private void UpdateIsOpen() {
 //    bool isOpen =
 //    SetIsOpen(isOpen);
 //}
 private void SetIsOpen(bool _isOpen)
 {
     isOpen = _isOpen;
     SaveStorage.SetBool(SaveKeys.IsProgressGateOpen(MyRoom, myIndex), isOpen);
     UpdateIsReadyToOpen();
     UpdateOpennessVisuals();
 }
コード例 #5
0
    private void StartPack(int packIndex)
    {
        int levelIndex = SaveStorage.GetInt(SaveKeys.LastPlayedLevelInPack(packIndex));

        levelIndex = 0;//QQQ
        StartLevel(new LevelAddress(packIndex, levelIndex));
    }
コード例 #6
0
    private void SaveAndAffiliateAudioFile()
    {
        // First, delete the old clip.
        dm.DeleteTermAudio0(currTerm);

        AudioClip clip = clipPlayer.GetClip();

        clip = AudioEditor.GetTrailingSilenceTrimmed(clip);
        Guid newGuid = Guid.NewGuid();

        // Assign it to the Term!
        currTerm.audio0Guid = newGuid.ToString();
        dm.SaveStudySetLibrary();

        // Save audio file.
        string filePath = SaveKeys.TermAudioClip0(currTerm.audio0Guid);

        SavWav.Save(filePath, clip);
        //EncodeMP3.ConvertAndWrite(clip, filePath, 128);
        Debug.Log("SAVED audio. Length: " + clip.length);

        // Set this as the current clip!
        UpdateVisualsForClip(clip);
        GameManagers.Instance.EventManager.OnAnySetContentsChanged();
    }
コード例 #7
0
    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);
    }
コード例 #8
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.
                }
            }
        }
    }
コード例 #9
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);
    }
コード例 #10
0
 public void OnPlayerExitMyRoom()
 {
     // Save when the Player EXITS this Room.
     if (doSaveIsUnlocked)
     {
         SaveStorage.SetBool(SaveKeys.IsGateUnlocked(myRoom, channelID), IsUnlocked);
     }
 }
コード例 #11
0
ファイル: Gem.cs プロジェクト: BATzerk/Unity-BounceMeister
 // ----------------------------------------------------------------
 //  Events
 // ----------------------------------------------------------------
 override public void GetEaten()
 {
     base.GetEaten();
     // Save the value!
     SaveStorage.SetBool(SaveKeys.DidEatGem(MyRoom, myIndex), true);
     // Particle bursttt
     ps_collectedBurst.Emit(16);
 }
コード例 #12
0
ファイル: LevelData.cs プロジェクト: BATzerk/Unity-Mobiusban
 // ----------------------------------------------------------------
 //  Doers
 // ----------------------------------------------------------------
 public void SetDidCompleteLevel(bool _didCompleteLevel)
 {
     if (DidCompleteLevel != _didCompleteLevel)
     {
         DidCompleteLevel = _didCompleteLevel;
         SaveStorage.SetBool(SaveKeys.DidCompleteLevel(myAddress), DidCompleteLevel);
     }
 }
コード例 #13
0
 public void OnPlayerEnterMe()
 {
     // First time in room?? Update hasPlayerBeenHere!!
     if (!HasPlayerBeenHere)
     {
         HasPlayerBeenHere = true;
         SaveStorage.SetBool(SaveKeys.HasPlayerBeenInRoom(this), HasPlayerBeenHere);
     }
 }
コード例 #14
0
ファイル: LevelData.cs プロジェクト: BATzerk/Unity-AbbaIsYou
    // ----------------------------------------------------------------
    //  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));
    }
コード例 #15
0
    // ----------------------------------------------------------------
    //  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));
        }
    }
コード例 #16
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>();
    }
コード例 #17
0
ファイル: Snack.cs プロジェクト: BATzerk/Unity-BounceMeister
 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);
 }
コード例 #18
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();
    }
コード例 #19
0
ファイル: Snack.cs プロジェクト: BATzerk/Unity-BounceMeister
    public void Initialize(Room _myRoom, SnackData data, int myIndex)
    {
        base.InitializeAsProp(_myRoom, data);
        this.myIndex    = myIndex;
        this.playerType = PlayerTypeHelper.TypeFromString(data.playerType);

        // Load wasEverEaten!
        wasEverEaten = SaveStorage.GetBool(SaveKeys.DidEatSnack(MyRoom, myIndex));
        isEaten      = wasEverEaten;

        UpdatePresence();
    }
コード例 #20
0
    private void SwapPlayerType(Player player)
    {
        PlayerTypes playerNewType = CharTypeInMe;
        PlayerTypes myNewType     = player.PlayerType();

        // Set Player's type!
        MyRoom.GameController.SetPlayerType(playerNewType);
        // Set/save my type!
        SetCharTypeInMe(myNewType);
        SaveStorage.SetString(SaveKeys.CharBarrelTypeInMe(MyRoom.MyRoomData, myIndex), myNewType.ToString());
        // Reset timeWhenCanSensePlayer!
        timeWhenCanSensePlayer = Time.time + 0.1f;
    }
コード例 #21
0
ファイル: InputMap.cs プロジェクト: DustinPouncey/GameJam
    public static void LoadDefaults()
    {
        string   Json  = File.ReadAllText(Application.dataPath + "/bin/defaults.json");
        SaveKeys saved = JsonUtility.FromJson <SaveKeys>(Json);
        int      i     = 0;

        KeyBinds.Clear();
        foreach (var key in saved.keys)
        {
            KeyBinds.Add(key, saved.values[i]);
            i++;
        }
    }
コード例 #22
0
    public void SetClustIndex(int clustIndex)
    {
        this.MyAddress  = new RoomAddress(WorldIndex, clustIndex);
        this.IsUnlocked = SaveStorage.GetBool(SaveKeys.ClustIsUnlocked(MyAddress), false);
        if (GameProperties.IsFirstCluster(MyAddress))
        {
            this.IsUnlocked = true;
        }                                                                         // First cluster is ALWAYS unlocked.
        //this.IsUnlocked = true; // TEMP!! ALL clusters start unlocked!! Test!

        // Set NumSnacksReq
        NumSnacksReq = GameProperties.ClustNumSnacksReq(MyAddress);
        // NOTE: Doesn't seem as if we need to update Rooms, so I'm not doing that.
    }
コード例 #23
0
    // ----------------------------------------------------------------
    //  Audio Save/Load
    // ----------------------------------------------------------------
    void LoadClipForCurrTerm()
    {
        string clipPath   = SaveKeys.TermAudioClip0(currTerm.audio0Guid);
        bool   isClipFile = File.Exists(clipPath);

        if (isClipFile)
        {
            clipPlayer.LoadClipFromPath(clipPath, false);
        }
        else
        {
            UpdateVisualsForNoClip();
        }
    }
コード例 #24
0
    //private Rect MyRect {
    //    get {
    //        return new Rect(sr_body.transform.localPosition, sr_body.size);
    //    }
    //}


    // ----------------------------------------------------------------
    //  Initialize
    // ----------------------------------------------------------------
    public void Initialize(Room _myRoom, VeilData data, int myIndex)
    {
        base.InitializeAsProp(_myRoom, data);
        this.myIndex = myIndex;
        Size         = data.size;

        // Color me right-o.
        sr_body.color = Colors.GroundBaseColor(WorldIndex);

        // Start opaque.
        bool isUnveiled = SaveStorage.GetBool(SaveKeys.IsVeilUnveiled(MyRoom.MyRoomData, myIndex), false);

        SetIsUnveiled(isUnveiled, false);
    }
コード例 #25
0
    // ----------------------------------------------------------------
    //  Start
    // ----------------------------------------------------------------
    public void Initialize(Room _myRoom, CharBarrelData data, int myIndex)
    {
        base.InitializeAsProp(_myRoom, data);

        timeWhenCanSensePlayer = Time.time;

        this.otherCharName = data.otherCharName;
        this.myIndex       = myIndex;

        // Load what character's in me!
        string savedCharType = SaveStorage.GetString(SaveKeys.CharBarrelTypeInMe(MyRoom.MyRoomData, myIndex), otherCharName);

        SetCharTypeInMe(PlayerTypeHelper.TypeFromString(savedCharType));
    }
コード例 #26
0
    // ----------------------------------------------------------------
    //  Audio
    // ----------------------------------------------------------------
    public void DeleteTermAudio0(Term term)
    {
        // No audio? Get outta here.
        if (!term.HasAudio0())   //string.IsNullOrEmpty(term.audio0Guid)
        {
            return;
        }
        // Delete the actual file!
        string clipPath = SaveKeys.TermAudioClip0(term.audio0Guid);

        File.Delete(clipPath);
        // Null out the Term's guid, and save our library!
        term.audio0Guid = "";
        SaveStudySetLibrary();
    }
コード例 #27
0
    public void PlayTermClip(Term term)
    {
        // NOTE: For now, just load the clip EVERY time for safety. We want it definitely trimmed/normalized.
        //// Is it a new clip? Load a new clip!
        //if (currClipGuid != term.audio0Guid) {
        currClipGuid = term.audio0Guid;
        string clipPath = SaveKeys.TermAudioClip0(term.audio0Guid);

        LoadClipFromPath(clipPath, true);
        //}
        //// Otherwise, play what's loaded; it's already the correct clip.
        //else {
        //    Play();
        //}
    }
コード例 #28
0
    static public void OpenGameplayScene(RoomClusterData clust)
    {
        // Default to the first Room in the cluster.
        RoomData room = clust.rooms[0];
        // Did we last play this cluster? Start in the last room we were in!
        string lastPlayedRoomKey = SaveStorage.GetString(SaveKeys.LastPlayedRoomKey(clust.WorldIndex));

        for (int i = 0; i < clust.rooms.Count; i++)
        {
            if (lastPlayedRoomKey == clust.rooms[i].RoomKey)
            {
                room = clust.rooms[i];
                break;
            }
        }
        OpenGameplayScene(room);
    }
コード例 #29
0
ファイル: Gem.cs プロジェクト: BATzerk/Unity-BounceMeister
    [SerializeField] private int type = 0; // 0 is action, 1 is puzzle.


    // ----------------------------------------------------------------
    //  Initialize
    // ----------------------------------------------------------------
    public void Initialize(Room _myRoom, GemData data, int myIndex)
    {
        base.InitializeAsProp(_myRoom, data);
        this.myIndex = myIndex;
        this.type    = data.type;

        // Load wasEverEaten!
        wasEverEaten = SaveStorage.GetBool(SaveKeys.DidEatGem(MyRoom, myIndex));

        // Set wasEverEaten visuals.
        if (wasEverEaten)
        {
            sr_body.color = new Color(0.2f, 0.2f, 0.2f, 0.25f);
        }

        // Apply type visuals.
        sr_body.sprite = ResourcesHandler.Instance.GetGemSprite(type);
    }
コード例 #30
0
 public void Refresh(RoomData rd)
 {
     // Clear totals.
     ZeroCounts();
     // Recalculate totals!
     for (int i = 0; i < rd.snackDatas.Count; i++)
     {
         PlayerTypes playerType = PlayerTypeHelper.TypeFromString(rd.snackDatas[i].playerType);
         total[playerType]++;
         Total_All++;
         //total[PlayerTypes.Every] ++;
         if (SaveStorage.GetBool(SaveKeys.DidEatSnack(rd, i)))
         {
             eaten[playerType]++;
             Eaten_All++;
         }
     }
 }