Ejemplo n.º 1
0
        // 設定文字 拆解 字串
        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 );
            }
        }
Ejemplo n.º 2
0
        // 在指定位置插入文字
		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);
                
            }
        
        }
Ejemplo n.º 3
0
	// 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;
			}
		}
	}