// 設定文字 拆解 字串 public void SetText( string sText) { Clear(); if (String.IsNullOrEmpty(sText)) return; sText = sText.Replace(" ", ""); // 過濾空白字元 防止錯誤 sText = sText.Replace("()", "(0)"); // 無參數時傳0為參數。以吻和 parser 時 一個命令,一個 param 的結構 // 拆解 lines string[] lines = sText.Split( m_sRawToken.ToCharArray() ); foreach (string s in lines) { if (String.IsNullOrEmpty(s)) continue; //拆解 Rows CTextLine newline = new CTextLine(); string [] rows = s.Split(m_sColToken.ToCharArray()); foreach (string r in rows) { if (String.IsNullOrEmpty(r)) continue; newline.m_kTextPool.Add( r ); } if (newline.GetRowNum() > 0 ) m_kTextLinePool.Add( newline ); } }
// 在指定位置插入文字 public void Insert(int nCol, string s) { if (nCol < 0) return; if (String.IsNullOrEmpty(s)) return ; //拆解 Rows CTextLine newline = new CTextLine(); string[] rows = s.Split(m_sColToken.ToCharArray()); foreach (string r in rows) { if (String.IsNullOrEmpty(r)) continue; newline.m_kTextPool.Add(r); } if (newline.GetRowNum() > 0) { m_kTextLinePool.Insert(nCol, newline); } }
List< List<cTextFunc> > CondLst; // multi array. public void Add( CTextLine line ) { if (CondLst == null) CondLst = new List< List<cTextFunc> > (); if (line == null) return; CondLst.Add (line.GetFuncList ()); }
// this should be menthod of text panel // Sys func to parser one line script void ParserScript( CTextLine line ) { for( int i = 0 ; i < line.GetRowNum() ; i++ ) { string s = line.GetString( i ).ToUpper(); if( s == "ADDCHAR" ) { string sp = line.GetString( ++i ); if( sp == null ) return; // null = error List<string> lst = cTextArray.GetParamLst( sp ); // default value int[] array1 = new int[5]; int j = 0 ; foreach( string s2 in lst ) { array1[j++] = int.Parse( s2.Trim( ) ); } AddChar( array1[0] , array1[1] , array1[2] ); } else if( s == "MOVECHAR" ) { string sp = line.GetString( ++i ); if( sp == null ) return; // null = error List<string> lst = cTextArray.GetParamLst( sp ); // default value int[] array1 = new int[5]; int j = 0 ; foreach( string s2 in lst ) { array1[j++] = int.Parse( s2.Trim( ) ); } MoveChar( array1[0] , array1[1] , array1[2] ); } else if( s == "DELCHAR" ) { string sp = line.GetString( ++i ); if( sp == null ) return; // null = error List<string> lst = cTextArray.GetParamLst( sp ); // default value int[] array1 = new int[5]; int j = 0 ; foreach( string s2 in lst ) { array1[j++] = int.Parse( s2.Trim( ) ); } DelChar( array1[0] , array1[1] ); } else if( s == "DELALL" ) { string sp = line.GetString( ++i ); if( sp == null ) return; // null = error int nType = 0; nType = int.Parse( sp.Trim() ); //if( lst.Count > 0 ) // nID = int.Parse( lst[0] ); DelAll( nType ); //DelChar( nCharid , nType ); } else if( s == "TEXT" ) { string sp= line.GetString( ++i ); if( sp == null ) return; // null = error //List<string> lst = cTextArray.GetParamLst( sp ); // only 1 par default value int nID = 0; nID = int.Parse( sp.Trim() ); //if( lst.Count > 0 ) // nID = int.Parse( lst[0] ); AddStoryText( nID ); } else if( s == "BGM" ) { string sp1 = line.GetString( ++i ); if( sp1 == null ) return; // null = error int nBgm = int.Parse( sp1 ); GameSystem.PlayBGM( nBgm ) ; } else if( s == "END" ) { // no need param End(); return; } } }
public void ParserStoryScript( CTextLine line ) { }
//------------------ // Stage Run //----------------- public void ParserScript( CTextLine line ,cUnitData data_I=null , cUnitData data_E=null ) { List<cTextFunc> funcList =line.GetFuncList(); foreach( cTextFunc func in funcList ) { if( func.sFunc == "POPCHAR" ) { StagePopUnitEvent evt = new StagePopUnitEvent (); evt.eCamp = _CAMP._PLAYER; evt.nCharID = func.I( 0 ); evt.nX = func.I( 1 ); evt.nY = func.I( 2 ); evt.nValue1 = func.I( 3 ); // pop num GameEventManager.DispatchEvent ( evt ); } else if( func.sFunc == "POPMOB" ) { StagePopUnitEvent evt = new StagePopUnitEvent (); evt.eCamp = _CAMP._ENEMY; evt.nCharID = func.I( 0 ); evt.nX = func.I( 1 ); evt.nY = func.I( 2 ); evt.nValue1 = func.I( 3 ); // pop num //test code GameEventManager.DispatchEvent ( evt ); } else if( func.sFunc == "POP" ) { StagePopUnitEvent evt = new StagePopUnitEvent (); evt.eCamp = (_CAMP)func.I( 0 ); evt.nCharID = func.I( 1 ); evt.nX = func.I( 2 ); evt.nY = func.I( 3 ); evt.nValue1 = func.I( 4 ); // pop num GameEventManager.DispatchEvent ( evt ); } else if( func.sFunc == "POPGROUP" ) { StagePopGroupEvent evt = new StagePopGroupEvent (); //evt.eCamp = (_CAMP)func.I( 0 ); evt.nLeaderCharID = func.I( 0 ); evt.nCharID = func.I( 1 ); evt.stX = func.I( 2 ); evt.stY = func.I( 3 ); evt.edX = func.I( 4 ); evt.edY = func.I( 5 ); evt.nPopType = func.I( 6 ); // pop num GameEventManager.DispatchEvent ( evt ); } else if( func.sFunc == "TALK" ) // open talkui { #if UNITY_EDITOR // return ; #endif int nID = func.I( 0 ); GameSystem.TalkEvent( nID ); } else if( func.sFunc == "BGM" ) { int nID = func.I( 0 ); // change bgm GameSystem.PlayBGM ( nID ); } else if( func.sFunc == "SAY" ) { TalkSayEvent evt = new TalkSayEvent(); //evt.nType = func.I(0); evt.nChar = func.I(0); evt.nSayID = func.I(1); //Say( func.I(0), func.I(1) ); GameEventManager.DispatchEvent ( evt ); } else if( func.sFunc == "SETCHAR" ) { TalkSetCharEvent evt = new TalkSetCharEvent(); evt.nType = func.I(0); evt.nChar = func.I(1); //Say( func.I(0), func.I(1) ); GameEventManager.DispatchEvent ( evt ); } else if( func.sFunc == "CHANGEBACK") { } else if( func.sFunc == "SAYEND") { TalkSayEndEvent evt = new TalkSayEndEvent(); //evt.nType = func.I(0); evt.nChar = func.I(0); GameEventManager.DispatchEvent ( evt ); // CloseBox( func.I(0), func.I(1) ); } // stage event else if( func.sFunc == "STAGEBGM") { GameEventManager.DispatchEvent ( new StageBGMEvent() ); } else if( func.sFunc == "ATTACK") // pop a group of mob { StageBattleAttackEvent evt = new StageBattleAttackEvent(); evt.nAtkCharID = func.I(0); evt.nDefCharID = func.I(1); evt.nAtkSkillID = func.I(2); GameEventManager.DispatchEvent ( evt ); } else if( func.sFunc == "MOVETOUNIT") // pop a group of mob { StageMoveToUnitEvent evt = new StageMoveToUnitEvent(); evt.nAtkCharID = func.I(0); evt.nDefCharID = func.I(1); //evt.nAtkSkillID = func.I(2); GameEventManager.DispatchEvent ( evt ); } else if( func.sFunc == "DELUNIT") { StageDelUnitEvent evt = new StageDelUnitEvent (); //evt.eCamp = (_CAMP)func.I( 0 ); evt.nCharID = func.I( 0 ); GameEventManager.DispatchEvent ( evt ); } else if( func.sFunc == "WIN") { PanelManager.Instance.OpenUI( Panel_Win.Name ); //Panel_StageUI.Instance.bIsStageEnd = true; } else if( func.sFunc == "LOST") { PanelManager.Instance.OpenUI( Panel_Lost.Name ); //Panel_StageUI.Instance.bIsStageEnd = true; } else { Debug.LogError( string.Format( "Error-Can't find script func '{0}'" , func.sFunc ) ); } } }
public bool CheckEventCondition( CTextLine line ) { if( line == null ) return false; List<cTextFunc> funcList =line.GetFuncList(); foreach( cTextFunc func in funcList ) { if( func.sFunc == "GO" ) { if( ConditionGO( ) == false ) { return false; } } else if( func.sFunc == "ALLDEAD" ) { if( ConditionAllDead( func.I(0) ) == false ) { return false; } } else if( func.sFunc == "DEAD" ) { if( ConditionUnitDead( func.I(0), func.I(1) ) == false ) { return false; } } else if( func.sFunc == "ROUND" ) { if( ConditionRound( func.I(0) ) == false ) { return false; } } else if( func.sFunc == "AFTER" ) { if( ConditionAfter( func.I(0),func.I(1) ) == false ) { return false; } } else if( func.sFunc == "COMBAT" ) { if( ConditionCombat( func.I(0),func.I(1) ) == false ) { return false; } } else if( func.sFunc == "DIST" ) { if( ConditionDist( func.I(0),func.I(1) ,func.I(2) ) == false ) { return false; } } else if( func.sFunc == "HP" ) { if( ConditionHp( func.I(0), func.S(1) ,func.F(2) ) == false ) { return false; } } else{ Debug.LogError( string.Format( "Error-Can't find script cond func '{0}'" , func.sFunc ) ); } } return true; }