private void OnFly(float time) { //生命周期检测 if (nowLifeTime >= lifeTime) { poolObject.DesSpawn(); } //飞行位置改变 transform.position += transform.forward * flySpeed * time; //碰撞检测 if (Physics.Linecast(oldPos, transform.position, out hit, layerMask)) { //TODO:计算伤害 //生成碰撞特效 PoolManager.Instance.GetPool(POOLNAME_BULLETBOOM).Spawn((PoolObject po) => { po.transform.position = hit.point; po.OnDesSpawned(); }); //生成碰撞音效 PoolManager.Instance.GetPool(POOLNAME_BOOMAUDIO).Spawn((PoolObject po) => { po.transform.position = hit.point; po.OnDesSpawned(); }); //回收自身 poolObject.DesSpawn(); } oldPos = transform.position; nowLifeTime += time; }
public void OnHit() { isHit = true; //生成爆炸特效 PoolManager.Instance.GetPool(FireMissle.POOLNAME_BULLETBOOM).Spawn((PoolObject po) => { po.transform.position = transform.position; }); //生成爆炸音效 PoolManager.Instance.GetPool(FireMissle.POOLNAME_BOOMAUDIO).Spawn((PoolObject po) => { po.transform.position = transform.position; }); poolObject.DesSpawn(); }
/// <summary> /// 当碰撞或被回收时执行爆炸 /// </summary> /// <param name="boomPos"></param> private void OnDesSpawn(Vector3 boomPos) { //TODO:计算伤害 //生成碰撞特效 PoolManager.Instance.GetPool(POOLNAME_BULLETBOOM).Spawn((PoolObject po) => { po.transform.position = boomPos; po.OnDesSpawned(); }); //生成碰撞音效 PoolManager.Instance.GetPool(POOLNAME_BOOMAUDIO).Spawn((PoolObject po) => { po.transform.position = boomPos; po.OnDesSpawned(); }); //回收自身 poolObject.DesSpawn(); }