//------------------------------------------------------------------------- public void s2allcManualFire(int bullet_objid, float turret_angle, int turret_rate, int locked_fish_id) { bool is_me = (mScene.getMyPlayerId() == mPlayer.et_player_rpcid); if (!is_me) { mTurretAngle = turret_angle; mTurretRate = turret_rate; mBulletFirePos = mTurretPos + CLogicUtility.getDirection(mTurretAngle).normalized *mBarrelOffset; mCSpriteTurretShow.fireAt(mTurretAngle); int bullet_vibid = mVibTurret.BulletDataKey.Id; CRenderBullet bullet = new CRenderBullet(mScene); bullet.create(mPlayer.et_player_rpcid, bullet_objid, bullet_vibid, CBulletConstant.ManualSpeed, locked_fish_id, mBulletFirePos, mTurretAngle, mVibTurret.HitFishParticleDataKey); //int vib_compose_data_id = getVibTurret().EffectComposeFire.Data.ID; //mScene.addEffect(vib_compose_data_id, new Dictionary<string, object>(), EffectTypeEnum.Client); mScene.getListener().onSceneFire(mPlayer.et_player_rpcid, getPlayerGold()); } else { mfIdleSecond = 0.0f; mfObCountdown = 60.0f; } }
//--------------------------------------------------------------------- void updatePosition() { float clip = mVibFishData.CycleHeight; float offset = 0f; if (isOdd(mFishNumber)) { offset = (int)(((float)mFishNumber - 1f) / 2f); } else { offset = mFishNumber / 2 - 0.5f; } int index = 0; foreach (var it in mFishs) { it.setPosition(mPosition + new EbVector3(CLogicUtility.getDirection(mAngle + 90).x, CLogicUtility.getDirection(mAngle + 90).y, CLogicUtility.getDirection(mAngle + 90).z) * (index - offset) * clip); it.setDirection(mAngle); index++; } if (mRedBottom != null) { mRedBottom.setPosition(mPosition, mAngle); } }
//------------------------------------------------------------------------- public void setDirection(float angle) { EbVector3 vec = CLogicUtility.getDirection(angle); Vector3 direction = new Vector3(vec.x, vec.y, 0); mTransform.localRotation = Quaternion.FromToRotation(Vector3.up, direction); }
//------------------------------------------------------------------------- void _updateDigitsLayout() { float offset = 0f; switch (mNumberInfo.Align) { case _eNumberAlign.Left: offset = 0.5f; break; case _eNumberAlign.Right: offset = mNumberInfo.DigitCount + 0.5f; break; default: if (_isOdd(mNumberInfo.DigitCount)) { offset = (int)(((float)mNumberInfo.DigitCount - 1f) / 2f); } else { offset = mNumberInfo.DigitCount / 2 - 0.5f; } break; } for (int i = mNumberInfo.DigitCount - 1; i >= 0; i--) { mListDigit[i].setPosition(mNumberInfo.Position + CLogicUtility.getDirection(mNumberInfo.UpAngle + 90) * (mNumberInfo.DigitCount - 1 - i - offset) * mNumberInfo.DigitGap); mListDigit[i].setDirection(mNumberInfo.UpAngle); } }
//------------------------------------------------------------------------- public void update(float elapsed_tm) { if (!mIsShockingScreen) { return; } mSecondsSinceSwitchBackground += elapsed_tm; EbVector3 background_new_position = EbVector3.Zero; if (_isInFirstFrame()) { background_new_position = CLogicUtility.getDirection(mShakeAngle) * mFirstFrameTimeDistance; } else if (_isInSecondFrame()) { background_new_position = CLogicUtility.getDirection(mShakeAngle) * mSecondFrameTimeDistance; } else if (_isInInitFrame()) { mSecondsSinceSwitchBackground = 0; } mShockBackgroundStillSprite.setPosition(background_new_position); }
//----------------------------------------------------------------------------- public void create(EbVector3 init_position, float init_angle, float width, float height) { mInitPosition = init_position; mInitAngle = init_angle; mDirection = CLogicUtility.getDirection(mInitAngle); mDuration = width; mParaParamB = 4 * height / width; mParaParamA = -mParaParamB / width; }
//------------------------------------------------------------------------- void _updateBufferPosition() { EbVector3 right_direction = CLogicUtility.getVector2ByRotateAngle(CLogicUtility.getDirection(mUpAngle), 90).normalized; int index = 0; foreach (var i in mMapBuffer) { i.Value.setPosition(mFisrtPoint + right_direction * index * mGap, mUpAngle); index++; } }
//------------------------------------------------------------------------- public void doOtherFire(int bullet_objid, float bullet_speed) { mBulletFirePos = mTurretPos + CLogicUtility.getDirection(mTurretAngle).normalized *mBarrelOffset; mCSpriteTurretShow.fireAt(mTurretAngle); int bullet_vibid = mVibTurret.BulletDataKey.Id; CRenderBullet bullet = new CRenderBullet(mScene); bullet.create(mPlayer.et_player_rpcid, bullet_objid, bullet_vibid, bullet_speed, _getLockedFishIdFromLockedBuffer(), mBulletFirePos, mTurretAngle, mVibTurret.HitFishParticleDataKey); mScene.getListener().onSceneFire(mPlayer.et_player_rpcid, getPlayerGold()); }
public override void update(float elapsed_tm) { if (Done) { return; } base.update(elapsed_tm); //线型点出鱼代码 if (getGeneratorData().mStartTime < getPassedTime()) { if (getGeneratorData().mAmount == 0) { return; } EbVector3 centre_position = new EbVector3(getGeneratorData().mStartPointX, getGeneratorData().mStartPointY, 0); float delta_angle = 360f / getGeneratorData().mAmount; int fish_vib_id = -1; for (int i = getGeneratorData().mAmount; i > 0; i--) { if (getGeneratorData().mRedFishIndex == i - 1) { fish_vib_id = getGeneratorData().mRedFishVibId; if (fish_vib_id <= 0) { fish_vib_id = getGeneratorData().mFishVibID; } } else { fish_vib_id = getGeneratorData().mFishVibID; } EbVector3 point_position = centre_position + CLogicUtility.getDirection(90 + delta_angle * i) * getGeneratorData().mRadius; BaseEntity entity = buildEntity( fish_vib_id); entity.setPosition(point_position); entity.setDirection(CLogicUtility.getRightAngle(CLogicUtility.getAngle(point_position - centre_position))); entity.setSpeed(getGeneratorData().mAngleSpeed * 2f * (float)Math.PI * getGeneratorData().mRadius / 360f); entity.setAngleSpeed(getGeneratorData().mAngleSpeed); } setDone(); } }
//------------------------------------------------------------------------- public CSpriteCounter(CRenderScene scene, EbVector3 origin_position, float up_angle) { mScene = scene; mCounterScruct.MovingSpeed = 100f; mCounterScruct.OriginPosition = origin_position; mCounterScruct.UpAngle = up_angle; mCounterScruct.GapBetweenHeaps = mScene.getRenderConfigure().ChipHSpace; mCounterScruct.RightAngle = CLogicUtility.getRightAngle(up_angle); mCounterScruct.RightDistance = CLogicUtility.getDirection(mCounterScruct.RightAngle) * mCounterScruct.GapBetweenHeaps; mCounterState = _eCounterState.Adding; mCSpriteHeapGroup = new CSpriteHeapGroup(4); mScoreCounterMap.create(mScene.getRenderConfigure().ScoreGap); }
//--------------------------------------------------------------------- public override void update(float elapsed_tm) { mOutFishDelay -= elapsed_tm; if (mOutFishDelay >= 0) { return; } if (Done) { return; } var list_serverparam = getServerParam(); int index = -1; int normal_fish_vib_id = int.Parse(list_serverparam[++index]); int red_fish_vib_id = int.Parse(list_serverparam[++index]); int red_fish_index = int.Parse(list_serverparam[++index]); int fish_count = int.Parse(list_serverparam[++index]); float position_x = float.Parse(list_serverparam[++index]); float position_y = float.Parse(list_serverparam[++index]); int red_fish_obj_id = int.Parse(list_serverparam[++index]); if (index + 2 == (int)getServerParam().Count) { position_x = float.Parse(list_serverparam[++index]); position_y = float.Parse(list_serverparam[++index]); } EbVector3 position = new EbVector3(position_x, position_y, 0); float angle = 360.0f / fish_count; for (int i = 0; i < fish_count; i++) { float direction = angle * i; int current_fish_vib_id = normal_fish_vib_id; if (i == red_fish_index) { current_fish_vib_id = red_fish_vib_id; } BaseEntity entity = buildEntity(current_fish_vib_id); entity.addRoute(RouteHelper.buildLineRoute(position, CLogicUtility.getDirection(direction), 2000)); } setDone(); }
//------------------------------------------------------------------------- public void update(float elapsed_tm) { mCurrentAngle += elapsed_tm * mAngleSpeed; EbVector3 right_direction = CLogicUtility.getVector2ByRotateAngle(CLogicUtility.getDirection(mUpAngle), 90).normalized; EbVector3 postion = mFisrtPoint + CLogicUtility.getDirection(mCurrentAngle) * mRadius; for (int i = 0; i < mMapBuffer.Count; i++) { var item = mMapBuffer.ElementAt(i); item.Value.update(elapsed_tm); item.Value.setPosition(postion + right_direction * i * mGap, mUpAngle); if (item.Value.canDestroy()) { item.Value.destroy(); mMapBuffer.Remove(item.Key); } } }
//------------------------------------------------------------------------- public void doLocalFire(int bullet_objid, float bullet_speed) { mBulletFirePos = mTurretPos + CLogicUtility.getDirection(mTurretAngle).normalized *mBarrelOffset; mCSpriteTurretShow.fireAt(mTurretAngle); int bullet_vibid = mVibTurret.BulletDataKey.Id; CRenderBullet bullet = new CRenderBullet(mScene); bullet.create(mPlayer.et_player_rpcid, bullet_objid, bullet_vibid, bullet_speed, _getLockedFishIdFromLockedBuffer(), mBulletFirePos, mTurretAngle, mVibTurret.HitFishParticleDataKey); int vib_compose_data_id = getVibTurret().EffectComposeFire.Id; mScene.addEffect(vib_compose_data_id, new Dictionary <string, object>(), EffectTypeEnum.Client); mScene.getListener().onSceneFire(mPlayer.et_player_rpcid, getPlayerGold()); }
//------------------------------------------------------------------------- void _updateChipsView(EbVector3 position, float up_angle) { float chip_gap = mScene.getRenderConfigure().ChipVSpace; float chip_number_offset = mScene.getRenderConfigure().ChipNumberOffset; EbVector3 new_position = EbVector3.Zero; int index = 0; foreach (var it in mStackChips) { new_position = position; new_position += CLogicUtility.getDirection(up_angle) * (chip_gap * index++); it.setPosition(new_position); it.setDirection(up_angle); } new_position += CLogicUtility.getDirection(up_angle) * chip_number_offset; mCSpriteBgNumber.setPosition(new_position, up_angle); }
//--------------------------------------------------------------------- public override void update(float elapsed_tm) { if (Done) { return; } base.update(elapsed_tm); //线型点出鱼代码 if (getGeneratorData().mStartTime < getPassedTime()) { EbVector3 position = new EbVector3(getGeneratorData().mStartPointX, getGeneratorData().mStartPointY, 0); BaseEntity entity = buildEntity(getGeneratorData().mFishVibID); entity.addRoute(RouteHelper.buildLineRoute(position, CLogicUtility.getDirection(getGeneratorData().mStartAngle), 1153.7f)); entity.setSpeed(getGeneratorData().mSpeed); setDone(); } }
//--------------------------------------------------------------------- public override void update(float elapsed_tm) { if (Done) { return; } base.update(elapsed_tm); if (getGeneratorData().mStartTime < getPassedTime()) { if (getGeneratorData().mAmount != 0) { float delta_angle = 360f / getGeneratorData().mAmount; EbVector3 position = new EbVector3(getGeneratorData().mGenerationPointX, getGeneratorData().mGenerationPointY, 0); BaseEntity base_entity = null; for (int i = getGeneratorData().mAmount; i > 0; i--) { if (getGeneratorData().mRadius == 0) { base_entity = buildEntity(getGeneratorData().mFishVibID); base_entity.setPosition(position); base_entity.setDirection(delta_angle * i); } else { base_entity = buildEntity(getGeneratorData().mFishVibID); base_entity.setPosition(position + CLogicUtility.getDirection(delta_angle * i) * getGeneratorData().mRadius); base_entity.setDirection(delta_angle * i); } base_entity.setSpeed(getGeneratorData().mSpeed); } } setDone(); } }
//--------------------------------------------------------------------- EbVector3 getFirePos() { return(mTurretPos + CLogicUtility.getDirection(mTurretAngle).normalized *mBarrelOffset); }
//------------------------------------------------------------------------- public void switchBackground(string prefab_name, float already_update_time) { if (mBgMgr == null) { _loadBgSprite(prefab_name); if (onLoadMapEnd != null) { onLoadMapEnd(); } } else { if (mIsSwitching) { if (!mHasEarlyClean) { mScene.getLevel().clearAllFish(); } switchBackgroundPic(); mWaveStillSprite.setActive(false); mIsSwitching = false; } mAlreadyUpdateTime = already_update_time; mBgMgr.mBgClippedSprite.ClipRect = new Rect(1, 0, 1, 1); _loadFgSprite(prefab_name); mMassEntity = new MassEntity(); mMassEntity.setSpeed(mSpeed); mMassEntity.setRoute(RouteHelper.buildLineRoute(new EbVector3(650, 0, 0), CLogicUtility.getDirection(-90), 2000)); mWaveStillSprite.setActive(true); mWaveStillSprite.setDirection(-90); mWaveStillSprite.setPosition(new EbVector3(650, 0, 0)); mWaveStillSprite.setLayer(mScene.getLayerAlloter().getLayer(_eLevelLayer.Ripple)); mIsSwitching = true; mHasEarlyClean = false; } }
//------------------------------------------------------------------------- public void setTurretAngle(float turret_angel) { mTurretAngle = turret_angel; mBulletFirePos = mTurretPos + CLogicUtility.getDirection(mTurretAngle).normalized *mBarrelOffset; mCSpriteTurretShow.aimAt(mTurretAngle); }
//------------------------------------------------------------------------- public void update(float elapsed_tm) { if (mDynamicSystem != null) { mTotalElapsedTime += elapsed_tm; EbVector3 acc = mDynamicSystem.getAcce(mTotalElapsedTime, mViSpeed); if (mDynamicSystem.IsDelay) { } else { mViSpeed = mViSpeed + acc * elapsed_tm; mPosition = mPosition + mViSpeed * elapsed_tm; mAngle = CLogicUtility.getAngle(mViSpeed); if (mDynamicSystem.IsEnd) { mIsEndRoute = true; } } } else if (mIRoute != null) { mIRoute.next(elapsed_tm, mSpeed); mPosition = mIRoute.Position; mAngle = CLogicUtility.getAngle(mIRoute.Direction); if (mIRoute.IsEndRoute) { mIsEndRoute = true; } } else { //mAngle += mAngleSpeed * elapsed_tm; float newAngle = mAngle + mAngleSpeed * elapsed_tm; if (mAngleSpeed > 0) { if (mAngle <= 180 && newAngle > 180) { mAngle = newAngle - 360; } else { mAngle = newAngle; } } else { //if (mAngle <= -180) mAngle = mAngle - 180; if (mAngle > -180 && newAngle <= 180) { mAngle = newAngle + 360; } else { mAngle = newAngle; } } //mAngle = regularAngle(mAngle); mPosition += CLogicUtility.getDirection(mAngle) * mSpeed * elapsed_tm; } _updateState(); }
//--------------------------------------------------------------------- EbVector3 getSpeed(RouteObject.Velocity velocity) { EbVector3 speed = CLogicUtility.getDirection(velocity.direction); return(speed * velocity.speed); }
//--------------------------------------------------------------------- public bool check(ref EbVector3 position, ref float direction) { EbVector3 dir_vector = CLogicUtility.getDirection(direction); if (position.x < -CCoordinate.LogicSceneLength / 2) { if (dir_vector.x == 0) { return(false); } EbVector3 return_postion = new EbVector3(); return_postion.x = -CCoordinate.LogicSceneLength / 2; return_postion.y = straightLineEquationByX(position, dir_vector, return_postion.x); return_postion.z = position.z; position = return_postion; dir_vector.x = -dir_vector.x; direction = CLogicUtility.getAngle(dir_vector); return(true); } if (position.x > CCoordinate.LogicSceneLength / 2) { if (dir_vector.x == 0) { return(false); } EbVector3 return_postion = new EbVector3(); return_postion.x = CCoordinate.LogicSceneLength / 2; return_postion.y = straightLineEquationByX(position, dir_vector, return_postion.x); return_postion.z = position.z; position = return_postion; dir_vector.x = -dir_vector.x; direction = CLogicUtility.getAngle(dir_vector); return(true); } if (position.y < -CCoordinate.LogicSceneWidth / 2) { if (dir_vector.y == 0) { return(false); } EbVector3 return_postion = new EbVector3(); return_postion.y = -CCoordinate.LogicSceneWidth / 2; return_postion.x = straightLineEquationByY(position, dir_vector, return_postion.y); return_postion.z = position.z; position = return_postion; dir_vector.y = -dir_vector.y; direction = CLogicUtility.getAngle(dir_vector); return(true); } if (position.y > CCoordinate.LogicSceneWidth / 2) { if (dir_vector.y == 0) { return(false); } EbVector3 return_postion = new EbVector3(); return_postion.y = CCoordinate.LogicSceneWidth / 2; return_postion.x = straightLineEquationByY(position, dir_vector, return_postion.y); return_postion.z = position.z; position = return_postion; dir_vector.y = -dir_vector.y; direction = CLogicUtility.getAngle(dir_vector); return(true); } return(false); }
//--------------------------------------------------------------------- public CDirection(float angle) { mDirection = CLogicUtility.getDirection(angle); }