예제 #1
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);
            }
        }
예제 #2
0
        public void PreloadLevelScript(string file)
        {
            Reset();
            ClearWallInfo();
            Stream s = XResources.ReadText("Table/" + file);

            {
                using (StreamReader sr = new StreamReader(s))
                {
                    string line;
                    string curFunc = "";
                    while (true)
                    {
                        line = sr.ReadLine();
                        if (line == null)
                        {
                            break;
                        }
                        line = line.Trim();
                        if (line.StartsWith("func:"))
                        {
                            string func = line.Substring(5);
                            List <LevelCmdDesc> subQueue = new List <LevelCmdDesc>();
                            _LevelScripts.Add(func, subQueue);
                            curFunc = func;
                        }
                        if (line.StartsWith("talkl"))
                        {
                            string[]     str = line.Split(XGlobalConfig.TabSeparator);
                            LevelCmdDesc cmd = new LevelCmdDesc();
                            cmd.cmd = LevelCmd.Level_Cmd_TalkL;
                            cmd.Param.Add(str[1]);
                            cmd.Param.Add(str[2]);
                            if (str.Length > 3)
                            {
                                cmd.Param.Add(str[3]);
                            }
                            _LevelScripts[curFunc].Add(cmd);
                        }
                        else if (line.StartsWith("talkr"))
                        {
                            string[]     str = line.Split(XGlobalConfig.TabSeparator);
                            LevelCmdDesc cmd = new LevelCmdDesc();
                            cmd.cmd = LevelCmd.Level_Cmd_TalkR;
                            cmd.Param.Add(str[1]);
                            cmd.Param.Add(str[2]);
                            if (str.Length > 3)
                            {
                                cmd.Param.Add(str[3]);
                            }
                            _LevelScripts[curFunc].Add(cmd);
                        }
                        else if (line.StartsWith("stoptalk"))
                        {
                            LevelCmdDesc cmd = new LevelCmdDesc();
                            cmd.cmd = LevelCmd.Level_Cmd_Notalk;
                            _LevelScripts[curFunc].Add(cmd);
                        }
                        else if (line.StartsWith("addbuff"))
                        {
                            string[] str = line.Split(XGlobalConfig.TabSeparator);

                            if (str.Length >= 4)
                            {
                                LevelCmdDesc cmd = new LevelCmdDesc();
                                cmd.cmd = LevelCmd.Level_Cmd_Addbuff;
                                cmd.Param.Add(str[1]);
                                cmd.Param.Add(str[2]);
                                cmd.Param.Add(str[3]);
                                _LevelScripts[curFunc].Add(cmd);
                            }
                        }
                        else if (line.StartsWith("removebuff"))
                        {
                            string[] str = line.Split(XGlobalConfig.TabSeparator);
                            if (str.Length >= 3)
                            {
                                LevelCmdDesc cmd = new LevelCmdDesc();
                                cmd.cmd = LevelCmd.Level_Cmd_Removebuff;
                                cmd.Param.Add(str[1]);
                                cmd.Param.Add(str[2]);
                                _LevelScripts[curFunc].Add(cmd);
                            }
                        }
                        else if (line.StartsWith("hidebillboard"))
                        {
                            string[] str = line.Split(XGlobalConfig.TabSeparator);
                            if (str.Length >= 3)
                            {
                                LevelCmdDesc cmd = new LevelCmdDesc();
                                cmd.cmd = LevelCmd.Level_Cmd_HideBillboard;
                                cmd.Param.Add(str[1]);
                                cmd.Param.Add(str[2]);
                                _LevelScripts[curFunc].Add(cmd);
                            }
                        }
                        else if (line.StartsWith("playfx"))
                        {
                            string[] str = line.Split(XGlobalConfig.TabSeparator);
                            if (str.Length >= 3)
                            {
                                LevelCmdDesc cmd = new LevelCmdDesc();
                                cmd.cmd = LevelCmd.Level_Cmd_PlayFx;
                                cmd.Param.Add(str[1]);
                                cmd.Param.Add(str[2]);
                                _LevelScripts[curFunc].Add(cmd);
                            }
                        }
                        else if (line.StartsWith("opendoor"))
                        {
                            string[] str = line.Split(XGlobalConfig.TabSeparator);
                            if (str.Length >= 2)
                            {
                                LevelCmdDesc cmd = new LevelCmdDesc();
                                cmd.cmd = LevelCmd.Level_Cmd_Opendoor;
                                cmd.Param.Add(str[1]);
                                if (str.Length > 2)
                                {
                                    cmd.Param.Add(str[2]);
                                }
                                _LevelScripts[curFunc].Add(cmd);
                            }
                        }
                        else if (line.StartsWith("killspawn"))
                        {
                            string[] str = line.Split(XGlobalConfig.TabSeparator);
                            if (str.Length >= 2)
                            {
                                LevelCmdDesc cmd = new LevelCmdDesc();
                                cmd.cmd = LevelCmd.Level_Cmd_KillSpawn;
                                cmd.Param.Add(str[1]);
                                _LevelScripts[curFunc].Add(cmd);
                            }
                        }
                        else if (line.StartsWith("killallspawn"))
                        {
                            LevelCmdDesc cmd = new LevelCmdDesc();
                            cmd.cmd = LevelCmd.Level_Cmd_KillAllSpawn;
                            _LevelScripts[curFunc].Add(cmd);
                        }
                        else if (line.StartsWith("killwave"))
                        {
                            string[] str = line.Split(XGlobalConfig.TabSeparator);
                            if (str.Length >= 2)
                            {
                                LevelCmdDesc cmd = new LevelCmdDesc();
                                cmd.cmd = LevelCmd.Level_Cmd_KillWave;
                                cmd.Param.Add(str[1]);
                                _LevelScripts[curFunc].Add(cmd);
                            }
                        }
                        else if (line.StartsWith("showcutscene"))
                        {
                            string[] str = line.Split(XGlobalConfig.TabSeparator);
                            if (str.Length >= 2)
                            {
                                LevelCmdDesc cmd = new LevelCmdDesc();
                                cmd.cmd = LevelCmd.Level_Cmd_Cutscene;
                                cmd.Param.Add(str[1]);
                                if (str.Length >= 6)
                                {
                                    cmd.Param.Add(str[2]);
                                    cmd.Param.Add(str[3]);
                                    cmd.Param.Add(str[4]);
                                    cmd.Param.Add(str[5]);
                                    if (str.Length >= 7)
                                    {
                                        cmd.Param.Add(str[6]);
                                    }
                                }
                                else if (str.Length == 3)
                                {
                                    cmd.Param.Add(str[2]);
                                }
                                _LevelScripts[curFunc].Add(cmd);
                            }
                        }
                        else if (line.StartsWith("continue_UI"))
                        {
                            LevelCmdDesc cmd = new LevelCmdDesc();
                            cmd.cmd = LevelCmd.Level_Cmd_Continue;
                            _LevelScripts[curFunc].Add(cmd);
                        }
                        else if (line.StartsWith("showskillslot"))
                        {
                            string[] str = line.Split(XGlobalConfig.TabSeparator);

                            if (str.Length >= 2)
                            {
                                LevelCmdDesc cmd = new LevelCmdDesc();
                                cmd.cmd = LevelCmd.Level_Cmd_ShowSkill;
                                cmd.Param.Add(str[1]);
                                _LevelScripts[curFunc].Add(cmd);
                            }
                        }
                        else if (line.StartsWith("showdirection"))
                        {
                            string[] str = line.Split(XGlobalConfig.TabSeparator);
                            if (str.Length >= 2)
                            {
                                LevelCmdDesc cmd = new LevelCmdDesc();
                                cmd.cmd = LevelCmd.Level_Cmd_Direction;
                                cmd.Param.Add(str[1]);
                                _LevelScripts[curFunc].Add(cmd);
                            }
                        }
                        else if (line.StartsWith("npcpopspeek"))
                        {
                            string[] str = line.Split(XGlobalConfig.TabSeparator);
                            if (str.Length >= 5)
                            {
                                LevelCmdDesc cmd = new LevelCmdDesc();
                                cmd.cmd = LevelCmd.Level_Cmd_NpcPopSpeek;
                                cmd.Param.Add(str[1]);
                                cmd.Param.Add(str[2]);
                                cmd.Param.Add(str[3]);
                                cmd.Param.Add(str[4]);
                                if (str.Length >= 6)
                                {
                                    cmd.Param.Add(str[5]);
                                }
                                _LevelScripts[curFunc].Add(cmd);
                            }
                        }
                        else if (line.StartsWith("aicommand"))
                        {
                            string[] str = line.Split(XGlobalConfig.TabSeparator);
                            if (str.Length >= 3)
                            {
                                LevelCmdDesc cmd = new LevelCmdDesc();
                                cmd.cmd = LevelCmd.Level_Cmd_SendAICmd;
                                cmd.Param.Add(str[1]);
                                cmd.Param.Add(str[2]);
                                if (str.Length >= 4)
                                {
                                    cmd.Param.Add(str[3]);
                                }
                                else
                                {
                                    cmd.Param.Add("0");
                                }
                                _LevelScripts[curFunc].Add(cmd);
                            }
                        }
                        else if (line.StartsWith("info"))
                        {
                            string[] str = line.Split(XGlobalConfig.TabSeparator);
                            string[] pos = str[1].Split(XGlobalConfig.ListSeparator);

                            XLevelInfo xInfo = new XLevelInfo();
                            xInfo.infoName = str[0].Substring(5);
                            xInfo.x        = float.Parse(pos[0]);
                            xInfo.y        = float.Parse(pos[1]);
                            xInfo.z        = float.Parse(pos[2]);
                            xInfo.face     = float.Parse(pos[3]);

                            if (str.Length >= 3)
                            {
                                xInfo.enable = (str[2] == "on" ? true : false);
                            }
                            if (str.Length >= 4)
                            {
                                xInfo.width = float.Parse(str[3]);
                            }
                            if (str.Length >= 5)
                            {
                                xInfo.height = float.Parse(str[4]);
                            }
                            else
                            {
                                xInfo.height = float.MaxValue;
                            }

                            if (str.Length >= 6)
                            {
                                xInfo.thickness = float.Parse(str[5]);
                            }

                            _LevelInfos.Add(xInfo);
                        }
                    }
                }
            }
            XResources.ClearStream(s);
        }