void Start() { GameObject pixel_res = Resources.Load("spirit") as GameObject; for (int i = 0; i <= 1; i++) { GameObject pixel = Instantiate(pixel_res) as GameObject; particle particle = pixel.GetComponent <particle> (); int size = (int)(Random.value * 3) + 1; pixel.transform.localScale = new Vector2(size, size); int life_time = (int)(100 * Random.value + 100); int wait_time = (int)(5 * Random.value); particle.init(life_time, wait_time, new Color(1f, 0.259f, 0, 1), new Color(0, 0, 0, 0)); particle.set_gravity(0.05f * (Random.value * 2 - 1)); particle.set_speed(new Vector2(Random.value * 0.5f * transform.localScale.x, Random.value * 0.5f)); if (transform.parent != null) { particle.set_target(transform.parent.gameObject); } else { particle.set_target(null); } } Destroy(transform.gameObject); }
void Start() { GameObject pixel_res = Resources.Load("pixel") as GameObject; for (int i = 0; i <= 50; i++) { GameObject pixel = Instantiate(pixel_res) as GameObject; particle particle = pixel.GetComponent <particle> (); int size = (int)(Random.value * 3) + 1; pixel.transform.localScale = new Vector2(size, size); int life_time = (int)(60 * Random.value + 60); int wait_time = (int)(15 * Random.value); float speed = 3.5f; Vector2 speed2 = new Vector2(Random.value * 2 - 1, Random.value * 2 - 1).normalized *speed; particle.init(life_time, wait_time, new Color(1, 0.8978f, 0, 1), new Color(1f, 0.259f, 0, 1)); particle.set_gravity(0.05f * (Random.value * 2 - 1) + 0.8f); particle.set_speed(speed2); particle.set_target(transform.parent.gameObject); particle.set_position_miu(transform.localPosition); } Destroy(transform.gameObject); }
void Update() { if (is_active) { wait--; if (wait < 0) { if (transform.parent != null && transform.parent.gameObject != null) { GameObject pixel_res = Resources.Load("pixel") as GameObject; for (int i = 0; i <= 1; i++) { GameObject pixel = Instantiate(pixel_res) as GameObject; particle particle = pixel.GetComponent <particle> (); int size = (int)(Random.value * 2) + 1; pixel.transform.localScale = new Vector2(size, size); int life_time = (int)(20 * Random.value + 20); int wait_time = (int)(2 * Random.value); particle.init(life_time, wait_time, new Color(1, 1, 1, 1), new Color(1, 1, 1, 0)); particle.set_speed(random_vector(direction2) * (Random.value * 8 + 8)); particle.set_gravity(0.05f * (Random.value * 2 - 1) + 0.1f); particle.set_target(transform.parent.gameObject); } for (int i = 0; i <= 3; i++) { GameObject pixel = Instantiate(pixel_res) as GameObject; particle particle = pixel.GetComponent <particle> (); int size = (int)(Random.value * 2) + 1; pixel.transform.localScale = new Vector2(size, size); int life_time = (int)(35 * Random.value + 35); int wait_time = (int)(2 * Random.value); particle.init(life_time, wait_time, new Color(1, 1, 1, 1), new Color(1, 1, 1, 0)); particle.set_speed(random_vector(direction2) * (Random.value * 4 + 4)); particle.set_gravity(0.05f * (Random.value * 2 - 1) + 1.5f); particle.set_target(transform.parent.gameObject); } Destroy(transform.gameObject); } } } }