// Use this for initialization void Awake() { projectileParentPoolInstance = this; GameObject[] objects = GameObject.FindGameObjectsWithTag("ProjectileParent"); foreach (GameObject obj in objects) { obj.SetActive(false); unactiveObjects.Add(obj); } }
public void ReturnObjToSpell(GameObject obj) { obj.SetActive(false); foreach (Transform child in obj.transform) { child.gameObject.SetActive(false); } if (returned) { //Debug.LogError("THIS IS WRONG"); ProjectileParentPool.Give(obj); foreach (Transform child in obj.transform) { child.parent = ProjectilePool.projectilePoolInstance.transform; ProjectilePool.Give(child.gameObject); } } else { openObjs[obj.GetComponent <ProjectileController>().spellSeg].Add(obj); } }
public void ReturnProj() { returned = true; foreach (KeyValuePair <SpellCreationSegment, List <GameObject> > entry in openObjs) { foreach (GameObject obj in entry.Value) { ProjectileParentPool.Give(obj); List <Transform> objectsToReparent = new List <Transform>(); foreach (Transform child in obj.transform) { objectsToReparent.Add(child); } foreach (Transform t in objectsToReparent) { t.parent = ProjectilePool.projectilePoolInstance.transform; ProjectilePool.Give(t.gameObject); } } } openObjs.Clear(); }
// Check out and init projectiles foreach seg void CheckOutProj(ProjectileSpellBookBuilder builder) { foreach (SpellCreationSegment seg in builder.GetSpellSegs()) { List <GameObject> gameObjs = new List <GameObject>(); for (int i = 0; i < 15; i++) { GameObject projParent = ProjectileParentPool.Take(); if (builder.trigger == ProjectileSpellBookBuilder.EventTrigger.Proximity) { projParent.GetComponent <Trigger>().active = true; projParent.GetComponent <Trigger>().spellEvent = builder.spellEvent; } foreach (SpellPixelFinal spf in seg.GetPixels()) { GameObject projPixel = ProjectilePool.Take(); projPixel.transform.parent = projParent.transform; projPixel.transform.localPosition = Vector2.zero + spf.m_position * .25f; projPixel.transform.rotation = Quaternion.identity; projPixel.GetComponent <SpriteRenderer>().color = spf.m_ink.GetColor(); ProjectileCollision projCollision = projPixel.GetComponent <ProjectileCollision>(); projCollision.caster = caster; projCollision.priority = spf.m_ink.GetPriority(); projCollision.spellCollisionBehaviour = spf.m_ink.GetOnSpellCollisionEffect(); projCollision.damage = spf.damage; projCollision.damageBehaviour = spf.m_ink.GetOnHitEffect(); projCollision.backGroundCollisionBehaviour = builder.lang.GetCollisionBehaviour(); } projParent.GetComponent <ProjectileController>().SetProjectile(seg, this); gameObjs.Add(projParent); projParent.SetActive(false); } openObjs.Add(seg, gameObjs); } }