//加载声音 private async ETTask <SoundData> LoadSound(string soundName) { ResourcesComponent resourcesComponent = Game.Scene.GetComponent <ResourcesComponent>(); if (!abSounds.ContainsKey(soundName) || abSounds[soundName] == null) { await resourcesComponent.CacheBundleAsync(soundName); var prefab = UnityEngine.Object.Instantiate((GameObject)resourcesComponent.GetAsset(SoundPrefab)); prefab.name = soundName; abSounds.Add(soundName, prefab.GetComponent <SoundData>()); abSounds[soundName].GetAudio().clip = (AudioClip)resourcesComponent.GetAsset(soundName); } return(abSounds[soundName]); }
public UI Create(Scene scene, string type, GameObject parent) { try { //加载AB包 ResourcesComponent resourcesComponent = ETModel.Game.Scene.GetComponent <ResourcesComponent>(); resourcesComponent.LoadBundle($"{type}.unity3d"); //加载大厅界面预设并生成实例 GameObject bundleGameObject = (GameObject)resourcesComponent.GetAsset($"{type}.unity3d", $"{type}"); GameObject mainLobby = UnityEngine.Object.Instantiate(bundleGameObject); //设置UI层级,只有UI摄像机可以渲染 mainLobby.layer = LayerMask.NameToLayer(LayerNames.UI); UI ui = ComponentFactory.Create <UI, GameObject>(mainLobby); ui.AddComponent <StartLobbyComponent>(); return(ui); } catch (Exception e) { Log.Error(e); return(null); } }
public static Unit Create(long id) { ResourcesComponent resourcesComponent = Game.Scene.GetComponent <ResourcesComponent>(); GameObject bundleGameObject = (GameObject)resourcesComponent.GetAsset("Unit.unity3d", "Unit"); GameObject prefab = bundleGameObject.Get <GameObject>("Skeleton"); UnitComponent unitComponent = Game.Scene.GetComponent <UnitComponent>(); GameObject go = UnityEngine.Object.Instantiate(prefab); Unit unit = ComponentFactory.CreateWithId <Unit, GameObject>(id, go); unit.AddComponent <AnimatorComponent>(); SyncType type = Game.Scene.GetComponent <NetSyncComponent>().type; if (type == SyncType.Frame) { unit.AddComponent <FrameMoveComponent>(); } else if (type == SyncType.State) { unit.AddComponent <MoveComponent>(); unit.AddComponent <TurnComponent>(); unit.AddComponent <UnitPathComponent>(); } unitComponent.Add(unit); return(unit); }
public static Bullet Create(Tank tank) { ResourcesComponent resourcesComponent = Game.Scene.GetComponent <ResourcesComponent>(); Game.Scene.GetComponent <ResourcesComponent>().LoadBundle($"Unit.unity3d"); GameObject bundleGameObject = (GameObject)resourcesComponent.GetAsset("Unit.unity3d", "Unit"); Game.Scene.GetComponent <ResourcesComponent>().UnloadBundle($"Unit.unity3d"); GameObject prefab = bundleGameObject.Get <GameObject>("Bullet"); BulletComponent bulletComponent = tank.GetComponent <BulletComponent>(); Bullet bullet = ComponentFactory.CreateWithId <Bullet, Tank>(IdGenerater.GenerateId(), tank); bullet.GameObject = resourcesComponent.NewObj(PrefabType.Bullet, prefab); GameObject parent = tank.GameObject.FindChildObjectByPath("bullets"); bullet.GameObject.transform.SetParent(parent.transform, false); bulletComponent.Add(bullet); BulletCollision bulletCollision = bullet.GameObject.AddComponent <BulletCollision>(); // 子弹添加飞行 bulletCollision.BulletFly = bullet.AddComponent <BulletFlyComponent>(); return(bullet); }
/// <summary> /// 初始化对象池容器 /// </summary> /// <param name="poolName"></param> /// <param name="abName"></param> /// <param name="assetName"></param> /// <param name="capacity"></param> public ObjPool(string poolName, string abName, string assetName, int capacity) { _poolName = poolName; _abName = abName; _assetName = assetName; poolQuque = new Queue <GameObject>(capacity); PoolParent = GameObject.Find("ObjectPool").transform; ResourcesComponent res = ETModel.Game.Scene.GetComponent <ResourcesComponent>(); res.LoadBundle(abName.StringToAB()); assetObject = (GameObject)res.GetAsset(abName.StringToAB(), assetName); for (int i = 0; i < capacity; i++) { GameObject objClone = (GameObject)UnityEngine.Object.Instantiate(assetObject); objClone.SetActive(false); objClone.transform.SetParent(PoolParent); poolQuque.Enqueue(objClone); } }
Sprite CreateSprite(string abName, string imgName) { ResourcesComponent resourcesComponent = Game.Scene.GetComponent <ResourcesComponent>(); Texture2D tex = (Texture2D)resourcesComponent.GetAsset(abName.StringToAB(), imgName); return(Sprite.Create(tex, new Rect(0.0f, 0.0f, tex.width, tex.height), new Vector2(0.5f, 0.5f), 100.0f)); }
private void LoadGraph() { ResourcesComponent resourcesComponent = Game.Scene.GetComponent <ResourcesComponent>(); resourcesComponent.LoadBundle("graph.unity3d"); GameObject graphRef = resourcesComponent.GetAsset("graph.unity3d", "Graph") as GameObject; TextAsset graph = graphRef.Get <TextAsset>("Graph"); this.AStarConfig.graphs = DeserializeHelper.Load(graph.bytes); }
public static BehaviorTree CreateEnemy() { ResourcesComponent resourcesComponent = Game.Scene.GetComponent <ResourcesComponent>(); GameObject bundleGameObject = (GameObject)resourcesComponent.GetAsset("enemy.unity3d", "Enemy"); GameObject prefab = bundleGameObject.Get <GameObject>("Enemy1"); GameObject go = UnityEngine.Object.Instantiate(prefab); BehaviorTree behaviorTree = go.GetComponent <BehaviorTree>(); return(behaviorTree); }
//加载声音 private async Task <SoundData> LoadSound(string soundName) { ResourcesComponent resourcesComponent = Game.Scene.GetComponent <ResourcesComponent>(); if (!abSounds.ContainsKey(soundName) || abSounds[soundName] == null) { //await resourcesComponent.LoadBundleAsync("sound.unity3d"); abSounds.Add(soundName, GameObject.Instantiate((GameObject)resourcesComponent.GetAsset("sound.unity3d", soundName)).GetComponent <SoundData>()); //resourcesComponent.UnloadBundle("sound.unity3d"); } return(abSounds[soundName]); }
public void Awake() { m_tank = this.GetParent <Tank>(); wheels = m_tank.GameObject.FindComponentInChildren <Transform>("wheels"); tracks = m_tank.GameObject.FindComponentInChildren <Transform>("tracks"); motorAudioSource = m_tank.GameObject.GetComponent <AudioSource>(); if (this.motorAudioSource == null) { motorAudioSource = m_tank.GameObject.AddComponent <AudioSource>(); } motorAudioSource.playOnAwake = false; motorAudioSource.spatialBlend = 1; motorAudioSource.volume = GameSettingInfo.AudioVolume(); ResourcesComponent resourcesComponent = Game.Scene.GetComponent <ResourcesComponent>(); Game.Scene.GetComponent <ResourcesComponent>().LoadBundle($"Unit.unity3d"); GameObject bundleGameObject = (GameObject)resourcesComponent.GetAsset("Unit.unity3d", "Unit"); Game.Scene.GetComponent <ResourcesComponent>().UnloadBundle($"Unit.unity3d"); motorClip = bundleGameObject.Get <AudioClip>("motor"); this.motorAudioSource.loop = true; this.motorAudioSource.clip = this.motorClip; axleInfos = new List <AxleInfo>(2); // 前轮 AxleInfo axleInfo = new AxleInfo(); axleInfo.leftWheel = m_tank.GameObject.FindComponentInChildren <WheelCollider>("PhysicalBody/wheelL1"); axleInfo.rightWheel = m_tank.GameObject.FindComponentInChildren <WheelCollider>("PhysicalBody/wheelR1"); axleInfo.montor = false; axleInfo.steering = true; this.axleInfos.Add(axleInfo); axleInfo = new AxleInfo(); axleInfo.leftWheel = m_tank.GameObject.FindComponentInChildren <WheelCollider>("PhysicalBody/wheelL2"); axleInfo.rightWheel = m_tank.GameObject.FindComponentInChildren <WheelCollider>("PhysicalBody/wheelR2"); axleInfo.montor = true; axleInfo.steering = false; this.axleInfos.Add(axleInfo); }
private void InitPhysical() { wheels = m_tank.FindComponentInChildren <Transform>("wheels"); tracks = m_tank.FindComponentInChildren <Transform>("tracks"); motorAudioSource = m_tank.GetComponent <AudioSource>(); if (motorAudioSource == null) { motorAudioSource = m_tank.AddComponent <AudioSource>(); } motorAudioSource.spatialBlend = 1; motorAudioSource.volume = GameSettingInfo.AudioVolume(); ResourcesComponent resourcesComponent = Game.Scene.GetComponent <ResourcesComponent>(); //Game.Scene.GetComponent<ResourcesComponent>().LoadBundle($"Unit.unity3d"); GameObject bundleGameObject = (GameObject)resourcesComponent.GetAsset(AssetBundleName.Unit, PrefabName.Unit); //Game.Scene.GetComponent<ResourcesComponent>().UnloadBundle($"Unit.unity3d"); motorClip = bundleGameObject.Get <AudioClip>("motor"); motorAudioSource.loop = true; motorAudioSource.clip = this.motorClip; axleInfos = new List <AxleInfo>(2); // 前轮 转向轮 AxleInfo axleInfo = new AxleInfo(); axleInfo.leftWheel = m_tank.FindComponentInChildren <WheelCollider>("PhysicalBody/wheelL1"); axleInfo.rightWheel = m_tank.FindComponentInChildren <WheelCollider>("PhysicalBody/wheelR1"); axleInfo.montor = false; axleInfo.steering = true; this.axleInfos.Add(axleInfo); // 后轮 动力轮 axleInfo = new AxleInfo(); axleInfo.leftWheel = m_tank.FindComponentInChildren <WheelCollider>("PhysicalBody/wheelL2"); axleInfo.rightWheel = m_tank.FindComponentInChildren <WheelCollider>("PhysicalBody/wheelR2"); axleInfo.montor = true; axleInfo.steering = false; this.axleInfos.Add(axleInfo); }
public void Update() { ClientPredictionComponent clientPredictionComponent = Game.Scene.GetComponent <ClientPredictionComponent>(); UnitStateComponent unitStateComponent = this.Entity.GetComponent <UnitStateComponent>(); UnitState serverState; if (this.isLocal) { serverState = clientPredictionComponent.VerifyState; } else { //serverState = unitStateComponent.GetServerState(); serverState = unitStateComponent.State; } if (this.Instance == null && serverState.Frame > 0) { ResourcesComponent resourcesComponent = Game.Scene.GetComponent <ResourcesComponent>(); GameObject bundleGameObject = (GameObject)resourcesComponent.GetAsset("Unit.unity3d", "Unit"); GameObject prefab = bundleGameObject.Get <GameObject>("Skeleton"); GameObject instance = UnityEngine.Object.Instantiate(prefab); GameObject parent = GameObject.Find($"/Global/Unit"); instance.transform.SetParent(parent.transform, false); this.Instance = instance; this.anim = instance.GetComponent <Animator>(); if (this.isLocal) { ETModel.Game.Scene.AddComponent <CameraComponent>().Unit = this.Instance; } } else if (this.Instance != null) { if (this.isLocal) { this.State = clientPredictionComponent.PredictedState; } else { this.State = unitStateComponent.State; } UpdateInstance(); } }
public void Awake() { if (string.IsNullOrEmpty(abName)) { Log.Error(this.GetType() + "/Awake() 初始化Ui界面失败,Gobj为空!"); return; } //string bundleName = this.abName.ToLower(); string bundleName = abName; ResourcesComponent resourcesComponent = ETModel.Game.Scene.GetComponent <ResourcesComponent>(); resourcesComponent.LoadBundle($"{bundleName }.unity3d"); GameObject bundleGameObject = (GameObject)resourcesComponent.GetAsset($"{bundleName }.unity3d", $"{bundleName }"); GObj = UnityEngine.Object.Instantiate(bundleGameObject); InitUI(); }
public static GameObject Create(Vector3 pos) { // 创建爆炸效果 ResourcesComponent resourcesComponent = Game.Scene.GetComponent <ResourcesComponent>(); //resourcesComponent.LoadBundle(AssetBundleName.Unit); GameObject bundleGameObject = (GameObject)resourcesComponent.GetAsset(AssetBundleName.Unit, PrefabName.Unit); //resourcesComponent.UnloadBundle(AssetBundleName.Unit); GameObject explosion = bundleGameObject.Get <GameObject>(PrefabName.BulletBoomEffect); GameObject explosionGameObject = resourcesComponent.NewObj(PrefabType.BulletBoom, explosion); explosionGameObject.SetActive(false); explosionGameObject.transform.position = pos; // 创建爆炸音效 AudioClip audio = bundleGameObject.Get <AudioClip>(PrefabName.BulletBoomAudio); AudioSource audioSource = explosionGameObject.GetComponent <AudioSource>(); if (audioSource == null) { audioSource = explosionGameObject.AddComponent <AudioSource>(); audioSource.spatialBlend = 1; audioSource.loop = false; audioSource.clip = audio; audioSource.playOnAwake = true; audioSource.volume = GameSettingInfo.AudioVolume(); } explosionGameObject.SetActive(true); FairyGUI.Timers.inst.Add(7f, 1, (_) => { resourcesComponent.RecycleObj(PrefabType.BulletBoom, explosionGameObject); }); return(explosionGameObject); }
public static UI Create(string type, UI parent) { ResourcesComponent resourcesComponent = ETModel.Game.Scene.GetComponent <ResourcesComponent>(); resourcesComponent.LoadBundle($"{type}.unity3d"); GameObject prefab = (GameObject)resourcesComponent.GetAsset($"{type}.unity3d", $"{type}"); GameObject interaction = UnityEngine.Object.Instantiate(prefab); interaction.layer = LayerMask.NameToLayer("UI"); UI ui = ComponentFactory.Create <UI, GameObject>(interaction); parent.Add(ui); ui.GameObject.transform.SetParent(parent.GameObject.transform, false); ui.AddComponent <LandInteractionComponent>(); return(ui); }
public static UI Create() { try { ResourcesComponent resourcesComponent = ETModel.Game.Scene.GetComponent <ResourcesComponent>(); resourcesComponent.LoadBundle(UIType.UILobby.StringToAB()); GameObject bundleGameObject = (GameObject)resourcesComponent.GetAsset(UIType.UILobby.StringToAB(), UIType.UILobby); GameObject gameObject = UnityEngine.Object.Instantiate(bundleGameObject); UI ui = ComponentFactory.Create <UI, string, GameObject>(UIType.UILobby, gameObject, false); ui.AddComponent <UILobbyComponent>(); return(ui); } catch (Exception e) { Log.Error(e); return(null); } }
public static Unit Create(Entity domain, long id) { ResourcesComponent resourcesComponent = Game.Scene.GetComponent <ResourcesComponent>(); GameObject bundleGameObject = (GameObject)resourcesComponent.GetAsset("Unit.unity3d", "Unit"); GameObject prefab = bundleGameObject.Get <GameObject>("Skeleton"); UnitComponent unitComponent = Game.Scene.GetComponent <UnitComponent>(); GameObject go = UnityEngine.Object.Instantiate(prefab); Unit unit = EntityFactory.CreateWithId <Unit, GameObject>(domain, id, go); unit.AddComponent <AnimatorComponent>(); unit.AddComponent <MoveComponent>(); unit.AddComponent <TurnComponent>(); unit.AddComponent <UnitPathComponent>(); unitComponent.Add(unit); return(unit); }
public static Ship Create(long id) { ResourcesComponent resourcesComponent = Game.Scene.GetComponent <ResourcesComponent>(); GameObject bundleGameObject = (GameObject)resourcesComponent.GetAsset("Unit.unity3d", "Unit"); //GameObject prefab = bundleGameObject.Get<GameObject>("Skeleton"); GameObject prefab = bundleGameObject.Get <GameObject>("SpaceShip"); ShipComponent shipComponent = Game.Scene.GetComponent <ShipComponent>(); GameObject go = UnityEngine.Object.Instantiate(prefab); Ship ship = ComponentFactory.CreateWithId <Ship, GameObject>(id, go); //ship.AddComponent<AnimatorComponent>(); //ship.AddComponent<MoveComponent>(); //ship.AddComponent<TurnComponent>(); //ship.AddComponent<UnitPathComponent>(); shipComponent.Add(ship); return(ship); }
public static Unit Create(long id) { ResourcesComponent resourcesComponent = Game.Scene.GetComponent <ResourcesComponent>(); GameObject bundleGameObject = (GameObject)resourcesComponent.GetAsset("Unit.unity3d", "Unit"); GameObject prefab = bundleGameObject.Get <GameObject>("Skeleton"); UnitComponent unitComponent = Game.Scene.GetComponent <UnitComponent>(); Unit unit = ComponentFactory.CreateWithId <Unit>(id); unit.GameObject = UnityEngine.Object.Instantiate(prefab); GameObject parent = GameObject.Find($"/Global/Unit"); unit.GameObject.transform.SetParent(parent.transform, false); unit.AddComponent <AnimatorComponent>(); unit.AddComponent <MoveComponent>(); Debug.Log("create Skeleton"); unitComponent.Add(unit); return(unit); }
public UI Create() { try { ResourcesComponent res = ETModel.Game.Scene.GetComponent <ResourcesComponent>(); res.LoadBundle(UIType.UIHUDText.StringToAB()); GameObject bundleGameObject = res.GetAsset(UIType.UIHUDText.StringToAB(), UIType.UIHUDText) as GameObject; GameObject go = UnityEngine.Object.Instantiate(bundleGameObject); go.layer = LayerMask.NameToLayer(LayerNames.UI); UI ui = ComponentFactory.Create <UI, string, GameObject>(UIType.UIHUDText, go, false); var com = ui.AddComponent <UIHUDTextComponent>(); adapter = ui.AddComponent <UIHUDTextAdapterComponent>(); adapter.Init(com); return(ui); } catch (Exception e) { Log.Error(e); return(null); } }
public static GameObject CreateTankBoomEffect(Tank tank) { ResourcesComponent resourcesComponent = Game.Scene.GetComponent <ResourcesComponent>(); //resourcesComponent.LoadBundle(AssetBundleName.Unit); GameObject unit = (GameObject)resourcesComponent.GetAsset(AssetBundleName.Unit, PrefabName.Unit); //resourcesComponent.UnloadBundle(AssetBundleName.Unit); GameObject boomPrefab = unit.Get <GameObject>(PrefabName.TankBoomEffect); UnityEngine.GameObject boomEffect = resourcesComponent.NewObj(PrefabType.TankBoom, boomPrefab); boomEffect.transform.SetParent(tank.GameObject.FindComponentInChildren <Transform>("BoomEffect"), false); boomEffect.transform.localPosition = Vector3.zero; boomEffect.transform.localScale = Vector3.one * 10; return(boomEffect); }
public static Unit Create(long id, int typeId, UnitData unitData) { ResourcesComponent resourcesComponent = Game.Scene.GetComponent <ResourcesComponent>(); UnitConfig unitConfig = Game.Scene.GetComponent <ConfigComponent>().Get(typeof(UnitConfig), typeId) as UnitConfig; resourcesComponent.LoadBundle(unitConfig.ABPacketName.ToLower().StringToAB()); GameObject bundleGameObject = (GameObject)resourcesComponent.GetAsset(unitConfig.ABPacketName.ToLower().StringToAB(), unitConfig.ABPacketName); UnitComponent unitComponent = Game.Scene.GetComponent <UnitComponent>(); GameObject go = UnityEngine.Object.Instantiate(bundleGameObject); Unit unit = ComponentFactory.CreateWithId <Unit, GameObject>(id, go); unit.AddComponent <NumericComponent, int>(typeId); unit.AddComponent <AnimatorComponent>(); unit.AddComponent <UnitStateComponent>(); unit.AddComponent <UnitPathComponent>(); unit.AddComponent <AudioComponent>(); unit.AddComponent <BuffMgrComponent>(); var activeSkillCom = unit.AddComponent <ActiveSkillComponent>(); var passiveSkillCom = unit.AddComponent <PassiveSkillComponent>(); unit.AddComponent <SkillEffectComponent>(); if (!GlobalConfigComponent.Instance.networkPlayMode) { //添加碰撞体 AddCollider(unit, unitData, true); } unit.AddComponent <CharacterStateComponent>(); unit.AddComponent <CharacterMoveComponent>(); if (!Game.Scene.GetComponent <GlobalConfigComponent>().networkPlayMode) { unit.AddComponent <CalNumericComponent>(); } if (unitConfig.Skills != null && unitConfig.Skills.Length > 0) { SkillConfigComponent skillConfigComponent = Game.Scene.GetComponent <SkillConfigComponent>(); foreach (var v in unitConfig.Skills) { if (string.IsNullOrEmpty(v)) { continue; } var activeSkill = skillConfigComponent.GetActiveSkill(v); if (activeSkill != null) { Log.Debug(string.Format("{0} 添加主动技能 {1} ({2})成功!", typeId, v, activeSkill.skillName)); activeSkillCom.AddSkill(v); continue; } var passiveSkill = skillConfigComponent.GetPassiveSkill(v); if (passiveSkill != null) { Log.Debug(string.Format("{0} 添加被动技能 {1} ({2})成功!", typeId, v, passiveSkill.skillName)); passiveSkillCom.AddSkill(v); continue; } Log.Error(v + " 这样的技能不存在!"); } } //unit.AddComponent<TurnComponent>(); unitComponent.Add(unit); return(unit); }
public static Tank Create(TankInfoFirstEnter firstInfo, Vector3 Pos, Vector3 Rot) { long id = firstInfo.TankFrameInfo.TankId; ResourcesComponent resourcesComponent = Game.Scene.GetComponent <ResourcesComponent>(); //Game.Scene.GetComponent<ResourcesComponent>().LoadBundle($"Unit.unity3d"); GameObject bundleGameObject = (GameObject)resourcesComponent.GetAsset(AssetBundleName.Unit, PrefabName.Unit); //Game.Scene.GetComponent<ResourcesComponent>().UnloadBundle($"Unit.unity3d"); GameObject prefab = bundleGameObject.Get <GameObject>(PrefabName.Tank); TankComponent tankComponent = Game.Scene.GetComponent <TankComponent>(); Tank tank = ComponentFactory.CreateWithId <Tank>(id); tank.GameObject = resourcesComponent.NewObj(PrefabType.Tank, prefab); tank.GameObject.transform.position = Pos; tank.GameObject.transform.eulerAngles = Rot; GameObject parent = GameObject.Find($"/Global/Unit"); tank.GameObject.transform.SetParent(parent.transform, false); NumericComponent numericComponent = tank.AddComponent <NumericComponent>(); tank.Name = firstInfo.Name; tank.TankCamp = firstInfo.TankCamp; if (id == 10000 || PlayerComponent.Instance.MyPlayer.TankId == id) { tank.TankType = TankType.Local; tank.AddComponent <TankMoveComponent>(); tank.AddComponent <CameraComponent>(); tank.AddComponent <TurretComponent>(); // 子弹管理组件 tank.AddComponent <BulletComponent>(); // 发射子弹的组件 tank.AddComponent <TankShootComponent>(); tank.AddComponent <LocalTankComponent>(); tankComponent.MyTank = tank; // 如果是自己设置层级为9,为了让坦克不打中自己 Utility.ChangeLayer(tank.GameObject, LayerNames.OwnTank); tank.GameObject.layer = 9; } else { tank.TankType = TankType.Remote; tank.AddComponent <RemoteTankComponent>(); tank.AddComponent <TurretComponent>(); tank.AddComponent <TankShootComponent>(); tank.AddComponent <BulletComponent>(); tank.AddComponent <OverHeadComponent>(); } tankComponent.Add(tank); // 先将坦克加入TankComponent再赋值,因为赋值的时候会触发事件,事件中可能要从TankComponent中取坦克 numericComponent[NumericType.MaxHpBase] = firstInfo.MaxHpBase; numericComponent[NumericType.HpBase] = firstInfo.HpBase; numericComponent[NumericType.AtkBase] = firstInfo.AtkBase; return(tank); }
public void Awake() { Type[] types = typeof(NodeType).Assembly.GetTypes(); foreach (Type type in types) { if (type.IsSubclassOf(typeof(NP_NodeDataBase)) || type.IsSubclassOf(typeof(NP_ClassForStoreAction)) || type.IsSubclassOf(typeof(BuffNodeDataBase)) || type.IsSubclassOf(typeof(BuffDataBase)) || type.IsSubclassOf(typeof(ListenBuffEvent_Normal)) || type.IsSubclassOf(typeof(NP_DataSupportorBase))) { BsonClassMap.LookupClassMap(type); } } BsonClassMap.LookupClassMap(typeof(NP_BBValue_Int)); BsonClassMap.LookupClassMap(typeof(NP_BBValue_Bool)); BsonClassMap.LookupClassMap(typeof(NP_BBValue_Float)); BsonClassMap.LookupClassMap(typeof(NP_BBValue_String)); BsonClassMap.LookupClassMap(typeof(NP_BBValue_Vector3)); BsonClassMap.LookupClassMap(typeof(NP_BBValue_Long)); BsonClassMap.LookupClassMap(typeof(NP_BBValue_List_Long)); #if SERVER DirectoryInfo directory = new DirectoryInfo(NPDataPath); FileInfo[] fileInfos = directory.GetFiles(); foreach (var fileInfo in fileInfos) { byte[] mfile = File.ReadAllBytes(fileInfo.FullName); if (mfile.Length == 0) { Log.Info("没有读取到文件"); } try { NP_DataSupportor MnNpDataSupportor = BsonSerializer.Deserialize <NP_DataSupportor>(mfile); Log.Info($"反序列化行为树:id:{MnNpDataSupportor.NpDataSupportorBase.RootId} {fileInfo.FullName}完成"); m_NpRuntimeTreesDatas.Add(MnNpDataSupportor.NpDataSupportorBase.RootId, MnNpDataSupportor); } catch (Exception e) { Console.WriteLine(e); throw; } } #else ResourcesComponent resourcesComponent = Game.Scene.GetComponent <ResourcesComponent>(); resourcesComponent.LoadBundle("skillconfigs.unity3d"); GameObject skillConfigs = (GameObject)resourcesComponent.GetAsset("skillconfigs.unity3d", "SkillConfigs"); foreach (var referenceCollectorData in skillConfigs.GetComponent <ReferenceCollector>().data) { TextAsset textAsset = skillConfigs.GetTargetObjectFromRC <TextAsset>(referenceCollectorData.key); if (textAsset.bytes.Length == 0) { Log.Info("没有读取到文件"); } try { NP_DataSupportor MnNpDataSupportor = BsonSerializer.Deserialize <NP_DataSupportor>(textAsset.bytes); Log.Info($"反序列化行为树:{referenceCollectorData.key}完成"); this.m_NpRuntimeTreesDatas.Add(MnNpDataSupportor.NpDataSupportorBase.RootId, MnNpDataSupportor); } catch (Exception e) { Log.Error(e); throw; } } #endif }