Example #1
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);
            }
        }
Example #2
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);
        }