Exemple #1
0
        public bool ExecuteWaveExtraScript(int wave)
        {
            for (int i = 0; i < waves.Count; i++)
            {
                XLevelDynamicInfo dInfo = GetWaveDynamicInfo(waves[i].ID);

                if (dInfo == null)
                {
                    continue;
                }
                if (dInfo.pushIntoTask)
                {
                    continue;
                }

                if (waves[i].preWave.Count > 0 && waves[i].preWave[0] == wave && waves[i].IsScriptWave())
                {
                    if (XLevelScriptMgr.singleton.IsTalkScript(waves[i].levelscript))
                    {
                        XLevelSpawnMgr.singleton.BossExtarScriptExecuting = true;
                        XTimerMgr.singleton.SetTimer(waves[i].time, RunExtraScript, waves[i].levelscript);
                        return(true);
                    }
                }
            }
            return(false);
        }
Exemple #2
0
        public void OnEnterScene(uint sceneid)
        {
            _time = 0;
            XLevelScriptMgr.singleton.CommandCount = 0;
            string configFile = XScene.singleton.SceneRow.SceneFile;

            if (configFile.Length == 0)
            {
                _curSpawner = null;
                XLevelScriptMgr.singleton.ClearWallInfo();
                XLevelScriptMgr.singleton.Reset();
                return;
            }

            if (_curSpawner == null)
            {
                _curSpawner = new XLevelSpawnInfo();
            }
            else
            {
                _curSpawner.Clear();
            }
            Stream s = XResources.ReadText("Table/" + configFile);
            //using (StreamReader sr = new StreamReader(s))
            StreamReader sr = new StreamReader(s);
            {
                string line      = sr.ReadLine();
                int    totalWave = int.Parse(line);
                line = sr.ReadLine();
                int PreloadWave = int.Parse(line);
                for (int i = 0; i < PreloadWave; i++)
                {
                    line = sr.ReadLine();
                    string[] info    = line.Split(',');
                    int      enemyID = int.Parse(info[0].Substring(3));
                    int      count   = int.Parse(info[1]);
                    _curSpawner.preloadInfo.Add(enemyID, count);
                }
                for (int id = 0; id < totalWave; id++)
                {
                    XLevelWave wave = new XLevelWave();
                    wave.ReadFromFile(sr);
                    _curSpawner.waves.Add(wave);

                    XLevelDynamicInfo dInfo = new XLevelDynamicInfo();
                    dInfo.id         = wave.ID;
                    dInfo.totalCount = wave.Count;
                    dInfo.Reset();
                    _curSpawner.wavesDynamicInfo.Add(wave.ID, dInfo);
                }

                XResources.ClearStream(s);
            }
        }
Exemple #3
0
        public override bool Execute(float time)
        {
            base.Execute(time);
            XLevelDynamicInfo dInfo = null;

            if (!isSummonTask)
            {
                dInfo = _spawner.GetWaveDynamicInfo(_id);
                if (dInfo == null)
                {
                    return(true);
                }
            }
            XEntity entity = null;

            if (spawnType == LevelSpawnType.Spawn_Monster)
            {
                // 从本地创建
                entity = CreateMonster(UID, rot, pos + new Vector3(0, 0.02f, 0), _id);
                XLevelStatistics.singleton.ls.AddLevelSpawnEntityCount(entity.EntityID);
            }
            else if (spawnType == LevelSpawnType.Spawn_Buff)
            {
                // 单机现在不处理直接掉doodad
            }
            else if (spawnType == LevelSpawnType.Spawn_NPC)
            {
                entity = CreateNPC(UID, rot, pos + new Vector3(0, 0.02f, 0), _id);
            }
            else //player or monster
            {
                // 属性和外形来自服务器
            }

            if (dInfo != null)
            {
                if (entity != null)
                {
                    dInfo.generateCount++;
                    dInfo.entityIds.Add(entity.EntityID);
                }
                if (dInfo.generateCount == dInfo.totalCount)
                {
                    dInfo.generatetime = time;
                }
                if (entity != null && entity.IsBoss)
                {
                    return(false);
                }
            }
            return(true);
        }
Exemple #4
0
        protected void SoloUpdate(float time)
        {
            for (int i = 0; i < waves.Count; i++)
            {
                XLevelDynamicInfo dInfo = GetWaveDynamicInfo(waves[i].ID);
                if (dInfo == null || dInfo.pushIntoTask)
                {
                    continue;
                }
                if (dInfo.totalCount != 0 && dInfo.generateCount == dInfo.totalCount)
                {
                    continue;
                }

                bool preWaveFinished = true;
                for (int j = 0; j < waves[i].preWave.Count; j++)
                {
                    XLevelDynamicInfo predInfo;
                    if (wavesDynamicInfo.TryGetValue(waves[i].preWave[j], out predInfo))
                    {
                        if ((predInfo.generateCount != predInfo.totalCount))
                        { // 还没生成
                            preWaveFinished = false;
                            break;
                        }
                        if (predInfo.entityIds.Count > 0)
                        {
                            if (predInfo.generateCount != predInfo.dieCount)
                            {
                                preWaveFinished = false;
                                break;
                            }
                        }
                    }
                }
                if (!preWaveFinished)
                {
                    continue;
                }

                bool exStringExists = true;
                if (!string.IsNullOrEmpty(waves[i].exString))
                {
                    if (!XLevelScriptMgr.singleton.QueryExternalString(waves[i].exString, false))
                    {
                        exStringExists = false;
                    }
                }
                if (exStringExists && dInfo.exStringFinishTime == 0f)
                {
                    dInfo.exStringFinishTime = time;
                }
                if (dInfo.startTime == 0f)
                {
                    dInfo.startTime = time;
                }
                bool bCanGenerate = false;
                if (!string.IsNullOrEmpty(waves[i].exString))
                {
                    if (time - dInfo.exStringFinishTime >= waves[i].time && dInfo.exStringFinishTime > 0)
                    {
                        bCanGenerate = true;
                    }
                }
                else if (waves[i].IsScriptWave() || dInfo.generateCount < dInfo.totalCount)
                {
                    if (time - dInfo.startTime >= waves[i].time)
                    {
                        bCanGenerate = true;
                    }
                }

                if (bCanGenerate)
                {
                    if (waves[i].IsScriptWave())
                    {
                        GenerateScriptTask(waves[i]);
                    }
                    else
                    {
                        GenerateEntityTask(waves[i]);
                    }
                    if (!waves[i].repeat)
                    {
                        dInfo.pushIntoTask = true;
                    }
                    if (waves[i].repeat && waves[i].exString != null && waves[i].exString.Length > 0)
                    {
                        XLevelScriptMgr.singleton.QueryExternalString(waves[i].exString, true);
                        dInfo.exStringFinishTime = 0;
                    }
                }
            }
            ProcessTaskQueue(time);
        }