public static MapObjInfo CreateSelfCopyMapObjInfo(int poolID, int sceneID, int pointGroupID, BattleBaseInfo battleInfo) { MapObjInfo mapObjInfo = new MapObjInfo(); mapObjInfo.objType = GameObjectType.ENUM.Role; mapObjInfo.id = (long)poolID; mapObjInfo.ownerId = EntityWorld.Instance.EntSelf.OwnerID; mapObjInfo.typeId = EntityWorld.Instance.EntSelf.TypeID; mapObjInfo.modelId = EntityWorld.Instance.EntSelf.ModelID; mapObjInfo.name = EntityWorld.Instance.EntSelf.Name; mapObjInfo.rankValue = EntityWorld.Instance.EntSelf.TypeRank; Vector2 point = MapDataManager.Instance.GetPoint(sceneID, pointGroupID); string[] array = DataReader <Scene> .Get(sceneID).LockLookPoint.Split(new char[] { ';' }); float num = float.Parse(array[0]); float num2 = float.Parse(array[1]); Vector2 vector = new Vector2(num, num2); mapObjInfo.pos = new Pos(); mapObjInfo.pos.x = point.x; mapObjInfo.pos.y = point.y; mapObjInfo.vector = new Vector2(); mapObjInfo.vector.x = (vector - point).get_normalized().x; mapObjInfo.vector.y = (vector - point).get_normalized().y; mapObjInfo.mapLayer = 0; mapObjInfo.battleInfo = battleInfo; return(mapObjInfo); }
protected void OnAOIEnterMap(short state, MapObjEnterMapNty down = null) { if (state != 0) { StateManager.Instance.StateShow(state, 0); return; } if (down == null) { return; } for (int i = 0; i < down.mapObjs.get_Count(); i++) { MapObjInfo mapObjInfo = down.mapObjs.get_Item(i); if (mapObjInfo.objType == GameObjectType.ENUM.Role) { if (this.counter > AOIService.MaxCounter) { break; } this.counter++; } this.CreateEntity(mapObjInfo, false); } }
protected void CreateBattleEntity(MapObjInfo item, bool isClientCreate) { switch (item.battleInfo.wrapType) { case GameObjectType.ENUM.Role: EntityWorld.Instance.CreateOtherPlayer(item); break; case GameObjectType.ENUM.Monster: if (isClientCreate) { Loom.Current.QueueOnMainThread(delegate { EntityWorld.Instance.CreateMonster(item, isClientCreate, 0L); }, 0.1f); } else { EntityWorld.Instance.CreateMonster(item, isClientCreate, 0L); } break; case GameObjectType.ENUM.Pet: EntityWorld.Instance.CreatePet(item, isClientCreate); break; } }
public void Copy(MapObjInfo MapInfo) { m_eMapObjectType = MapInfo.m_eMapObjectType; m_nDurability = MapInfo.m_nDurability; m_nCrashDamage = MapInfo.m_nCrashDamage; m_Score = MapInfo.m_Score; }
public void SetMapArrivedObj(List <MapObjInfo> mapObjs) { this.counter = 0; if (mapObjs == null) { return; } List <MapObjInfo> list = new List <MapObjInfo>(); List <MapObjInfo> list2 = new List <MapObjInfo>(); List <MapObjInfo> list3 = new List <MapObjInfo>(); for (int i = 0; i < mapObjs.get_Count(); i++) { MapObjInfo mapObjInfo = mapObjs.get_Item(i); if (mapObjInfo.objType == GameObjectType.ENUM.Role) { list.Add(mapObjInfo); } else if (mapObjInfo.battleInfo != null) { switch (mapObjInfo.battleInfo.wrapType) { case GameObjectType.ENUM.Role: list.Add(mapObjInfo); break; case GameObjectType.ENUM.Monster: list3.Add(mapObjInfo); break; case GameObjectType.ENUM.Pet: list2.Add(mapObjInfo); break; } } } List <MapObjInfo> list4 = new List <MapObjInfo>(); for (int j = 0; j < list.get_Count(); j++) { MapObjInfo mapObjInfo2 = list.get_Item(j); if (mapObjInfo2.objType == GameObjectType.ENUM.Role) { if (this.counter > AOIService.MaxCounter) { break; } this.counter++; } list4.Add(mapObjInfo2); } list4.AddRange(list2); list4.AddRange(list3); for (int k = 0; k < list4.get_Count(); k++) { MapObjInfo item = list4.get_Item(k); this.CreateEntity(item, false); } }
public override void SetDataByMapObjInfo(MapObjInfo info, bool isClientCreate = false) { base.SetDataByMapObjInfo(info, isClientCreate); if (this.IsClientDominate && info != null && info.battleInfo != null) { this.BackUpBattleBaseAttrs.AssignAllAttrs(info.battleInfo); } }
public void RestoreMapObjects(string Name, string Author) { print("restore map objects"); string dir = GetMapDir() + "/Levels/" + Name + "_" + Author; //FileSystemInfo fileInfo = MyUtils.GetFile(dir); print("Load from: " + dir); BinaryFormatter bf = new BinaryFormatter(); MapObjInfo mapObjInfo = new MapObjInfo(); FileStream fs = File.Open(dir + "/general", FileMode.Open); mapObjInfo = (MapObjInfo)bf.Deserialize(fs); fs.Close(); mapObjInfo.ballInfo.SetTransformProperty(ref ball); mapObjInfo.destInfo.SetTransformProperty(ref destination); int childNum = walls.transform.childCount; for (int i = 0; i < childNum; i++) { //print("delete a wall"); Destroy(walls.transform.GetChild(i).gameObject); } foreach (TransformProperty t in mapObjInfo.wallInfo) { //print("restore a wall"); GameObject go = CreateWall(); t.SetTransformProperty(ref go); } dir = dir + "/fields"; FileSystemInfo[] files = MyUtils.GetFiles(dir); foreach (Transform trans in mapFields.GetComponentsInChildren <Transform>()) { DeleteObject(trans.gameObject); } if (files != null) { foreach (FileSystemInfo file in files) { fs = File.Open(file.FullName, FileMode.Open); FieldInfo info = (FieldInfo)bf.Deserialize(fs); GameObject go = CreateField(info.fieldType, true); go.GetComponent <Field>().Restore(info, false); } } for (int i = 0; i < mapObjInfo.fieldTypeList.Count; i++) { _fieldMaxDic[mapObjInfo.fieldTypeList[i]] = mapObjInfo.fieldNumList[i]; } }
public EA_CMapObject CreateMapObject(ObjectInfo GameObjInfo, MapObjInfo mapInfo) { GameObjInfo.m_eObjType = eObjectType.CT_MAPOBJECT; EA_CMapObject pObject = (EA_CMapObject)CreateGameObject(GameObjInfo); if (mapInfo != null) { pObject.SetMapInfo(mapInfo); } return(pObject); }
public void CreateEntity(MapObjInfo item, bool isClientCreate) { switch (item.objType) { case GameObjectType.ENUM.Role: this.CreateCityEntity(item); break; case GameObjectType.ENUM.Soldier: this.CreateBattleEntity(item, isClientCreate); break; } }
public override void SetDataByMapObjInfo(MapObjInfo info, bool isClientCreate = false) { base.IsClientCreate = isClientCreate; base.ObjType = (int)info.objType; base.ID = info.id; this.TypeID = info.typeId; this.ModelID = info.modelId; this.Name = info.name; this.TypeRank = info.rankValue; this.TitleID = info.titleId; this.GuildTitle = HeadInfoManager.GetGuildTitle(info.guildInfo); base.Floor = info.mapLayer; base.Pos = PosDirUtility.ToTerrainPoint(info.pos, base.CurFloorStandardHeight); base.Dir = new Vector3(info.vector.x, 0f, info.vector.y); this.SetMapObjSimpleInfo(info.otherInfo); this.Decorations = info.decorations; }
public static MapInfoJson SyncMapInfo() { string dir = Application.streamingAssetsPath + "/Levels"; FileSystemInfo[] files = GetFiles(dir); BinaryFormatter bf = new BinaryFormatter(); MapInfoJson mapInfoJson = new MapInfoJson(); foreach (FileSystemInfo tmp in files) { if (tmp is DirectoryInfo) { FileStream file = File.Open(tmp.FullName + "/general", FileMode.Open); MapObjInfo info = (MapObjInfo)bf.Deserialize(file); MapInfo map = info.mapInfo; mapInfoJson.officialMaps.Add(map); file.Close(); } } dir = Application.persistentDataPath + "/Levels"; files = GetFiles(dir); foreach (FileSystemInfo tmp in files) { if (tmp is DirectoryInfo) { FileStream file = File.Open(tmp.FullName + "/general", FileMode.Open); MapObjInfo info = (MapObjInfo)bf.Deserialize(file); MapInfo map = info.mapInfo; mapInfoJson.customMaps.Add(map); file.Close(); } } string json = JsonUtility.ToJson(mapInfoJson, true); File.WriteAllText(Application.persistentDataPath + "/General/MapsInfo.json", json); return(mapInfoJson); }
public static MapObjInfo CreatePetMapObjInfo(long ownerID, int index, PetInfo item, int sceneID) { MapObjInfo mapObjInfo = new MapObjInfo(); mapObjInfo.objType = GameObjectType.ENUM.Soldier; mapObjInfo.id = item.id; mapObjInfo.ownerId = ownerID; mapObjInfo.name = item.name; mapObjInfo.typeId = item.petId; mapObjInfo.modelId = PetManagerBase.GetPlayerPetModel(item.petId, item.star); mapObjInfo.name = item.name; mapObjInfo.rankValue = item.star; mapObjInfo.pos = new Pos(); Vector2 petPoint = MapDataManager.Instance.GetPetPoint(sceneID); mapObjInfo.pos.x = petPoint.x; mapObjInfo.pos.y = petPoint.y; mapObjInfo.vector = new Vector2(); mapObjInfo.vector.x = 0f; mapObjInfo.vector.y = 1f; mapObjInfo.mapLayer = 0; mapObjInfo.battleInfo = LocalDimensionPetInfoCreator.CreatePetBattleBaseInfo(item, index); return(mapObjInfo); }
public int SaveMapObjects(string name) { print("save map objects"); MapInfo mapInfo = new MapInfo(); mapInfo.name = name; mapInfo.author = player.name; mapInfo.dateTime = DateTime.Now.ToString(); if (isOfficial) { mapInfoJson.officialMaps.Add(mapInfo); } else { mapInfoJson.customMaps.Add(mapInfo); } string json = JsonUtility.ToJson(mapInfoJson, true); File.WriteAllText(Application.persistentDataPath + "/General/MapsInfo.json", json); MapObjInfo mapObjInfo = new MapObjInfo(); Transform t; t = ball.transform; mapObjInfo.ballInfo = new TransformProperty(t.position, t.localEulerAngles, t.localScale); t = destination.transform; mapObjInfo.destInfo = new TransformProperty(t.position, t.localEulerAngles, t.localScale); mapObjInfo.mapInfo = mapInfo; mapObjInfo.wallInfo = new List <TransformProperty>(); for (int i = 0; i < walls.transform.childCount; i++) { t = walls.transform.GetChild(i); mapObjInfo.wallInfo.Add(new TransformProperty(t.position, t.localEulerAngles, t.localScale)); } mapObjInfo.fieldNumList = new List <int>(); mapObjInfo.fieldTypeList = new List <string>(); foreach (KeyValuePair <string, int> kv in _fieldMaxDic) { mapObjInfo.fieldTypeList.Add(kv.Key); mapObjInfo.fieldNumList.Add(myUI.FieldNumLimitGet(kv.Key)); } BinaryFormatter bf = new BinaryFormatter(); string dir = GetMapDir() + "/Levels/" + name + "_" + player.name; if (!Directory.Exists(dir)) { Directory.CreateDirectory(dir); } FileStream file = File.Open(dir + "/general", FileMode.OpenOrCreate); bf.Serialize(file, mapObjInfo); file.Close(); //Transform[] fieldsTrans = mapFields.transform.GetComponentsInChildren<Transform>(); dir = dir + "/fields"; MyUtils.EmptyOrCreateDir(dir); foreach (var kv in mapFieldDic) { for (int i = 0; i < kv.Value.Count; i++) { file = File.Open(dir + '/' + kv.Key + i, FileMode.OpenOrCreate); FieldInfo info = kv.Value[i].GetComponent <Field>().Save(); bf.Serialize(file, info); file.Close(); } } return(-1); }
public static MapObjInfo CreateMonsterMapObjInfo(int poolID, int monsterTypeID, int monsterLevel, long ownerID, int camp, bool isBoss, Vector3 position, bool isFighting = true) { Monster monsterData = DataReader <Monster> .Get(monsterTypeID); if (monsterData == null) { EntityWorld.Instance.ForceOut("没有数据", string.Format("Monster表根本没有怪物{0}的数据", monsterTypeID), null); } MonsterAttr monsterAttr = Enumerable.FirstOrDefault <MonsterAttr>(DataReader <MonsterAttr> .DataList, (MonsterAttr x) => x.lv == monsterLevel && x.id == monsterData.AttributeTemplateID); if (monsterAttr == null) { EntityWorld.Instance.ForceOut("没有数据", string.Format("怪物属性表里没有模板ID{0} & 等级{1}的数据\n怪物id为{2}", monsterData.AttributeTemplateID, monsterLevel, monsterTypeID), null); } MapObjInfo mapObjInfo = new MapObjInfo(); mapObjInfo.objType = GameObjectType.ENUM.Soldier; mapObjInfo.id = (long)poolID; mapObjInfo.ownerId = ownerID; mapObjInfo.typeId = monsterTypeID; mapObjInfo.modelId = monsterData.model; mapObjInfo.name = mapObjInfo.id.ToString(); mapObjInfo.rankValue = 0; mapObjInfo.pos = new Pos(); mapObjInfo.pos.x = (float)((int)position.x * 100); mapObjInfo.pos.y = (float)((int)position.z * 100); mapObjInfo.vector = InstanceManager.GetMonsterFixBornDirection(monsterData.monsterBornDirection, position, ownerID, monsterData.scenePoint); mapObjInfo.mapLayer = 0; BattleBaseAttrs battleBaseAttrs = new BattleBaseAttrs(); battleBaseAttrs.SetValue(GameData.AttrType.Lv, monsterLevel, true); battleBaseAttrs.SetValue(GameData.AttrType.HpLmt, monsterAttr.hp, true); battleBaseAttrs.SetValue(GameData.AttrType.Atk, monsterAttr.atk, true); battleBaseAttrs.SetValue(GameData.AttrType.Defence, monsterAttr.defence, true); battleBaseAttrs.SetValue(GameData.AttrType.HitRatio, monsterAttr.hit, true); battleBaseAttrs.SetValue(GameData.AttrType.DodgeRatio, monsterAttr.dex, true); battleBaseAttrs.SetValue(GameData.AttrType.CritRatio, monsterAttr.crt, true); battleBaseAttrs.SetValue(GameData.AttrType.DecritRatio, monsterAttr.penetration, true); battleBaseAttrs.SetValue(GameData.AttrType.CritHurtAddRatio, monsterAttr.critHurtAddRatio, true); battleBaseAttrs.SetValue(GameData.AttrType.ParryRatio, monsterAttr.parry, true); battleBaseAttrs.SetValue(GameData.AttrType.DeparryRatio, monsterAttr.vigour, true); battleBaseAttrs.SetValue(GameData.AttrType.ParryHurtDeRatio, monsterAttr.parryHurtDeRatio, true); battleBaseAttrs.SetValue(GameData.AttrType.ActSpeed, monsterAttr.attackSpeed, true); battleBaseAttrs.SetValue(GameData.AttrType.VpLmt, monsterAttr.Vp, true); battleBaseAttrs.SetValue(GameData.AttrType.VpResume, monsterAttr.VpResume, true); battleBaseAttrs.SetValue(GameData.AttrType.IdleVpResume, monsterAttr.IdleVpResume, true); if (monsterData.propId != 0) { battleBaseAttrs.AddValuesByTemplateID(monsterData.propId); } battleBaseAttrs.SetValue(GameData.AttrType.HpLmt, (long)((double)battleBaseAttrs.GetValue(GameData.AttrType.HpLmt) * (1.0 + (double)monsterData.HpAmplificationRate * 0.001)), true); battleBaseAttrs.SetValue(GameData.AttrType.Atk, (int)((double)battleBaseAttrs.GetValue(GameData.AttrType.Atk) * (1.0 + (double)monsterData.AttAmplificationRate * 0.001)), true); battleBaseAttrs.SetValue(GameData.AttrType.Defence, (int)((double)battleBaseAttrs.GetValue(GameData.AttrType.Defence) * (1.0 + (double)monsterData.DefAmplificationRate * 0.001)), true); battleBaseAttrs.SetValue(GameData.AttrType.HitRatio, (int)((double)battleBaseAttrs.GetValue(GameData.AttrType.HitRatio) * (1.0 + (double)monsterData.HitAmplificationRate * 0.001)), true); battleBaseAttrs.SetValue(GameData.AttrType.DodgeRatio, (int)((double)battleBaseAttrs.GetValue(GameData.AttrType.DodgeRatio) * (1.0 + (double)monsterData.DexAmplificationRate * 0.001)), true); battleBaseAttrs.SetValue(GameData.AttrType.CritRatio, (int)((double)battleBaseAttrs.GetValue(GameData.AttrType.CritRatio) * (1.0 + (double)monsterData.CrtAmplificationRate * 0.001)), true); battleBaseAttrs.SetValue(GameData.AttrType.DecritRatio, (int)((double)battleBaseAttrs.GetValue(GameData.AttrType.DecritRatio) * (1.0 + (double)monsterData.PenAmplificationRate * 0.001)), true); battleBaseAttrs.SetValue(GameData.AttrType.CritHurtAddRatio, (int)((double)battleBaseAttrs.GetValue(GameData.AttrType.CritHurtAddRatio) * (1.0 + (double)monsterData.CthAmplificationRate * 0.001)), true); battleBaseAttrs.SetValue(GameData.AttrType.ParryRatio, (int)((double)battleBaseAttrs.GetValue(GameData.AttrType.ParryRatio) * (1.0 + (double)monsterData.ParAmplificationRate * 0.001)), true); battleBaseAttrs.SetValue(GameData.AttrType.DeparryRatio, (int)((double)battleBaseAttrs.GetValue(GameData.AttrType.DeparryRatio) * (1.0 + (double)monsterData.VigAmplificationRate * 0.001)), true); battleBaseAttrs.SetValue(GameData.AttrType.ParryHurtDeRatio, (int)((double)battleBaseAttrs.GetValue(GameData.AttrType.ParryHurtDeRatio) * (1.0 + (double)monsterData.PrhAmplificationRate * 0.001)), true); battleBaseAttrs.SetValue(GameData.AttrType.ActSpeed, (int)((double)battleBaseAttrs.GetValue(GameData.AttrType.ActSpeed) * (1.0 + (double)monsterData.AtsAmplificationRate * 0.001)), true); battleBaseAttrs.SetValue(GameData.AttrType.VpLmt, (int)((double)battleBaseAttrs.GetValue(GameData.AttrType.VpLmt) * (1.0 + (double)monsterData.VpAmplificationRate * 0.001)), true); battleBaseAttrs.SetValue(GameData.AttrType.VpResume, (int)((double)battleBaseAttrs.GetValue(GameData.AttrType.VpResume) * (1.0 + (double)monsterData.VsAmplificationRate * 0.001)), true); battleBaseAttrs.SetValue(GameData.AttrType.IdleVpResume, (int)((double)battleBaseAttrs.GetValue(GameData.AttrType.IdleVpResume) * (1.0 + (double)monsterData.IvAmplificationRate * 0.001)), true); mapObjInfo.battleInfo = LocalDimensionMonsterInfoCreator.CreateMonsterBattleBaseInfo(monsterData, battleBaseAttrs, camp, isBoss, isFighting); return(mapObjInfo); }
public bool SetMapInfo(MapObjInfo mapInfo) { m_MapInfo.Copy(mapInfo); return(true); }
public abstract void OnCreate(MapObjInfo info, bool isClient = false);
protected void CreateCityEntity(MapObjInfo item) { EntityWorld.Instance.CreateCityOtherPlayer(item); }
public static MapObjInfo CreateSelfMapObjInfo(int instanceType, int instanceDataID, int sceneID, int trailType = 0, int trailModel = 0, MapObjDecorations trialDecorations = null, List <PetInfo> trialPetInfos = null, List <BattleSkillInfo> trialSkillInfos = null) { FuBenJiChuPeiZhi fuBenJiChuPeiZhi = DataReader <FuBenJiChuPeiZhi> .Get(instanceDataID); MapObjInfo mapObjInfo = new MapObjInfo(); mapObjInfo.objType = GameObjectType.ENUM.Role; mapObjInfo.id = EntityWorld.Instance.EntSelf.ID; mapObjInfo.ownerId = EntityWorld.Instance.EntSelf.OwnerID; if (trailType == 0) { mapObjInfo.typeId = EntityWorld.Instance.EntSelf.TypeID; } else { mapObjInfo.typeId = trailType; } if (trailModel == 0) { mapObjInfo.modelId = EntityWorld.Instance.EntSelf.ModelID; } else { mapObjInfo.modelId = trailModel; } mapObjInfo.name = EntityWorld.Instance.EntSelf.Name; mapObjInfo.rankValue = EntityWorld.Instance.EntSelf.TypeRank; Vector2 point = MapDataManager.Instance.GetPoint(sceneID, fuBenJiChuPeiZhi.pointId); string[] array = DataReader <Scene> .Get(sceneID).LockLookPoint.Split(new char[] { ';' }); Vector2 vector = new Vector2(float.Parse(array[0]), float.Parse(array[1])); mapObjInfo.pos = new Pos(); mapObjInfo.pos.x = point.x; mapObjInfo.pos.y = point.y; mapObjInfo.vector = new Vector2(); mapObjInfo.vector.x = (vector - point).get_normalized().x; mapObjInfo.vector.y = (vector - point).get_normalized().y; mapObjInfo.mapLayer = 0; mapObjInfo.decorations = new MapObjDecorations(); if (trialDecorations == null) { mapObjInfo.decorations.career = EntityWorld.Instance.EntSelf.Decorations.career; mapObjInfo.decorations.modelId = EntityWorld.Instance.EntSelf.Decorations.modelId; mapObjInfo.decorations.equipIds.Clear(); if (EntityWorld.Instance.EntSelf.Decorations.equipIds != null) { mapObjInfo.decorations.equipIds.AddRange(EntityWorld.Instance.EntSelf.Decorations.equipIds); } mapObjInfo.decorations.petUUId = EntityWorld.Instance.EntSelf.Decorations.petUUId; mapObjInfo.decorations.petId = EntityWorld.Instance.EntSelf.Decorations.petId; mapObjInfo.decorations.petStar = EntityWorld.Instance.EntSelf.Decorations.petStar; mapObjInfo.decorations.wingId = EntityWorld.Instance.EntSelf.Decorations.wingId; mapObjInfo.decorations.wingLv = EntityWorld.Instance.EntSelf.Decorations.wingLv; mapObjInfo.decorations.wingHidden = EntityWorld.Instance.EntSelf.Decorations.wingHidden; mapObjInfo.decorations.fashions.Clear(); if (EntityWorld.Instance.EntSelf.Decorations.fashions != null) { mapObjInfo.decorations.fashions.AddRange(EntityWorld.Instance.EntSelf.Decorations.fashions); } } else { mapObjInfo.decorations.career = trialDecorations.career; mapObjInfo.decorations.modelId = trialDecorations.modelId; mapObjInfo.decorations.equipIds.Clear(); if (trialDecorations.equipIds != null) { mapObjInfo.decorations.equipIds.AddRange(trialDecorations.equipIds); } mapObjInfo.decorations.petUUId = trialDecorations.petUUId; mapObjInfo.decorations.petId = trialDecorations.petId; mapObjInfo.decorations.petStar = trialDecorations.petStar; mapObjInfo.decorations.wingId = trialDecorations.wingId; mapObjInfo.decorations.wingLv = trialDecorations.wingLv; mapObjInfo.decorations.wingHidden = trialDecorations.wingHidden; mapObjInfo.decorations.fashions.Clear(); if (trialDecorations.fashions != null) { mapObjInfo.decorations.fashions.AddRange(trialDecorations.fashions); } } mapObjInfo.battleInfo = LocalDimensionSelfInfoCreator.CreateSelfBattleBaseInfo(instanceType, fuBenJiChuPeiZhi, trialPetInfos, trialSkillInfos); return(mapObjInfo); }