예제 #1
0
    //called from PrizmRecord class to add itself to the database
    public IEnumerator AddRecord(PrizmRecord record)
    {
        Debug.Log("Adding Record: " + record.ToString());
        associates.Add(record);         //adds record to list of all associated prizm records

        //forms a dictionary to pass into meteor's 'addGameObject' from the record's databaseEntry parameters
        //simplify this for the developer in the future (maybe use an enum?)
        Dictionary <string, string> dict = new Dictionary <string, string> ()
        {
            { "playersID", record.dbEntry.playersID },
            { "playersName", record.dbEntry.playersName },
            { "totalScore", record.dbEntry.totalScore.ToString() },
            { "timePlayed", record.dbEntry.timePlayed.ToString() }
        };

        var methodCall = Meteor.Method <ChannelResponse> .Call("addGameObject", tabletopInitObject.sessionID, defaultRecordGroup, dict);

        yield return((Coroutine)methodCall);

        if (methodCall.Response.success)
        {
            Debug.Log("call to 'addGameObject' succeeded, response: " + methodCall.Response.message);
            string UniqueID = methodCall.Response.message;
            record.dbEntry._id = UniqueID;
        }
        else
        {
            Debug.LogError("uh oh! call to 'addGameObject' failed! Response: " + methodCall.Response.message);
        }
    }
    //removes record from GameObjects
    public IEnumerator RemoveRecord(PrizmRecord <TMongoDocument> record)
    {
        Debug.Log("RemoveRecord");
        associates.Remove(record);

        if (!record.WasRemovedByServer)
        {
            Debug.Log("Removing from database: _id: " + record.mongoDocument._id);

            var methodCall = Meteor.Method <ChannelResponse> .Call("removeGameObject", record.mongoDocument._id, this.collectionKey);

            yield return((Coroutine)methodCall);

            if (methodCall.Response.success)
            {
                //Destroy(record);			//optional to remove it from the scene too
                Debug.Log("Successfully removed");
            }
            else
            {
                //Debug.LogError ("Uh oh! call to 'removeGameObject' failed on record: " + record.name + ", with _id: " + record.mongoDocument._id);
            }
        }

        yield return(null);
    }
    public IEnumerator AddRecord(PrizmRecord <TMongoDocument> record)
    {
        Debug.Log("trying to add record");

        record.recordGroup         = this;
        record.mongoDocument._GUID = System.Guid.NewGuid();
        record.mongoDocument.key   = this.collectionKey;

        associates.Add(record);
        unboundAssociates.Add(record.mongoDocument._GUID, record);

        Debug.Log("AddRecord: " + record.mongoDocument.toDictionary()["key"]);

        var methodCall = Meteor.Method <ChannelResponse> .Call("addGameObject", this.sessionID, collectionKey, record.mongoDocument.toDictionary());

        yield return((Coroutine)methodCall);

        if (methodCall.Response.success)
        {
            // at this time, mongoCollection.DidAddRecord should have bound the _id to its record
//			bindRecord(methodCall.Response.message);
            Debug.Log("AFTER updateGameObject, response: " + methodCall.Response.message + ", key:" + record.mongoDocument.toDictionary()["key"]);
        }
        else
        {
            Debug.LogError("uh oh! call to 'addGameObject' failed! Response: " + methodCall.Response.message);
        }

        yield return(null);
    }
예제 #4
0
    //called from PrizmRecord class to add itself to the database
    //use this when the tabletop does not add the record to the database itself
    public IEnumerator AddRecordDB(PrizmRecord record)
    {
        Debug.LogError("Adding Record: " + record.name);
        associates.Add(record);         //adds record to list of all associated prizm records

        //forms a dictionary to pass into meteor's 'addGameObject' from the record's databaseEntry parameters
        Dictionary <string, string> dict = new Dictionary <string, string> ()
        {
            { "location", record.dbEntry.location },
            { "color", record.dbEntry.color },
        };

        var methodCall = Meteor.Method <ChannelResponse> .Call("addGameObject", handheldInitObject.sessionID, defaultRecordGroup, dict);

        yield return((Coroutine)methodCall);

        if (methodCall.Response.success)
        {
            Debug.LogError("call to 'addGameObject' succeeded, response: " + methodCall.Response.message);
            string UniqueID = methodCall.Response.message;
        }
        else
        {
            Debug.LogError("uh oh! call to 'addGameObject' failed! Response: " + methodCall.Response.message);
        }
    }
예제 #5
0
    public void HandleDidAddRecord(string arg1, DatabaseEntry arg2)
    {
        Debug.Log("Record added: " + arg2.location + arg2.color + arg2._id + ".");
        if (arg2.location == "home")
        {
            something      = Instantiate(newThing, new Vector3(0f, 10f, 0f), newThing.transform.rotation) as GameObject;
            something.name = "thing";

            exampleObject = something.GetComponent <ExampleObject> ();

            //sets the variables to a local copy of the card
            exampleObject.dbEntry.location = arg2.location;
            exampleObject.dbEntry.color    = arg2.color;
            exampleObject.dbEntry._id      = arg2._id;
            Debug.Log("Make sure ID is set: " + exampleObject.dbEntry._id);


            //keep track of this card and enable us to manipulate it
            exampleObject.AddToRecordGroup();
            something.SetActive(false);


            //if the tabletop device is recalling the cards (to reshuffle)
        }
        else
        {
            Debug.LogError("this: " + arg2.location);
        }
    }
예제 #6
0
    //functions that show how to 'give' players objects
    //instantiates ship and creates the game object from the shiprecord
    void giveShipToPlayer(Player ply, PrizmRecord <ShipSchema> shipRecord)
    {
        numShips++;

        GameObject ship_obj = Instantiate(Resources.Load <GameObject> ("ShipPrefabs/" + shipRecord.mongoDocument.name));

        shipRecord.gameObject = ship_obj;

        ship_obj.layer = 10;



        //give database items
        ship_obj.GetComponent <Ship> ().record = shipRecord;
        ship_obj.GetComponent <Ship>().AnnounceSelf();

        //give pilot
        ship_obj.GetComponent <Ship>().GivePilot(shipRecord.mongoDocument.selectedPilot);
        ship_obj.GetComponent <Ship> ().PlayerOwner = ply;

        ply.shipsUnderCommand.Add(ship_obj);
        ship_obj.transform.SetParent(ply.transform);
        //Debug.Log ("faction: " + ply.faction);
        ship_obj.transform.position = GetRandomSpawnPosition(ply.faction);
    }
    //sync all objects with 'needsUpdate' flag to database
    //developer calls at own discretion
    public IEnumerator Sync(PrizmRecord <TMongoDocument> itemToSync)
    {
        Debug.Log("PrizmRecordGroup Sync() " + this.collectionKey);

        if (itemToSync.needsUpdate)
        {
            //forms a dictionary to pass into meteor's 'updateGameObject' from the record's databaseEntry parameters
            //simplify this for the developer in the future (maybe use an enum?)

            var methodCall = Meteor.Method <ChannelResponse> .Call("updateGameObject", itemToSync.mongoDocument._id, itemToSync.mongoDocument.toDictionary(), collectionKey);

            yield return((Coroutine)methodCall);

            if (methodCall.Response.success)
            {
                //Debug.LogError (associates[i].dbEntry._id + " should = " + methodCall.Response.message);
                itemToSync.dbUpdated();                         //tells the record that it was updated and it can rest now
            }
            else
            {
                //Debug.LogError ("Uh oh! database sync failed on record: " + itemToSync.name + ", with _id: " + itemToSync.mongoDocument._id);
            }

            yield return(null);
        }
        else
        {
            //Debug.LogError(itemToSync.name + "did not need to be updated, but Sync() was called on it");
        }
        Debug.Log("Finished with Sync()");
        yield return(null);
    }
    private void bindRecord(TMongoDocument mongoDoc)
    {
        PrizmRecord <TMongoDocument> unboundRecord = unboundAssociates[mongoDoc._GUID];

        unboundRecord.mongoDocument._id = mongoDoc._id;
        unboundRecord.mongoDocument.key = this.collectionKey;

        unboundAssociates.Remove(mongoDoc._GUID);
    }
    //removes record from GameObjects
    public IEnumerator RemoveRecord(PrizmRecord record)
    {
        Debug.LogError ("Removing from database: " + record.name + ", _id: " + record.dbEntry._id);

        var methodCall = Meteor.Method<ChannelResponse>.Call ("removeGameObject", record.dbEntry._id);
        yield return (Coroutine)methodCall;
        if (methodCall.Response.success) {
            //Destroy(record);			//optional to remove it from the scene too
            Debug.LogError ("Successfully removed");
        } else {
            Debug.LogError ("Uh oh! call to 'removeGameObject' failed on record: " + record.name + ", with _id: " + record.dbEntry._id);
        }
    }
예제 #10
0
    void HandleDidAddShipRecord(string arg1, ShipSchema arg2)
    {
        Debug.Log("added ship: " + arg1);

        //make a record on our side from the data received
        PrizmRecord <ShipSchema> tempRecord = new PrizmRecord <ShipSchema> ();

        tempRecord.mongoDocument = arg2;

        //find the owner from the list
        GameObject owner = playerList.Find(p => p.GetComponent <Player> ().playerID.Equals(arg2.owner));

        Debug.Log("faction before giving: " + owner.GetComponent <Player> ().faction);
        //give the ship to the player
        giveShipToPlayer(owner.GetComponent <Player>(), tempRecord);
    }
예제 #11
0
    //removes record from GameObjects
    public IEnumerator RemoveRecord(PrizmRecord record)
    {
        Debug.Log("Removing from database: " + record.ToString() + ", _id: " + record.dbEntry._id);

        var methodCall = Meteor.Method <ChannelResponse> .Call("removeGameObject", record.dbEntry._id);

        yield return((Coroutine)methodCall);

        if (methodCall.Response.success)
        {
            //Destroy(record);			//optional to remove it from the scene too
            Debug.Log("Successfully removed");
        }
        else
        {
            Debug.LogError("Uh oh! call to 'removeGameObject' failed on record: " + record.ToString() + ", with _id: " + record.dbEntry._id);
        }
    }
    //collection of gameObjects
    public IEnumerator CreateMeteorCollection()
    {
        var methodCall = Meteor.Method <ChannelResponse> .Call("createGameObjectCollection", this.sessionID, collectionKey);

        yield return((Coroutine)methodCall);


        var initMethodCall = Meteor.Method <ChannelResponse> .Call("initGameObjectCollections", collectionKey);

        yield return((Coroutine)initMethodCall);


        var subscription = Meteor.Subscription.Subscribe("gameObjectCollection", collectionKey);

        yield return((Coroutine)subscription);          //wait until subscription successful


        mongoCollection = Meteor.Collection <TMongoDocument> .Create(this.collectionKey);

        yield return(mongoCollection);

        mongoCollection.DidAddRecord += (string arg1, TMongoDocument arg2) => {
            //we only need to bind the record if the object was created by Tabletop and hasn't been bound.
            try {
                bindRecord(arg2);
            }
            catch (KeyNotFoundException e) {
                Debug.Log("didn't find the record guid, assuming dont have to bind (object wasn't in the unbound things)");
            }
        };

        mongoCollection.DidRemoveRecord += (string obj) => {
            PrizmRecord <TMongoDocument> record = this.LookUpPrizmRecordBy_ID(obj);
            if (record != null)
            {
                record.WasRemovedByServer = true;
            }
            else
            {
                Debug.Log("record wasn't associated with us");
            }
//			if (record != null) CoroutineHost.Instance.StartCoroutine (RemoveRecord(record));
        };
    }
    //called from PrizmRecord class to add itself to the database
    //use this when the tabletop does not add the record to the database itself
    public IEnumerator AddRecordDB(PrizmRecord record)
    {
        Debug.LogError ("Adding Record: " + record.name);
        associates.Add(record);	//adds record to list of all associated prizm records

        //forms a dictionary to pass into meteor's 'addGameObject' from the record's databaseEntry parameters
        Dictionary<string, string> dict = new Dictionary<string, string> () {
            {"location", record.dbEntry.location},
            {"color", record.dbEntry.color},
        };
        //tabletopInitObject.sessionID
        var methodCall = Meteor.Method<ChannelResponse>.Call ("addGameObject", "hello", defaultRecordGroup, dict);
        yield return (Coroutine)methodCall;
        if (methodCall.Response.success) {
            Debug.LogError ("call to 'addGameObject' succeeded, response: " + methodCall.Response.message);
            string UniqueID = methodCall.Response.message;
        } else {
            Debug.LogError ("uh oh! call to 'addGameObject' failed! Response: " + methodCall.Response.message);
        }
    }
예제 #14
0
    //sync all objects with 'needsUpdate' flag to database
    //developer calls at own discretion
    public IEnumerator Sync(PrizmRecord itemToSync)
    {
        Debug.LogError("now syncing: " + itemToSync.ToString());

        if (itemToSync.needsUpdate)
        {
            //forms a dictionary to pass into meteor's 'updateGameObject' from the record's databaseEntry parameters
            //simplify this for the developer in the future (maybe use an enum?)
            Dictionary <string, string> dict = new Dictionary <string, string> ()
            {
                { "playersID", itemToSync.dbEntry.playersID },
                { "playersName", itemToSync.dbEntry.playersName },
                { "totalScore", itemToSync.dbEntry.totalScore.ToString() },
                { "timePlayed", itemToSync.dbEntry.timePlayed.ToString() }
            };


            var methodCall = Meteor.Method <ChannelResponse> .Call("updateGameObject", itemToSync.dbEntry._id, dict);

            yield return((Coroutine)methodCall);

            if (methodCall.Response.success)
            {
                //Debug.LogError (associates[i].dbEntry._id + " should = " + methodCall.Response.message);
                itemToSync.dbUpdated();                         //tells the record that it was updated and it can rest now
            }
            else
            {
                Debug.LogError("Uh oh! database sync failed on record: " + itemToSync.ToString() + ", with _id: " + itemToSync.dbEntry._id);
            }
        }
        else
        {
            Debug.LogError(itemToSync.ToString() + "did not need to be updated, but Sync() was called on it");
        }
        Debug.Log("Finished with Sync()");
        yield return(null);
    }
    public void HandleDidAddRecord(string arg1, DatabaseEntry arg2)
    {
        Debug.Log ("Record added: " + arg2.location + arg2.color + arg2._id + ".");
        if (arg2.location == "home") {
            something = Instantiate (newThing, new Vector3 (0f, 10f, 0f), newThing.transform.rotation) as GameObject;
            something.name = "thing";

            exampleObject = something.GetComponent<ExampleObject> ();

            //sets the variables to a local copy of the card
            exampleObject.dbEntry.location = arg2.location;
            exampleObject.dbEntry.color = arg2.color;
            exampleObject.dbEntry._id = arg2._id;
            Debug.Log ("Make sure ID is set: " + exampleObject.dbEntry._id);

            //keep track of this card and enable us to manipulate it
            exampleObject.AddToRecordGroup ();
            something.SetActive(false);

            //if the tabletop device is recalling the cards (to reshuffle)
        } else {
            Debug.LogError ("this: " + arg2.location);
        }
    }
예제 #16
0
    public IEnumerator ConfigureObstacleDatabase()
    {
        Debug.Log("Creating obstacles into database...");
        //GameManager.Instance.GameStateReporter.text = "Game is creating DB records and\ndistributing all starting items to PLAYERS";

        obstacleRecordGroup = new PrizmRecordGroup <ObstacleSchema> (sessionID, "obstacles");
        yield return(StartCoroutine(obstacleRecordGroup.CreateMeteorCollection()));

        obstacleRecordGroup.mongoCollection.DidAddRecord += (string arg1, ObstacleSchema arg2) => {
            Debug.Log("New obstacle added!" + arg1 + " ID is: " + arg2._id + " rest is: " + arg2.ToString());

            PrizmRecord <ObstacleSchema> record = obstacleRecordGroup.LookUpPrizmRecordBy_ID(arg2._id);

            if (record == null)
            {
                return;
            }
            //giveRoadToPlayer(record.mongoDocument.myOwner, record);
        };

        obstacleRecordGroup.mongoCollection.DidChangeRecord += (string arg1, ObstacleSchema arg2, IDictionary arg3, string[] arg4) => {
            Debug.Log("obstacle changed! SessionID: " + arg1 + " key is: " + arg2.key + " rest is: " + arg2.ToString());

            PrizmRecord <ObstacleSchema> record = obstacleRecordGroup.LookUpPrizmRecordBy_ID(arg2._id);
            if (record == null)
            {
                return;
            }

            GameObject obj = record.gameObject;
            // ...do something with GameObject


            //Road road = obj.GetComponent<Road>();
            // ...do something with Road
        };

        obstacleRecordGroup.mongoCollection.DidRemoveRecord += (string arg1) => {
            Debug.Log("obstacle removed! _id: " + arg1);

            PrizmRecord <ObstacleSchema> record = obstacleRecordGroup.LookUpPrizmRecordBy_ID(arg1);
            if (record != null)
            {
                Destroy(record.gameObject);
            }
        };


        //make obstacles? will implement later after combat
        //obstacles probably will get generated in-game anyways
        for (int i = 0; i < 2; i++)
        {
            PrizmRecord <ObstacleSchema> obstacleRecord = new PrizmRecord <ObstacleSchema>();
            obstacleRecord.mongoDocument.size     = 1;
            obstacleRecord.mongoDocument.position = new int[2] {
                1, 2
            };
            yield return(StartCoroutine(obstacleRecordGroup.AddRecord(obstacleRecord)));

            while (obstacleRecord.gameObject == null)
            {
                Debug.Log("waiting for database confirmation");
                yield return(null);
            }
        }

        yield return(null);
    }
    //sync all objects with 'needsUpdate' flag to database
    //developer calls at own discretion
    public IEnumerator Sync(PrizmRecord itemToSync)
    {
        Debug.LogError ("now syncing: " + itemToSync.name);

        if (itemToSync.needsUpdate) {
            //forms a dictionary to pass into meteor's 'updateGameObject' from the record's databaseEntry parameters
            //simplify this for the developer in the future (maybe use an enum?)
            Dictionary<string, string> dict = new Dictionary<string, string> () {
                {"location", itemToSync.dbEntry.location}
            };

            var methodCall = Meteor.Method<ChannelResponse>.Call ("updateGameObject", itemToSync.dbEntry._id, dict);
            yield return (Coroutine)methodCall;
            if (methodCall.Response.success) {
                //Debug.LogError (associates[i].dbEntry._id + " should = " + methodCall.Response.message);
                itemToSync.dbUpdated();		//tells the record that it was updated and it can rest now
            } else {
                Debug.LogError ("Uh oh! database sync failed on record: " + itemToSync.name + ", with _id: " + itemToSync.dbEntry._id);
            }

        } else {
            Debug.LogError(itemToSync.name + "did not need to be updated, but Sync() was called on it");
        }
        Debug.LogError ("Finished with Sync()");
        yield return null;
    }
예제 #18
0
 //called from PrizmRecord class to add to the list of objects that need to be synced
 //this does NOT create a new entry in the database, it is so that the handheld client can
 //sync PrizmRecords
 public void AddRecord(PrizmRecord record)
 {
     Debug.LogError("Adding Record: " + record.name + record.dbEntry._id);
     associates.Add(record);         //adds record to list of all associated prizm records
     Debug.Log("associates ID: " + associates [0].dbEntry._id);
 }
예제 #19
0
 //removes record from associates list to not keep track of it
 public void RemoveRecord(PrizmRecord record)
 {
     associates.Remove(record);
 }
예제 #20
0
    public IEnumerator ConfigureShipDatabase()
    {
        Debug.Log("Trying to create ship collection");
        shipRecordGroup = new PrizmRecordGroup <ShipSchema> (sessionID, "shipYard");
        yield return(StartCoroutine(shipRecordGroup.CreateMeteorCollection()));

        Debug.Log("CREATED OUR METEOR COLLECTION FOR the ships");


        //set up handlers
        shipRecordGroup.mongoCollection.DidAddRecord += (string arg1, ShipSchema arg2) => {
            //Debug.Log ("New Ship Added! "+arg1 +" ID is: "+arg2._id+" name is: " + arg2.name);


            Debug.Log("PRINTING name: " + arg2.name);
            Debug.Log("PRINTING owner: " + arg2.owner);
            Debug.Log("PRINTING faction: " + arg2.faction);
            Debug.Log("PRINTING isStressed: " + arg2.isStressed.ToString());
            Debug.Log("PRINTING second action: " + arg2.actions[1]);
            Debug.Log("PRINTING maneuvers count: " + arg2.maneuvers.Count.ToString());
            Debug.Log("PRINTING fourht maneuver: " + arg2.maneuvers[3].Serialize().ToString());

            Debug.Log("PRINTING fifth maneuver difficulty: " + arg2.maneuvers[4].difficulty.ToString());
            Debug.Log("PRINTING currentshield: " + arg2.currentShield.ToString());
            Debug.Log("PRINTING selectedUpgrades: " + arg2.selectedUpgrades.ToString());
            Debug.Log("PRINTING selectedUpgrades count: " + arg2.selectedUpgrades.Count.ToString());
            Debug.Log("PRINTING second pilot: " + arg2.pilots[1].Serialize().ToString());
            Debug.Log("PRINTING second pilot ability: " + arg2.pilots[1].ability);



            PrizmRecord <ShipSchema> record = shipRecordGroup.LookUpPrizmRecordBy_ID(arg2._id);
            //if record == null, implies record was created by the server
            if (record == null)
            {
                PrizmRecord <ShipSchema> newRecord = new PrizmRecord <ShipSchema>();

                newRecord.mongoDocument = arg2;

                newRecord.recordGroup         = shipRecordGroup;
                newRecord.mongoDocument._GUID = System.Guid.NewGuid();
                newRecord.mongoDocument.key   = shipRecordGroup.collectionKey;


                shipRecordGroup.associates.Add(newRecord);
            }

            //instantiate the ship
        };


        shipRecordGroup.mongoCollection.DidChangeRecord += (string arg1, ShipSchema arg2, IDictionary arg3, string[] arg4) => {
            Debug.Log("Resource changed! SessionID: " + arg1 + " key is: " + arg2.key + " rest is: " + arg2.ToString());
            //Debug.Log("checking if things change on both ends automatically");
            //Debug.Log("record side: " + arg2.selectedAction);

            //this record automagically has all the same attributes as arg2 (no need to re-assign them)
            PrizmRecord <ShipSchema> record = shipRecordGroup.LookUpPrizmRecordBy_ID(arg2._id);
            if (record == null)
            {
                return;                                 //didn't find the record in the recordgroup
            }
            ///Debug.Log(" unity side: " + record.mongoDocument.selectedAction);
            Debug.Log("unity side, checking _guid and _id" + record.mongoDocument._GUID + ":" + record.mongoDocument._id);
        };

        shipRecordGroup.mongoCollection.DidRemoveRecord += (string arg1) => {
            Debug.Log("Destroyed a Resource Record " + arg1);
            PrizmRecord <ShipSchema> record = shipRecordGroup.LookUpPrizmRecordBy_ID(arg1);
            if (record != null)
            {
                Destroy(record.gameObject);
            }
        };

        //make like 2 ships instantiated in database
        //load all from json l8tr g8tr


        /*
         * for (int i=0; i<2; i++) {
         *      Debug.Log ("Trying to make a bunch of WHEAT! lol jk, im makin ships");
         *      PrizmRecord<ShipSchema> shipRecord = new PrizmRecord<ShipSchema>();
         *      shipRecord.mongoDocument.name = "Tie Fighter";
         *
         *      //set up the rest of the stuff later,
         *      //probably load from a JSON that contains configurations for available ships
         *
         *
         *      yield return StartCoroutine (shipRecordGroup.AddRecord (shipRecord));
         * }
         */


        yield return(null);
    }
 //called from PrizmRecord class to add to the list of objects that need to be synced
 //this does NOT create a new entry in the database, it is so that the handheld client can
 //sync PrizmRecords
 public void AddRecord(PrizmRecord record)
 {
     Debug.LogError ("Adding Record: " + record.name + record.dbEntry._id);
     associates.Add(record);	//adds record to list of all associated prizm records
     Debug.Log ("associates ID: " + associates [0].dbEntry._id);
 }
 //removes record from associates list to not keep track of it
 public void RemoveRecord(PrizmRecord record)
 {
     associates.Remove (record);
 }
 //called from PrizmRecord class to add to the list of objects that need to be synced
 //this does NOT create a new entry in the database, it is so that the handheld client can
 //sync PrizmRecords
 public void AddRecord(PrizmRecord record)
 {
     Debug.LogError ("Adding Record: " + record.name);
     associates.Add(record);	//adds record to list of all associated prizm records
 }
예제 #24
0
    //also probably read from a config.json file... u no wot? everything is json. there, i said it. everything is json here
    public IEnumerator ConfigureUpgradesDatabase()
    {
        Debug.Log("Creating upgrades into database...");
        //GameManager.Instance.GameStateReporter.text = "Game is creating DB records and\ndistributing all starting items to PLAYERS";

        upgradeRecordGroup = new PrizmRecordGroup <UpgradeSchema> (sessionID, "upgrades");

        yield return(StartCoroutine(upgradeRecordGroup.CreateMeteorCollection()));

        upgradeRecordGroup.mongoCollection.DidAddRecord += (string arg1, UpgradeSchema arg2) => {
            Debug.Log("New upgrade added!" + arg1 + " ID is: " + arg2._id + " rest is: " + arg2.ToString());

            PrizmRecord <UpgradeSchema> record = upgradeRecordGroup.LookUpPrizmRecordBy_ID(arg2._id);

            if (record == null)
            {
                return;
            }
            //giveRoadToPlayer(record.mongoDocument.myOwner, record);
        };

        upgradeRecordGroup.mongoCollection.DidChangeRecord += (string arg1, UpgradeSchema arg2, IDictionary arg3, string[] arg4) => {
            Debug.Log("upgrade changed! SessionID: " + arg1 + " key is: " + arg2.key + " rest is: " + arg2.ToString());

            PrizmRecord <UpgradeSchema> record = upgradeRecordGroup.LookUpPrizmRecordBy_ID(arg2._id);
            if (record == null)
            {
                return;
            }

            GameObject obj = record.gameObject;
            // ...do something with GameObject


            //Road road = obj.GetComponent<Road>();
            // ...do something with Road
        };

        upgradeRecordGroup.mongoCollection.DidRemoveRecord += (string arg1) => {
            Debug.Log("upgrade removed! _id: " + arg1);

            PrizmRecord <UpgradeSchema> record = upgradeRecordGroup.LookUpPrizmRecordBy_ID(arg1);
            if (record != null)
            {
                Destroy(record.gameObject);
            }
        };



        //give the ships upgrades somewhere else
        //this simply loads all upgrades from a json

        /*
         * foreach (Player ply in GameManager.Instance.TheOneOfficialAllPlayerListInOrderOfTurns) {
         *      for (int i=0; i<15; i++) {
         *              PrizmRecord<UpgradeSchema> roadRecord = new PrizmRecord<UpgradeSchema> ();
         *              roadRecord.mongoDocument.name = "protein torpedos";
         *              //initialize the rest from json
         *
         *              yield return StartCoroutine (upgradeRecordGroup.AddRecord (roadRecord));
         *              while (roadRecord.gameObject==null){
         *                      Debug.Log ("waiting for database confirmation");
         *                      yield return null;
         *              }
         *              //giveRoadToPlayer(ply,roadRecord);
         *      }
         * }
         */
    }
예제 #25
0
 private bool scoreChartExists(PrizmRecord scoreRecord)
 {
     return(scoreRecord.dbEntry.playersName == findName);
 }