aminusia

Untitled

Feb 25th, 2016
31
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.     public void QuickAdventureSyncServer(DBStage onStage, DBProgress onProgress, int inputQuick, OnQuickAdventureSyncFinishedEvent result) {
  2.         string queryString =
  3.             "{\"userId\":\"" + GetId() + "\", " +
  4.                 "\"authToken\":\"" + GetToken() + "\", " +
  5.                 "\"inputDifficulty\":" + onStage.difficulty + ", " +
  6.                 "\"inputLevel\":" + onStage.level + ", " +
  7.                 "\"inputQuick\":" + inputQuick + "}";
  8.         JSONNode query = JSONNode.Parse(queryString);
  9.        
  10.         Debug.Log(query.ToString());
  11.         ServerHandler.instance.SendQueryToServer("DBUser", "QuickAdventure", query.ToString(), (result2) => {
  12.             Debug.Log(result2);
  13.  
  14.             //nambah quest: Get gold, spend gold, reach player level, kill monster times
  15.             AddJSONReward(JSONNode.Parse(result2));
  16.             AddMoney(-inputQuick, DBShop.CoinType.QUICK_COIN);
  17.             AddQuest(DBQuest.MISSIONTYPE.KillMonster, onStage);
  18.             AddQuest(DBQuest.MISSIONTYPE.ClearStage, onStage);
  19.             DBQuest.AddQuestProgress();
  20.            
  21.             onProgress.progressNow["count"] = ""+onProgress.count+inputQuick;
  22.             onProgress.progressNow["dailyCount"] = ""+(onProgress.dailyCount+inputQuick);
  23.             onProgress.count+=inputQuick;
  24.             onProgress.dailyCount+=inputQuick;
  25.  
  26.             result(result2);
  27.         }, (result2) => {
  28.             //error
  29.             Debug.Log(result2);
  30.             result(result2);
  31.         });
  32.     }
  33.    
  34.     public void AddJSONReward(JSONNode JSONResult){
  35.         JSONNode rewards = JSONResult["rewards"];
  36.         int v = 0;
  37.        
  38.         //-->add reward gold
  39.         v = rewards["stageGold"].AsInt;
  40.         AddMoney(v, DBShop.CoinType.GOLD);
  41.         if(v>0) AddQuest(DBQuest.MISSIONTYPE.GetGold, v);
  42.  
  43.         //-->add player exp
  44.         v = rewards["stagePlayerExp"].AsInt;
  45.         AddPlayerExp(v);
  46.         AddQuest(DBQuest.MISSIONTYPE.ReachPlayerLevel, jsonUser["level"].AsInt);
  47.  
  48.         //-->add reward monster (ItemType==1)
  49.         int loopCount = rewards["newOwnedMonsters"].Count;
  50.         for(int i=0;i<loopCount;i++){
  51.             JSONNode monsterJSON = JSONNode.Parse(rewards["newOwnedMonsters"][i].ToString());
  52.             jsonUser["ownedMonsters"][jsonUser["ownedMonsters"].Count] = monsterJSON;
  53.         }
  54.         if(loopCount>0) AddQuest(DBQuest.MISSIONTYPE.GetMonster, loopCount);
  55.  
  56.         //-->add reward item equip (ItemType==2)
  57.         loopCount = rewards["newOwnedItemEquips"].Count;
  58.         for(int i=0;i<loopCount;i++){
  59.             JSONNode itemJSON = JSONNode.Parse(rewards["newOwnedItemEquips"][i].ToString());
  60.             jsonUser["ownedItemEquips"][jsonUser["ownedItemEquips"].Count] = itemJSON;
  61.         }
  62.         if(loopCount>0) AddQuest(DBQuest.MISSIONTYPE.GetEquipment, loopCount);
  63.  
  64.         //add reward item etc (ItemType==3)
  65.         loopCount = rewards["newOwnedItemEtcs"].Count;
  66.         for(int i=0;i<loopCount;i++){
  67.             v = rewards["newOwnedItemEtcs"][i].AsInt;
  68.             if(v>0) jsonUser["ownedItemEtcs"][i] = ""+(jsonUser["ownedItemEtcs"][i].AsInt+v);
  69.         }
  70.  
  71.         //add reward egg shell (ItemType==4)
  72.         loopCount = rewards["newEggShells"].Count;
  73.         for(int i=0;i<loopCount;i++){
  74.             v = rewards["newEggShells"][i].AsInt;
  75.             if(v>0) jsonUser["ownedEggs"][i] = ""+(jsonUser["ownedEggs"][i].AsInt+v);
  76.         }
  77.  
  78.         //add reward new money (ItemType>=5)
  79.         AddMoney(rewards["newMoney"]["gold"].AsInt, DBShop.CoinType.GOLD);
  80.         AddMoney(rewards["newMoney"]["pearl"].AsInt, DBShop.CoinType.PEARL);
  81.         AddMoney(rewards["newMoney"]["arenaCoin"].AsInt, DBShop.CoinType.ARENA_COIN);
  82.         AddMoney(rewards["newMoney"]["guildCoin"].AsInt, DBShop.CoinType.GUILD_COIN);
  83.         AddMoney(rewards["newMoney"]["darkQuestCoin"].AsInt, DBShop.CoinType.DARK_QUEST_COIN);
  84.         AddMoney(rewards["newMoney"]["deityCoin"].AsInt, DBShop.CoinType.DEITY_COIN);
  85.         AddMoney(rewards["newMoney"]["quickCoin"].AsInt, DBShop.CoinType.QUICK_COIN);
  86.         if(rewards["newMoney"]["gold"].AsInt>0) AddQuest(DBQuest.MISSIONTYPE.GetGold, rewards["newMoney"]["gold"].AsInt);
  87.         if(rewards["newMoney"]["pearl"].AsInt>0) AddQuest(DBQuest.MISSIONTYPE.GetPearl, rewards["newMoney"]["pearl"].AsInt);
  88.  
  89.         //add reward new bonus
  90.         v = rewards["newBonus"]["potSmall"].AsInt;
  91.         if(v>0) jsonUser["ownedItemEtcs"][12] = ""+(jsonUser["ownedItemEtcs"][12].AsInt+v);
  92.         v = rewards["newBonus"]["potMedium"].AsInt;
  93.         if(v>0) jsonUser["ownedItemEtcs"][13] = ""+(jsonUser["ownedItemEtcs"][13].AsInt+v);
  94.         v = rewards["newBonus"]["potHigh"].AsInt;
  95.         if(v>0) jsonUser["ownedItemEtcs"][14] = ""+(jsonUser["ownedItemEtcs"][14].AsInt+v);
  96.     }
Add Comment
Please, Sign In to add comment