public void OnReceiveLogin(Packet packet) { byte[] bytes = packet.GetBytes(); PBLoginSucc pb = PBLoginSucc.Parser.ParseFrom(bytes); PlayerManager.GetInstance().InitFromLoginData(pb); UnityEngine.Debug.LogError("f**k the result is " + pb.PlayerId); GameUiManager.getInst().showWindow(PanelType.UILogin, false); // login success and begin to do something ; GameUiManager.getInst().showWindow(PanelType.UIMain_bottom, true); GameUiManager.getInst().showWindow(PanelType.UIMain, true); VoiceManager.Instance.PlayMusic("world01"); }
public void InitFromLoginData(PBLoginSucc pb) { this.playerId = pb.PlayerId; this.userId = pb.UserId; this.name = pb.Name; this.tili = pb.Tili; this.jingli = pb.Jingli; this.battleScore = pb.BattleScore; resMap.Clear(); List <KeyValuePair <int, long> > list = pb.ResMap.ToList <KeyValuePair <int, long> >(); for (int i = 0, count = list.Count; i < count; i++) { resMap.Add((EMoney)list[i].Key, list[i].Value); } for (int i = 0, count = pb.HeroList.Count; i < count; i++) { HeroManager.Instance.addHeroEntity(pb.HeroList[i]); } for (int i = 0, count = pb.EquipList.Count; i < count; i++) { EquipManager.Instance.addEquipEntity(pb.EquipList[i]); } formations = new Formation[6]; for (int i = 0, count = pb.Formation.Formation.Count; i < count; i++) { PBOneFormation formationPb = pb.Formation.Formation[i]; formations[i] = new Formation(); formations[i].HeroId = formationPb.HeroId; formations[i].PetId = formationPb.PetId; formations[i].HorseId = formationPb.HorseId; formations[i].MingjiangId = formationPb.MingjiangId; for (int j = 0, equipCount = formationPb.Equip.Count; j < count; j++) { formations[i].EquipList[i] = formationPb.Equip[i]; } } partners = pb.Formation.Partner.ToArray <long>(); battleFormation = pb.Formation.BattleFormation.ToArray <long>(); }