//------------------------------------------------------------------------- public override void start() { base.start(); mSourcePosition = (EbVector3)mMapParam["SourcePosition"]; TbDataEffectAOE effect_data = EbDataMgr.Instance.getData <TbDataEffectAOE>(mEffectId); mEffectAOEData = effect_data; mCurrentRate = (int)mMapParam["Rate"]; mPlayerId = (uint)mMapParam["PlayerId"]; List <string> custom_param_list = (List <string>)mMapParam["EffectCustomParam"]; foreach (var it in custom_param_list) { CRenderFish fish = mScene.getLevel().findFish(int.Parse(it)); if (fish == null) { continue; } mDieFishList.Add(fish); } mFishList = getFishByPositionAndRadius(mSourcePosition, mEffectAOEData.Radius); foreach (var it in mDieFishList) { mFishList.Remove(it); } mTimeCounter = 5f; }
//------------------------------------------------------------------------- public BaseEntity buildBaseEntity(int vib_id, int fish_id) { CRenderFish fish = new CRenderFish(mScene); fish.create(vib_id, fish_id); return(fish); }
public void display(CRenderFish fish) { mIsDisplaying = true; setActive(true); updateView(fish); }
//------------------------------------------------------------------------- public void update(float elapsed_tm) { if (mIsSignDestroy) { return; } CRenderFish fish = getLockFish(); if (fish == null || fish.IsDie) { EbVector3 cur_pos = CLogicUtility.getCurrentPos(mPos, mfAngle, mfBulletSpeed, elapsed_tm); mPos = cur_pos; mSpriteBullet.setPosition(mPos); mSpriteBullet.setDirection(mfAngle); } else { float angle = CLogicUtility.getAngle(fish.Position - mPos); mPos = CLogicUtility.getCurrentPos(mPos, angle, mfBulletSpeed, elapsed_tm); mSpriteBullet.setPosition(mPos); mSpriteBullet.setDirection(angle); } if (mScene.getSceneBox().check(ref mPos, ref mfAngle)) { mLockedFishObjid = -1; mSpriteBullet.setPosition(mPos); mSpriteBullet.setDirection(mfAngle); } }
//------------------------------------------------------------------------- void _hitFish(CRenderFish render_fish) { if (mRenderFishID.Contains(render_fish.FishObjId)) { return; } mMaxHitFish--; addFishList(render_fish); if (!render_fish.canHitByFishNet()) { return; } if (mScene.getMyPlayerId() == mPlayerId) { List <string> vec_param = new List <string>(); vec_param.Add("playerFishNetHit"); vec_param.Add(mPlayerId.ToString()); vec_param.Add(render_fish.FishObjId.ToString()); mScene.getListener().onSceneRender2Logic(vec_param); } }
//------------------------------------------------------------------------- public void setLockFishByFishObjId(int lock_fish_obj_id) { CRenderFish fish = mScene.getLevel().getFishByObjId(lock_fish_obj_id); if (fish != null) { if (!mRenderBufferMgr.hasBuffer("BufLock")) { List <object> param_list = new List <object>(); param_list.Add(lock_fish_obj_id); mRenderBufferMgr.addBuffer("BufLock", param_list); } else if (mRenderBufferMgr.hasBuffer("BufLock")) { CRenderBufferLock buf_lock = (CRenderBufferLock)mRenderBufferMgr.getBuffer("BufLock"); if (buf_lock.getLockFishObjId() != lock_fish_obj_id) { buf_lock.resetLockedFishObjId(lock_fish_obj_id); } } } else { if (mRenderBufferMgr.hasBuffer("BufLock")) { mRenderBufferMgr.removeBuffer("BufLock"); } } }
//------------------------------------------------------------------------- public void s2allcCreateClientEffect( uint et_player_rpcid, int bullet_rate, EbVector3 position, int fish_id, int effect_id, string effect_name, int effect_type, float effect_delay_time, List <string> custom_param_list) { Dictionary <string, object> map_param = new Dictionary <string, object>(); map_param.Add("PlayerId", et_player_rpcid); map_param.Add("Rate", bullet_rate); map_param.Add("FishId", fish_id); map_param.Add("EffectCustomParam", custom_param_list); // 根据死亡鱼的id查位置,查不到就用服务器的位置 CRenderFish fish = (CRenderFish)mBaseFishLordMgr.findBaseEntity(fish_id); if (fish != null) { map_param.Add("SourcePosition", fish.Position); } else { map_param.Add("SourcePosition", position); } mScene.addSingleEffect(effect_id, effect_name, effect_type, effect_delay_time, map_param, EffectTypeEnum.Server2Client); }
//------------------------------------------------------------------------- public FishParticleMgr(CRenderScene render_scene, CRenderFish fish, int fish_vib_id, ISpriteFish sprite_fish) { mScene = render_scene; mCRenderFish = fish; mParticlemanager = mScene.getParticlemanager(); mISpriteFish = sprite_fish; mFishData = EbDataMgr.Instance.getData <TbDataFish>(fish_vib_id); //解析鱼带的特效数据并保存下来,等待鱼指定播放特效 foreach (var it in mFishData.ParticleArray) { if (null == it.TbDataParticle || it.TbDataParticle.Id <= 0) { continue; } TbDataFish.ParticleProduceTimeEnum time_enum = (TbDataFish.ParticleProduceTimeEnum)it.ParticleProduceTime; if (!mDicParticleData.ContainsKey(time_enum)) { mDicParticleData[time_enum] = new List <TbDataFish.ParticleDataStruct>(); } mDicParticleData[time_enum].Add(it); } }
//------------------------------------------------------------------------- //根据vib数据创建鱼的代码全部放在这里,ISpriteFish的实现类不在需要知道TbDataFish的任何事情?// public ISpriteFish buildSpriteFish(CRenderFish render_fish, int fish_vib_id) { TbDataFish fish_data = EbDataMgr.Instance.getData <TbDataFish>(fish_vib_id); ISpriteFish sprite_fish = null; if (fish_data.Type == TbDataFish.FishType.Custom) { sprite_fish = new CSpriteCustomGroup(); } else if (fish_data.Type == TbDataFish.FishType.EvenFour) { sprite_fish = new CSpriteEvenFourFish(); } else if (fish_data.Type == TbDataFish.FishType.EvenFive) { sprite_fish = new CSpriteEvenFiveFish(); } else { sprite_fish = new CSpriteFishGroup((int)fish_data.Type); } sprite_fish.create(mScene, fish_data); sprite_fish.setRenderFish(render_fish); sprite_fish.setTag("CSpriteFish"); sprite_fish.setTrigger(true); sprite_fish.setLayer(mScene.getLayerAlloter().getFishLayer(fish_vib_id)); #if UNITY_EDITOR //ViDebuger.Warning("TkFish_vib_id_ " + fish_vib_id); sprite_fish.setGameobjectName("TkFish_vib_id_" + fish_vib_id); #endif return(sprite_fish); }
//------------------------------------------------------------------------- public void onFingerTouchFish(List <FishStillSprite> fishs) { if (!canLockFish()) { return; } if (fishs.Count <= 0) { return; } CRenderFish lock_fish = null; foreach (var it in fishs) { if (lock_fish == null) { lock_fish = it.getSpriteFish().getRenderFish(); } else if (lock_fish.getVibData().LockFishWeight < it.getSpriteFish().getRenderFish().getVibData().LockFishWeight) { lock_fish = it.getSpriteFish().getRenderFish(); } } mCSpriteTurretShow.setAim(lock_fish); setLockFishByFishObjId(lock_fish.FishObjId); }
//------------------------------------------------------------------------- public void displayLinkFish(CRenderFish fish) { if (mScene.isBot()) { return; } mSpriteTurret.displayLinkFish(fish); }
//------------------------------------------------------------------------- public void setAim(CRenderFish lock_fish) { if (mScene.isBot()) { return; } mCSpriteTurretScoreShow.setAim(lock_fish); }
//------------------------------------------------------------------------- public void setAim(CRenderFish lock_fish) { if (mCRenderTurret.getVibTurret().AimParticle.Id <= 0) { return; } StillParticle still_particle = mScene.getParticlemanager().newParticle(mCRenderTurret.getVibTurret().AimParticle.ParticlePrefabName); mAimParticle = new AimParticle(lock_fish, still_particle); }
//------------------------------------------------------------------------- public void create(Color color, uint et_player_rpcid, CRenderFish hit_by_bullet_fish, CRenderScene scene, string animation_name) { mScene = scene; mPlayerId = et_player_rpcid; mCSpriteFishNetGroup = new CSpriteFishNetGroup(); mCSpriteFishNetGroup.create(mScene, color, mPlayerId, animation_name); mCSpriteFishNetGroup.setTrigger(true); mCSpriteFishNetGroup.setColor(color); mCSpriteFishNetGroup.onTriggerEnter += OnTriggerEnter; addFishList(hit_by_bullet_fish); }
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); }
//------------------------------------------------------------------------- // 服务端广播消息:鱼死亡 public void s2allcFishDie(uint et_player_rpcid, int total_score, int bullet_objid, int fish_objid, int effect_fish_vibid, int current_rate) { CRenderFish fish = (CRenderFish)mBaseFishLordMgr.findBaseEntity(fish_objid); if (fish != null) { //fish.signDestroy(); // 销毁鱼 fish.dieWithTotalScore(et_player_rpcid, total_score); // 更新金币和筹码 CRenderTurret turret = mScene.getTurret(et_player_rpcid); if (turret != null) { //turret.setPlayerGold(gold); TbDataFish fish_data = EbDataMgr.Instance.getData <TbDataFish>(fish.FishVibId); if (fish_data.FishDisplayScoreType == TbDataFish._eDisplayScoreType.Turnplate) { //turret.displayScoreTurnplate(total_score, fish_data.TurnplateParticle.Data); } else if (fish_data.FishDisplayScoreType == TbDataFish._eDisplayScoreType.Chips) { turret.displayChips(total_score); } else if (fish_data.FishDisplayScoreType == TbDataFish._eDisplayScoreType.ChipsAndTurnplate) { turret.displayChips(total_score); //turret.displayScoreTurnplate(total_score, fish_data.TurnplateParticle.Data); } } } // 销毁子弹 if (mMapBullet.ContainsKey(et_player_rpcid)) { Dictionary <int, CRenderBullet> m = mMapBullet[et_player_rpcid]; if (!m.ContainsKey(bullet_objid)) { return; } m[bullet_objid].signDestroy(); } else { //Debug.LogError("CRenderLevel::s2allcFishDie() not found player_id=" + player_id + " when signdestroy bullet"); } }
public void update(float elapsed_tm) { if (!mIsDisplaying) { return; } CRenderFish fish = mCRenderTurret.getLockFish(); if (fish == null) { hide(); return; } updateView(fish); }
//------------------------------------------------------------------------- public EbVector3 getRedFishPosition(int red_fish_obj_id) { if (mDieRedFishPositionSaver.ContainsKey(red_fish_obj_id)) { return(mDieRedFishPositionSaver[red_fish_obj_id]); } CRenderFish fish = (CRenderFish)mBaseFishLordMgr.findBaseEntity(red_fish_obj_id); if (fish != null) { return(fish.Position); } //ViDebuger.Error("getRedFishPosition error, coun't find the id " + red_fish_obj_id + " red fish."); return(new EbVector3(10000, 0, 0)); }
//------------------------------------------------------------------------- void _hitFish(CRenderFish render_fish) { if (render_fish == null || render_fish.IsDie) { return; } uint et_player_rpcid = mBullet.getPlayerId(); if (mBullet.getScene().getMyPlayerId() == et_player_rpcid) { mBullet.getScene().getProtocol().c2sFishHit(et_player_rpcid, mBullet.getBulletObjId(), render_fish.FishObjId); } mBullet.signDestroy(); mIsSignDestroy = true; CRenderTurret turret = mBullet.getScene().getTurret(et_player_rpcid); if (turret == null) { return; } TbDataTurret vib_turret = turret.getVibTurret(); Dictionary <string, object> map_param = new Dictionary <string, object>(); map_param.Add("SourcePosition", getHitPosition(render_fish.Position, mBullet.getPosition())); map_param["NetColor"] = mBullet.getScene().getTurret(et_player_rpcid).getTurretColor(); map_param["PlayerId"] = et_player_rpcid; map_param["BulletHitFish"] = render_fish; TbDataBullet buttlt_data = mBullet.getBulletData(); mBullet.getScene().addEffect(buttlt_data.EffectCompose.Id, map_param, EffectTypeEnum.Client); if (!string.IsNullOrEmpty(mHitParticle.ParticlePrefabName)) { StillParticle particle = mScene.getParticlemanager().newParticle(mHitParticle.ParticlePrefabName); particle.setPosition(getHitPosition(render_fish.Position, mBullet.getPosition())); particle.setLayer(mScene.getLayerAlloter().getLayer(_eLevelLayer.FishHitParticle)); } }
//------------------------------------------------------------------------- void OnTriggerEnter(Collider other) { if (mMaxHitFish <= 0) { mCSpriteFishNetGroup.setTrigger(false); return; } if ("CSpriteFish" != other.gameObject.tag) { return; } FishStillSprite sprite_fish = other.gameObject.GetComponent <FishStillSprite>(); CRenderFish render_fish = sprite_fish.getSpriteFish().getRenderFish(); if (render_fish != null) { _hitFish(render_fish); } }
//------------------------------------------------------------------------- public FishParticleMgr(CRenderScene render_scene, CRenderFish fish, int fish_vib_id, ISpriteFish sprite_fish) { mScene = render_scene; mCRenderFish = fish; mParticlemanager = mScene.getParticlemanager(); mISpriteFish = sprite_fish; mFishData = EbDataMgr.Instance.getData<TbDataFish>(fish_vib_id); //解析鱼带的特效数据并保存下来,等待鱼指定播放特效 foreach (var it in mFishData.ParticleArray) { if (null == it.TbDataParticle || it.TbDataParticle.Id <= 0) continue; TbDataFish.ParticleProduceTimeEnum time_enum = (TbDataFish.ParticleProduceTimeEnum)it.ParticleProduceTime; if (!mDicParticleData.ContainsKey(time_enum)) { mDicParticleData[time_enum] = new List<TbDataFish.ParticleDataStruct>(); } mDicParticleData[time_enum].Add(it); } }
//------------------------------------------------------------------------- public void resetLockedFishObjId(int lock_fish_objid) { if (mSpriteFish != null) { mSpriteFish.destroy(); mSpriteFish = null; } mLockFishObjId = lock_fish_objid; CRenderFish fish = mScene.getLevel().findFish(mLockFishObjId); if (fish != null && !fish.IsDie) { int fish_vib_id = fish.FishVibId; string tag = "CSpriteBuffer" + mTurret.getTurretId().ToString(); mSpriteFish = mScene.getSpriteFishFactory().buildSpriteFish(null, fish_vib_id); mSpriteFish.setTag(tag); mSpriteFish.setLayer(mScene.getLayerAlloter().getLayer(_eLevelLayer.BufferLockFish)); if (EbDataMgr.Instance.getData <TbDataFish>(fish_vib_id).Red == TbDataFish.IsRed.YES) { mSpriteFish.setColor(new Color(1, 0, 0)); } else { mSpriteFish.setColor(new Color(1, 1, 1)); } mSpriteFish.setScale(EbDataMgr.Instance.getData <TbDataFish>(fish_vib_id).getLockCardFishScale()); mSpriteFish.setTrigger(true); mTurret.displayLinkFish(fish); } if (_isMe()) { mScene.getProtocol().c2sLockFish(mScene.getMyPlayerId(), lock_fish_objid); } }
//------------------------------------------------------------------------- public override void update(float elapsed_tm) { if (canDestroy()) { return; } if (mSpriteFish != null) { mSpriteFish.update(elapsed_tm); } CRenderLevel level = mScene.getLevel(); if (level == null) { signDestroy(); return; } bool level_isrun = level.isNormal(); if (!level_isrun) { signDestroy(); return; } CRenderFish fish = mScene.getLevel().getFishByObjId(mLockFishObjId); if (fish == null || fish.IsDie || !_isInScene(fish.Position)) { mLockFishObjId = -1; signDestroy(); return; } mTurret.updateTurretAngle(fish.Position); }
//------------------------------------------------------------------------- public AimParticle(CRenderFish lock_fish, StillParticle still_particle) { mLockFish = lock_fish; mStillParticle = still_particle; mStillParticle.setLooping(false); }
//------------------------------------------------------------------------- public void setAim(CRenderFish lock_fish) { if (mCRenderTurret.getVibTurret().AimParticle.Id <= 0) return; StillParticle still_particle = mScene.getParticlemanager().newParticle(mCRenderTurret.getVibTurret().AimParticle.ParticlePrefabName); mAimParticle = new AimParticle(lock_fish, still_particle); }
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 addFishList(CRenderFish fish) { mRenderFishID.Add(fish.FishObjId); }
//------------------------------------------------------------------------- public BaseEntity buildBaseEntity(int vib_id, int fish_id) { CRenderFish fish = new CRenderFish(mScene); fish.create(vib_id, fish_id); return fish; }
//------------------------------------------------------------------------- //根据vib数据创建鱼的代码全部放在这里,ISpriteFish的实现类不在需要知道TbDataFish的任何事情?// public ISpriteFish buildSpriteFish(CRenderFish render_fish, int fish_vib_id) { TbDataFish fish_data = EbDataMgr.Instance.getData<TbDataFish>(fish_vib_id); ISpriteFish sprite_fish = null; if (fish_data.Type == TbDataFish.FishType.Custom) { sprite_fish = new CSpriteCustomGroup(); } else if (fish_data.Type == TbDataFish.FishType.EvenFour) { sprite_fish = new CSpriteEvenFourFish(); } else if (fish_data.Type == TbDataFish.FishType.EvenFive) { sprite_fish = new CSpriteEvenFiveFish(); } else { sprite_fish = new CSpriteFishGroup((int)fish_data.Type); } sprite_fish.create(mScene, fish_data); sprite_fish.setRenderFish(render_fish); sprite_fish.setTag("CSpriteFish"); sprite_fish.setTrigger(true); sprite_fish.setLayer(mScene.getLayerAlloter().getFishLayer(fish_vib_id)); #if UNITY_EDITOR //ViDebuger.Warning("TkFish_vib_id_ " + fish_vib_id); sprite_fish.setGameobjectName("TkFish_vib_id_" + fish_vib_id); #endif return sprite_fish; }
//------------------------------------------------------------------------- void _hitFish(CRenderFish render_fish) { if (mRenderFishID.Contains(render_fish.FishObjId)) { return; } mMaxHitFish--; addFishList(render_fish); if (!render_fish.canHitByFishNet()) return; if (mScene.getMyPlayerId() == mPlayerId) { List<string> vec_param = new List<string>(); vec_param.Add("playerFishNetHit"); vec_param.Add(mPlayerId.ToString()); vec_param.Add(render_fish.FishObjId.ToString()); mScene.getListener().onSceneRender2Logic(vec_param); } }
//------------------------------------------------------------------------- public void setRenderFish(CRenderFish render_fish) { mRenderFish = render_fish; }
//------------------------------------------------------------------------- public void displayLinkFish(CRenderFish fish) { mCSpriteTurretShow.displayLinkFish(fish); }
//------------------------------------------------------------------------- public void displayLinkFish(CRenderFish fish) { mLinkLockedFishFeature.display(fish); }
//--------------------------------------------------------------------- public void setRenderFish(CRenderFish render_fish) { mRenderFish = render_fish; }
//------------------------------------------------------------------------- public void setAim(CRenderFish lock_fish) { if (mScene.isBot()) return; mCSpriteTurretScoreShow.setAim(lock_fish); }
//------------------------------------------------------------------------- public void displayLinkFish(CRenderFish fish) { if (mScene.isBot()) return; mSpriteTurret.displayLinkFish(fish); }
//------------------------------------------------------------------------- public CRenderFish getFishByObjId(int fish_obj_id) { CRenderFish fish = (CRenderFish)mBaseFishLordMgr.findBaseEntity(fish_obj_id); return(fish); }
//------------------------------------------------------------------------- void _hitFish(CRenderFish render_fish) { if (render_fish == null || render_fish.IsDie) return; uint et_player_rpcid = mBullet.getPlayerId(); if (mBullet.getScene().getMyPlayerId() == et_player_rpcid) { mBullet.getScene().getProtocol().c2sFishHit(et_player_rpcid, mBullet.getBulletObjId(), render_fish.FishObjId); } mBullet.signDestroy(); mIsSignDestroy = true; CRenderTurret turret = mBullet.getScene().getTurret(et_player_rpcid); if (turret == null) return; TbDataTurret vib_turret = turret.getVibTurret(); Dictionary<string, object> map_param = new Dictionary<string, object>(); map_param.Add("SourcePosition", getHitPosition(render_fish.Position, mBullet.getPosition())); map_param["NetColor"] = mBullet.getScene().getTurret(et_player_rpcid).getTurretColor(); map_param["PlayerId"] = et_player_rpcid; map_param["BulletHitFish"] = render_fish; TbDataBullet buttlt_data = mBullet.getBulletData(); mBullet.getScene().addEffect(buttlt_data.EffectCompose.Id, map_param, EffectTypeEnum.Client); if (!string.IsNullOrEmpty(mHitParticle.ParticlePrefabName)) { StillParticle particle = mScene.getParticlemanager().newParticle(mHitParticle.ParticlePrefabName); particle.setPosition(getHitPosition(render_fish.Position, mBullet.getPosition())); particle.setLayer(mScene.getLayerAlloter().getLayer(_eLevelLayer.FishHitParticle)); } }