Exemplo n.º 1
0
        //---------------------------------------------------------------------
        // 定时1秒,根据创建鱼群规则决定是否需要创建新鱼群
        void _checkAndCreateFishCrowd(float elapsed_tm)
        {
            mfCheckAndCreateFishCrowdCountSecond += elapsed_tm;
            if (mfCheckAndCreateFishCrowdCountSecond > 1.0f)
            {
                mfCheckAndCreateFishCrowdCountSecond = 0.0f;
            }
            else
            {
                return;
            }

            int cur_fishcrowd_count      = mBaseFishLordMgr.getAllEntityCount();
            int cur_need_fishcrowd_count = getRandoNumber(miMinFishCrowdCount, miMaxFishCrowdCount) - cur_fishcrowd_count;

            if (cur_need_fishcrowd_count <= 0)
            {
                return;
            }

            mListRouteIdSaver.Clear();// 清除上波出鱼记下来的随机路径id

            if (cur_need_fishcrowd_count > mOutFishSpeed)
            {
                cur_need_fishcrowd_count = (int)mOutFishSpeed;
            }

            int random_max_count = cur_need_fishcrowd_count * 2;// 防止没有鱼可以出的时候发生死循环

            while (cur_need_fishcrowd_count > 0 && random_max_count > 0)
            {
                if (_createFishCrowd())
                {
                    --cur_need_fishcrowd_count;
                }
                --random_max_count;
            }
            return;
        }