Exemplo n.º 1
0
        //-------------------------------------------------------------------------
        public void setLockFishByFishObjId(int lock_fish_obj_id)
        {
            CRenderFish fish = mScene.getLevel().getFishByObjId(lock_fish_obj_id);

            if (fish != null)
            {
                if (!mRenderBufferMgr.hasBuffer("BufLock"))
                {
                    List <object> param_list = new List <object>();
                    param_list.Add(lock_fish_obj_id);
                    mRenderBufferMgr.addBuffer("BufLock", param_list);
                }
                else if (mRenderBufferMgr.hasBuffer("BufLock"))
                {
                    CRenderBufferLock buf_lock = (CRenderBufferLock)mRenderBufferMgr.getBuffer("BufLock");
                    if (buf_lock.getLockFishObjId() != lock_fish_obj_id)
                    {
                        buf_lock.resetLockedFishObjId(lock_fish_obj_id);
                    }
                }
            }
            else
            {
                if (mRenderBufferMgr.hasBuffer("BufLock"))
                {
                    mRenderBufferMgr.removeBuffer("BufLock");
                }
            }
        }
Exemplo n.º 2
0
        //-------------------------------------------------------------------------
        public override void start()
        {
            base.start();

            mSourcePosition = (EbVector3)mMapParam["SourcePosition"];
            TbDataEffectAOE effect_data = EbDataMgr.Instance.getData <TbDataEffectAOE>(mEffectId);

            mEffectAOEData = effect_data;

            mCurrentRate = (int)mMapParam["Rate"];
            mPlayerId    = (uint)mMapParam["PlayerId"];
            List <string> custom_param_list = (List <string>)mMapParam["EffectCustomParam"];

            foreach (var it in custom_param_list)
            {
                CRenderFish fish = mScene.getLevel().findFish(int.Parse(it));
                if (fish == null)
                {
                    continue;
                }
                mDieFishList.Add(fish);
            }

            mFishList = getFishByPositionAndRadius(mSourcePosition, mEffectAOEData.Radius);

            foreach (var it in mDieFishList)
            {
                mFishList.Remove(it);
            }

            mTimeCounter = 5f;
        }
Exemplo n.º 3
0
        //-------------------------------------------------------------------------
        //根据vib数据创建鱼的代码全部放在这里,ISpriteFish的实现类不在需要知道TbDataFish的任何事情?//
        public ISpriteFish buildSpriteFish(CRenderFish render_fish, int fish_vib_id)
        {
            TbDataFish  fish_data   = EbDataMgr.Instance.getData <TbDataFish>(fish_vib_id);
            ISpriteFish sprite_fish = null;

            if (fish_data.Type == TbDataFish.FishType.Custom)
            {
                sprite_fish = new CSpriteCustomGroup();
            }
            else if (fish_data.Type == TbDataFish.FishType.EvenFour)
            {
                sprite_fish = new CSpriteEvenFourFish();
            }
            else if (fish_data.Type == TbDataFish.FishType.EvenFive)
            {
                sprite_fish = new CSpriteEvenFiveFish();
            }
            else
            {
                sprite_fish = new CSpriteFishGroup((int)fish_data.Type);
            }

            sprite_fish.create(mScene, fish_data);
            sprite_fish.setRenderFish(render_fish);
            sprite_fish.setTag("CSpriteFish");
            sprite_fish.setTrigger(true);
            sprite_fish.setLayer(mScene.getLayerAlloter().getFishLayer(fish_vib_id));

#if UNITY_EDITOR
            //ViDebuger.Warning("TkFish_vib_id_ " + fish_vib_id);
            sprite_fish.setGameobjectName("TkFish_vib_id_" + fish_vib_id);
#endif

            return(sprite_fish);
        }
Exemplo n.º 4
0
        //-------------------------------------------------------------------------
        public void update(float elapsed_tm)
        {
            if (mIsSignDestroy)
            {
                return;
            }

            CRenderFish fish = getLockFish();

            if (fish == null || fish.IsDie)
            {
                EbVector3 cur_pos = CLogicUtility.getCurrentPos(mPos, mfAngle, mfBulletSpeed, elapsed_tm);
                mPos = cur_pos;
                mSpriteBullet.setPosition(mPos);

                mSpriteBullet.setDirection(mfAngle);
            }
            else
            {
                float angle = CLogicUtility.getAngle(fish.Position - mPos);
                mPos = CLogicUtility.getCurrentPos(mPos, angle, mfBulletSpeed, elapsed_tm);

                mSpriteBullet.setPosition(mPos);
                mSpriteBullet.setDirection(angle);
            }

            if (mScene.getSceneBox().check(ref mPos, ref mfAngle))
            {
                mLockedFishObjid = -1;
                mSpriteBullet.setPosition(mPos);
                mSpriteBullet.setDirection(mfAngle);
            }
        }
Exemplo n.º 5
0
        //-------------------------------------------------------------------------
        public BaseEntity buildBaseEntity(int vib_id, int fish_id)
        {
            CRenderFish fish = new CRenderFish(mScene);

            fish.create(vib_id, fish_id);
            return(fish);
        }
Exemplo n.º 6
0
        public void display(CRenderFish fish)
        {
            mIsDisplaying = true;
            setActive(true);

            updateView(fish);
        }
Exemplo n.º 7
0
        //-------------------------------------------------------------------------
        public void onFingerTouchFish(List <FishStillSprite> fishs)
        {
            if (!canLockFish())
            {
                return;
            }

            if (fishs.Count <= 0)
            {
                return;
            }
            CRenderFish lock_fish = null;

            foreach (var it in fishs)
            {
                if (lock_fish == null)
                {
                    lock_fish = it.getSpriteFish().getRenderFish();
                }
                else if (lock_fish.getVibData().LockFishWeight < it.getSpriteFish().getRenderFish().getVibData().LockFishWeight)
                {
                    lock_fish = it.getSpriteFish().getRenderFish();
                }
            }

            mCSpriteTurretShow.setAim(lock_fish);
            setLockFishByFishObjId(lock_fish.FishObjId);
        }
Exemplo n.º 8
0
        //-------------------------------------------------------------------------
        public void s2allcCreateClientEffect(
            uint et_player_rpcid, int bullet_rate, EbVector3 position, int fish_id,
            int effect_id, string effect_name, int effect_type, float effect_delay_time,
            List <string> custom_param_list)
        {
            Dictionary <string, object> map_param = new Dictionary <string, object>();

            map_param.Add("PlayerId", et_player_rpcid);
            map_param.Add("Rate", bullet_rate);
            map_param.Add("FishId", fish_id);
            map_param.Add("EffectCustomParam", custom_param_list);

            // 根据死亡鱼的id查位置,查不到就用服务器的位置
            CRenderFish fish = (CRenderFish)mBaseFishLordMgr.findBaseEntity(fish_id);

            if (fish != null)
            {
                map_param.Add("SourcePosition", fish.Position);
            }
            else
            {
                map_param.Add("SourcePosition", position);
            }

            mScene.addSingleEffect(effect_id, effect_name, effect_type, effect_delay_time, map_param, EffectTypeEnum.Server2Client);
        }
Exemplo n.º 9
0
        void updateView(CRenderFish fish)
        {
            EbVector3 turret_position = mCRenderTurret.getTurretPos();
            EbVector3 fish_position   = fish.Position;

            float turret_fish_distance = turret_position.getDistance(fish_position);

            int rectangle_count = (int)(turret_fish_distance / mRectangleGap);

            if (rectangle_count < 0)
            {
                rectangle_count = 0;
            }
            if (mRectangle.Count > rectangle_count)
            {
                int remove_count = mRectangle.Count - rectangle_count;

                do
                {
                    mScene.getRenderObjectPool().freeStillSprite(mRectangle[0]);
                    mRectangle.RemoveAt(0);
                    --remove_count;
                } while (remove_count > 0);
            }
            else if (mRectangle.Count < rectangle_count)
            {
                int add_count = rectangle_count - mRectangle.Count;
                do
                {
                    newRectangleSprite();
                    --add_count;
                } while (add_count > 0);
            }


            float angle = CLogicUtility.getAngle(fish_position - turret_position);

            float node_count = mRectangle.Count + 2;

            for (int i = 0; i < mRectangle.Count; i++)
            {
                mRectangle[i].setPosition(EbVector3.lerp(turret_position, fish_position, ((float)i + 1) / node_count));
                mRectangle[i].setDirection(angle);
            }

            mArrow.setPosition(EbVector3.lerp(turret_position, fish_position, (node_count - 1) / node_count));
            mArrow.setDirection(angle);

            mNumber.setPosition(fish_position);
        }
Exemplo n.º 10
0
        //-------------------------------------------------------------------------
        // 服务端广播消息:鱼死亡
        public void s2allcFishDie(uint et_player_rpcid, int total_score,
                                  int bullet_objid, int fish_objid, int effect_fish_vibid, int current_rate)
        {
            CRenderFish fish = (CRenderFish)mBaseFishLordMgr.findBaseEntity(fish_objid);

            if (fish != null)
            {
                //fish.signDestroy();
                // 销毁鱼
                fish.dieWithTotalScore(et_player_rpcid, total_score);

                // 更新金币和筹码
                CRenderTurret turret = mScene.getTurret(et_player_rpcid);
                if (turret != null)
                {
                    //turret.setPlayerGold(gold);

                    TbDataFish fish_data = EbDataMgr.Instance.getData <TbDataFish>(fish.FishVibId);
                    if (fish_data.FishDisplayScoreType == TbDataFish._eDisplayScoreType.Turnplate)
                    {
                        //turret.displayScoreTurnplate(total_score, fish_data.TurnplateParticle.Data);
                    }
                    else if (fish_data.FishDisplayScoreType == TbDataFish._eDisplayScoreType.Chips)
                    {
                        turret.displayChips(total_score);
                    }
                    else if (fish_data.FishDisplayScoreType == TbDataFish._eDisplayScoreType.ChipsAndTurnplate)
                    {
                        turret.displayChips(total_score);
                        //turret.displayScoreTurnplate(total_score, fish_data.TurnplateParticle.Data);
                    }
                }
            }

            // 销毁子弹
            if (mMapBullet.ContainsKey(et_player_rpcid))
            {
                Dictionary <int, CRenderBullet> m = mMapBullet[et_player_rpcid];
                if (!m.ContainsKey(bullet_objid))
                {
                    return;
                }
                m[bullet_objid].signDestroy();
            }
            else
            {
                //Debug.LogError("CRenderLevel::s2allcFishDie() not found player_id=" + player_id + " when signdestroy bullet");
            }
        }
Exemplo n.º 11
0
        //-------------------------------------------------------------------------
        public EbVector3 getRedFishPosition(int red_fish_obj_id)
        {
            if (mDieRedFishPositionSaver.ContainsKey(red_fish_obj_id))
            {
                return(mDieRedFishPositionSaver[red_fish_obj_id]);
            }

            CRenderFish fish = (CRenderFish)mBaseFishLordMgr.findBaseEntity(red_fish_obj_id);

            if (fish != null)
            {
                return(fish.Position);
            }

            //ViDebuger.Error("getRedFishPosition error, coun't find the id " + red_fish_obj_id + " red fish.");
            return(new EbVector3(10000, 0, 0));
        }
Exemplo n.º 12
0
        public void update(float elapsed_tm)
        {
            if (!mIsDisplaying)
            {
                return;
            }

            CRenderFish fish = mCRenderTurret.getLockFish();

            if (fish == null)
            {
                hide();
                return;
            }

            updateView(fish);
        }
Exemplo n.º 13
0
        //-------------------------------------------------------------------------
        public override void update(float elapsed_tm)
        {
            if (canDestroy())
            {
                return;
            }

            if (mSpriteFish != null)
            {
                mSpriteFish.update(elapsed_tm);
            }

            CRenderLevel level = mScene.getLevel();

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

            bool level_isrun = level.isNormal();

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

            CRenderFish fish = mScene.getLevel().getFishByObjId(mLockFishObjId);

            if (fish == null || fish.IsDie || !_isInScene(fish.Position))
            {
                mLockFishObjId = -1;
                signDestroy();
                return;
            }

            mTurret.updateTurretAngle(fish.Position);
        }
Exemplo n.º 14
0
        //-------------------------------------------------------------------------
        public void resetLockedFishObjId(int lock_fish_objid)
        {
            if (mSpriteFish != null)
            {
                mSpriteFish.destroy();
                mSpriteFish = null;
            }

            mLockFishObjId = lock_fish_objid;

            CRenderFish fish = mScene.getLevel().findFish(mLockFishObjId);

            if (fish != null && !fish.IsDie)
            {
                int    fish_vib_id = fish.FishVibId;
                string tag         = "CSpriteBuffer" + mTurret.getTurretId().ToString();
                mSpriteFish = mScene.getSpriteFishFactory().buildSpriteFish(null, fish_vib_id);
                mSpriteFish.setTag(tag);
                mSpriteFish.setLayer(mScene.getLayerAlloter().getLayer(_eLevelLayer.BufferLockFish));
                if (EbDataMgr.Instance.getData <TbDataFish>(fish_vib_id).Red == TbDataFish.IsRed.YES)
                {
                    mSpriteFish.setColor(new Color(1, 0, 0));
                }
                else
                {
                    mSpriteFish.setColor(new Color(1, 1, 1));
                }

                mSpriteFish.setScale(EbDataMgr.Instance.getData <TbDataFish>(fish_vib_id).getLockCardFishScale());
                mSpriteFish.setTrigger(true);

                mTurret.displayLinkFish(fish);
            }

            if (_isMe())
            {
                mScene.getProtocol().c2sLockFish(mScene.getMyPlayerId(), lock_fish_objid);
            }
        }
Exemplo n.º 15
0
        //-------------------------------------------------------------------------
        public CRenderFish getFishByObjId(int fish_obj_id)
        {
            CRenderFish fish = (CRenderFish)mBaseFishLordMgr.findBaseEntity(fish_obj_id);

            return(fish);
        }
Exemplo n.º 16
0
 //-------------------------------------------------------------------------
 public void displayLinkFish(CRenderFish fish)
 {
     mCSpriteTurretShow.displayLinkFish(fish);
 }
Exemplo n.º 17
0
 //---------------------------------------------------------------------
 public void setRenderFish(CRenderFish render_fish)
 {
     mRenderFish = render_fish;
 }