/* * Load From Json File PropertyKey * * No State Code * 根据从服务器加载的角色数据来初始化NpcAttribute 中的数值(后续可能需要调整这种方式) */ IEnumerator InitProperty() { Log.Net("characterinfo init"); NetDebug.netDebug.AddConsole("CharacterInfo:: Init Property " + gameObject.name); CGGetCharacterInfo.Builder getChar = CGGetCharacterInfo.CreateBuilder(); getChar.PlayerId = photonView.GetServerID(); getChar.AddParamKey((int)CharAttribute.CharAttributeEnum.LEVEL); getChar.AddParamKey((int)CharAttribute.CharAttributeEnum.EXP); getChar.AddParamKey((int)CharAttribute.CharAttributeEnum.GOLD_COIN); getChar.AddParamKey((int)CharAttribute.CharAttributeEnum.JING_SHI); NetDebug.netDebug.AddConsole("GetChar is " + getChar.ParamKeyCount); KBEngine.PacketHolder packet = new KBEngine.PacketHolder(); yield return(StartCoroutine(KBEngine.Bundle.sendSimple(this, getChar, packet))); if (packet.packet.responseFlag == 0) { var info = packet.packet.protoBody as GCGetCharacterInfo; Debug.Log("CharacterInfo::InitProperty " + info); foreach (RolesAttributes att in info.AttributesList) { if (att.AttrKey == (int)CharAttribute.CharAttributeEnum.GOLD_COIN) { Log.Net("attr int " + att.BasicData.Indicate); Log.Net("attr key " + att.BasicData.TheInt32); Log.Net("attr " + att.ToString()); } if (att.BasicData.Indicate == 2) { propertyValue[(CharAttribute.CharAttributeEnum)att.AttrKey] = (int)att.BasicData.TheInt64; } else { propertyValue[(CharAttribute.CharAttributeEnum)att.AttrKey] = att.BasicData.TheInt32; } } } else { Debug.LogError("CharacterInfo::InitProperty Error"); } var m = GetProp(CharAttribute.CharAttributeEnum.GOLD_COIN); Log.Net(m.ToString()); Log.Important("PropertyValue is " + propertyValue); attribute.ChangeLevel(GetProp(CharAttribute.CharAttributeEnum.LEVEL)); attribute.ChangeHP(0); attribute.ChangeMP(0); attribute.ChangeExp(0); Log.Important("Init HP " + attribute.HP); Log.Important("Init Property Over"); initYet = true; NetDebug.netDebug.AddConsole("Init CharacterInfo Over"); Log.Sys("UpdatePlayerData " + attribute.ObjUnitData.Level); var evt = new MyEvent(MyEvent.EventType.UpdatePlayerData); evt.localID = attribute.GetLocalId(); MyEventSystem.myEventSystem.PushEvent(evt); }