private void OnTriggerEnter2D(Collider2D collision) { if (collision.tag == "Bullet") { CSoundPlayer.PlaySound("Touhou_death", true); Destroy(gameObject); Destroy(collision.gameObject); } }
// Update is called once per frame void Update() { CalcInput(); VX = VY = 0 < InputArray["Fire3"] ? 2.5f * Time.deltaTime : 7.0f * Time.deltaTime; float x = Input.GetAxisRaw("Horizontal"); float y = Input.GetAxisRaw("Vertical"); if (x < 0) { VX = -VX; } else if (x == 0) { VX = 0; } if (y < 0) { VY = -VY; } else if (y == 0) { VY = 0; } // 斜め方向の速度調節 if (VX != 0 && VY != 0) { VX = VX * Sqrt2; VY = VY * Sqrt2; } transform.position = CUtility.ClampPosition(new Vector3(transform.position.x + VX, transform.position.y + VY, 0)); // Zキー押しっぱなしで6フレームに1度ショットを発射する if (0 < InputArray["Fire1"] && InputArray["Fire1"] % 6 == 0) { CSoundPlayer.PlaySound("cshot", true); if (0 < InputArray["Fire3"])//低速移動中なら { LowerSpeedShot(); } else // 通常移動中なら { HiSpeedShot(); } } _Animator.SetFloat("H", x); }
//GameObject newParent = new GameObject(); // Update is called once per frame void Update() { if (Cnt < 100) { transform.position += new Vector3(0.0f, -3.0f, 0.0f) * Time.deltaTime; } if (Cnt == 300) { CSoundPlayer.PlaySound("enemy_shot", true); GameObject.Find("GameManager").GetComponent <CGameManager>().BulletFactory[3].CreateBullet(transform.position, 0); } if (Cnt > 340) { transform.position += new Vector3(0.0f, 3.0f, 0.0f) * Time.deltaTime; } Cnt++; if (CUtility.IsOut(transform.position)) { Destroy(gameObject); } }