public void makeWeaponShot(MissileSource source) { for (int i = 0; i < weapons.Length; ++i) { if (weapons[i].makeShot()) { MissilePool.FireMissile(weapons[i].damage, transform.position + weapons[i].shotPositionOffset, weapons[i].missileSpeed, weapons[i].shotDirection, source, weapons[i].missileType); } } }
public void Initialize(Damage damage, Vector3 pos, float speed, Vector2 dir, MissileSource source, MissileType type) { transform.position = pos; this.speed = speed; this.direction = dir; this.lifetime = 0.0f; this.source = source; this.type = type; this.damage = damage; gameObject.SetActive(true); spriteRenderer.enabled = true; collider.enabled = true; audioSource.PlayOneShot(shot_sound); }
public void fireMissile(Damage damage, Vector3 pos, float speed, Vector2 direction, MissileSource source, MissileType type) { for (int i = 0; i < missiles.Count; ++i) { if (!goList[i].activeSelf) { goList[i].SetActive(true); missiles[i].Initialize(damage, pos, speed, direction, source, type); return; } } if (isExtendAllowed) { //extend the pool goList.Add(GameObject.Instantiate(prefabMissile) as GameObject); int idx = goList.Count - 1; missiles.Add(goList[idx].GetComponent<Missile>()); goList[idx].transform.parent = goList[0].transform.parent ; goList[idx].SetActive(true); missiles[idx].Initialize(damage, pos, speed, direction, source, type); } }
public static void FireMissile(Damage damage, Vector3 pos, float speed, Vector2 direction, MissileSource source, MissileType type) { int idx = -1; instance.poolMap.TryGetValue(type, out idx); instance.pools[idx].fireMissile(damage, pos, speed, direction, source, type); }