// Update is called once per frame void Update() { primaryRef.SetValue(createLocationEntry()); //bot1Ref.SetValue (getBotTransformInfo (1)); //bot2Ref.SetValue (getBotTransformInfo (2)); }
/// <summary> /// Fixeds the update. Only the player controlling can write to firebase, everyone else must read and interpret /// </summary> public void Update() { if (_isPlayer && _playerRef != null) { _playerRef.SetValue(_properties); } else { _properties = (Dictionary <string, object>)NetworkManager.items [identifier]; } }
// Use this for initialization void Start() { firebase = Firebase.CreateNew("https://incandescent-torch-2575.firebaseio.com/testing"); firebase.AuthWithPassword("*****@*****.**", "password", (AuthData auth) => { Debug.Log("auth success!!" + auth.Uid); }, (FirebaseError e) => { Debug.Log("auth failure!!"); }); firebase.ChildAdded += (object sender, FirebaseChangedEventArgs e) => { Debug.Log("Child added!"); }; firebase.ChildRemoved += (object sender, FirebaseChangedEventArgs e) => { Debug.Log("Child removed!"); }; firebase.SetValue("SetValue working?"); firebase.SetJsonValue("{\"example_child\":{\"child_working\" : true}}"); }
// Use this for initialization void Start() { Debug.Log("TestScript start+"); firebase = Firebase.CreateNew("https://boiling-torch-7529.firebaseio.com/test"); //firebase.AuthWithPassword("*****@*****.**", "iloveawei", (AuthData auth) => //{ // Debug.Log("auth success!!" + auth.Uid); //}, (FirebaseError e) => //{ // Debug.Log("auth failure!!"); //}); firebase.ChildAdded += (object sender, ChangedEventArgs e) => { Debug.Log("Child added!"); }; firebase.ChildRemoved += (object sender, ChangedEventArgs e) => { Debug.Log("Child removed!"); }; firebase.SetValue("working? no auth"); Debug.Log("TestScript start-"); }
// Use this for initialization private void gameStart() { Debug.Log("GameController start+"); _gameProcessing = true; controlUIPanelHost.SetActive(true); unitControlPanels = controlUIPanelHost.GetComponentsInChildren <UnitControlPanel>(); createHumanoid(); FireBase_battle_event = FireBase_battle.Child(RemoteEventBase.KEY_EVENT_ROOT); ////firebase.AuthWithPassword("*****@*****.**", "iloveawei", (AuthData auth) => ////{ //// Debug.Log("auth success!!" + auth.Uid); ////}, (FirebaseError e) => ////{ //// Debug.Log("auth failure!!"); ////}); FireBase_battle_event.ChildAdded += (object sender, ChangedEventArgs e) => { IDataSnapshot dataSnap = e.DataSnapshot; Logger.firebase("Child added! " + sender + ", " + e + ", " + dataSnap.Key); try { List <RemoteEventBase> result = FireBaseUtil.getBattleEventValue(dataSnap); onRemoteEvents(result); } catch (Exception ex) { Debug.Log(ex.Message); } // ////String x = dataSnap.Child("x").StringValue; // ////String y = dataSnap.Child("y").StringValue; // ////String z = dataSnap.Child("z").StringValue; // //Dictionary<string, object> value = dataSnap.DictionaryValue; // //string x = value["x"].ToString(); // //string y = value["y"].ToString(); // //string z = value["z"].ToString(); // //if (debugFirebase) // // Debug.Log("Child added! " + dataSnap.Key + ", s " + dataSnap.DictionaryValue + ", x " + x + ", y " + y + ", z " + z); // //Vector3 p = new Vector3(float.Parse(x), float.Parse(y), float.Parse(z)); // //foreach (Humanoid h in humanoid) // //{ // // h.onRemoteUpdate(Int32.Parse(dataSnap.Key), p); // //}; }; //firebase.ChildRemoved += (object sender, ChangedEventArgs e) => //{ // IDataSnapshot dataSnap = e.DataSnapshot; // if (debugFirebase) // Debug.Log("Child removed! " + sender + ", " + e + ", " + dataSnap); //}; FireBase_battle_event.ValueUpdated += (object sender, ChangedEventArgs ex) => { IDataSnapshot dataSnap = ex.DataSnapshot; Logger.firebase("Child ValueUpdated! " + sender + ", " + ex + ", " + dataSnap.Key); // //String x = dataSnap.Child("x").StringValue; // //String y = dataSnap.Child("y").StringValue; // //String z = dataSnap.Child("z").StringValue; // //Debug.Log("Child ValueUpdated! " + dataSnap.Key + ", " + dataSnap.StringValue + ", " + x + ", " + y + ", " + z); // //Vector3 p = new Vector3(x, y, z); // //foreach (Humanoid h in humanoid) // //{ // // h.onRemoteUpdate(Int32.Parse(dataSnap.Key), p); // //}; // //try // //{ // // Dictionary<string, object> value = dataSnap.DictionaryValue; // // string x = value["x"].ToString(); // // string y = value["y"].ToString(); // // string z = value["z"].ToString(); // // Debug.Log("Child ValueUpdated! " + dataSnap.Key + ", s " + dataSnap.DictionaryValue + ", x " + x + ", y " + y + ", z " + z); // // Vector3 p = new Vector3(float.Parse(x), float.Parse(y), float.Parse(z)); // // foreach (Humanoid h in humanoid) // // { // // h.onRemoteUpdate(Int32.Parse(dataSnap.Key), p); // // }; // //} // //catch (Exception exx) { // // Debug.Log(exx.ToString()); // //} }; FireBase_battle_event.ChildChanged += (object sender, ChangedEventArgs e) => { //firebase.Child(enemyId.ToString()).ChildChanged += (object sender, ChangedEventArgs e) => { IDataSnapshot dataSnap = e.DataSnapshot; Logger.firebase("Child ChildChanged! " + sender + ", " + e + ", " + dataSnap.Key); //String x = dataSnap.Child("x").StringValue; //String y = dataSnap.Child("y").StringValue; //String z = dataSnap.Child("z").StringValue; //Debug.Log("Child ChildChanged! " + dataSnap.Key + ", " + x + ", " + y + ", " + z); //Vector3 p = new Vector3(float.Parse(x), float.Parse(y), float.Parse(z)); //foreach (Humanoid h in humanoid) //{ // h.onRemoteUpdate(Int32.Parse(dataSnap.Key), p); //}; /* * try * { * List<JsonBaseUnit> result = JsonBaseUnit.getFirebaseValue(dataSnap); * foreach (Humanoid h in humanoid) * { * foreach (JsonBaseUnit json in result) * { * h.onRemoteUpdate(json); * } * } * } * catch (Exception ex) * { * Debug.Log(ex.ToString()); * }*/ }; //firebase.ChildChanged += (object sender, ChangedEventArgs e) => { //firebase.Child(playerId.ToString()).Child("attack").ChildChanged += (object sender, ChangedEventArgs e) => { //IDataSnapshot dataSnap = e.DataSnapshot; //if (debugFirebase) // Debug.Log("attack ChildChanged! " + sender + ", " + e + ", " + dataSnap.Key); /* try * { * List<JsonBaseAttack> result = JsonBaseAttack.getFirebaseValue(dataSnap); * foreach (Humanoid h in humanoid) * { * foreach (JsonBaseAttack json in result) * { * //h.onRemoteUpdate(json.getId(), json.getVector3()); * } * } * } * catch (Exception ex) * { * Debug.Log(ex.ToString()); * }*/ //}; FireBase_battle.SetValue("GameStart!"); //Dictionary<string, object> value = new Dictionary<string, object>(); //Dictionary<string, object> location = new Dictionary<string, object>(); //location.Add("x", "9"); //location.Add("y", "9"); //location.Add("z", "999"); //value.Add("action", "move"); //value.Add("action_unit_id", "123"); //value.Add("current_location", location); //firebase.Child("FightLog").Push().SetValue(value); //value.Add("target_location", location); //firebase.Child("FightLog").Push().SetValue(value); Debug.Log("GameController start-"); }