public static Units CreateEyeItemByUnitInfo(UnitInfo info) { if (!StringUtils.CheckValid(info.burnValue)) { ClientLogger.Error(string.Concat(new object[] { "burnValue is invalid, use default position #", info.typeId, " utype:", info.unitType })); return(null); } string[] stringValue = StringUtils.GetStringValue(info.burnValue, '|'); if (stringValue.Length != 6) { ClientLogger.Error("eye item burnValue is stuctured wrong"); return(null); } int num = -1; if (!int.TryParse(stringValue[2], out num)) { ClientLogger.Error("parse eye item pos failed"); return(null); } if (num < 0) { ClientLogger.Error("eye item pos invalid"); return(null); } Transform spawnPos = MapManager.Instance.GetSpawnPos(TeamType.Neutral, num); TeamType teamType = PvpProtocolTools.GroupToTeam((int)info.group); EntityVo npcinfo = new EntityVo(EntityType.Monster, info.typeId, num, 9, string.Empty, "Default", 0) { uid = info.unitId }; SpawnUtility spawnUtility = GameManager.Instance.Spawner.GetSpawnUtility(); Units units = spawnUtility.SpawnEyeItemInstance(npcinfo, "Monster", teamType, "[]", spawnPos, info.position, stringValue[4], UnitControlType.None); if (units == null) { ClientLogger.Error("P2C_CreateUnits create monster failed, " + StringUtils.DumpObject(info)); return(null); } units.SetOrigin(true, info.creepId.ToString(), info.monsterTeamId); units.TryAddBirthEffect(); units.SetIsMonsterCreep(false); PvpProtocolTools.SyncUnitLifeStateAndSkill(units, info, 0L); if (units.isMonster && units.skillManager != null) { units.skillManager.EnableSkills(true); } return(units); }
public static void UpdateHeroSkins(IEnumerable <ReadyPlayerSampleInfo> allPlayers) { HeroSkins.Clear(); foreach (ReadyPlayerSampleInfo current in allPlayers) { if (!string.IsNullOrEmpty(current.heroSkinId)) { int skinIdx = 0; if (int.TryParse(current.heroSkinId, out skinIdx)) { HeroSkins.SetHeroSkin(PvpProtocolTools.GroupToTeam((int)current.group), current.heroInfo.heroId, skinIdx); } } } }
public static TeamType GetTeam(this ReadyPlayerSampleInfo info) { return(PvpProtocolTools.GroupToTeam((int)info.group)); }
public static Units CreateMonsterByUnitInfo(UnitInfo info) { Units result; try { if (info == null) { ClientLogger.Error("CreateMonsterByUnitInfo: info is null"); result = null; } else if (MapManager.Instance == null) { ClientLogger.Error("MapManager.Instance is null"); result = null; } else if (GlobalSettings.TestCreep) { Singleton <CreepSpawner> .Instance.CreateCreeps(new List <string> { "101" }, info.unitId); result = null; } else if (GlobalSettings.NoMonster) { ClientLogger.Warn("P2C_CreateUnits create monster ignored"); result = null; } else if (info.unitType == UnitType.EyeItem) { result = PvpProtocolTools.CreateEyeItemByUnitInfo(info); } else { TeamType teamType = PvpProtocolTools.GroupToTeam((int)info.group); int num = -1; Transform transform = null; if (StringUtils.CheckValid(info.burnValue)) { string[] stringValue = StringUtils.GetStringValue(info.burnValue, '|'); UnitType unitType = info.unitType; if (unitType != UnitType.Monster) { if (unitType != UnitType.Soldier) { ClientLogger.Error("cannot be here"); } else { num = int.Parse(stringValue[2]); } } else { num = int.Parse(stringValue[1]); transform = MapManager.Instance.GetSpawnPos(TeamType.Neutral, num); } if (num < 0) { ClientLogger.Error("burnValue is invalid, use position #" + info.typeId + " " + info.burnValue); } } else if (info.unitType == UnitType.EyeUnit) { transform = MapManager.Instance.GetSpawnPos(TeamType.Neutral, 1); if (transform != null) { transform.position = new Vector3(info.position.x, info.position.y, info.position.z); } } else if (info.unitType == UnitType.SummonMonster || info.unitType == UnitType.BoxUnit) { transform = MapManager.Instance.GetSpawnPos((TeamType)info.group, 1); if (transform != null) { transform.position = new Vector3(info.position.x, info.position.y, info.position.z); } } else if (info.unitType == UnitType.Pet) { transform = MapManager.Instance.GetSpawnPos((TeamType)info.group, 1); if (transform != null) { transform.position = new Vector3(info.position.x, info.position.y, info.position.z); } } else if (info.unitType == UnitType.LabisiUnit) { transform = MapManager.Instance.GetSpawnPos((TeamType)info.group, 1); if (transform != null) { transform.position = new Vector3(info.position.x, info.position.y, info.position.z); } } else { ClientLogger.Error(string.Concat(new object[] { "burnValue is invalid, use default position #", info.typeId, " utype:", info.unitType })); } Units unit = MapManager.Instance.GetUnit(info.mainHeroId); int skin = 0; if (unit != null && info.unitType == UnitType.SummonMonster) { skin = HeroSkins.GetRealHeroSkin((TeamType)unit.teamType, unit.model_id); } EntityVo npcinfo = new EntityVo(EntityType.Monster, info.typeId, num, 0, string.Empty, "Default", 0) { uid = info.unitId, skin = skin }; if (null == GameManager.Instance) { Debug.LogError("null == GameManager.Instance"); result = null; } else if (GameManager.Instance.Spawner == null) { Debug.LogError("null == GameManager.Instance.Spawner"); result = null; } else { SpawnUtility spawnUtility = GameManager.Instance.Spawner.GetSpawnUtility(); Units units = spawnUtility.SpawnInstance(npcinfo, "Monster", teamType, num, "[]", transform, UnitControlType.None, info.unitType); if (units == null) { ClientLogger.Error(string.Concat(new object[] { "P2C_CreateUnits create monster failed, creepId=", info.creepId, " typeid= ", info.typeId, " burnValue=", info.burnValue ?? "null" })); result = null; } else { if (units.UnitType == UnitType.EyeUnit) { } if (unit != null) { units.ParentUnit = unit; } if (units.UnitType == UnitType.EyeUnit || units.UnitType == UnitType.SummonMonster) { units.m_fLiveTime = info.liveTime; units.m_fLeftTime = info.liveTime; } units.SetOrigin(true, info.creepId.ToString(), info.monsterTeamId); units.TryAddBirthEffect(); units.SetIsMonsterCreep(info.unitType == UnitType.Monster || info.unitType == UnitType.CreepBoss); PvpProtocolTools.SyncUnitLifeStateAndSkill(units, info, 0L); if (units.isMonster && units.skillManager != null) { units.skillManager.EnableSkills(true); } if (units != null && transform != null) { units.SetPosition(transform.position, true); } result = units; } } } } catch (Exception e) { ClientLogger.LogException(e); result = null; } return(result); }