public void DebugToyCustomData(BitToys.Toy debugtoy) { string debugstring = "toy id = " + debugtoy.bitToysId; debugstring = debugstring + "\n " + debugtoy.customData.AsJSONString(); this.WriteToErrorLog(debugstring); }
public void UpdateAllCards(BitToys.Toy myToy)//TODO { List <KeyValuePair <string, int> > questData = this.GetQuestData(); foreach (GameObject card in myResourceCards) { int d = 0; //update each stamp on each card for (int i = 0; i < 8; i++) { StampCard myStampcard = card.GetComponent <StampCard>(); if (questData[d].Value > -1) { //display correct resource myStampcard.SetCompletedStamp(d, questData[d].Key); //display stamp if obtained d++; } else { d++; } } } }
public void ResetFakeScan() { this.CurrentPlayerID = "player1test"; this.MyCurrentToy = new BitToys.Toy(); this.MyCurrentToy.bitToysId = this.CurrentPlayerID; this.MyCurrentToy.customData.ClearAll_Local();// clear all data? this.MyCurrentToy.customData.SendAsync(); WriteToErrorLog("Reset Fake Scan"); }
public static ToyWrapper FromToy(BitToys.Toy toy) { ToyWrapper tw = new ToyWrapper(); tw.bitToysId = toy.bitToysId; tw.styleId = toy.styleId; tw.ownerId = toy.ownerId; tw.skuId = toy.skuId; tw.customData = new LiteralCustomData(toy.customData); return(tw); }
public void SetNewToyVars(BitToys.Toy theToy, bool val) { bool needsVars = theToy.customData.GetBool("needsVars", true); if (needsVars) { Debug.Log("NUX!"); theToy.customData.AddBool("needsVars", false); theToy.customData.AddInt("QuestsCompleted", 0); theToy.customData.AddInt("CurrentQuest", -1); theToy.customData.AddBool("DragonUpgraded", false); //did i do a quest that could upgrade the dragon? theToy.customData.AddBool("NewUser", true); // does the user need the NUX (New User eXperience)? //resources tracked in OnClickHarvest } }
public void FakeScanNUX() { this.CurrentPlayerID = "player1NUXtest"; this.MyCurrentToy = new BitToys.Toy(); this.MyCurrentToy.customData.ClearAll_Local();// clear all data? this.MyCurrentToy.bitToysId = this.CurrentPlayerID; //first set of quests this.MyCurrentToy.customData.AddInt("DragonLevel", 0); // this.MyCurrentToy.customData.AddInt("") //this.MyCurrentToy.customData.SendAsync(); this.OnClaimToy_Success(this.MyCurrentToy, true);// fake the scan this.OnPutData_Success(MyCurrentToy); WriteToErrorLog("Fake NUX"); }
public void SetAllStationResoruces2(BitToys.Toy myToy)//unused? { for (int i = 0; i < this.myResourceCards.Count; i++) { string temp = myToy.customData.GetString("CompletedQuests", i, ""); if (temp != "") { StampCard myStampCard = this.myResourceCards[i].GetComponent <StampCard>(); //update each stamp on each card for (int j = 0; j < 8; j++) { myStampCard.GetComponent <StampCard>().SetCompletedStamp(i, "temp"); } } } }
public void OnPutData_Success(BitToys.Toy _toy) { WriteToErrorLog("Updating customData succeeded for toy: " + _toy.bitToysId); // public enum NextActive { SANCPAGE, SANCTOOSOON, SCANWRONG, SCANSUCCESS, NUX, NEWQUESTS } switch (activateThis) { case NextActive.SANCPAGE: SanctuaryPage.SetActive(true); break; case NextActive.SANCTOOSOON: SanctuaryTooSoon.SetActive(true); break; case NextActive.SCANWRONG: ScanCardWrong.SetActive(true); break; case NextActive.SCANSUCCESS: ScanCardSuccess.SetActive(true); break; case NextActive.NUX: ScanCardNUX.SetActive(true); break; case NextActive.NEWQUESTS: ScanCardNewQuests.SetActive(true); break; default: SanctuaryPage.SetActive(true); break; } }
public void OnClaimToy_Success(BitToys.Toy theToy, bool val) { WriteToErrorLog("ClaimToySuccess"); //debug for erasing cards SetLastToyScanned(theToy); //ready2scan = true;// override ready to scan non-sense if (!ready2scan) { //UniClipboard.SetText(UniClipboard.GetText() + "\n" + " " + System.DateTime.Now + " Tried to scan but the reader wasn't ready..."); this.WriteToErrorLog("ClaimToySuccess but was not ready"); return; } ready2scan = false;// only take one scan at a time// reset in SetIsReadyForScan.cs // StartCoroutine(EnableReady2Scan()); this.MyCurrentToy = theToy; CurrentPlayerID = theToy.bitToysId; bool validscan = true; //was false// Scans always Active (unless a player is in progress) /* * if (!playerScanInTimes.ContainsKey(CurrentPlayerID)) * { * playerScanInTimes.Add(CurrentPlayerID, Time.time); * validscan = true; * * } * else * { * validscan = CheckForValidScanTime(CurrentPlayerID); * * }*/ if (!validscan) { this.ScanScreen.SetActive(false); this.ScanCardTooRecent.SetActive(true); //weve seen this player before, and the time //hasnt expired yet, so they need to come back later //no need for return here, this goes to the end of the function just the same // UniClipboard.SetText(UniClipboard.GetText() + "\n" + " " + System.DateTime.Now + " Tried to scan but it was too soon..."); StartCoroutine(EnableReady2Scan()); } else// if valid scan { //only works if id is longer than 3 , which it should be //commented out for doug //if(MyCurrentToy.styleId != null && MyCurrentToy.styleId.Length >= 3) //{ // string last3chars = MyCurrentToy.styleId.Substring(MyCurrentToy.styleId.Length - 3); // bool isThisADebugCard; // if (last3chars == "dev") // isThisADebugCard = true; // else // isThisADebugCard = false; // if (isThisADebugCard) // { // debugmode = false; // ToggleDebugStuff(); // } //} WriteToErrorLog("GotValidScan"); //we always need to update the station resources! SetStationPages tempSetStationPages = this.gameObject.GetComponent <SetStationPages>(); DictionariesForThings tempConverstions = this.gameObject.GetComponent <DictionariesForThings>(); Debug.Log("location = " + this.currentLocation.ToString() + "\t Location2ResourceDic = " + tempSetStationPages.Location2ResourceDic[this.currentLocation].ToString()); Debug.Log("location = " + this.currentLocation.ToString() + "\t Location2Resource = " + tempConverstions.Location2Resource[this.currentLocation.ToString()].ToString()); tempSetStationPages.SetAllStationResoruces(tempConverstions.Resource2Sprite[tempConverstions.Location2Resource[this.currentLocation.ToString()]]); // QuestProgress myQuestProgress = this.gameObject.GetComponent <QuestProgress>(); bool correctstation = myQuestProgress.StationIsForQuest(); AddLocationData(correctstation, myQuestProgress.NumberOfQuestsToComplete()); if (this.ShowNUX && this.MyCurrentToy.customData.GetBool("NewUser", true)) { int test = this.MyCurrentToy.customData.GetInt("DragonsReleased", -999); if (test == -999) { this.MyCurrentToy.customData.AddInt("DragonsReleased", 0); } this.MyCurrentToy.customData.AddBool("NewUser", false); // flag as an old user // this.ScanCardNUX.SetActive(true); activateThis = NextActive.NUX; //first set of quests this.MyCurrentToy.customData.AddInt("DragonLevel", 0); this.SetNewQuestCard(this.MyCurrentToy.customData.GetInt("DragonLevel", 0));//rando some quests? WriteToErrorLog("Scan = New User Experience"); this.SetPageInfoEX(); // we need to set page infor for a correct scan } else { // which state are we in? if (myQuestProgress.StationIsForQuest() && (currentLocation != Location.SANC2)) { //increment data for going to this station// ie collecting the resource this.MyCurrentToy.customData.SetInt(this.GetComponent <DictionariesForThings>().Location2Resource[this.currentLocation.ToString()], 1); this.SetPageInfoEX();// we need to set cards after new resource if (myQuestProgress.CompletedAllQuests()) { // this.ScanCardNewQuests.SetActive(true); activateThis = NextActive.NEWQUESTS; int currentDragonLevel = this.MyCurrentToy.customData.GetInt("DragonLevel", 0); if (currentDragonLevel == 0) { changing_from_egg_2_hatchling = true; } currentDragonLevel += 1; MyCurrentToy.customData.SetInt("DragonLevel", currentDragonLevel); //HACK for getting new locations //this.GetComponent<QuestProgress>().SetQuests(this.LocationsListHack()); this.SetNewQuestCard(currentDragonLevel); SetNewResourceCards(); // should update the new cards with new quests //update new quest ui? //update new dragon? //get new quests? //get next dragon? WriteToErrorLog("Scan = New Quests"); } else// haven't completed all quests { this.SetPageInfoEX(); // we need to set up cards even if not right // this.ScanCardSuccess.SetActive(true); activateThis = NextActive.SCANSUCCESS; WriteToErrorLog("Scan = Progress Quests"); } } else if (currentLocation != Location.SANC2) // wrong station { this.SetPageInfoEX(); // we need to set up cards even if not right // this.ScanCardWrong.SetActive(true); activateThis = NextActive.SCANWRONG; WriteToErrorLog("Scan = Wrong Station"); //update cards ui? //update dragon ui? } //TODO sanctuary too early if (currentLocation == Location.SANC2) { int currentDragonLevel = this.MyCurrentToy.customData.GetInt("DragonLevel", 0); //release it if (currentDragonLevel > 1) { int currentDragonsReleased = this.MyCurrentToy.customData.GetInt("DragonsReleased", 0); // this.SetPageInfoEX(); currentDragonsReleased += 1; this.MyCurrentToy.customData.SetInt("DragonsReleased", currentDragonsReleased); MyCurrentToy.customData.Remove("NewUser"); MyCurrentToy.customData.Remove("DragonLevel"); //setactive // SanctuaryPage.SetActive(true); activateThis = NextActive.SANCPAGE; } else if (currentDragonLevel < 2)//too early { // SanctuaryTooSoon.SetActive(true); activateThis = NextActive.SANCTOOSOON; } } //TODO sanctuary } leftScanParticles.gameObject.SetActive(false); rightscanParticles.gameObject.SetActive(false); idleparticles1.gameObject.SetActive(false); idleparticles2.gameObject.SetActive(false); // if(MegaScanInParticles.gameObject.activeSelf) MegaScanInParticles.Play(); //at this point it will always contain the key, this is just to prevent nulls if (playerScanInTimes.ContainsKey(CurrentPlayerID)) { playerScanInTimes[CurrentPlayerID] = Time.time; } string tempDebug = ""; tempDebug += ""; //clear text tempDebug += "\n Toy id = " + theToy.bitToysId; tempDebug += "\n Owner id = " + theToy.ownerId; tempDebug += "\n Style id = " + theToy.styleId; tempDebug += "\n SKU id = " + theToy.skuId; tempDebug += "\n customData has: " + theToy.customData.ToString(); tempDebug += "\n " + System.DateTime.Now; tempDebug += "\n ******************************"; this.WriteToErrorLog(tempDebug); foreach (KeyValuePair <string, float> entry in playerScanInTimes) { this.WriteToErrorLog("\n Player ID: " + entry.Key.ToString() + " val is " + entry.Value.ToString()); }//end for each //reset the location timer back to 0 (dont get a new location) GetComponent <PickLocationTimer>().ResetTimer(); //handle screen activations this.ScanScreen.SetActive(false);// deactivate scan screen //UPDATE CUSTOM DATA!!! int currentDragonLevel2 = this.MyCurrentToy.customData.GetInt("DragonLevel", 0); this.MyCurrentToy.customData.SendAsync();//update that toy data! }//end of else valid scan } // end of function
public void SetLastToyScanned(BitToys.Toy lastToyScanned) { this.Debug_LastToyScanned = lastToyScanned; this.myLastToyText.text = "Toy ID: " + lastToyScanned.bitToysId; }
/* * public void SetPageinfo2()// updates the pages with player information * { * SetStationPages tempSetStationPages = this.gameObject.GetComponent<SetStationPages>(); * * float ratio = 0; //use this for progress ratio * * foreach (GameObject stampCard in tempSetStationPages.myResourceCards) * { * * } * //tempSetStationPages.SetAllStationResoruces(tempSetStationPages.GetStationResource()); * foreach (GameObject stationResource in tempSetStationPages.myStationResources) * { * * } * foreach (GameObject dragonObject in tempSetStationPages.myDragons) * { * int dragonlevel = MyCurrentToy.customData.GetInt("DragonLevel", 0); * // dragonObject = GetComponent<getdragonbasedonlevel>().dragonlevel2Object[dragonlevel]; * } * foreach (GameObject progressBar in tempSetStationPages.myProgressBars) * { * progressBar.GetComponent<EnergyBar>().SetValueF(ratio); * } * }*/ public void ClearCard(BitToys.Toy cardtoclear) { cardtoclear.customData.ClearAll_Local(); cardtoclear.customData.SendAsync(); }
public void OnPutData_Success(BitToys.Toy _toy) { // UniClipboard.SetText(UniClipboard.GetText() + "\n" + System.DateTime.Now + " " + " data successfully updated on server "); StartCoroutine(WaitAndThenActivate());// bump players to next screen }
private void OnClaimToy_OKWrapper(BitToys.Toy toy, bool TLL_val) { ToyWrapper tw = ToyWrapper.FromToy(toy); OnClaimToy_OK(tw, TLL_val); }