コード例 #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);
            }
        }
コード例 #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);
        }
コード例 #3
0
        //-------------------------------------------------------------------------
        public void create(int turret_id, ref _tScenePlayer scene_player, int player_gold,
                           bool buffer_power, bool buffer_freeze, bool buffer_longpress, bool buffer_rapid, int turret_rate, float turret_angle, int locked_fish_objid
                           , TbDataTurret.TurretType turret_type)
        {
            mTurretId    = turret_id;
            mPlayer      = scene_player;
            mTurretAngle = turret_angle;

            mTurretType      = turret_type;
            mTurretDataTable = new TurretDataTable();

            _setTurretRate(turret_rate);

            CTurretHelper turret_helper = mScene.getTurretHelper();

            mTurretPos = turret_helper.getPositionByOffset(turret_id,
                                                           mScene.getRenderConfigure().TurretOffset);
            mBaseAngle   = turret_helper.getBaseAngleByTurretId(turret_id);
            mTurretColor = turret_helper.getBaseColorByTurretId(turret_id).convert();

            float scene_length = mScene.getSceneLength();
            float scene_width  = mScene.getSceneWidth();

            mCSpriteTurretShow = new CSpriteTurretShow();
            mCSpriteTurretShow.create(mScene, this);

            _displayTurretRate();

            mRenderBufferMgr = new CRenderBufferMgr(mScene, this,
                                                    turret_helper.getPositionByOffset(turret_id, mScene.getRenderConfigure().TurretBufferOffset), mBaseAngle);
            setLockFishByFishObjId(locked_fish_objid);

            if (buffer_power)
            {
                List <object> param_list = new List <object>();
                mRenderBufferMgr.addBuffer("BufPower", param_list);
            }

            if (buffer_freeze)
            {
                List <object> param_list = new List <object>();
                mRenderBufferMgr.addBuffer("BufFreeze", param_list);
            }

            if (buffer_longpress)
            {
                List <object> param_list = new List <object>();
                mRenderBufferMgr.addBuffer("BufLongpress", param_list);
            }

            if (buffer_rapid)
            {
                List <object> param_list = new List <object>();
                mRenderBufferMgr.addBuffer("BufRapid", param_list);
            }

            mScene.getListener().onSceneTurretCreated(mTurretId);
        }
コード例 #4
0
ファイル: RenderScene.cs プロジェクト: zhilianghuang/Fishing
        //-------------------------------------------------------------------------
        public CRenderTurret createTurret(int turret_id, ref _tScenePlayer scene_player, int player_gold,
                                          bool buffer_power, bool buffer_freeze, bool buffer_longpress, bool buffer_rapid,
                                          int turret_rate, float turret_angle, int locked_fish_objid, TbDataTurret.TurretType turret_type)
        {
            CRenderTurret turret = new CRenderTurret(this);

            turret.create(turret_id, ref scene_player, player_gold, buffer_power, buffer_freeze, buffer_longpress,
                          buffer_rapid, turret_rate, turret_angle, locked_fish_objid, turret_type);
            mMapPlayerTurret[scene_player.et_player_rpcid] = turret;
            return(turret);
        }
コード例 #5
0
        //---------------------------------------------------------------------
        // 服务端响应玩家获取场景快照
        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);
        }