//--------------------------------------------------------------------- public override void create(Dictionary <string, object> param) { mMapParam = param; mScene = mMapParam["LogicScene"] as CLogicScene; mPos = (EbVector3)mMapParam["SourcePosition"]; int score = 0; List <CLogicFish> all_fish = mScene.getLevel().getAllFish(); if (all_fish != null && all_fish.Count > 0) { foreach (var f in all_fish) { score += EbDataMgr.Instance.getData <TbDataFish>(f.FishVibId).FishScore; f.signDestroy(); } } mReturnValue = new List <object>(); ReturnValue.Add("FullScreenBomb"); ReturnValue.Add(score); mDelayTime = 8; mScene.getLevel().setPauseCreateFishCrowd(true); }
//--------------------------------------------------------------------- // 服务端响应玩家获取场景快照 public void s2cSnapshotScene(uint et_player_rpcid) { List <string> vec_param_ret = new List <string>(); vec_param_ret.Add(((byte)_eProtocolDesktop.s2cSnapshotScene).ToString()); vec_param_ret.Add(et_player_rpcid.ToString()); // 关卡信息 CLogicLevel level = mScene.getLevel(); vec_param_ret.Add(((byte)level.getLevelState()).ToString()); vec_param_ret.Add(level.getLevelVibId().ToString()); vec_param_ret.Add(level.CurMapVibId.ToString()); vec_param_ret.Add(level.NextMapVibId.ToString()); vec_param_ret.Add(level.getCurSecond().ToString()); vec_param_ret.Add(level.getMaxSecond().ToString()); vec_param_ret.Add(level.isFormation().ToString()); // 同步房间炮台倍率信息。 List <int> list_rate = mScene.getListTurretRate(); vec_param_ret.Add(list_rate.Count.ToString()); foreach (var i in list_rate) { vec_param_ret.Add(i.ToString()); } // 炮台信息 Dictionary <uint, CLogicTurret> map_turret = mScene.getMapTurret(); vec_param_ret.Add(map_turret.Count.ToString()); foreach (var i in map_turret) { _tScenePlayer scene_player = i.Value.getScenePlayerInfo(); vec_param_ret.Add(scene_player.et_player_rpcid.ToString()); vec_param_ret.Add(scene_player.nickname); int player_gold = mScene.getListener().onLogicSceneGetPlayerGold(scene_player.et_player_rpcid); vec_param_ret.Add(player_gold.ToString()); vec_param_ret.Add(scene_player.rate.ToString()); vec_param_ret.Add(i.Value.getTurretId().ToString()); vec_param_ret.Add(i.Value.getBufferPower().ToString()); vec_param_ret.Add(i.Value.getBufferFreeze().ToString()); vec_param_ret.Add(i.Value.getBufferLongpress().ToString()); vec_param_ret.Add(i.Value.getBufferRapid().ToString()); vec_param_ret.Add(i.Value.getTurretAngle().ToString()); vec_param_ret.Add(i.Value.getTurretRate().ToString()); vec_param_ret.Add(((byte)(i.Value.getTurretType())).ToString()); vec_param_ret.Add(i.Value.getLockFishObjId().ToString()); } mScene.getListener().onLogicScene2Render(et_player_rpcid, vec_param_ret); }
//--------------------------------------------------------------------- public override void update(float elapsed_tm) { mTimeCounter += elapsed_tm * mScene.getLevel().getTimeFactor(); if (mTimeCounter > mEffectGapTime) { if (mWaveCount > 0) { _outFishCrowd(mWaveCount == 1); --mWaveCount; mTimeCounter = 0; } else { signDestroy(); } } }
//--------------------------------------------------------------------- // 客户端请求手动发炮 public void c2sManualFire(int bullet_objid, float turret_angle, int turret_rate, int locked_fish_id) { if (!_canLockFish()) { locked_fish_id = -1; } // 扣币 int cur_gold = mScene.getListener().onLogicSceneGetPlayerGold(mPlayer.et_player_rpcid); if (cur_gold < turret_rate) { return; } cur_gold -= turret_rate; mScene.getListener().onLogicSceneSetPlayerGold(mPlayer.et_player_rpcid, cur_gold, -1, "TurretFire", turret_rate); mTurretAngle = turret_angle; mTurretRate = turret_rate; // 创建子弹 float level_cur_second = mScene.getLevel().getCurSecond(); CLogicBullet bullet = new CLogicBullet(mScene); bullet.create(mPlayer.et_player_rpcid, bullet_objid, mTurretRate, -1, getFirePos(), mTurretAngle, CBulletConstant.ManualSpeed); if (!mMapBullet.ContainsKey(bullet_objid)) { mMapBullet[bullet_objid] = bullet; } else { bullet.Dispose(); bullet = null; } // 服务端广播发炮 mScene.getProtocol().s2allcManualFire(mPlayer.et_player_rpcid, bullet_objid, turret_angle, turret_rate, locked_fish_id); }
//--------------------------------------------------------------------- CLogicFish findMaxVibIdFish() { List <CLogicFish> list_fish = mScene.getLevel().getAllFish(); int max_fish_vib_id = 0; CLogicFish fish = null; foreach (var it in list_fish) { if (!_isInScene(it.Position, -80)) { continue; } if (max_fish_vib_id < it.FishVibId) { max_fish_vib_id = it.FishVibId; fish = it; } } return(fish); }
//------------------------------------------------------------------------- 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 override void start() { base.start(); mScene = (CLogicScene)mMapParam["LogicScene"]; TbDataEffectLockScreen effect_data = EbDataMgr.Instance.getData <TbDataEffectLockScreen>(mEffectId); mScene.getLevel().setTimeFactor(0.0f); mFunDelayTime = effect_data.LastTime; uint et_player_rpcid = (uint)mMapParam["PlayerID"]; int bullet_rate = (int)mMapParam["BulletRate"]; EbVector3 source_position = (EbVector3)mMapParam["SourcePosition"]; int current_die_fish_id = (int)mMapParam["DieFishObjId"];//触发这个效果的鱼 mScene.getProtocol().s2allcCreateClientEffect( et_player_rpcid, bullet_rate, source_position, current_die_fish_id, mEffectId, mEffectName, (int)mEffectType, mDelayTime, new List <string>()); }
//------------------------------------------------------------------------- public override void create(Dictionary <string, object> param) { mMapParam = param; mScene = mMapParam["LogicScene"] as CLogicScene; mPos = (EbVector3)mMapParam["SourcePosition"]; uint et_player_rpcid = (uint)mMapParam["PlayerID"]; int bullet_rate = (int)mMapParam["BulletRate"]; int die_fish_id = (int)mMapParam["DieFishObjId"]; int score = 0; TbDataEffectRadiationLighting effect_data = EbDataMgr.Instance.getData <TbDataEffectRadiationLighting>(mEffectId); List <CLogicFish> fish_list = mScene.getLevel().getListFishById(effect_data.NormalFish.Id); int each_fish_score = EbDataMgr.Instance.getData <TbDataFish>(effect_data.NormalFish.Id).FishScore; foreach (var n in fish_list) { score += each_fish_score; n.signDestroy(); } // 服务端广播创建特效 List <string> custom_param_list = new List <string>(); custom_param_list.Add(effect_data.NormalFish.Id.ToString()); mScene.getProtocol().s2allcCreateClientEffect( et_player_rpcid, bullet_rate, mPos, die_fish_id, mEffectId, mEffectName, (int)mEffectType, mDelayTime, custom_param_list); mReturnValue = new List <object>(); ReturnValue.Add("Lighting"); ReturnValue.Add(score); ReturnValue.Add(effect_data.NormalFish.Id); }
//------------------------------------------------------------------------- void end() { mScene.getLevel().setTimeFactor(1.0f); signDestroy(); }
//------------------------------------------------------------------------- public CLogicFish getLockFish() { return(mScene.getLevel().findFish(mLockedFishObjid)); }
//------------------------------------------------------------------------- // 被击中,返回是否鱼死亡 public bool hit(uint et_player_rpcid, int bullet_rate, ref int score, ref int effect_fish_vib_id) { if (IsDie) { return(false); // 死鱼是打不死的 } double random_double = mScene.getLevel().getRandomScore(); double die_chance = 1.0; // 鱼自身概率 if (mFishData.FishDieChance >= 0) { die_chance = 1.0 / (double)mFishData.FishDieChance; } // 系统抽水率+玩家动态概率提升 CLogicTurret turret = mScene.getTurret(et_player_rpcid); if (turret != null) { die_chance *= mScene.getPumpingRate() * turret.getScenePlayerInfo().rate; } if (mScene.isFishMustDie()) { // 调试需要,鱼必死 } else if (random_double > die_chance) { // 根据概率计算,鱼不一定死 return(false); } // 使用固定分值 score = mFishData.FishScore; // 极速发炮时命中鱼后有一定概率获得能量炮状态 if (turret != null && turret.getBufferRapid()) { if (mScene.getLevel().getRandoNumber(0, 10000) < 50) { turret.activeBufferPower(); } } // 需要在特效参数前加入销毁列表,aoe会根据这个列表判断鱼是不是已经死了死了就不计算。 signDestroy(); foreach (var it in mFishData.Effects) { int vib_compose_id = it.Id; if (vib_compose_id > 0) { Dictionary <string, object> param = new Dictionary <string, object>(); param.Add("SourcePosition", mMassEntity.Position); param.Add("PlayerID", et_player_rpcid); param.Add("BulletRate", bullet_rate); param.Add("RedFishObjId", mFishObjId); param.Add("DieFishObjId", mFishObjId); List <List <object> > obj = mScene.addEffect(vib_compose_id, param, EffectTypeEnum.Server); if (obj == null) { continue; } foreach (var l in obj) { if (l.Count == 0) { continue; } string effect_name = (string)l[0]; if (effect_name == "Lighting") { score += (int)l[1]; effect_fish_vib_id = (int)l[2]; } else if (effect_name == "FullScreenBomb") { score += (int)l[1]; } else if (effect_name == "EffectAOE") { score += (int)l[1]; } } } } return(true); }