示例#1
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);
        }
示例#2
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);
            }
        }
示例#3
0
        //---------------------------------------------------------------------
        public BaseEntity buildBaseEntity(int vib_id, int fish_id)
        {
            CLogicFish fish = new CLogicFish(mScene);

            fish.create(vib_id, fish_id);
            return(fish);
        }
示例#4
0
        //---------------------------------------------------------------------
        public void create(int turret_id, uint et_player_rpcid, string nickname,
                           bool is_bot, int default_turret_rate, TbDataTurret.TurretType turret_type)
        {
            mTurretId               = turret_id;
            mLockedFish             = null;
            mPlayer.et_player_rpcid = et_player_rpcid;
            mPlayer.nickname        = nickname;
            mPlayer.is_bot          = is_bot;
            mPlayer.rate            = 1.0f;
            mTurretType             = turret_type;
            mTurretDataTable        = new TurretDataTable();

            mBotRandom = new System.Random(unchecked ((int)System.DateTime.Now.Ticks) + turret_id * 1000);

            // 更新炮台倍率
            _setTurretRate(default_turret_rate);

            // 初始化炮台位置
            CTurretHelper turret_helper = new CTurretHelper();

            mTurretPos = turret_helper.getPositionByOffset(turret_id,
                                                           new EbVector3(0, 68, 0));
            mTurretAngle = turret_helper.getBaseAngleByTurretId(turret_id);

            if (isBot())
            {
                mLogicBot = new CLogicBot();
                mLogicBot.create(mScene, this, turret_type);
            }
        }
示例#5
0
        //---------------------------------------------------------------------
        // 客户端请求解锁鱼
        public void c2sUnlockFish()
        {
            // 解锁鱼
            mLockedFish = null;

            // 服务端广播解锁鱼
            mScene.getProtocol().s2allcUnlockFish(mPlayer.et_player_rpcid);
        }
示例#6
0
        //---------------------------------------------------------------------
        // 客户端请求锁定鱼
        public void c2sLockFish(int locked_fish_id)
        {
            // 锁定鱼
            if (locked_fish_id > 0)
            {
                mLockedFish = mScene.getLevel().findFish(locked_fish_id);
            }

            // 服务端广播锁定鱼
            mScene.getProtocol().s2allcLockFish(mPlayer.et_player_rpcid, locked_fish_id);
        }
示例#7
0
 //---------------------------------------------------------------------
 void randomUnlockFish()
 {
     if (!mIsLock)
     {
         return;
     }
     if (mAttentionFireFish == null || !_isInScene(mAttentionFireFish.Position, -100) || getRandom01() > 0.999f)
     {
         mTurret.c2sUnlockFish();
         mAttentionFireFish = null;
         mIsLock            = false;
         change2observeState();
     }
 }
示例#8
0
        //-------------------------------------------------------------------------
        void onCollision(TagCollider other)
        {
            CLogicFish fish = ((FishCollider)other).LogicFish;

            if (fish == null)
            {
                return;
            }
            if (!isTargetFish(fish))
            {
                return;
            }
            mScene.getLevel().c2sFishHit(mPlayerId, mBulletObjId, fish.FishObjId);// 暂时关闭
        }
示例#9
0
        //---------------------------------------------------------------------
        public void destroy()
        {
            mLockedFish = null;

            foreach (var i in mMapBullet)
            {
                i.Value.Dispose();
            }
            mMapBullet.Clear();

            if (mLogicBot != null)
            {
                mLogicBot.destroy();
                mLogicBot = null;
            }
        }
示例#10
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);
        }
示例#11
0
        //---------------------------------------------------------------------
        void attentionFire(float elapsed_tm)
        {
            if (mDecisionCounter.notYet(elapsed_tm))
            {
                return;
            }

            float random = getRandom01();

            if (mAttentionFireFish == null || random < 0.1f)
            {
                mAttentionFireFish = null;
                change2observeState();
            }
            else
            {
                manualFire(mTurret.getTurretAngle());
            }
        }
示例#12
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);
            }
        }
示例#13
0
        //---------------------------------------------------------------------
        void lockFish(float elapsed_tm)
        {
            if (mTurretType != TbDataTurret.TurretType.DragonTurret)
            {
                return;
            }
            if (mDecisionCounter.notYet(elapsed_tm))
            {
                return;
            }

            mAttentionFireFish = findBotLoveFish();
            if (mAttentionFireFish == null)
            {
                change2observeState();
                return;
            }
            mIsLock = true;
            mTurret.c2sLockFish(mAttentionFireFish.FishObjId);
            randomFireState(elapsed_tm);
        }
示例#14
0
        //---------------------------------------------------------------------
        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);
        }
示例#15
0
        //---------------------------------------------------------------------
        void randomFireState(float elapsed_tm)
        {
            float random = getRandom01();

            int   max_index  = 4;
            float base_value = 1f / max_index;

            if (random > base_value * --max_index)
            {
                if (mAttentionFireFish == null)
                {
                    return;
                }
                mAttentionFireFish = findMaxVibIdFish();
                change2attentionFireState();
            }
            else if (random > base_value * --max_index)
            {
                mfFireTimeSpan       = 0.2f;
                mAutoFireTargetAngle = randomTurretAngle();
                mTurret.c2sBeginLongpress();
                change2longFireState();
            }
            else if (random > base_value * --max_index)
            {
                mfFireTimeSpan       = 0.1f;
                mAutoFireTargetAngle = randomTurretAngle();
                mTurret.c2sBeginRapid();
                change2rapidFireState();
            }
            else
            {
                startStrafeFire(randomTurretAngle(), randomTurretAngle(), getRandomRange(10, 30));
                change2strafeFireState();
            }
        }
示例#16
0
 //---------------------------------------------------------------------
 public FishCollider(float center_x, float center_y, float width, float height, CLogicFish fish)
     : base(0, center_x, center_y, width, height)
 {
     mLogicFish = fish;
 }
示例#17
0
        //---------------------------------------------------------------------
        public FishCollider newFishCollider(float center_x, float center_y, float width, float height, CLogicFish fish)
        {
            FishCollider collider = new FishCollider(center_x, center_y, width, height, fish);

            mTagColliderList.Add(collider);
            return(collider);
        }
示例#18
0
 //---------------------------------------------------------------------
 public FishCollider newFishCollider(float center_x, float center_y, float width, float height, CLogicFish fish)
 {
     FishCollider collider = new FishCollider(center_x, center_y, width, height, fish);
     mTagColliderList.Add(collider);
     return collider;
 }
示例#19
0
        //---------------------------------------------------------------------
        public void destroy()
        {
            mLockedFish = null;

            foreach (var i in mMapBullet)
            {
                i.Value.Dispose();
            }
            mMapBullet.Clear();

            if (mLogicBot != null)
            {
                mLogicBot.destroy();
                mLogicBot = null;
            }
        }
示例#20
0
        //---------------------------------------------------------------------
        public void create(int turret_id, uint et_player_rpcid, string nickname,
            bool is_bot, int default_turret_rate, TbDataTurret.TurretType turret_type)
        {
            mTurretId = turret_id;
            mLockedFish = null;
            mPlayer.et_player_rpcid = et_player_rpcid;
            mPlayer.nickname = nickname;
            mPlayer.is_bot = is_bot;
            mPlayer.rate = 1.0f;
            mTurretType = turret_type;
            mTurretDataTable = new TurretDataTable();

            mBotRandom = new System.Random(unchecked((int)System.DateTime.Now.Ticks) + turret_id * 1000);

            // 更新炮台倍率
            _setTurretRate(default_turret_rate);

            // 初始化炮台位置
            CTurretHelper turret_helper = new CTurretHelper();
            mTurretPos = turret_helper.getPositionByOffset(turret_id,
                new EbVector3(0, 68, 0));
            mTurretAngle = turret_helper.getBaseAngleByTurretId(turret_id);

            if (isBot())
            {
                mLogicBot = new CLogicBot();
                mLogicBot.create(mScene, this, turret_type);
            }
        }
示例#21
0
        //---------------------------------------------------------------------
        // 客户端请求解锁鱼
        public void c2sUnlockFish()
        {
            // 解锁鱼
            mLockedFish = null;

            // 服务端广播解锁鱼
            mScene.getProtocol().s2allcUnlockFish(mPlayer.et_player_rpcid);
        }
示例#22
0
        //---------------------------------------------------------------------
        // 客户端请求锁定鱼
        public void c2sLockFish(int locked_fish_id)
        {
            // 锁定鱼
            if (locked_fish_id > 0)
            {
                mLockedFish = mScene.getLevel().findFish(locked_fish_id);
            }

            // 服务端广播锁定鱼
            mScene.getProtocol().s2allcLockFish(mPlayer.et_player_rpcid, locked_fish_id);
        }
示例#23
0
 //-------------------------------------------------------------------------
 bool isTargetFish(CLogicFish fish)
 {
     return(mLockedFishObjid < 0 || getLockFish() == fish);
 }
示例#24
0
 //---------------------------------------------------------------------
 public FishCollider(float center_x, float center_y, float width, float height, CLogicFish fish)
     : base(0, center_x, center_y, width, height)
 {
     mLogicFish = fish;
 }
示例#25
0
 //-------------------------------------------------------------------------
 bool isTargetFish(CLogicFish fish)
 {
     return mLockedFishObjid < 0 || getLockFish() == fish;
 }
示例#26
0
        //---------------------------------------------------------------------
        void attentionFire(float elapsed_tm)
        {
            if (mDecisionCounter.notYet(elapsed_tm)) return;

            float random = getRandom01();
            if (mAttentionFireFish == null || random < 0.1f)
            {
                mAttentionFireFish = null;
                change2observeState();
            }
            else
            {
                manualFire(mTurret.getTurretAngle());
            }
        }
示例#27
0
        //---------------------------------------------------------------------
        void randomFireState(float elapsed_tm)
        {
            float random = getRandom01();

            int max_index = 4;
            float base_value = 1f / max_index;

            if (random > base_value * --max_index)
            {
                if (mAttentionFireFish == null) return;
                mAttentionFireFish = findMaxVibIdFish();
                change2attentionFireState();
            }
            else if (random > base_value * --max_index)
            {
                mfFireTimeSpan = 0.2f;
                mAutoFireTargetAngle = randomTurretAngle();
                mTurret.c2sBeginLongpress();
                change2longFireState();
            }
            else if (random > base_value * --max_index)
            {
                mfFireTimeSpan = 0.1f;
                mAutoFireTargetAngle = randomTurretAngle();
                mTurret.c2sBeginRapid();
                change2rapidFireState();
            }
            else
            {
                startStrafeFire(randomTurretAngle(), randomTurretAngle(), getRandomRange(10, 30));
                change2strafeFireState();
            }
        }
示例#28
0
        //---------------------------------------------------------------------
        void lockFish(float elapsed_tm)
        {
            if (mTurretType != TbDataTurret.TurretType.DragonTurret) return;
            if (mDecisionCounter.notYet(elapsed_tm)) return;

            mAttentionFireFish = findBotLoveFish();
            if (mAttentionFireFish == null)
            {
                change2observeState();
                return;
            }
            mIsLock = true;
            mTurret.c2sLockFish(mAttentionFireFish.FishObjId);
            randomFireState(elapsed_tm);
        }
示例#29
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);
            }
        }
示例#30
0
 //---------------------------------------------------------------------
 void randomUnlockFish()
 {
     if (!mIsLock) return;
     if (mAttentionFireFish == null || !_isInScene(mAttentionFireFish.Position, -100) || getRandom01() > 0.999f)
     {
         mTurret.c2sUnlockFish();
         mAttentionFireFish = null;
         mIsLock = false;
         change2observeState();
     }
 }
示例#31
0
 //---------------------------------------------------------------------
 public BaseEntity buildBaseEntity(int vib_id, int fish_id)
 {
     CLogicFish fish = new CLogicFish(mScene);
     fish.create(vib_id, fish_id);
     return fish;
 }