/// <summary>
 /// 파라미터 문자열을 변수명으로 해서 세션 변수값을 가져오거나, 세션 변수값이 아닌 것 같은 경우 리터럴로 처리
 /// </summary>
 /// <param name="param"></param>
 /// <returns></returns>
 static float GetValueOrLiteral(string param)
 {
     if (engine.ScriptValueIsDeclared(param))
     {
         return(engine.GetScriptValue(param));
     }
     else
     {
         return(FSNUtils.StringToValue <float>(param));
     }
 }
    // Util funcs

    /// <summary>
    /// 파라미터 문자열을 변수명으로 해서 세션 플래그값을 가져오거나, 세션 플래그값이 아닌 것 같은 경우 리터럴로 처리
    /// </summary>
    /// <param name="param"></param>
    /// <returns></returns>
    static bool GetFlagOrLiteral(string param)
    {
        if (engine.ScriptFlagIsDeclared(param))
        {
            return(engine.GetScriptFlag(param));
        }
        else
        {
            return(FSNUtils.StringToValue <bool>(param));
        }
    }
Example #3
0
        //---------------------------------------------------------------------------------------

        /// <summary>
        /// 헤더 정보 먼저 처리
        /// </summary>
        /// <param name="scriptData"></param>
        /// <param name="session"></param>
        static void ProcessHeaders(string scriptData, FSNScriptSequence sequence, FSNSession session)
        {
            var    strstream  = new System.IO.StringReader(scriptData);
            string line       = null;
            int    linenumber = 0;                        // 줄 번호

            while ((line = strstream.ReadLine()) != null) // 줄 단위로 읽는다.
            {
                linenumber++;
                FSNDebug.currentProcessingScriptLine = linenumber;                       // 디버깅 정보 설정

                if (line.Length > 0 && line.Substring(0, 1) == c_token_PreProcessor)     // 프리프로세서 기호에만 반응한다
                {
                    var commandAndParam = line.Substring(1).Split(c_whiteSpaceArray, 2); // 명령어 파라미터 구분
                    var command         = commandAndParam[0];
                    var paramStr        = commandAndParam.Length > 1? commandAndParam[1] : "";

                    // 아직까지는 header 커맨드밖에 없으므로 간단하게 if로만 체크한다. 더 늘어나면 리팩토링이 필요해질듯...
                    if (command == "헤더" || command == "header")
                    {
                        sequence.Header.FromAsset(paramStr.Trim());
                    }
                    else
                    {
                        Debug.LogErrorFormat("[FSNSequence] line {0} : unknown preprocessor command {1}", linenumber, command);
                    }
                }
            }

            // 읽어들인 헤더 정보를 바탕으로 플래그/변수 기본값들 세팅하기 (선언되어있지 않은 경우에만)

            foreach (var pair in sequence.Header.FlagDeclarations)                    // 플래그 선언
            {
                if (!session.FlagIsDeclared(pair.Key))                                // 아직 선언되지 않은 경우만 세팅
                {
                    bool value = string.IsNullOrEmpty(pair.Value)?
                                 false : FSNUtils.StringToValue <bool>(pair.Value);                 // 초기값까지 선언한 경우 값 해독, 아니면 기본값 false
                    session.SetFlagValue(pair.Key, value, true);
                }
            }

            foreach (var pair in sequence.Header.ValueDeclarations)                   // 값 선언
            {
                if (!session.ValueIsDeclared(pair.Key))                               // 아직 선언되지 않은 경우만 세팅
                {
                    float value = string.IsNullOrEmpty(pair.Value)?
                                  0 : FSNUtils.StringToValue <float>(pair.Value);                   // 초기값까지 선언한 경우 값 해독, 아니면 기본값 false
                    session.SetNumberValue(pair.Key, value, true);
                }
            }
        }
        public void SetPropertyByString(string propName, string strval)
        {
            var propInfo = typeof(Chain).GetProperty(propName);

            if (propInfo == null)
            {
                Debug.LogError("Cannot find a property named " + propName);
            }
            else
            {
                object value = FSNUtils.StringToValue(propInfo.PropertyType, strval);
                propInfo.SetValue(this, value, null);
            }
        }
    public static void __fsnengine_SetValues(params string [] param)
    {
        int    count   = param.Length;
        string varname = null;

        for (int i = 0; i < count; i++)
        {
            if (i % 2 == 0)                                     // 홀수번째 파라미터는 플래그 이름
            {
                varname = param[i];
            }
            else
            {                                                                   // 짝수번째는 변수값. 바로 이전에 얻은 변수 이름으로 세팅한다
                engine.SetScriptValue(varname, FSNUtils.StringToValue <float>(param[i]));
                varname = null;
            }
        }
    }
Example #6
0
        protected override bool SetPropertyImpl(string name, string param)
        {
            // 기존 속성들은 사용하지 않음
            //return base.SetPropertyImpl(name, param);

            bool success = false;

            switch (name)
            {
            case c_property_clipPath:
                clipPath = param;
                success  = true;
                break;

            case c_property_volume:
                volume  = float.Parse(param);
                success = true;
                break;

            case c_property_panning:
                panning = float.Parse(param);
                success = true;
                break;

            case c_property_looping:
                looping = FSNUtils.StringToValue <bool>(param);
                success = true;
                break;

            case c_property_Transition:
                transition = float.Parse(param);
                success    = true;
                break;

            default:
                Debug.LogErrorFormat("[Segments.Sound] Wrong property name {0}", name);
                success = false;
                break;
            }
            return(success);
        }
Example #7
0
        protected override bool SetPropertyImpl(string name, string param)
        {
            switch (name)
            {
            case c_property_TexturePath:
                texturePath = param;
                return(true);

            case c_property_Pivot:
                pivot = FSNUtils.StringToValue <PivotPreset>(param);
                return(true);

            case c_property_CombImgPath:
                combinedImgPath = param;
                return(true);

            case c_property_AdaptToPerspective:
                adaptToPerspective = FSNUtils.StringToValue <bool>(param);
                return(true);
            }
            return(base.SetPropertyImpl(name, param));
        }