public void OnSelectHeroSkin(int userId, string skinId) { ReadyPlayerSampleInfo readyPlayerSampleInfo = this.TryFindPlayerInfo(userId, "OnSelectHeroSkin"); if (readyPlayerSampleInfo != null) { readyPlayerSampleInfo.heroSkinId = skinId; HeroSkins.SetHeroSkin(this.GetTeam(userId), this.GetPlayerHero(userId), int.Parse(skinId)); MobaMessageManager.DispatchMsg(ClientC2C.PvpSelectHeroSkin, new ParamSelectHeroSkin(userId, skinId)); } }
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 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 T Load <T>(string resId, bool loadFromCache = true, bool loadFromBundle = true, Action <T> firstLoadCallback = null, int skin = 0, bool isMonsterSkin = false) where T : class { if (resId == null || resId == "[]") { return((T)((object)null)); } SysGameResVo gameResData = BaseDataMgr.instance.GetGameResData(resId); if (gameResData == null) { Debug.LogError("no such resId:" + resId + " 请检查GameRes表"); return((T)((object)null)); } if (ResourceManager.openLog) { } string path = gameResData.path; string id = gameResData.id; HeroSkins.GetHeroSkinResPath(skin, gameResData, ref path, ref id, isMonsterSkin); if (loadFromBundle && !string.IsNullOrEmpty(gameResData.bundle) && gameResData.bundle != "[]") { string bundle = gameResData.bundle; if (ResourceManager.openLog) { } if (ResourceManager.openLog) { } if (loadFromCache) { T t = AssetLoader.Load(path, bundle, false) as T; if (t != null) { return(t); } } else { T t2 = UnityEngine.Object.Instantiate(AssetLoader.Load(gameResData.path, bundle, false)) as T; AssetLoader.Instance.UnloadCachedAsset(path, bundle); if (t2 != null) { return(t2); } } } if (ResourceManager.openLog) { } if (ResourceManager.openLog) { } UnityEngine.Object @object = null; bool flag = ResourceManager.m_gameResList.TryGetValue(id, out @object); if (!flag || @object == null) { string[] array = path.Split(new char[] { '/' }); if (array != null && array[array.Length - 1] != null) { @object = AssetBundleMgr.Instance.Load(array[array.Length - 1], gameResData.bundle); } if (@object == null) { @object = Resources.Load(path); } if (@object != null) { if (flag) { ResourceManager.m_gameResList[id] = @object; } else { ResourceManager.m_gameResList.Add(id, @object); } } else if (skin == 0) { Debug.LogError("缺少美术资源 " + resId + " 在gameres表中的path:" + path); } } if (!loadFromCache) { return(UnityEngine.Object.Instantiate(@object) as T); } if (gameResData == null) { Debug.LogError("error gameRes id=" + resId); return((T)((object)null)); } T t3 = @object as T; if (t3 != null && firstLoadCallback != null) { firstLoadCallback(t3); } return(t3); }
public static GameObject GetSkinnedHeroPrefab(TeamType team, string heroResId) { SysGameResVo gameResData = BaseDataMgr.instance.GetGameResData(heroResId); return(HeroSkins.GetHeroPrefabWithSkin(gameResData.path, HeroSkins.GetHeroSkin(team, heroResId))); }
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); }