using System; using System.Collections.Generic; using UnityEngine; public class ProjectileInfo : MonoBehaviour { public static ProjectileInfo Ins; public Material[] arr_materials; // 0 얼음, 1 히트 Dictionary> dic_projectile = new Dictionary>(); private void Awake() { Ins = this; } private void Start() { var lst = table_effectlist.Ins.Get_DataList(2); for (int i = 0; i < lst.Count; i++) { dic_projectile.Add(lst[i].s_EffectPrefab, new List()); for (int j = 0; j < lst[i].n_PreLoadCount; j++) Load_Projectile(true, lst[i].s_EffectPrefab, null); } } void Load_Projectile(bool loadFirst, string projectile, Action act) { AddrResourceMgr.Ins.LoadObject($"Assets/Res_Addr/Projectile/{projectile}.prefab", handle => { var temp = DSUtil.Get_Clone(handle.Result, transform); if (!loadFirst) temp.Off_FisrLoad(); dic_projectile[projectile].Add(temp); act?.Invoke(temp); }); } void Get_Projectile(string projectile, Action act) { if (!dic_projectile.ContainsKey(projectile)) dic_projectile.Add(projectile, new List()); for (int i = 0; i < dic_projectile[projectile].Count; i++) { if (!dic_projectile[projectile][i].gameObject.activeInHierarchy) { act?.Invoke(dic_projectile[projectile][i]); return; } } Load_Projectile(true, projectile, act); } public void Shoot_Projectile(string projectile, Actor shooter, Actor target, float adddmgrate = 1f, Vector3? startpos = null, float liftTime = 4f, float skilldmg = 1f) { Get_Projectile(projectile, proj => { if (!DSUtil.CheckNull(startpos)) proj.Set(new ProjectileData { shooter = shooter, target = target, HitDamage = adddmgrate, eStartPos = eProjectileStartPos.Custom, v3_StartPos = startpos.Value, LifeTime = liftTime, LookTarget = true }); else proj.Set(new ProjectileData { shooter = shooter, target = target, HitDamage = adddmgrate, eStartPos = eProjectileStartPos.ShooterCenter, LifeTime = liftTime }); }); } public void Shoot_Projectile(string projectile, ProjectileData pd, Action act = null) { Get_Projectile(projectile, proj => { if (!DSUtil.CheckNull(proj)) { proj.Set(pd); act?.Invoke(proj); } }); } }