Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void QuickAdventureSyncServer(DBStage onStage, DBProgress onProgress, int inputQuick, OnQuickAdventureSyncFinishedEvent result) {
- string queryString =
- "{\"userId\":\"" + GetId() + "\", " +
- "\"authToken\":\"" + GetToken() + "\", " +
- "\"inputDifficulty\":" + onStage.difficulty + ", " +
- "\"inputLevel\":" + onStage.level + ", " +
- "\"inputQuick\":" + inputQuick + "}";
- JSONNode query = JSONNode.Parse(queryString);
- Debug.Log(query.ToString());
- ServerHandler.instance.SendQueryToServer("DBUser", "QuickAdventure", query.ToString(), (result2) => {
- Debug.Log(result2);
- //nambah quest: Get gold, spend gold, reach player level, kill monster times
- AddJSONReward(JSONNode.Parse(result2));
- AddMoney(-inputQuick, DBShop.CoinType.QUICK_COIN);
- AddQuest(DBQuest.MISSIONTYPE.KillMonster, onStage);
- AddQuest(DBQuest.MISSIONTYPE.ClearStage, onStage);
- DBQuest.AddQuestProgress();
- onProgress.progressNow["count"] = ""+onProgress.count+inputQuick;
- onProgress.progressNow["dailyCount"] = ""+(onProgress.dailyCount+inputQuick);
- onProgress.count+=inputQuick;
- onProgress.dailyCount+=inputQuick;
- result(result2);
- }, (result2) => {
- //error
- Debug.Log(result2);
- result(result2);
- });
- }
- public void AddJSONReward(JSONNode JSONResult){
- JSONNode rewards = JSONResult["rewards"];
- int v = 0;
- //-->add reward gold
- v = rewards["stageGold"].AsInt;
- AddMoney(v, DBShop.CoinType.GOLD);
- if(v>0) AddQuest(DBQuest.MISSIONTYPE.GetGold, v);
- //-->add player exp
- v = rewards["stagePlayerExp"].AsInt;
- AddPlayerExp(v);
- AddQuest(DBQuest.MISSIONTYPE.ReachPlayerLevel, jsonUser["level"].AsInt);
- //-->add reward monster (ItemType==1)
- int loopCount = rewards["newOwnedMonsters"].Count;
- for(int i=0;i<loopCount;i++){
- JSONNode monsterJSON = JSONNode.Parse(rewards["newOwnedMonsters"][i].ToString());
- jsonUser["ownedMonsters"][jsonUser["ownedMonsters"].Count] = monsterJSON;
- }
- if(loopCount>0) AddQuest(DBQuest.MISSIONTYPE.GetMonster, loopCount);
- //-->add reward item equip (ItemType==2)
- loopCount = rewards["newOwnedItemEquips"].Count;
- for(int i=0;i<loopCount;i++){
- JSONNode itemJSON = JSONNode.Parse(rewards["newOwnedItemEquips"][i].ToString());
- jsonUser["ownedItemEquips"][jsonUser["ownedItemEquips"].Count] = itemJSON;
- }
- if(loopCount>0) AddQuest(DBQuest.MISSIONTYPE.GetEquipment, loopCount);
- //add reward item etc (ItemType==3)
- loopCount = rewards["newOwnedItemEtcs"].Count;
- for(int i=0;i<loopCount;i++){
- v = rewards["newOwnedItemEtcs"][i].AsInt;
- if(v>0) jsonUser["ownedItemEtcs"][i] = ""+(jsonUser["ownedItemEtcs"][i].AsInt+v);
- }
- //add reward egg shell (ItemType==4)
- loopCount = rewards["newEggShells"].Count;
- for(int i=0;i<loopCount;i++){
- v = rewards["newEggShells"][i].AsInt;
- if(v>0) jsonUser["ownedEggs"][i] = ""+(jsonUser["ownedEggs"][i].AsInt+v);
- }
- //add reward new money (ItemType>=5)
- AddMoney(rewards["newMoney"]["gold"].AsInt, DBShop.CoinType.GOLD);
- AddMoney(rewards["newMoney"]["pearl"].AsInt, DBShop.CoinType.PEARL);
- AddMoney(rewards["newMoney"]["arenaCoin"].AsInt, DBShop.CoinType.ARENA_COIN);
- AddMoney(rewards["newMoney"]["guildCoin"].AsInt, DBShop.CoinType.GUILD_COIN);
- AddMoney(rewards["newMoney"]["darkQuestCoin"].AsInt, DBShop.CoinType.DARK_QUEST_COIN);
- AddMoney(rewards["newMoney"]["deityCoin"].AsInt, DBShop.CoinType.DEITY_COIN);
- AddMoney(rewards["newMoney"]["quickCoin"].AsInt, DBShop.CoinType.QUICK_COIN);
- if(rewards["newMoney"]["gold"].AsInt>0) AddQuest(DBQuest.MISSIONTYPE.GetGold, rewards["newMoney"]["gold"].AsInt);
- if(rewards["newMoney"]["pearl"].AsInt>0) AddQuest(DBQuest.MISSIONTYPE.GetPearl, rewards["newMoney"]["pearl"].AsInt);
- //add reward new bonus
- v = rewards["newBonus"]["potSmall"].AsInt;
- if(v>0) jsonUser["ownedItemEtcs"][12] = ""+(jsonUser["ownedItemEtcs"][12].AsInt+v);
- v = rewards["newBonus"]["potMedium"].AsInt;
- if(v>0) jsonUser["ownedItemEtcs"][13] = ""+(jsonUser["ownedItemEtcs"][13].AsInt+v);
- v = rewards["newBonus"]["potHigh"].AsInt;
- if(v>0) jsonUser["ownedItemEtcs"][14] = ""+(jsonUser["ownedItemEtcs"][14].AsInt+v);
- }
Add Comment
Please, Sign In to add comment