Created
December 3, 2014 00:30
-
-
Save EsProgram/d08303cca0af63586375 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 System.Linq; | |
using UnityEngine; | |
public class Sin_Expr : MonoBehaviour | |
{ | |
[SerializeField] | |
private GameObject ball = default(GameObject); | |
[SerializeField] | |
private float speed = default(float); | |
private GameObject[] circles = new GameObject[instans_num]; | |
private bool isExpr; | |
private const int instans_num = 50; | |
private int count = 0; | |
private int instantiate_flame = 0; | |
[SerializeField] | |
private Direction dir = Direction.Right; | |
private enum Direction | |
{ | |
Left = -1, | |
Right = 1, | |
} | |
private void Update() | |
{ | |
if(Random.Range(0, 90) == 0 || isExpr) | |
{ | |
++instantiate_flame; | |
if(!isExpr) | |
{ | |
isExpr = true; | |
} | |
if(count < instans_num) | |
{ | |
if(instantiate_flame < 10) | |
{ | |
circles[count] = Instantiate(ball, transform.position, Quaternion.identity) as GameObject; | |
MoveBall move = circles[count++].GetComponent<MoveBall>(); | |
int param = default(int); | |
while(param == 0) | |
param = Random.Range(-5, 5); | |
move.StartMove(Move, param); | |
instantiate_flame = 0; | |
} | |
} | |
else | |
{ | |
isExpr = false; | |
count = 0; | |
} | |
} | |
} | |
private void Move(Transform tr, object param) | |
{ | |
tr.Translate(speed * (int)dir * Time.deltaTime, (int)param * Mathf.Sin(tr.position.x) * speed * Time.deltaTime, 0); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment