2using System.Collections.Generic;
8 public List<Popper>
list =
new List<Popper>();
10 public Popper Pop(Vector3 pos,
string id, Sprite sprite)
13 popper.sr.sprite = sprite;
17 public Popper Pop(Vector3 pos,
string id =
"Default")
19 return Pop(pos,
null,
id);
22 public Popper Pop(Func<Vector3> func,
string id =
"Default")
24 return Pop(func(), func,
id);
27 public Popper Pop(Vector3 pos, Func<Vector3> func,
string id =
"Default")
30 p.SetActive(enable:
true);
33 p.anime.transform.localPosition =
new Vector3(p.
posFix.x + p.
posRandom.x * UnityEngine.Random.Range(-1f, 1f), p.
posFix.y + p.
posRandom.y * UnityEngine.Random.Range(-1f, 1f), p.
posFix.z - 0.01f * (
float)
list.Count);
37 p.anime.transform.position =
new Vector3(pos.x + p.
posFix.x + p.
posRandom.x * UnityEngine.Random.Range(-1f, 1f), pos.y + p.
posFix.y + p.
posRandom.y * UnityEngine.Random.Range(-1f, 1f), pos.z + p.
posFix.z - 0.01f * (
float)
list.Count);
39 p.
anime.onComplete.AddListener(delegate
45 p.
anime.onUpdate.AddListener(delegate
47 p.transform.position = func();
50 DOTweenAnimation[] componentsInChildren = p.GetComponentsInChildren<DOTweenAnimation>();
51 for (
int i = 0; i < componentsInChildren.Length; i++)
53 componentsInChildren[i].DORestart(fromHere:
true);
65 p.
anime.onComplete.RemoveAllListeners();
66 if (p.
anime.onUpdate !=
null)
68 p.
anime.onUpdate.RemoveAllListeners();
70 if (p.
anime.onPlay !=
null)
72 p.
anime.onPlay.RemoveAllListeners();
static void Despawn(Component c)
static Transform Spawn(string id, string path, Transform parent)
void Kill(Popper p, bool removeFromList=true)
Popper Pop(Vector3 pos, string id, Sprite sprite)
Popper Pop(Vector3 pos, string id="Default")
Popper Pop(Func< Vector3 > func, string id="Default")
Popper Pop(Vector3 pos, Func< Vector3 > func, string id="Default")