//collection of gameObjects public IEnumerator CreateGameObjectCollection() { gameObjectCollection = Meteor.Collection <DatabaseEntry>.Create ("gameObjects"); yield return gameObjectCollection; /* Handler for debugging the addition of gameObjects: */ /* gameObjectCollection.DidAddRecord += (string id, DatabaseEntry document) => { Debug.LogError(string.Format("gameObject document added:\n{0}", document.Serialize())); }; */ }
//collection of gameObjects public IEnumerator CreateGameObjectCollection() { gameObjectCollection = Meteor.Collection <DatabaseEntry>.Create ("gameObjects"); yield return gameObjectCollection; /* Handler for debugging the addition of gameObjects: */ /* gameObjectCollection.DidAddRecord += (string id, DatabaseEntry document) => { Debug.LogError(string.Format("gameObject document added:\n{0}", document.Serialize())); }; */ Debug.LogError ("adding record change handler(s)"); gameObjectCollection.DidChangeRecord += GetComponent<GameManager>().HandleDidChangeRecord; gameObjectCollection.DidAddRecord += HandleDidAddRecord; gameObjectCollectionCreated = true; }
//associates sessionCollection with meteor's session document IEnumerator CreateSessionDoc(string recordGroupName) { // sessionCollection = Meteor.Collection <SessionTemplate>.Create (recordGroupName); yield return sessionCollection; //waits until collection is finished being created /* Add handler for debugging session adds: */ /* sessionCollection.DidAddRecord += (string id, SessionTemplate document) => { Debug.LogError(string.Format("Session document added:\n{0}", document.Serialize())); }; */ }
//associates clientCollection with meteor's client document IEnumerator CreateClientDoc(string recordGroupName) { // clientCollection = Meteor.Collection <ClientTemplate>.Create (recordGroupName); yield return clientCollection; //waits until collection is finished being created /* Add handler for debugging client adds: */ /* clientCollection.DidAddRecord += (string id, ClientTemplate document) => { Debug.LogError(string.Format("Client document added:\n{0}", document.Serialize())); }; */ }
//associates sessionCollection to meteor's sessions document IEnumerator CreateSessionDoc(string recordGroupName) { sessionCollection = Meteor.Collection <SessionTemplate>.Create (recordGroupName); //creates meteor collection yield return sessionCollection; //waits until collection is finished being created /* Add handler for debugging session adds: */ /* sessionCollection.DidAddRecord += (string id, SessionTemplate document) => { Debug.LogError(string.Format("Session document added:\n{0}", document.Serialize())); }; sessionCollection.DidChangeRecord += (string arg1, ChannelTemplate arg2, IDictionary arg3, string[] arg4) => { Debug.Log ("Session document CHANGED: " + arg2.Serialize()); }; */ }
//associates playerCollection to meteor's channel document IEnumerator CreatePlayerDoc(string recordGroupName) { playerCollection = Meteor.Collection <PlayerTemplate>.Create (recordGroupName); //creates meteor collection yield return playerCollection; //waits until collection is finished being created /* Add handler for debugging channel adds: */ /* playerCollection.DidAddRecord += (string id, ChannelTemplate document) => { Debug.LogError(string.Format("Player document added:\n{0}", document.Serialize())); }; */ //triggered when player receives their color from the tabletop //this changes the UI of the chip Debug.Log ("recordchangehandler added for player"); playerCollection.DidChangeRecord += (string arg1, PlayerTemplate arg2, IDictionary arg3, string[] arg4) => { Debug.Log ("record changed in playerCollection, the change is: " + arg2._id + ", but our ID is : " + playerID); if (arg2._id == playerID) { /* Debug.Log ("showing the player's token now"); //set color to the same one as on tabletop color = (PlayerColor.color)System.Enum.Parse(typeof(PlayerColor.color), arg2.color); string colorName = color.ToString(); Transform foundColor = GameObject.Find("PlayerCircle").transform.FindChild(colorName).transform; if (foundColor) { foundColor.gameObject.SetActive(true); } */ //creates client document and opens channels if (arg2.sessionID != null) { sessionID = arg2.sessionID; Debug.Log ("sessionID set: " + sessionID); StartCoroutine (OpenSession (sessionName)); } } }; }
//associates clientCollection to meteor's client document IEnumerator CreateClientDoc(string recordGroupName) { clientCollection = Meteor.Collection <ClientTemplate>.Create (recordGroupName); //creates meteor collection yield return clientCollection; /* Handler for knowing our client's color */ clientCollection.DidAddRecord += (string id, ClientTemplate document) => { Debug.LogError(string.Format("Client document added:\n{0}", document.Serialize())); }; }