public void EnterWorld(MapConfig data) { for (int i = 0; i < data.MapNpcs.Count; i++) { MapNpc cfg = data.MapNpcs[i]; DActor db = ReadCfgActor.GetDataById(cfg.NpcID); if (db == null) { continue; } XCharacter c = new XCharacter(); c.Id = cfg.NpcID; c.Name = db.Name; c.GUID = GTGUID.NewGUID(); c.PosX = cfg.Pos.x; c.PosY = cfg.Pos.y; c.PosZ = cfg.Pos.z; c.Face = cfg.Face; c.Type = (int)EActorType.NPC; c.Camp = (int)EBattleCamp.CT_PVE_NEUTRAL; c.CurAttrs.AddRange(GTTools.GetListFromEnumNames <int>(typeof(EAttr))); foreach (var current in db.Attrs) { c.CurAttrs[(int)current.Key - 1] = current.Value; } m_AllActors.Add(c.GUID, c); } for (int i = 0; i < data.MapAreaMonsters.Count; i++) { MapAreaMonster cfg = data.MapAreaMonsters[i]; DActor db = ReadCfgActor.GetDataById(cfg.MonsterID); if (db == null) { continue; } for (int k = 0; k < cfg.Points.Count; k++) { MapPoint p = cfg.Points[k]; XCharacter c = new XCharacter(); c.Id = cfg.MonsterID; c.Name = db.Name; c.GUID = GTGUID.NewGUID(); c.PosX = p.Pos.x; c.PosY = p.Pos.y; c.PosZ = p.Pos.z; c.Face = p.EulerAngles.y; c.Type = (int)EActorType.MONSTER; c.Camp = (int)EBattleCamp.CT_PVE_ENEMY; c.CurAttrs.AddRange(GTTools.GetListFromEnumNames <int>(typeof(EAttr))); foreach (var current in db.Attrs) { c.CurAttrs[(int)current.Key - 1] = current.Value; } m_AllActors.Add(c.GUID, c); } } }
private void OnAck_EnterScene(MessageRecv obj) { System.IO.MemoryStream ms = new System.IO.MemoryStream(obj.Data); EnterSceneAck ack = Serializer.Deserialize <EnterSceneAck>(ms); if (GTItemHelper.ShowNetworkError(ack.RetCode) == false) { return; } XCharacter data = DataDBSCharacter.GetDataById(GTGlobal.CurPlayerCarrerID); if (data == null) { GTItemHelper.ShowTip("职业错误"); return; } else { data.Id = ack.ActorID; data.PosX = ack.x; data.PosY = ack.y; data.PosZ = ack.z; data.Face = ack.vx; data.Type = (int)EActorType.PLAYER; data.Camp = ack.Camp; data.CurAttrs.AddRange(GTTools.GetListFromEnumNames <int>(typeof(EAttr))); data.CurAttrs[(int)EAttr.MAXHP - 1] = ack.hpmax; data.CurAttrs[(int)EAttr.MAXMP - 1] = ack.mpmax; data.CurAttrs[(int)EAttr.HP - 1] = ack.hp; data.CurAttrs[(int)EAttr.MP - 1] = ack.mp; data.CurAttrs[(int)EAttr.SPEED - 1] = 600; GTGlobal.Main = data; GTGlobal.CurCopyGUID = ack.CopyGuid; GTSimulateServer.CalcMainPropertys(); GTWorld.Instance.ResetGuide(); GTWorld.Instance.EnterWorld(ack.CopyID); GTEventCenter.FireEvent(GTEventID.TYPE_MAP_ENTERWORLD); } }
private void OnNty_ObjectNew(MessageRecv obj) { System.IO.MemoryStream ms = new System.IO.MemoryStream(obj.Data); ObjectNewNty nty = Serializer.Deserialize <ObjectNewNty>(ms); for (int i = 0; i < nty.NewList.Count; i++) { NewItem item = nty.NewList[i]; XCharacter data = new XCharacter(); data.Id = item.ActorID; data.GUID = item.ObjectGuid; data.Level = item.Level; data.Name = item.Name; switch ((OBJECT_TYPE)item.ObjType) { case OBJECT_TYPE.OT_PLAYER: data.Type = (int)EActorType.PLAYER; break; case OBJECT_TYPE.OT_MONSTER: data.Type = (int)EActorType.MONSTER; break; } data.PosX = item.x; data.PosY = item.y; data.PosZ = item.z; data.Face = Quaternion.FromToRotation(Vector3.forward, new Vector3(item.x, item.y, item.z)).eulerAngles.y; data.CurAttrs.AddRange(GTTools.GetListFromEnumNames <int>(typeof(EAttr))); data.CurAttrs[(int)EAttr.MAXHP - 1] = item.hpmax; data.CurAttrs[(int)EAttr.MAXMP - 1] = item.mpmax; data.CurAttrs[(int)EAttr.HP - 1] = item.hp; data.CurAttrs[(int)EAttr.MP - 1] = item.mp; data.CurAttrs[(int)EAttr.SPEED - 1] = 400; Character cc = GTWorld.Instance.AddActorSync(data); } }