public override void read(ErlKVMessage message) { ErlArray enemyArray = message.getValue("msg") as ErlArray; if (enemyArray != null) { ErlType tmp = new ErlType(); List <GodsWarUserInfo> list = new List <GodsWarUserInfo> (); list.Clear(); for (int i = 0; i < enemyArray.Value.Length; i++) { tmp = enemyArray.Value [i]; ErlArray empArray = tmp as ErlArray; GodsWarUserInfo enemy = new GodsWarUserInfo(); enemy.massPosition = i; if (empArray.Value.Length == 0) { enemy.uid = "-1"; list.Add(enemy); continue; //如果为0表示该位置没有对手 } int tmpPos = 0; enemy.serverName = empArray.Value [tmpPos++].getValueString(); enemy.uid = empArray.Value [tmpPos++].getValueString(); enemy.name = empArray.Value [tmpPos++].getValueString(); enemy.headIcon = StringKit.toInt(empArray.Value [tmpPos++].getValueString()); enemy.level = StringKit.toInt(empArray.Value [tmpPos++].getValueString()); enemy.winScore = StringKit.toInt(empArray.Value [tmpPos++].getValueString()); enemy.challengedWin = StringKit.toInt(empArray.Value [tmpPos++].getValueString()) == 1; list.Add(enemy); } GodsWarManagerment.Instance.setEnemyList(list); if (callback != null) { callback(); } } else { MessageWindow.ShowAlert((message.getValue("msg") as ErlType).getValueString()); if (callback != null) { callback = null; } } }
public override void read(ErlKVMessage message) { ErlArray array = message.getValue("msg") as ErlArray; if (array != null) { int pos = 0; GodsWarUserInfo user = new GodsWarUserInfo(); user.bigTeam = array.Value [pos++].getValueString(); user.smallTeam = changeTeamtype(StringKit.toInt(array.Value [pos++].getValueString())); user.rank = StringKit.toInt(array.Value [pos++].getValueString()); user.numOfWinning = StringKit.toInt(array.Value [pos++].getValueString()); user.usedChallgeNum = StringKit.toInt(array.Value [pos++].getValueString()); user.todayIntegral = StringKit.toInt(array.Value [pos++].getValueString()); user.totalIntegral = StringKit.toInt(array.Value [pos++].getValueString()); GodsWarManagerment.Instance.challengeCount = user.usedChallgeNum; //已经挑战的次数 GodsWarManagerment.Instance.maxChallengeCount = GodsWarInfoConfigManager.Instance().getSampleBySid(1001).num[0]; //最大挑战次数 ErlType tmp = new ErlType(); ErlArray enemyArray = array.Value [pos++] as ErlArray; if (enemyArray != null) { List <GodsWarUserInfo> list = new List <GodsWarUserInfo> (); list.Clear(); for (int i = 0; i < enemyArray.Value.Length; i++) { tmp = enemyArray.Value [i]; ErlArray empArray = tmp as ErlArray; GodsWarUserInfo enemy = new GodsWarUserInfo(); enemy.massPosition = i; if (empArray.Value.Length == 0) { enemy.uid = "-1"; list.Add(enemy); continue; } //如果为0表示该位置没有对手 int tmpPos = 0; enemy.serverName = empArray.Value [tmpPos++].getValueString(); enemy.uid = empArray.Value [tmpPos++].getValueString(); enemy.name = empArray.Value [tmpPos++].getValueString(); enemy.headIcon = StringKit.toInt(empArray.Value [tmpPos++].getValueString()); enemy.level = StringKit.toInt(empArray.Value [tmpPos++].getValueString()); enemy.winScore = StringKit.toInt(empArray.Value [tmpPos++].getValueString()); enemy.challengedWin = StringKit.toInt(empArray.Value [tmpPos++].getValueString()) == 1; list.Add(enemy); } GodsWarManagerment.Instance.setEnemyList(list); GodsWarManagerment.Instance.self = user; } List <int> scores = new List <int>(); ErlArray mpt = array.Value[pos++] as ErlArray; if (mpt.Value.Length != 0) { for (int i = 0; i < mpt.Value.Length; i++) { scores.Add(StringKit.toInt(mpt.Value[i].getValueString())); } GodsWarManagerment.Instance.currentScores = scores; } else { GodsWarManagerment.Instance.currentScores = null; } if (callback != null) { callback(); } } else { MessageWindow.ShowAlert((message.getValue("msg") as ErlType).getValueString()); if (callback != null) { callback = null; } } }