コード例 #1
0
ファイル: FirebaseLevelLoader.cs プロジェクト: XR-lab/XRWorld
        // TODO: Filter the changed data to make specific changes related to the tiles
        void HandleChildChanged(object sender, ChildChangedEventArgs args)
        {
            if (args.DatabaseError != null)
            {
                Debug.LogError(args.DatabaseError.Message);
                return;
            }

            TileData newData     = JsonUtility.FromJson <TileData>(args.Snapshot.GetRawJsonValue());
            Tile     changedTile = _tileCollection.GetTileByID(Int32.Parse(args.Snapshot.Key));
            TileData currentData = changedTile.TileData;

            if (currentData.groundType != newData.groundType)
            {
                //changedTile.SetTileData(newData);
                changedTile.SetGroundType(newData.groundType);
            }

            if (currentData.placeableObjectData.id != newData.placeableObjectData.id)
            {
                Debug.Log("ID Change");
                if (newData.placeableObjectData.id != -1)
                {
                    changedTile.ReplacePlaceableObject(newData.placeableObjectData.id, newData.placeableObjectData.level);
                }
                else
                {
                    changedTile.RemovePlaceableObject();
                }
            }

            if (currentData.placeableObjectData.level != newData.placeableObjectData.level && newData.placeableObjectData.id != -1)
            {
                Debug.Log("Level Change");
                changedTile.ReplacePlaceableObject(newData.placeableObjectData.id, newData.placeableObjectData.level);
            }

            changedTile.SetTimeStamp(newData.placeableObjectData.timeStamp);
        }