You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
172 lines
6.3 KiB
172 lines
6.3 KiB
4 years ago
|
using AX.DevelopEngine;
|
||
|
using System;
|
||
|
using System.Collections;
|
||
|
using UnityEngine;
|
||
|
|
||
|
//Author: ZCG
|
||
|
/// <summary>资源管理</summary>
|
||
|
public class ResManage : MonoSingleton<ResManage>
|
||
|
{
|
||
|
public enum WaterType : int
|
||
|
{
|
||
|
/// <summary>
|
||
|
/// 空值
|
||
|
/// </summary>
|
||
|
None = 0,
|
||
|
/// <summary>
|
||
|
/// 直流水
|
||
|
/// </summary>
|
||
|
StraightStreamWater = 1,//
|
||
|
/// <summary>
|
||
|
/// 开花水
|
||
|
/// </summary>
|
||
|
BloomStreamWater = 2,//
|
||
|
/// <summary>
|
||
|
/// 喷雾水
|
||
|
/// </summary>
|
||
|
SprayStreamWater = 3,//
|
||
|
/// <summary>
|
||
|
/// 泡沫
|
||
|
/// </summary>
|
||
|
BubbleWater = 4,//
|
||
|
/// <summary>
|
||
|
/// 干粉
|
||
|
/// </summary>
|
||
|
DryPowder = 5//
|
||
|
}
|
||
|
private GameObject clone;
|
||
|
/// <summary>资源加载</summary>
|
||
|
/// <param name="loadPath">资源所在的路径</param>
|
||
|
/// <param name="ParentPos">加载后的父物体位置</param>
|
||
|
public void ResourcesLoad(string loadPath, Transform ParentPos, float scale = 0f)
|
||
|
{
|
||
|
//StartCoroutine(LoadAssetBundles.getInstance().LoadAssetByName<GameObject>(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<ParticleControlOfType>().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<ParticleControlOfType>().SetScaleValue(Scale);
|
||
|
}
|
||
|
private string particlePath = "assets/prefabs/prefabs/particle/";//粒子系统所在路径下的名字
|
||
|
private float Scale;
|
||
|
|
||
|
/// <summary>根据枚举加载粒子系统</summary>
|
||
|
/// <param name="particleName">根据需要的粒子选择对应的枚举</param>t
|
||
|
/// <param name="ParentPos">消防员/车辆的位置</param>
|
||
|
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);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
/// <summary>根据字符串加载粒子系统</summary>
|
||
|
/// <param name="TaskNameText">TaskName.text</param>
|
||
|
/// <param name="ParnetPos">消防员/车辆的位置</param>
|
||
|
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;
|
||
|
}
|
||
|
|
||
|
}
|
||
|
/// <summary>根据WaterType选择加载的特效</summary>
|
||
|
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;
|
||
|
}
|
||
|
}
|
||
|
/// <summary>销毁游戏物体下名字为**的所有子物体</summary>
|
||
|
/// <param name="ParentObj">游戏物体</param>
|
||
|
/// <param name="childName">该游戏物体下的孩子名称</param>
|
||
|
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);
|
||
|
}
|
||
|
}
|