Beispiel #1
0
        //---------------------------------------------------------------------
        // 计算鱼死亡分值并更新玩家状态
        void _calculateFishScore(uint et_player_rpcid, CLogicTurret turret, CLogicFish fish, int rate, int bullet_objid)
        {
            // 计算鱼的死亡概率,鱼死亡则销毁
            int score = 1;// 分值
            int effect_fish_vib_id = -1;

            bool fish_die = fish.hit(et_player_rpcid, rate, ref score, ref effect_fish_vib_id);

            if (fish_die)
            {
                // 奖励金币
                if (turret.getBufferPower())
                {
                    rate *= 2;
                }
                int total_score = rate * score;

                _tScenePlayer player   = turret.getScenePlayerInfo();
                int           cur_gold = mScene.getListener().onLogicSceneGetPlayerGold(player.et_player_rpcid);
                cur_gold += total_score;
                mScene.getListener().onLogicSceneSetPlayerGold(player.et_player_rpcid, cur_gold, fish.FishVibId, "FishLord", rate);

                // 通知其他模块鱼死亡
                mScene.getListener().onLogicSceneFishDie(et_player_rpcid, fish.FishVibId, total_score);

                // 服务端广播鱼死亡
                mScene.getProtocol().s2allcFishDie(et_player_rpcid,
                                                   total_score, bullet_objid, fish.FishObjId, effect_fish_vib_id, rate);
            }
        }
Beispiel #2
0
        //---------------------------------------------------------------------
        // 服务端广播玩家进入
        public void s2allcPlayerEnter(CLogicTurret turret)
        {
            List <string> vec_param = new List <string>();

            vec_param.Add(((byte)_eProtocolDesktop.s2allcPlayerEnter).ToString());

            _tScenePlayer scene_player = turret.getScenePlayerInfo();

            vec_param.Add(scene_player.et_player_rpcid.ToString());
            vec_param.Add(scene_player.nickname);
            int player_gold = mScene.getListener().onLogicSceneGetPlayerGold(scene_player.et_player_rpcid);

            vec_param.Add(player_gold.ToString());
            vec_param.Add(scene_player.rate.ToString());
            vec_param.Add(turret.getTurretId().ToString());
            vec_param.Add(turret.getBufferPower().ToString());
            vec_param.Add(turret.getBufferFreeze().ToString());
            vec_param.Add(turret.getBufferLongpress().ToString());
            vec_param.Add(turret.getBufferRapid().ToString());
            vec_param.Add(turret.getTurretAngle().ToString());
            vec_param.Add(turret.getTurretRate().ToString());
            vec_param.Add(turret.getTurretType().ToString());
            vec_param.Add(turret.getLockFishObjId().ToString());

            mQueProtocol.Enqueue(vec_param);
        }
Beispiel #3
0
        //---------------------------------------------------------------------
        // 玩家请求命中计算
        public void c2sFishHit(uint et_player_rpcid, int bullet_objid, int fish_objid)
        {
            CLogicFish fish = (CLogicFish)mBaseFishLordMgr.getBaseEntity(fish_objid);

            if (fish == null)
            {
                return;
            }
            CLogicTurret turret = mScene.getTurret(et_player_rpcid);

            if (turret == null)
            {
                return;
            }

            CLogicBullet bullet = turret.getBullet(bullet_objid);

            if (bullet == null)
            {
                return;
            }

            // 通知其他模块鱼命中
            mScene.getListener().onLogicSceneFishHit(et_player_rpcid, fish.FishVibId, bullet.getRate());

            _calculateFishScore(et_player_rpcid, turret, fish, bullet.getRate(), bullet_objid);

            turret.removeBullet(bullet_objid);
        }
Beispiel #4
0
        //---------------------------------------------------------------------
        public void create(CLogicScene logic_scene, CLogicTurret turret, TbDataTurret.TurretType turret_type)
        {
            mScene      = logic_scene;
            mTurret     = turret;
            mTurretType = turret_type;

            // 机器人锁定鱼初始化,依赖这些顺序
            mBotLoveFishList.Add(24);
            mBotLoveFishList.Add(21);

            addBotLove(31, 36);
            addBotLove(25, 30);

            mBotLoveFishList.Add(20);
            mBotLoveFishList.Add(39);
            mBotLoveFishList.Add(37);
            mBotLoveFishList.Add(22);
            mBotLoveFishList.Add(23);

            mDecisionCounter   = new Counter(0, true);
            mRandomRateCounter = new Counter(0, true);

            randomRateTime();
            mTurret.randomTurretRate();
        }
Beispiel #5
0
        //---------------------------------------------------------------------
        public void create(CLogicScene logic_scene, CLogicTurret turret, TbDataTurret.TurretType turret_type)
        {
            mScene = logic_scene;
            mTurret = turret;
            mTurretType = turret_type;

            // 机器人锁定鱼初始化,依赖这些顺序
            mBotLoveFishList.Add(24);
            mBotLoveFishList.Add(21);

            addBotLove(31, 36);
            addBotLove(25, 30);

            mBotLoveFishList.Add(20);
            mBotLoveFishList.Add(39);
            mBotLoveFishList.Add(37);
            mBotLoveFishList.Add(22);
            mBotLoveFishList.Add(23);

            mDecisionCounter = new Counter(0, true);
            mRandomRateCounter = new Counter(0, true);

            randomRateTime();
            mTurret.randomTurretRate();
        }
Beispiel #6
0
        //---------------------------------------------------------------------
        // 客户端提交自动发炮,需要广播给客户端
        void _c2sAutoFire(List <string> vec_param)
        {
            // 解析数据
            int  index           = 0;
            uint et_player_rpcid = uint.Parse(vec_param[++index]);
            int  bullet_count    = int.Parse(vec_param[++index]);

            Queue <_tBullet> que_bullet = new Queue <_tBullet>();

            for (int i = 0; i < bullet_count; ++i)
            {
                _tBullet bullet;
                bullet.bullet_objid      = int.Parse(vec_param[++index]);
                bullet.turret_angle      = float.Parse(vec_param[++index]);
                bullet.turret_rate       = int.Parse(vec_param[++index]);
                bullet.locked_fish_objid = int.Parse(vec_param[++index]);
                que_bullet.Enqueue(bullet);
            }

            // 处理请求
            CLogicTurret turret = mScene.getTurret(et_player_rpcid);

            if (turret != null)
            {
                turret.c2sAutoFire(que_bullet);
            }
        }
Beispiel #7
0
        //-------------------------------------------------------------------------
        public void setTurret(uint et_player_rpcid, TbDataTurret.TurretType turret_type)
        {
            CLogicTurret turret = getTurret(et_player_rpcid);

            if (turret == null)
            {
                return;
            }
            turret.setTurret(turret_type);
        }
Beispiel #8
0
        //---------------------------------------------------------------------
        // 玩家进入炮台
        public void scenePlayerEnter(uint et_player_rpcid, int turret_no, string nickname,
                                     bool is_bot, int default_turret_rate, TbDataTurret.TurretType turret_type)
        {
            scenePlayerLeave(et_player_rpcid);

            CLogicTurret turret = new CLogicTurret(this);

            turret.create(turret_no, et_player_rpcid, nickname, is_bot, default_turret_rate, turret_type);
            mMapPlayerTurret[et_player_rpcid] = turret;

            // 服务端广播玩家进入
            mProtocol.s2allcPlayerEnter(turret);
        }
Beispiel #9
0
        //---------------------------------------------------------------------
        // 客户端提交结束极速状态,需要广播给客户端
        void _c2sEndRapid(List <string> vec_param)
        {
            // 解析数据
            int  index           = 0;
            uint et_player_rpcid = uint.Parse(vec_param[++index]);

            // 处理请求
            CLogicTurret turret = mScene.getTurret(et_player_rpcid);

            if (turret != null)
            {
                turret.c2sEndRapid();
            }
        }
Beispiel #10
0
        //---------------------------------------------------------------------
        // 客户端提交锁定鱼,需要广播给客户端
        void _c2sLockFish(List <string> vec_param)
        {
            // 解析数据
            int  index             = 0;
            uint et_player_rpcid   = uint.Parse(vec_param[++index]);
            int  locked_fish_objid = int.Parse(vec_param[++index]);

            // 处理请求
            CLogicTurret turret = mScene.getTurret(et_player_rpcid);

            if (turret != null)
            {
                turret.c2sLockFish(locked_fish_objid);
            }
        }
Beispiel #11
0
        //---------------------------------------------------------------------
        // 客户端提交手动发炮,需要广播给客户端
        void _c2sManualFire(List <string> vec_param)
        {
            // 解析数据
            int   index           = 0;
            uint  et_player_rpcid = uint.Parse(vec_param[++index]);
            int   bullet_objid    = int.Parse(vec_param[++index]);
            float turret_angle    = float.Parse(vec_param[++index]);
            int   turret_rate     = int.Parse(vec_param[++index]);
            int   locked_fish_id  = int.Parse(vec_param[++index]);

            // 处理请求
            CLogicTurret turret = mScene.getTurret(et_player_rpcid);

            if (turret != null)
            {
                turret.c2sManualFire(bullet_objid, turret_angle, turret_rate, locked_fish_id);
            }
        }
Beispiel #12
0
        //---------------------------------------------------------------------
        // 玩家请求渔网命中计算
        public void c2sFishNetHit(uint et_player_rpcid, int fish_objid)
        {
            CLogicFish fish = (CLogicFish)mBaseFishLordMgr.getBaseEntity(fish_objid);

            if (fish == null)
            {
                return;
            }

            CLogicTurret turret = mScene.getTurret(et_player_rpcid);

            if (turret == null)
            {
                return;
            }

            _calculateFishScore(et_player_rpcid, turret, fish, turret.getTurretRate(), -1);
        }
Beispiel #13
0
        //---------------------------------------------------------------------
        public void update(float elapsed_tm)
        {
            mLifeCounter -= elapsed_tm;
            if (mLifeCounter < 0)
            {
                CLogicTurret turret = mScene.getTurret(mPlayerId);
                if (turret != null)
                {
                    turret.removeBullet(mBulletObjId);
                }
                return;
            }

            // 不是机器人则直接返回
            if (mBulletCollider == null)
            {
                return;
            }

            CLogicFish fish = getLockFish();

            if (fish == null || fish.IsDie)
            {
                EbVector3 cur_pos = CLogicUtility.getCurrentPos(mPos, mfAngle, mfBulletSpeed, elapsed_tm);
                mPos = cur_pos;
                mBulletCollider.setPosition(mPos);
            }
            else
            {
                mfAngle = CLogicUtility.getAngle(fish.Position - mPos);
                mPos    = CLogicUtility.getCurrentPos(mPos, mfAngle, mfBulletSpeed, elapsed_tm);
                mBulletCollider.setPosition(mPos);
                mBulletCollider.setDirection(mfAngle);
            }

            if (mScene.getSceneBox().check(ref mPos, ref mfAngle))
            {
                mLockedFishObjid = -1;
                mBulletCollider.setPosition(mPos);
                mBulletCollider.setDirection(mfAngle);
            }
        }
Beispiel #14
0
        //---------------------------------------------------------------------
        public void create(uint et_player_rpcid, int bullet_objid, int turret_rate, int bullet_vibid,
                           EbVector3 turret_pos, float turret_angle, float bullet_speed)
        {
            mPlayerId     = et_player_rpcid;
            mBulletObjId  = bullet_objid;
            mPos          = turret_pos;
            mfAngle       = turret_angle;
            miTurretRate  = turret_rate;
            mfBulletSpeed = bullet_speed;

            CLogicTurret turret = mScene.getTurret(mPlayerId);

            if (turret == null || !turret.isBot())
            {
                return;
            }

            mBulletCollider              = mScene.getColliderMgr().newBulletCollider(0, 0, 41, 47);// 读取vib配置
            mBulletCollider.onCollision += onCollision;
            mBulletCollider.setDirection(mfAngle);
            update(0);
        }
Beispiel #15
0
 //---------------------------------------------------------------------
 public void destroy()
 {
     mTurret = null;
 }
Beispiel #16
0
        //---------------------------------------------------------------------
        // 服务端广播玩家进入
        public void s2allcPlayerEnter(CLogicTurret turret)
        {
            List<string> vec_param = new List<string>();
            vec_param.Add(((byte)_eProtocolDesktop.s2allcPlayerEnter).ToString());

            _tScenePlayer scene_player = turret.getScenePlayerInfo();
            vec_param.Add(scene_player.et_player_rpcid.ToString());
            vec_param.Add(scene_player.nickname);
            int player_gold = mScene.getListener().onLogicSceneGetPlayerGold(scene_player.et_player_rpcid);
            vec_param.Add(player_gold.ToString());
            vec_param.Add(scene_player.rate.ToString());
            vec_param.Add(turret.getTurretId().ToString());
            vec_param.Add(turret.getBufferPower().ToString());
            vec_param.Add(turret.getBufferFreeze().ToString());
            vec_param.Add(turret.getBufferLongpress().ToString());
            vec_param.Add(turret.getBufferRapid().ToString());
            vec_param.Add(turret.getTurretAngle().ToString());
            vec_param.Add(turret.getTurretRate().ToString());
            vec_param.Add(turret.getTurretType().ToString());
            vec_param.Add(turret.getLockFishObjId().ToString());

            mQueProtocol.Enqueue(vec_param);
        }
Beispiel #17
0
 //---------------------------------------------------------------------
 public void destroy()
 {
     mTurret = null;
 }
Beispiel #18
0
        //---------------------------------------------------------------------
        // ��ҽ�����̨
        public void scenePlayerEnter(uint et_player_rpcid, int turret_no, string nickname,
            bool is_bot, int default_turret_rate, TbDataTurret.TurretType turret_type)
        {
            scenePlayerLeave(et_player_rpcid);

            CLogicTurret turret = new CLogicTurret(this);
            turret.create(turret_no, et_player_rpcid, nickname, is_bot, default_turret_rate, turret_type);
            mMapPlayerTurret[et_player_rpcid] = turret;

            // ����˹㲥��ҽ���
            mProtocol.s2allcPlayerEnter(turret);
        }
Beispiel #19
0
        //-------------------------------------------------------------------------
        // 被击中,返回是否鱼死亡
        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);
        }
Beispiel #20
0
        //---------------------------------------------------------------------
        // ������������ֵ���������״̬
        void _calculateFishScore(uint et_player_rpcid, CLogicTurret turret, CLogicFish fish, int rate, int bullet_objid)
        {
            // ��������������ʣ�������������
            int score = 1;// ��ֵ
            int effect_fish_vib_id = -1;

            bool fish_die = fish.hit(et_player_rpcid, rate, ref score, ref effect_fish_vib_id);
            if (fish_die)
            {
                // �������
                if (turret.getBufferPower()) rate *= 2;
                int total_score = rate * score;

                _tScenePlayer player = turret.getScenePlayerInfo();
                int cur_gold = mScene.getListener().onLogicSceneGetPlayerGold(player.et_player_rpcid);
                cur_gold += total_score;
                mScene.getListener().onLogicSceneSetPlayerGold(player.et_player_rpcid, cur_gold, fish.FishVibId, "FishLord", rate);

                // ֪ͨ����ģ��������
                mScene.getListener().onLogicSceneFishDie(et_player_rpcid, fish.FishVibId, total_score);

                // ����˹㲥������
                mScene.getProtocol().s2allcFishDie(et_player_rpcid,
                    total_score, bullet_objid, fish.FishObjId, effect_fish_vib_id, rate);
            }
        }