/// <summary> /// 毒圈收缩到安全区大小重新生成安全区 /// </summary> private void refreshNewSafeCircle() { if (m_CurrentLevel < m_PoisonConfig.ListPoisonData.Count - 1) { upLevel(); ResetConfigData(true); mRadius_inner = getCurrentLevelRadius(); mPoint_inner = CircleMathfHelper.PointOfRandom(mPoint_outer, mRadius_outer, mRadius_inner); m_InCircleChangeAction?.Invoke(mRadius_inner, mPoint_inner); m_OutCircleChangeAction?.Invoke(mRadius_outer, mPoint_outer); } else { mRadius_inner = 0; mPoint_inner = mPoint_outer; ResetConfigData(false); m_NoSafeAreaCallBack?.Invoke(); } }
//缩毒圈 private void shrinkPoisonCirCleRadius() { float changeradius = configReduceRadiusSpeed / 60; mRadius_outer -= changeradius; if (!CircleMathfHelper.isIntersect(mPoint_outer, mRadius_outer, mPoint_inner, mRadius_inner)) { m_OutCircleChangeAction?.Invoke(mRadius_outer, mPoint_outer); } else { if (mRadius_outer > mRadius_inner) //外圈和内圈圆心重合,半径相同 { // k = y/x // y = kx // x^2+y^2 = changeradius^2 // x^2 = 1/(k^2+1) float k = (mPoint_outer.y - mPoint_inner.y) / (mPoint_outer.x - mPoint_inner.x); float x_off = 1 * (float)Mathf.Sqrt((changeradius * changeradius) / (k * k + 1)); // k<0 x+x_off mPoint_outer.x += 1 * (mPoint_outer.x < mPoint_inner.x ? 1 : -1) * x_off; mPoint_outer.y = k * (mPoint_outer.x - mPoint_inner.x) + mPoint_inner.y; m_OutCircleChangeAction?.Invoke(mRadius_outer, mPoint_outer); } else { m_OutCircleChangeAction?.Invoke(mRadius_outer, mPoint_outer); refreshNewSafeCircle(); m_poisonstate = PoisonState.preShrink; } } if (mRadius_outer < 1) { m_poisonstate = PoisonState.End; } }