예제 #1
0
    private void CycleNote(ButtonModule clicked)
    {
        int index = GetModuleId(clicked);

        if (index != -1)
        {
            Synthetizer.CycleNote(FromIndex(index));
        }
    }
예제 #2
0
    private void CycleSegment(VirtualClickerModule clicked)
    {
        int index = GetModuleId(clicked);

        if (index != -1)
        {
            Synthetizer.CycleSegment(FromIndex(index));
        }
    }
예제 #3
0
 protected override void OnUnsnap(Module unsnapped, int index)
 {
     if (unsnapped is VirtualClickerModule)
     {
         Synthetizer.RemoveSegment(FromIndex(index));
         (unsnapped as VirtualClickerModule).OnMouseClick -= CycleSegment;
     }
     if (unsnapped is ButtonModule)
     {
         (unsnapped as ButtonModule).OnMouseClick -= CycleNote;
     }
 }
예제 #4
0
 protected override void OnSnap(Module snapped, Vector3Int cellCoordinates)
 {
     if (snapped is VirtualClickerModule)
     {
         Synthetizer.RegisterSegment(cellCoordinates, (snapped as VirtualClickerModule).GetSegment());
         (snapped as VirtualClickerModule).OnMouseClick += CycleSegment;
     }
     if (snapped is ButtonModule)
     {
         (snapped as ButtonModule).OnMouseClick += CycleNote;
     }
 }
예제 #5
0
    void _Save()
    {
        timeLeftToAutosave = autosaveDelay;
        SnappingGridData[] data = new SnappingGridData[grids.Length];
        for (int i = 0; i < grids.Length; i++)
        {
            data[i] = grids[i].Serialize();
        }

        string   bankBalance = Bank.GetBalance().ToString();
        SaveData save        = new SaveData(bankBalance, data, Synthetizer.Serialize());

        string json = JsonUtility.ToJson(save);

        using (var stream = File.CreateText(Path.Combine(Application.persistentDataPath, SAVE_FILE_NAME)))
        {
            Debug.Log(Path.Combine(Application.persistentDataPath, SAVE_FILE_NAME));
            stream.Write(json);
        }
    }
예제 #6
0
    void Load()
    {
        timeLeftToAutosave = autosaveDelay;
        string json = LoadJsonFromFile();

        if (string.IsNullOrEmpty(json))
        {
            json = DEFAULT_JSON;
        }

        SaveData data = JsonUtility.FromJson <SaveData>(json);

        Bank.SetBalance(decimal.Parse(data.bankBalance));
        for (int i = 0; i < grids.Length; i++)
        {
            grids[i].Deserialize(data.grids[i]);
        }

        Synthetizer.Deserialize(data.synth);
    }