private void _ChasingBullet(int count) { if (count % 30 != 0 || Time.timeScale <= 0f) { return; } Vector3 self = new Vector3(t.position.x, t.position.y, 0); if (MarisaTrans) { velocity = MarisaTrans.position - t.position; velocity.z = 0; velocity.Normalize(); } else { // 金发的孩子真可怜 velocity = new Vector3(0, -1, 0); //* flySpeed; } GameObject o = (GameObject)GameObject.Instantiate(bullet, self, t.rotation); EBullet e = o.GetComponent <EBullet> (); e.SetMarisa(Marisa); e.flySpeed = ChasingBulletSpeed; e.SetVelocity(velocity); }
private void OnTriggerEnter(Collider other) { if (other.gameObject.tag == "eBullet") { eBullet = other.gameObject.GetComponent <EBullet>(); CalShield(eBullet.BulletDamage); isAttack = true; Destroy(other.gameObject); } }
private void _CircleBullet(int count) { if (count % 10 != 0 || Time.timeScale <= 0f) { return; } int bias = (int)(Random.value * 30); Vector3 self = new Vector3(t.position.x, t.position.y, 0); for (int angle = -180 + bias; angle < 180 + bias; angle += 30) { GameObject o = (GameObject)GameObject.Instantiate(bullet, self, t.rotation); o.transform.Rotate(0, 0, angle); EBullet e = o.GetComponent <EBullet>(); e.flySpeed = CircleBulletSpeed; e.SetVelocity(1, 0, 0); } }
private IEnumerator _Cirno() { const int radius = 2; const int deltaAngle = 15; Vector3 self = new Vector3(t.position.x, t.position.y, 0); Vector3 cirPos = new Vector3(); int angle = -180; for (int i = 0; i < 30; angle += deltaAngle, i++) { //for (; angle < 180; angle += deltaAngle) { //angle%= 180; cirPos.x = Mathf.Cos(angle / 180f * Mathf.PI); cirPos.y = Mathf.Sin(angle / 180f * Mathf.PI); cirPos.z = 0; cirPos *= radius; cirPos += self; // Chasing if (MarisaTrans) { velocity = MarisaTrans.position - cirPos; velocity.z = 0; velocity.Normalize(); } else { // 金发的孩子真可怜 velocity = new Vector3(0, -1, 0); //* flySpeed; } GameObject o = (GameObject)GameObject.Instantiate(bullet_r, cirPos, t.rotation); EBullet e = o.GetComponent <EBullet> (); e.SetMarisa(Marisa); e.flySpeed = CirnoBulletSpeed; e.SetVelocity(velocity); o.GetComponent <AudioSource>().Play(); yield return(null); } }
public CommonTower(RenderTarget RenderTarget2D, Vector2 position) : base(RenderTarget2D) { _range = 10; _size = new Size2F(30, 30); _target.Size = _size; _position = position; _isSet = false; _bullets = new List <CommonBullet>(); var rand = new Random(); _speedFire = 3 + rand.Next(-10, 10) / 10.0f; _lastFire = 0; _bitmapRange = Helpers.LoadFromFile(RenderTarget2D, "TowerRange01.png");; _drawRange = false; _bulletType = EBullet.CommonBullet; _id = ++__commonId; }
void OnTriggerEnter2D(Collider2D other) { //collision with enemy if (other.gameObject.tag == "Enemy") { Player.Instance.Lives -= 1; Debug.Log("Collision with" + other.gameObject.tag); EnemyControl enemy = other.gameObject.GetComponent <EnemyControl>(); if (enemy != null) { GameObject ex = Instantiate(ExplosionGO); ex.transform.position = enemy.transform.position; } } if (other.gameObject.tag == "EnemyBulletTag") { //collision with enemy bullet Player.Instance.Lives -= 1; Debug.Log("Collision with" + other.gameObject.tag); EBullet eBullet = other.gameObject.GetComponent <EBullet>(); if (eBullet != null) { GameObject ex = Instantiate(ExplosionGO); ex.transform.position = eBullet.transform.position; } } if (other.gameObject.tag == "MeteorTag") { //collision with meteor Player.Instance.Lives -= 1; Debug.Log("Collision with" + other.gameObject.tag); Meteor meteor = other.gameObject.GetComponent <Meteor>(); if (meteor != null) { GameObject ex = Instantiate(ExplosionGO); ex.transform.position = meteor.transform.position; } } }