Ejemplo n.º 1
0
        //-------------------------------------------------------------------------
        public void s2allcUnlockFish()
        {
            bool is_me = (mScene.getMyPlayerId() == mPlayer.et_player_rpcid);

            if (is_me)
            {
                return;
            }

            CRenderBuffer buf = mRenderBufferMgr.getBuffer("BufLock");

            if (buf != null)
            {
                mRenderBufferMgr.removeBuffer("BufLock");
            }
        }
Ejemplo n.º 2
0
        //-------------------------------------------------------------------------
        public override void update(float elapsed_tm)
        {
            if (canDestroy())
            {
                return;
            }

            CRenderLevel level = mScene.getLevel();

            if (level == null)
            {
                signDestroy();
                return;
            }

            bool level_isrun = level.isNormal();

            if (!level_isrun)
            {
                signDestroy();
                return;
            }

            mfTotalSecond += elapsed_tm;

            bool is_me = _isMe();

            if (is_me)
            {
                // 本人发炮,子弹生产者
                if (mfTotalSecond - mfLastFireSecond > mfFireTimeSpan)
                {
                    mfLastFireSecond = mfTotalSecond;

                    if (!InputController.Instance.MouseDown)
                    {
                        signDestroy();
                        return;
                    }

                    if (mTurret.getPlayerGold() < mTurret.getTurretRate())
                    {
                        mTurret.goldNotEnough();
                        return;
                    }

                    if (mTurret.checkWhetherFire())
                    {
                        Vector2 mouse_pos    = InputController.Instance.CurrentMousePosition;
                        int     bullet_objid = mTurret.genBulletObjId(1);
                        mTurret.doLocalFire(mouse_pos, bullet_objid, CBulletConstant.AutoRapidSpeed);

                        _tBullet bullet;
                        bullet.bullet_objid      = bullet_objid;
                        bullet.turret_angle      = mTurret.getTurretAngle();
                        bullet.turret_rate       = mTurret.getTurretRate();
                        bullet.locked_fish_objid = mTurret.getLockFishObjId();
                        mQueBullet.Enqueue(bullet);
                    }

                    if (miLeftBulletObjIdNum > 0)
                    {
                        miLeftBulletObjIdNum--;
                    }
                    else
                    {
                        //signDestroy();

                        // 极速转长按
                        CRenderBufferMgr buf_mgr = mTurret.getBufferMgr();
                        buf_mgr.removeBuffer("BufRapid");
                        if (!buf_mgr.hasBuffer("BufLongpress"))
                        {
                            List <object> param_list = new List <object>();
                            buf_mgr.addBuffer("BufLongpress", param_list);
                        }
                    }
                }
            }
            else
            {
                // 他人发炮,子弹消费者
                if (mfTotalSecond - mfLastFireSecond > mfFireTimeSpan)
                {
                    mfLastFireSecond = mfTotalSecond;

                    if (mQueBullet.Count > 0)
                    {
                        _tBullet bullet = mQueBullet.Dequeue();
                        mTurret.setLockFishByFishObjId(bullet.locked_fish_objid);
                        mTurret.setTurretAngle(bullet.turret_angle);
                        mTurret.setTurretRate(bullet.turret_rate);
                        mTurret.doOtherFire(bullet.bullet_objid, CBulletConstant.AutoRapidSpeed);
                    }
                }
            }

            // 如果是本人,则按5Hz的频率进行自动发炮的网络同步
            if (is_me)
            {
                if (mfTotalSecond - mfLastSyncSecond > mfSyncTimeSpan)
                {
                    mfLastSyncSecond = mfTotalSecond;

                    mScene.getProtocol().c2sAutoFire(mTurret.getScenePlayerInfo().et_player_rpcid, mQueBullet);
                }
            }
        }