// public int MaxBullet { // get { return this.maxBullet; } // } // Use this for initialization void Start() { maxBullet = this.MAXBULLET; // 弾幕の登録 this.funcTables = new DanmakuFunc[4]; this.funcTables[0] = this.Func00; this.funcTables[1] = this.Func01; this.funcTables[2] = this.Func02; this.funcTables[3] = this.Func03; bulletList = new List <BulletWebGL> (); bulletList.Clear(); for (int i = 0; i < maxBullet; i++) { EnemyWebGL.bullet = Instantiate(this.bulletPrefab[0], this.transform.position, Quaternion.identity) as BulletWebGL; bulletList.Add(EnemyWebGL.bullet); } this.currentFuncIndex = 3; this.transformComponent = this.GetComponent <Transform> (); this.lua = new LuaEnv(); this.luaScript = new TextAsset(); this.luaScript = Resources.Load("test.lua", typeof(TextAsset)) as TextAsset; }
private void Func02() { if (frameCount % 4 == 0) { // 弾の生成 float col = 0.5f + 0.1f * Mathf.Sin(frameCount / 10.0f); for (int y = 0; y < 3; y++) { for (int x = 0; x < 6; x++) { bullet = Instantiate(this.bulletPrefab[0], this.transform.position, Quaternion.identity); bullet.SetAngle(6.28f / 6 * x + Mathf.Sin(frameCount / 16.0f) * 6.28f / 12, 6.28f / 16 * 5); bullet.SetSpeed(0.07f - 0.015f * y); bullet.accel.Set(0, -0.0003f, 0); bullet.SetColor(Color.HSVToRGB(col, 0.5f, 0.6f)); bulletList.Add(bullet); } } } int count = bulletList.Count; for (int i = count - 1; i >= 0; i--) { bulletList[i].velocity += bulletList[i].accel; bulletList[i].Move(); this.pos = bulletList[i].transform.position; if (this.pos.x < -10 || this.pos.x > 10 || this.pos.y < -10 || this.pos.y > 10 || this.pos.z < -10 || this.pos.z > 10) { Destroy(bulletList[i].gameObject); bulletList.Remove(bulletList[i]); } } }
private void Func01() { if (frameCount % 180 == 1) { // 弾の生成 float angle1 = Random.Range(0, 360); float angle2 = Random.Range(0, 360); float angle3 = Random.Range(0, 360); float col = Random.Range(0, 1.0f); for (int y = 0; y < 64; y++) { for (int x = 0; x < 32; x++) { bullet = Instantiate(this.bulletPrefab[0], this.transform.position, Quaternion.identity); bullet.SetAngle(6.28f / 64 * x, 6.28f / 64 * y); bullet.velocity = Quaternion.Euler(angle1, angle2, angle3) * bullet.velocity; bullet.SetColor(Color.HSVToRGB(col, 0.5f, 0.6f)); bulletList.Add(bullet); } } } int count = bulletList.Count; for (int i = count - 1; i >= 0; i--) { bulletList[i].Move(); this.pos = bulletList[i].transform.position; if (this.pos.x < -10 || this.pos.x > 10 || this.pos.y < -10 || this.pos.y > 10 || this.pos.z < -10 || this.pos.z > 10) { Destroy(bulletList[i].gameObject); bulletList.Remove(bulletList[i]); } } }
// 弾幕 private void Func00() { if (frameCount % 2 == 0) { // 弾の生成 for (int x = 0; x < 6; x++) { for (int y = 0; y < 3; y++) { BulletWebGL targetBullet = FindBullet(); if (targetBullet == null) { continue; } // ----- ここから弾幕の設定 ----- // 初期座標 targetBullet.TransformCache.position = this.transformComponent.position; // 初期速度 targetBullet.speed = 0.05f; // 初期角度 targetBullet.Angle1 = 6.28f / 6 * (x + y / 7.0f) + frameCount * frameCount / 10000.0f; targetBullet.Angle2 = 6.28f / 3 * y + Mathf.Sin(frameCount / 100f * y) / 12.0f; // 色設定 targetBullet.SetColor(Color.HSVToRGB( (frameCount / 100.0f + x * 0.08f) % 1.0f, 0.5f, 0.6f)); // ----- 弾幕設定ここまで ----- targetBullet.Activate(); } } } // 弾の移動処理 // ここが一番重い BulletWebGL target; for (int i = 0; i < maxBullet; i++) { target = bulletList[i]; if (target.active) { target.Move(); // 重い:要改善? this.pos = target.TransformCache.position; if (this.pos.x < -10 || this.pos.x > 10 || this.pos.y < -10 || this.pos.y > 10 || this.pos.z < -10 || this.pos.z > 10) { target.Diactivate(); } } } }
static public void BulletCreate(float px, float py, float pz, float speed, float angle1, float angle2, float h, float s, float v, float scale = 1) { bullet = FindBullet(); if (bullet == null) { return; } SetSpeed(speed); bullet.TransformCache.position = new Vector3(px, py, pz); SetAngle1(angle1); SetAngle2(angle2); SetColor(h, s, v); SetState(1); SetScale(scale); SetTime(0); bullet.Activate(); }
// Update is called once per frame void Update() { // this.angle1 += Input.GetAxis ("Vertical") * this.rotateSpeed; // this.angle2 += Input.GetAxis ("Horizontal") * this.rotateSpeed; if (Input.GetMouseButtonDown(0)) { this.screenPoint = Input.mousePosition; } if (Input.GetMouseButton(0)) { Vector3 currentScreenPoint = Input.mousePosition; this.angle1 += (currentScreenPoint.y - this.screenPoint.y) * this.rotateSpeed; this.angle2 += (currentScreenPoint.x - this.screenPoint.x) * this.rotateSpeed; this.screenPoint = currentScreenPoint; if (this.angle1 > 180) { this.angle1 = 180; } if (this.angle1 < -180) { this.angle1 = -180; } this.transform.rotation = Quaternion.Euler(this.angle1, this.angle2, 0); // 全ての弾の向きをカメラに合わせる int count = EnemyWebGL.BulletList.Count; for (int i = 0; i < count; i++) { BulletWebGL targetBullet = EnemyWebGL.BulletList[i]; if (targetBullet.active == false) { continue; } targetBullet.TransformCache.LookAt(targetBullet.CameraTransformCache.position); } } }
private void Func03() { this.lua.DoString(this.luaHeaderText + this.luaText); // BulletCreate (0, 0, 0, 0.05f, 0, 0, 0, 0.5f, 0.5f); // 弾の移動処理 // ここが一番重い BulletWebGL target; for (int i = 0; i < maxBullet; i++) { target = bulletList[i]; if (target.active) { target.Move(); // 重い:要改善? this.pos = target.TransformCache.position; if (this.pos.x < -10 || this.pos.x > 10 || this.pos.y < -10 || this.pos.y > 10 || this.pos.z < -10 || this.pos.z > 10) { target.Diactivate(); } } } return; if (frameCount % 3 == 0) { // 弾の生成 for (int x = 0; x < 12; x++) { XCount = x; for (int y = 0; y < 3; y++) { YCount = y; bullet = FindBullet(); if (bullet == null) { continue; } // ----- ここから弾幕の設定 ----- // 初期座標 bullet.TransformCache.position = this.transformComponent.position; // 初期速度 bullet.speed = 0.05f; // this.lua = new LuaEnv (); this.lua.DoString(this.luaScript.text); // this.lua.DoString ("require 'test'"); // this.lua.Dispose (); // 初期角度 // targetBullet.Angle1 = 6.28f / 6 * (x + y / 7.0f) + this.frameCount * this.frameCount / 10000.0f; // targetBullet.Angle2 = 6.28f / 3 * y + Mathf.Sin (this.frameCount / 100f * y) / 12.0f; // 色設定 // targetBullet.SetColor (Color.HSVToRGB ( // (this.frameCount / 100.0f + x * 0.08f) % 1.0f, // 0.5f, // 0.6f)); // ----- 弾幕設定ここまで ----- bullet.Activate(); } } } // 弾の移動処理 // ここが一番重い for (int i = 0; i < maxBullet; i++) { target = bulletList[i]; if (target.active) { target.Move(); // 重い:要改善? this.pos = target.TransformCache.position; if (this.pos.x < -10 || this.pos.x > 10 || this.pos.y < -10 || this.pos.y > 10 || this.pos.z < -10 || this.pos.z > 10) { target.Diactivate(); } } } }