//死亡以后清除所有屏幕上的弹幕 并且播放清除特效 private void ClearAllBullet() { GameObject[] bulletInScreen = GameObject.FindGameObjectsWithTag("EnemyBullet"); //BulletBase_Touhou[] bulletInScreen = UIShootRoot.tra_ShootRoot.GetComponentsInChildren<BulletBase_Touhou>(); foreach (GameObject go in bulletInScreen) { BulletBase_Touhou bullet = go.GetComponent <BulletBase_Touhou>(); bullet.ShowVanishEffect(); GameObject.Destroy(go); } }
//void FixedUpdate() //{ // rigidbody2D.velocity = shootBulletSpeed; //} //给生成的子弹赋值 private void InitBullet() { GameObject shot = Instantiate(projectilePrefab) as GameObject; shot.transform.parent = UIEmitterRoot.tra_ShootRoot; shot.transform.position = this.transform.position; shot.transform.localScale = Vector3.one; BulletBase_Touhou shotScript = shot.GetComponent <BulletBase_Touhou>(); shotScript.Speed = shootBulletSpeed; }
/// <summary> /// 初始化一个子弹的位置的出现效果 /// </summary> /// <param name="bullet"></param> /// <param name="position"></param> /// <param name="direct"></param> void InitOneBulletPosAndEffect(GameObject bullet, Vector2 position, Vector2 direct) { bullet.transform.position = position; bullet.transform.parent = UIEmitterRoot.tra_ShootRoot; bullet.transform.localScale = Vector3.one; BulletBase_Touhou bulletBase = bullet.GetComponent <BulletBase_Touhou>(); bulletBase.renderer.sortingLayerName = bulletLayerName; bulletBase.RotationWithDirction(direct); bulletBase.rigidbody2D.velocity = direct * SpeedScale; //生产发子弹的特效 GameObject effect = GameObject.Instantiate(Resources.Load(CommandString.BulletPrefabPath + "ShootBulletEffect")) as GameObject; effect.transform.parent = UIEmitterRoot.tra_ShootRoot; effect.transform.position = bullet.transform.position; effect.transform.localScale = Vector3.one * 2; }
protected override void InitBullet() { base.InitBullet(); GameObject bullet = Instantiate(BulletPrefab) as GameObject; bullet.transform.position = this.transform.position; BulletBase_Touhou bulletBase = bullet.GetComponent <BulletBase_Touhou>(); bulletBase.renderer.sortingLayerName = bulletLayerName; bulletBase.RotationToTarget(MyPlane.MyPos); bulletBase.rigidbody2D.velocity = getDirByTarget(MyPlane.MyPos) * SpeedScale; bullet.transform.parent = UIEmitterRoot.tra_ShootRoot; bullet.transform.position = (Vector2)transform.position; bullet.transform.localScale = Vector3.one; //生产发子弹的特效 GameObject effect = GameObject.Instantiate(Resources.Load(CommandString.BulletPrefabPath + "ShootBulletEffect")) as GameObject; effect.transform.parent = UIEmitterRoot.tra_ShootRoot; effect.transform.position = bullet.transform.position; effect.transform.localScale = Vector3.one * 2; }