//------------------------------------------------------------------------- EbVector3 getHitPosition(EbVector3 fish_pos, EbVector3 bullet_pos) { float distance = fish_pos.getDistance(bullet_pos); if (distance > 0) { return(EbVector3.lerp(bullet_pos, fish_pos, mBoxY / distance)); } return(fish_pos); }
public Bezier(EbVector3 p0, EbVector3 p1, EbVector3 p2, EbVector3 p3) { mPoint0 = p0; mPoint1 = p1; mPoint2 = p2; mPoint3 = p3; mLength = mPoint0.getDistance(mPoint1) + mPoint1.getDistance(mPoint2) + mPoint2.getDistance(mPoint3); }
void updateView(CRenderFish fish) { EbVector3 turret_position = mCRenderTurret.getTurretPos(); EbVector3 fish_position = fish.Position; float turret_fish_distance = turret_position.getDistance(fish_position); int rectangle_count = (int)(turret_fish_distance / mRectangleGap); if (rectangle_count < 0) { rectangle_count = 0; } if (mRectangle.Count > rectangle_count) { int remove_count = mRectangle.Count - rectangle_count; do { mScene.getRenderObjectPool().freeStillSprite(mRectangle[0]); mRectangle.RemoveAt(0); --remove_count; } while (remove_count > 0); } else if (mRectangle.Count < rectangle_count) { int add_count = rectangle_count - mRectangle.Count; do { newRectangleSprite(); --add_count; } while (add_count > 0); } float angle = CLogicUtility.getAngle(fish_position - turret_position); float node_count = mRectangle.Count + 2; for (int i = 0; i < mRectangle.Count; i++) { mRectangle[i].setPosition(EbVector3.lerp(turret_position, fish_position, ((float)i + 1) / node_count)); mRectangle[i].setDirection(angle); } mArrow.setPosition(EbVector3.lerp(turret_position, fish_position, (node_count - 1) / node_count)); mArrow.setDirection(angle); mNumber.setPosition(fish_position); }
//------------------------------------------------------------------------- List <CLogicFish> getFishByPositionAndRadius(EbVector3 position, float radius) { List <CLogicFish> fish_list = new List <CLogicFish>(); List <CLogicFish> scene_fish_list = mScene.getLevel().getAllFish(); foreach (var it in scene_fish_list) { if (position.getDistance(it.Position) > radius) { continue; } fish_list.Add(it); } return(fish_list); }
//----------------------------------------------------------------------------- public void next(float elapsed_tm, float speed) { if (mDelayTime > 0) { mDelayTime -= elapsed_tm; return; } if (mIsEndRoute || speed == 0) { return; } EbVector3 current_point = EbVector3.lerp(mPoints[mAtWhichPoint], mPoints[mAtWhichPoint + 1], mCurrentT); float max_distance = current_point.getDistance(mPoints[mAtWhichPoint + 1]); float need_distance = elapsed_tm * speed; if (need_distance < max_distance) { mCurrentT = (mGapList[mAtWhichPoint] - max_distance + need_distance) / mGapList[mAtWhichPoint]; mPosition = EbVector3.lerp(mPoints[mAtWhichPoint], mPoints[mAtWhichPoint + 1], mCurrentT); _calculateDirection(elapsed_tm); } else { mAtWhichPoint += 1; mCurrentT = 0; if (mAtWhichPoint >= mPoints.Count - 1) { mPosition = mPoints[mPoints.Count - 1]; mIsEndRoute = true; } else { _initTurning(); next((need_distance - max_distance) / speed, speed); } } }
//--------------------------------------------------------------------- List<CRenderFish> getFishByPositionAndRadius(EbVector3 position, float radius) { List<CRenderFish> fish_list = new List<CRenderFish>(); List<CRenderFish> scene_fish_list = mScene.getLevel().getAllFish(); foreach (var it in scene_fish_list) { if (position.getDistance(it.Position) > radius) continue; fish_list.Add(it); } return fish_list; }
public Bezier(EbVector3 p0, EbVector3 p1, EbVector3 p2, EbVector3 p3) { mPoint0 = p0; mPoint1 = p1; mPoint2 = p2; mPoint3 = p3; mLength = mPoint0.getDistance(mPoint1) + mPoint1.getDistance(mPoint2) + mPoint2.getDistance(mPoint3); }
//------------------------------------------------------------------------- EbVector3 getHitPosition(EbVector3 fish_pos, EbVector3 bullet_pos) { float distance = fish_pos.getDistance(bullet_pos); if (distance > 0) { return EbVector3.lerp(bullet_pos, fish_pos, mBoxY / distance); } return fish_pos; }