using AX.DevelopEngine; using System; using System.Collections; using UnityEngine; //Author: ZCG /// 资源管理 public class ResManage : MonoSingleton { public enum WaterType : int { /// /// 空值 /// None = 0, /// /// 直流水 /// StraightStreamWater = 1,// /// /// 开花水 /// BloomStreamWater = 2,// /// /// 喷雾水 /// SprayStreamWater = 3,// /// /// 泡沫 /// BubbleWater = 4,// /// /// 干粉 /// DryPowder = 5// } private GameObject clone; /// 资源加载 /// 资源所在的路径 /// 加载后的父物体位置 public void ResourcesLoad(string loadPath, Transform ParentPos, float scale = 0f) { //StartCoroutine(LoadAssetBundles.getInstance().LoadAssetByName(loadPath, (obj) => //{ // clone = Instantiate(obj); // DesChilds(ParentPos); // clone.transform.parent = ParentPos; // clone.transform.localPosition = Vector3.zero; // clone.transform.localRotation = Quaternion.Euler(Vector3.zero); // clone.transform.localScale = new Vector3(1, 1, 1); // var Scale = scale == 0f ? this.Scale : scale; // clone.GetComponentInChildren().SetScaleValue(Scale); //})); // clone = ObjectPool.Instance.GetObjByName(loadPath); DesChilds(ParentPos); clone = Instantiate(Resources.Load(loadPath)) as GameObject; clone.transform.parent = ParentPos; clone.transform.localPosition = Vector3.zero; clone.transform.localRotation = Quaternion.Euler(Vector3.zero); clone.transform.localScale = new Vector3(1, 1, 1); clone.GetComponentInChildren().SetScaleValue(Scale); } private string particlePath = "assets/prefabs/prefabs/particle/";//粒子系统所在路径下的名字 private float Scale; /// 根据枚举加载粒子系统 /// 根据需要的粒子选择对应的枚举t /// 消防员/车辆的位置 public void LoadParticleInEnum(ParticleEnum particleName, Transform ParentPos, float scale = 0f) { switch (particleName) { case ParticleEnum.WaterStraight://根据枚举选择加载的粒子 particlePath = "WaterStraight";//粒子系统的名称 Scale = 1f;//.3 break; case ParticleEnum.WaterFlower: particlePath = "WaterFlower"; Scale = 3f; break; case ParticleEnum.WaterFog: particlePath = "WaterFog"; Scale = 5f; break; case ParticleEnum.Froth: particlePath = "Froth"; Scale = 6f;//5 break; case ParticleEnum.DryPowder: particlePath = "DryPowder"; Scale = 1f; break; case ParticleEnum.Decontamination: particlePath = "Decontamination"; Scale = 3f; break; case ParticleEnum.None: particlePath = ""; break; } Scale = scale == 0 ? Scale : scale; if (particleName!=ParticleEnum.None) { ResourcesLoad("Prefab/Particle/" + particlePath, TransformHelper.FindChild(ParentPos, "Hose"), scale); } } /// 根据字符串加载粒子系统 /// TaskName.text /// 消防员/车辆的位置 public void LoadParticleInStr(string TaskNameText, Transform ParentPos) { switch (TaskNameText) { case "直流": LoadParticleInEnum(ParticleEnum.WaterStraight, ParentPos); break; case "开花": case "洗消": LoadParticleInEnum(ParticleEnum.WaterFlower, ParentPos); break; case "喷雾": LoadParticleInEnum(ParticleEnum.WaterFog, ParentPos); break; case "泡沫灭火": LoadParticleInEnum(ParticleEnum.Froth, ParentPos); break; case "干粉灭火": LoadParticleInEnum(ParticleEnum.DryPowder, ParentPos); break; } } /// 根据WaterType选择加载的特效 public void LoadParticleInWaterType(WaterType waterType, Transform ParentPos) { //DesChilds(ParentPos.gameObject, "Hose"); switch (waterType) { case WaterType.StraightStreamWater: LoadParticleInEnum(ParticleEnum.WaterStraight, ParentPos); break; case WaterType.BloomStreamWater: LoadParticleInEnum(ParticleEnum.WaterFlower, ParentPos); break; case WaterType.SprayStreamWater: LoadParticleInEnum(ParticleEnum.WaterFog, ParentPos); break; case WaterType.BubbleWater: LoadParticleInEnum(ParticleEnum.Froth, ParentPos); break; case WaterType.DryPowder: LoadParticleInEnum(ParticleEnum.DryPowder, ParentPos); break; } } /// 销毁游戏物体下名字为**的所有子物体 /// 游戏物体 /// 该游戏物体下的孩子名称 public void DesChilds(Transform Parent) { //找到所有childName的子物体并销毁他 // var Parent = TransformHelper.FindChild(ParentObj.gameObject.transform, childName); //for (int i = 0; i < Parent.childCount; i++) //{ // ObjectPool.Instance.RecycleObj(Parent.GetChild(i).gameObject); //} TransformHelper.DelChilds(Parent); } }