public static UI Create() { try { ResourcesComponent resourcesComponent = ETModel.Game.Scene.GetComponent <ResourcesComponent>(); resourcesComponent.LoadBundle(UIType.UILogin.StringToAB()); GameObject bundleGameObject = (GameObject)resourcesComponent.GetAsset(UIType.UILogin.StringToAB(), UIType.UILogin); GameObject gameObject = UnityEngine.Object.Instantiate(bundleGameObject); UI ui = ComponentFactory.Create <UI, string, GameObject>(UIType.UILogin, gameObject, false); ui.AddComponent <UILoginComponent>(); return(ui); } catch (Exception e) { Log.Error(e); return(null); } }
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 Unit Create(long id) { ResourcesComponent resourcesComponent = Game.Scene.GetComponent <ResourcesComponent>(); resourcesComponent.LoadBundle("Unit.unity3d"); 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>(); unitComponent.Add(unit); return(unit); }
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 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 }