Created
December 3, 2014 00:28
-
-
Save EsProgram/32d111c1d944f26804b0 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 Circle_Expr : MonoBehaviour | |
{ | |
[SerializeField] | |
private GameObject ball = default(GameObject); | |
[SerializeField] | |
private float speed = default(float); | |
private class Param | |
{ | |
internal int i; | |
internal int add_deg; | |
} | |
private void Update() | |
{ | |
if(Random.Range(0, 90) == 0) | |
{ | |
int exp_num = Random.Range(6, 20); | |
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; | |
moveBall[i] = circle[i].GetComponent<MoveBall>(); | |
//移動アルゴリズムを調整テスト | |
moveBall[i].StartMove(((tr, _param) => | |
{ | |
Param p = (Param)_param; | |
float rad = (p.add_deg + 360 / exp_num * p.i) * Mathf.Deg2Rad; | |
tr.Translate(Mathf.Cos(rad) * Time.deltaTime * speed, Mathf.Sin(rad) * Time.deltaTime * speed, 0); | |
}), (object)param); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment