void Update() { if (mTargetGO == null) { mCurrentBulletType = BulletElementType.Gun; } if (mCanRun) { if (mCurrentBulletType == BulletElementType.Missile && mIsRadar) { mRunDirect = mTargetGO.transform.position - transform.position; } transform.Translate(mRunDirect * Time.deltaTime * Speed); } }
public void Launch(Transform parentTran, GameObject targetGO = null) { mBulletPoint = parentTran.Find("BulletPoint"); mParentTag = parentTran.tag; transform.SetParent(parentTran); transform.localPosition = new Vector3(0f, 0.5f, 0f); mBulletPoint.LocalPositionY(transform.localPosition.y); transform.localRotation = Quaternion.identity; mRunDirect = mBulletPoint.localPosition - transform.localPosition; if (targetGO != null) { mTargetGO = targetGO; mCurrentBulletType = BulletElementType.Missile; Debug.Log(Distance + " " + RadarValue); mTouchScope.radius = RadarValue; this.Sequence() .Event(() => mCanRun = true) .Delay(Distance / Speed) .Event(() => mCanRun = false) .Event(() => mTouchScope.radius = Blow) .Begin() .OnDisposed(() => { Destroy(gameObject); }); } else { mCurrentBulletType = BulletElementType.Gun; this.Sequence() .Event(() => mCanRun = true) .Delay(Distance / Speed) .Event(() => mCanRun = false) .Begin() .OnDisposed(() => { Destroy(gameObject); }); } }