//------------------------------------------------------------------------- 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); }
//------------------------------------------------------------------------- void _initRippleBackground() { mRippleBackgroundStillSprite = _loadRippleStillSprite(); mRippleBackgroundStillSprite.setPosition(new EbVector3(-mScene.getSceneLength() / 2, -mScene.getSceneWidth() / 2, 0)); mRippleBackgroundStillSprite.setLayer(mScene.getLayerAlloter().getLayer(_eLevelLayer.Wave)); mRippleBackgroundStillSprite.setActive(false); }
//------------------------------------------------------------------------- public virtual void setPosition(EbVector3 position, float angle) { if (mSprite != null) { mSprite.setPosition(position); mSprite.setLayer(mScene.getLayerAlloter().getLayer(_eLevelLayer.Buffer)); mSprite.setDirection(angle); } }
//------------------------------------------------------------------------- void _initTurretUnit(ref StillSprite still_sprite, string animation_name, float scale, _eLevelLayer layer) { still_sprite = mScene.getRenderObjectPool().newStillSprite(); still_sprite.playAnimation(animation_name); still_sprite.setScale(scale); still_sprite.setLayer(mScene.getLayerAlloter().getLayer(layer)); still_sprite.setPosition(mRenderTurret.getTurretPos()); still_sprite.setDirection(mScene.getTurretHelper().getBaseAngleByTurretId(mRenderTurret.getTurretId())); still_sprite.setTag("CSpriteTurret" + mRenderTurret.getTurretId()); }
//------------------------------------------------------------------------- void _newShockBackground(string background_name) { mShockBackgroundStillSprite = mBackgroundLoader.newBackgroundStillSprite(background_name, mScene); mShockBackgroundStillSprite.setPosition(EbVector3.Zero); mShockBackgroundStillSprite.setLayer(mScene.getLayerAlloter().getLayer(_eLevelLayer.ShockBackground)); mShockBackgroundStillSprite.setActive(false); #if UNITY_EDITOR mShockBackgroundStillSprite.gameObject.name = "TkBackground"; #endif }
//------------------------------------------------------------------------- public void load(string prefab_name, _eLevelLayer layer) { mBgSprite = mBackgroundLoader.newBackgroundStillSprite(prefab_name, mScene); mBgSprite.setPosition(EbVector3.Zero); mBgSprite.setDirection(0); mBgSprite.setLayer(mScene.getLayerAlloter().getLayer(layer)); mBgClippedSprite = mBgSprite.gameObject.GetComponent <tk2dClippedSprite>(); #if UNITY_EDITOR mBgSprite.gameObject.name = "TkBackground"; #endif }
//------------------------------------------------------------------------- void _playFireAnimation() { mMassEntity = new MassEntity(); RouteParaCurve route = new RouteParaCurve(); route.create(mRenderTurret.getTurretPos(), mRenderTurret.getTurretAngle(), 0.1f, -13f); mMassEntity.setRoute(route); mIsFireAnimation = true; mTurretBlazeSprite.setActive(true); mTurretBlazeSprite.setPosition(mRenderTurret.getTurretPos()); mTurretBlazeSprite.setDirection(mRenderTurret.getTurretAngle()); }
//------------------------------------------------------------------------- public void switchBackgroundMap(int map_vibid, float already_update_time) { playSwitchAudio(EbDataMgr.Instance.getData <TbDataMap>(map_vibid).SwitchLevelAudioName); mLevelBackgroundMgr.onLoadMapEnd += resetNewBackground; mCurrentMapId = map_vibid; mLevelBackgroundMgr.switchBackground(EbDataMgr.Instance.getData <TbDataMap>(map_vibid).MapName, already_update_time); mRippleBackgroundStillSprite.setActive(true); mRippleBackgroundStillSprite.setPosition(new EbVector3(-mScene.getSceneLength() / 2, -mScene.getSceneWidth() / 2, 0)); }
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); }
//------------------------------------------------------------------------- void _updateFireAnimation(float elapsed_tm) { if (mIsFireAnimation) { mMassEntity.update(elapsed_tm); mTurretBarrelSprite.setPosition(mMassEntity.Position); mTurretBarrelSprite.setDirection(mMassEntity.Angle); if (!mMassEntity.IsEndRoute) { return; } mIsFireAnimation = false; mTurretBlazeSprite.setActive(false); } }
//------------------------------------------------------------------------- void create(EbVector3 cur_pos) { string animation_name = ""; float scale_x = 1f; float scale_y = 1f; float width_x = 10f; float width_y = 60f; if (mScene.getLevel().getRandoNumber(0, 100) < 50) { animation_name = "lightening-yellow"; scale_y = width_y / 132f; width_x = 360f; } else { animation_name = "lightning-green"; scale_y = width_y / 85f; width_x = 420f; } foreach (var n in fish_list) { float distance = n.Position.getDistance(cur_pos); if (distance > 1100) { continue; } EbVector3 middle_pos = EbVector3.lerp(n.Position, cur_pos, 0.5f); StillSprite still_sprite = mScene.getRenderObjectPool().newStillSprite(); still_sprite.setPosition(middle_pos); still_sprite.setLayer(mScene.getLayerAlloter().getLayer(_eLevelLayer.FishSwim)); still_sprite.setDirection(CLogicUtility.getAngle(CLogicUtility.getVector2ByRotateAngle(cur_pos - n.Position, 90))); still_sprite.setScale(n.Position.getDistance(cur_pos) / width_x, scale_y); still_sprite.playAnimation(animation_name); mListLight.Add(still_sprite); #if UNITY_EDITOR still_sprite.gameObject.name = "TkSpriteEffectLighting_" + animation_name; #endif } }
//------------------------------------------------------------------------- void buildFrame(string pic_name, float scale, int vib_id) { mPicName = pic_name; vmVibId = vib_id; if ((vib_id == 1 || vib_id == 2 || vib_id == 3 || vib_id == 4) && mMapParam.ContainsKey("NetColor")) { mAnimationName = pic_name; mCSpriteFishNet = new CSpriteFishNet(); Color color = (Color)mMapParam["NetColor"]; uint et_player_rpcid = (uint)mMapParam["PlayerId"]; mCSpriteFishNet.create(color, et_player_rpcid, (CRenderFish)mMapParam["BulletHitFish"], mScene, mAnimationName); mCSpriteFishNet.setScale(scale); } else { mStillSprite = mScene.getRenderObjectPool().newStillSprite(); mStillSprite.setScale(scale); mStillSprite.playAnimation(pic_name); #if UNITY_EDITOR mStillSprite.gameObject.name = "TkSpriteEffectFrameAnimation_" + pic_name; #endif } EbVector3 v2 = (EbVector3)mMapParam["SourcePosition"]; if (mCSpriteFishNet != null) { mCSpriteFishNet.setPosition(v2, 0); mCSpriteFishNet.setLayer(mScene.getLayerAlloter().getLayer(_eLevelLayer.FishNet)); } if (mStillSprite != null) { mStillSprite.setPosition(v2); mStillSprite.setLayer(mScene.getLayerAlloter().getLayer(_eLevelLayer.FishNet)); } }
//------------------------------------------------------------------------- public void setPosition(EbVector3 position) { mStillSprite.setPosition(position); }
//------------------------------------------------------------------------- public void setPosition(EbVector3 position, float angle) { mCSpriteNumber.setPosition(position, angle); mNumberBackgroundCSprite.setPosition(position); mNumberBackgroundCSprite.setDirection(angle); }
//------------------------------------------------------------------------- public void setBgPosition(EbVector3 position, float up_angle) { mBackground.setPosition(position); mBackground.setLayer(mScene.getLayerAlloter().getLayer(_eLevelLayer.TurretScoreBg)); mBackground.setDirection(up_angle); }