protected override void OnInit(bool isRebirth = false) { if (!base.MirrorState) { this.heroData = Singleton <PvpManager> .Instance.GetHeroInfoData(this.unique_id); } base.OnInit(isRebirth); this.m_fLiveTime = -1f; this.m_fLeftTime = 0f; this.musicid = this.data.GetData <string>(DataType.MusicId); if (this.m_hv != null) { this.m_hv.init(this.musicid); } if (RecieverObjCtrl.usefakeshadow) { if (this.roc == null) { this.roc = base.GetComponentInChildren <RecieverObjCtrl>(); } if (this.roc != null) { string[] array = base.name.Split(new char[] { '+' }); this.roc.setnpcid(array[0]); } } if (this.InitCount == 0) { AudioMgr.loadSoundBank_Skill(this.musicid, false, HeroSkins.GetRealHeroSkin(base.TeamType, base.model_id)); } if (this.m_eventPlayerSound != null) { this.m_eventPlayerSound.isplayer = this.isPlayer; } if (this.isPlayer) { base.controllerType = 1; AudioMgr.AddLisener(base.gameObject); AudioMgr.loadLanguageSoundBank(this.musicid, HeroSkins.GetRealHeroSkin(base.TeamType, base.model_id)); } else { base.controllerType = 0; } if (!base.MirrorState) { } this.InitCount++; this.TryInitHeroVisibleOnReplay(isRebirth); }
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); }