Created
December 3, 2014 00:29
-
-
Save EsProgram/263894de068e02cd82b2 to your computer and use it in GitHub Desktop.
偶然出来上がった産物
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Collections; | |
using UnityEngine; | |
public class Gero : MonoBehaviour | |
{ | |
[SerializeField] | |
private GameObject ball = default(GameObject); | |
[SerializeField] | |
private float speed = default(float); | |
[SerializeField] | |
private float geroSpeed = default(float); | |
private class Param | |
{ | |
internal int i; | |
internal int add_deg; | |
} | |
private void Update() | |
{ | |
if(Random.Range(0, 300) == 0) | |
{ | |
int exp_num = Random.Range(30, 50); | |
GameObject[] circle = new GameObject[exp_num]; | |
MoveBall[] moveBall = new MoveBall[exp_num]; | |
int add_deg = Random.Range(1, 360); | |
for(int i = 0; i < exp_num; ++i) | |
{ | |
Param param = new Param(); | |
param.i = i; | |
param.add_deg = add_deg; | |
circle[i] = Instantiate(ball, transform.position, Quaternion.identity) as GameObject; | |
circle[i].AddComponent<TimeDestroy>().SetTime(Random.Range(1, 10)); | |
moveBall[i] = circle[i].GetComponent<MoveBall>(); | |
moveBall[i].StartMove(((tr, _param) => | |
{ | |
Param p = (Param)_param; | |
float rad = Random.Range(0, 360) + (p.add_deg + 360 / exp_num * p.i) * Mathf.Deg2Rad; | |
tr.Translate(Mathf.Cos(rad) * Time.deltaTime * speed, Mathf.Sin(rad) * Time.deltaTime * speed - geroSpeed * Time.deltaTime, 0); | |
}), (object)param); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment