Beispiel #1
0
    public void SetColor(Int2 _tileGridPos, byte[] _colorIndices, bool _isPermanent)
    {
        if (_colorIndices.Length != ColorManager.COLOR_CHANNEL_COUNT)
        {
            Debug.LogError("_colorChannelIndices has a different length than what is supported!");
            return;
        }

        if (_isPermanent)
        {
            int _appliedColorIndex = (_tileGridPos.y * GameGrid.TILE_COUNT.x + _tileGridPos.x) * _colorIndices.Length;
            for (int i = 0; i < _colorIndices.Length; i++)
            {
                appliedColorIndices[_appliedColorIndex + i] = _colorIndices[i];
            }
        }

        // WARNING: using more than 3 bytes per int will cause instability when cast to float!
        Vector4 _newCompressedColorIndices = new Vector4(
            _newCompressedColorIndices.x = BitCompressor.ThreeBytesToFloat32(_colorIndices[0], _colorIndices[1], _colorIndices[2]),
            _newCompressedColorIndices.y = BitCompressor.ThreeBytesToFloat32(_colorIndices[3], _colorIndices[4], _colorIndices[5]),
            _newCompressedColorIndices.z = BitCompressor.ThreeBytesToFloat32(_colorIndices[6], _colorIndices[7], _colorIndices[8]),
            0
            );

        int _vertexIndex = (_tileGridPos.y * GameGrid.TILE_COUNT.x + _tileGridPos.x) * VERTICES_PER_TILE;

        for (int i = 0; i < VERTICES_PER_TILE; i++)
        {
            compressedColorIndices[_vertexIndex + i] = _newCompressedColorIndices;
        }

        isColorDirty = true;
    }
Beispiel #2
0
 public override void OnStartup()
 {
     if (File.Exists(_dataFilePath))
     {
         BitCompressor.FillObj(_saveData, File.ReadAllBytes(_dataFilePath));
     }
 }
Beispiel #3
0
        public override void OnStartup()
        {
            if (!File.Exists(NoteSaveFilePath))
            {
                return;
            }

            byte[] data = File.ReadAllBytes(NoteSaveFilePath);

            BitCompressor.FillObj(Notes, data);
        }
Beispiel #4
0
 void Save()
 {
     byte[] bytes = BitCompressor.GetBytes(_saveData);
     File.WriteAllBytes(_dataFilePath, bytes);
 }
Beispiel #5
0
 public override void OnShutDown()
 {
     byte[] data = BitCompressor.GetBytes(Notes);
     File.WriteAllBytes(NoteSaveFilePath, data);
 }