示例#1
0
        /// <summary>
        /// 文字列からピボットを解析する
        /// </summary>
        /// <param name="text">テキスト</param>
        /// <param name="defaultValue">デフォルト値</param>
        /// <returns>解析したピボット値。文字列が設定されてなかったらデフォルト値を。解析できなかったら例外を投げる</returns>
        public static Vector2 ParsePivotOptional(string text, Vector2 defaultValue)
        {
            //何も設定がなければデフォルト値を
            if (string.IsNullOrEmpty(text))
            {
                return(defaultValue);
            }

            Vector2 pivot = Vector2.one * 0.5f;

            Pivot pivotEnum;

            if (UtageToolKit.TryParaseEnum <Pivot>(text, out pivotEnum))
            {
                return(PivotUtil.PivotEnumToVector2(pivotEnum));
            }

            if (ParserUtil.TryParseVector2Optional(text, pivot, out pivot))
            {
                return(pivot);
            }
            else
            {
                throw new System.Exception(LanguageErrorMsg.LocalizeTextFormat(ErrorMsg.PivotParse, text));
            }
        }
示例#2
0
        /// <summary>
        /// 文字列で書かれた、スケール値を読みとる
        /// </summary>
        /// <param name="text">テキスト</param>
        /// <param name="defaultValue">デフォルト値</param>
        /// <returns>スケール値。文字列が設定されてなかったらデフォルト値を。解析できなかったら例外を投げる</returns>
        public static Vector2 ParseScale2DOptional(string text, Vector2 defaultValue)
        {
            //何も設定がなければデフォルト値を
            if (string.IsNullOrEmpty(text))
            {
                return(defaultValue);
            }

            Vector2 scale = defaultValue;

            //数字だけが書かれていた場合はx,yを同じ値として扱う
            float s;

            if (float.TryParse(text, out s))
            {
                return(Vector2.one * s);
            }

            if (ParserUtil.TryParseVector2Optional(text, scale, out scale))
            {
                return(scale);
            }
            else
            {
                throw new System.Exception("Parse Scale2D Error " + text);
            }
        }
示例#3
0
/*
 *              /// <summary>
 *              /// ラベルからファイルパスを取得
 *              /// </summary>
 *              /// <param name="name">キャラ名</param>
 *              /// <param name="label">ラベル</param>
 *              /// <returns>ファイルパス</returns>
 *              public string LabelToPath(string name, string label)
 *              {
 *                      //既に絶対URLならそのまま
 *                      if (UtageToolKit.IsAbsoluteUri(label))
 *                      {
 *                              return label;
 *                      }
 *                      else
 *                      {
 *                              string key = ToFileKey(name, label);
 *                              AdvCharacterSettingData data = FindData(key);
 *                              if (data == null)
 *                              {
 *                                      //ラベルをそのままファイル名扱いに
 *                                      return label;
 *                              }
 *                              else
 *                              {
 *                                      return data.FilePath;
 *                              }
 *                      }
 *              }
 */

        public AdvCharacterInfo ParseCharacterInfo(string nameText, string patternLabel, out string erroMsg)
        {
            string characterTag = "";
            bool   isHide       = false;
            string msg          = "";
            Func <string, string, bool> callbackTagParse = (tagName, arg) =>
            {
                switch (tagName)
                {
                case "Off":
                    isHide = true;
                    return(true);

                case "Character":
                    characterTag = arg;
                    return(true);

                default:
                    msg = "Unkownn Tag <" + tagName + ">";
                    return(false);
                }
            };

            patternLabel = ParserUtil.ParseTagTextToString(patternLabel, callbackTagParse);
            erroMsg      = msg;
            if (!string.IsNullOrEmpty(characterTag) && !Contains(characterTag))
            {
                if (!string.IsNullOrEmpty(erroMsg))
                {
                    erroMsg += "\n";
                }
                erroMsg = "Unknown Character [" + characterTag + "] ";
            }
            return(GetCharacterInfoSub(nameText, characterTag, patternLabel, isHide));
        }
示例#4
0
        /// <summary>
        /// 文字列で書かれた、スケール値を読みとる
        /// </summary>
        /// <param name="text">テキスト</param>
        /// <param name="defaultValue">デフォルト値</param>
        /// <returns>スケール値。文字列が設定されてなかったらデフォルト値を。解析できなかったら例外を投げる</returns>
        public static Vector3 ParseScale3DOptional(string text, Vector3 defaultValue)
        {
            //何も設定がなければデフォルト値を
            if (string.IsNullOrEmpty(text))
            {
                return(defaultValue);
            }

            Vector3 scale = defaultValue;

            //数字だけが書かれていた場合はx,yを同じ値として扱う
            float s;

            if (WrapperUnityVersion.TryParseFloatGlobal(text, out s))
            {
                return(Vector3.one * s);
            }

            if (ParserUtil.TryParseVector3Optional(text, scale, out scale))
            {
                return(scale);
            }
            else
            {
                throw new System.Exception("Parse Scale3D Error " + text);
            }
        }
示例#5
0
        public GraphicInfo(StringGridRow row)
        {
            this.RowData  = row;
            this.fileName = AdvParser.ParseCell <string>(row, AdvColumnName.FileName);
            try
            {
                this.pivot = ParserUtil.ParsePivotOptional(AdvParser.ParseCellOptional <string>(row, AdvColumnName.Pivot, ""), pivot);
            }
            catch (System.Exception e)
            {
                Debug.LogError(row.ToErrorString(e.Message));
            }

            try
            {
                this.scale = ParserUtil.ParseScale2DOptional(AdvParser.ParseCellOptional <string>(row, AdvColumnName.Scale, ""), this.scale);
            }
            catch (System.Exception e)
            {
                Debug.LogError(row.ToErrorString(e.Message));
            }
            this.CondionalExpression = AdvParser.ParseCellOptional <string>(row, AdvColumnName.Conditional, "");
            this.version             = AdvParser.ParseCellOptional <int>(row, AdvColumnName.Version, 0);
//			this.IgnoreLoad = AdvParser.ParseCellOptional<bool>(row, AdvColumnName.IgnoreLoad, false);
        }
示例#6
0
 /// <summary>
 /// メタデータを含むテキストデータを解析
 /// </summary>
 /// <param name="text">解析するテキスト</param>
 void Parse()
 {
     try
     {
         //テキストを先頭から1文字づつ解析
         int max = OriginalText.Length;
         currentTextIndex = 0;
         while (currentTextIndex < max)
         {
             if (ParseEscapeScance())
             {
                 //エスケープシーケンスの処理
             }
             else
             {
                 int endIndex = ParserUtil.ParseTag(OriginalText, currentTextIndex, ParseTagSub);
                 if (currentTextIndex == endIndex)
                 {
                     //通常パターンのテキストを1文字追加
                     AddChar(OriginalText[currentTextIndex]);
                     ++currentTextIndex;
                 }
                 else
                 {
                     currentTextIndex = endIndex + 1;
                 }
             }
         }
     }
     catch (System.Exception e)
     {
         AddErrorMsg(e.Message + e.StackTrace);
     }
 }
示例#7
0
        public AdvGraphicInfo(string dataType, int index, string key, StringGridRow row, IAdvSettingData advSettindData)
        {
            this.DataType    = dataType;
            this.Index       = index;
            this.Key         = key;
            this.SettingData = advSettindData;
            this.RowData     = row;

            switch (DataType)
            {
            case AdvGraphicInfo.TypeParticle:
                this.FileType = AdvGraphicInfo.FileTypeParticle;
                break;

            default:
                this.FileType = AdvParser.ParseCellOptional <string>(row, AdvColumnName.FileType, "");
                break;
            }

            this.FileName = AdvParser.ParseCell <string>(row, AdvColumnName.FileName);
            try
            {
                this.Pivot = ParserUtil.ParsePivotOptional(AdvParser.ParseCellOptional <string>(row, AdvColumnName.Pivot, ""), new Vector2(0.5f, 0.5f));
            }
            catch (System.Exception e)
            {
                Debug.LogError(row.ToErrorString(e.Message));
            }

            try
            {
                this.Pivot0 = ParserUtil.ParsePivotOptional(AdvParser.ParseCellOptional <string>(row, AdvColumnName.Pivot0, ""), new Vector2(0.5f, 0.5f));
            }
            catch (System.Exception e)
            {
                Debug.LogError(row.ToErrorString(e.Message));
            }

            try
            {
                this.Scale = ParserUtil.ParseScale3DOptional(AdvParser.ParseCellOptional <string>(row, AdvColumnName.Scale, ""), Vector3.one);
            }
            catch (System.Exception e)
            {
                Debug.LogError(row.ToErrorString(e.Message));
            }

            Vector3 pos;

            pos.x         = AdvParser.ParseCellOptional <float>(row, AdvColumnName.X, 0);
            pos.y         = AdvParser.ParseCellOptional <float>(row, AdvColumnName.Y, 0);
            pos.z         = AdvParser.ParseCellOptional <float>(row, AdvColumnName.Z, 0);
            this.Position = pos;

            this.SubFileName = AdvParser.ParseCellOptional <string>(row, AdvColumnName.SubFileName, "");

            this.ConditionalExpression = AdvParser.ParseCellOptional <string>(row, AdvColumnName.Conditional, "");
            this.RenderTextureSetting.Parse(row);
        }
示例#8
0
 protected virtual void ParseEffectTarget(AdvColumnName columnName)
 {
     this.targetName = base.ParseCell <string>(columnName);
     if (!ParserUtil.TryParaseEnum <AdvEffectManager.TargetType>(this.targetName, out this.targetType))
     {
         this.targetType = AdvEffectManager.TargetType.Default;
     }
 }
示例#9
0
 /// <summary>
 /// メタデータを含むテキストデータを解析
 /// </summary>
 /// <param name="text">解析するテキスト</param>
 protected virtual void Parse()
 {
     try
     {
         //テキストを先頭から1文字づつ解析
         int max   = OriginalText.Length;
         int index = 0;
         while (index < max)
         {
             if (ParseEscapeSequence(index))
             {
                 //エスケープシーケンスの処理
                 index += 2;
             }
             else
             {
                 string tagName  = "";
                 string tagArg   = "";
                 int    endIndex = ParserUtil.ParseTag(OriginalText, index,
                                                       (name, arg) =>
                 {
                     bool ret = ParseTag(name, arg);
                     if (ret)
                     {
                         tagName = name;
                         tagArg  = arg;
                     }
                     return(ret);
                 });
                 if (index == endIndex)
                 {
                     //タグがなかった
                     //通常パターンのテキストを1文字追加
                     AddChar(OriginalText[index]);
                     ++index;
                 }
                 else
                 {
                     //タグデータを挿入
                     string tagString = OriginalText.Substring(index, endIndex - index + 1);
                     PoolList.Insert(0, MakeTag(tagString, tagName, tagArg));
                     index = endIndex + 1;
                 }
             }
             ParsedDataList.AddRange(PoolList);
             PoolList.Clear();
         }
         PoolList.Clear();
     }
     catch (System.Exception e)
     {
         AddErrorMsg(e.Message + e.StackTrace);
     }
 }
示例#10
0
        /// <summary>
        /// メタデータを含むテキストデータを解析
        /// </summary>
        /// <param name="text">解析するテキスト</param>
        void Parse()
        {
            try
            {
                //テキストを先頭から1文字づつ解析
                int max = OriginalText.Length;
                currentTextIndex = 0;
                while (currentTextIndex < max)
                {
                    if (ParseEscapeSequence())
                    {
                        //エスケープシーケンスの処理
                    }
                    else
                    {
                        Func <string, string, bool> callbackParseTag;
                        if (isParseParamOnly)
                        {
                            callbackParseTag = ParseTagParamOnly;
                        }
                        else
                        {
                            callbackParseTag = ParseTag;
                        }

                        int endIndex = ParserUtil.ParseTag(OriginalText, currentTextIndex, callbackParseTag);
                        if (currentTextIndex == endIndex)
                        {
                            //通常パターンのテキストを1文字追加
                            AddChar(OriginalText[currentTextIndex]);
                            ++currentTextIndex;
                        }
                        else
                        {
                            currentTextIndex = endIndex + 1;
                        }
                    }
                }
            }
            catch (System.Exception e)
            {
                AddErrorMsg(e.Message + e.StackTrace);
            }
        }
示例#11
0
 public bool TryParse(string name, string type, string fileType)
 {
     this.key = name;
     if (!ParserUtil.TryParaseEnum <ParamType>(type, out this.type))
     {
         Debug.LogError(type + " is not ParamType");
         return(false);
     }
     if (string.IsNullOrEmpty(fileType))
     {
         this.fileType = FileType.Default;
     }
     else if (!ParserUtil.TryParaseEnum <FileType>(fileType, out this.fileType))
     {
         Debug.LogError(fileType + " is not FileType");
         return(false);
     }
     return(true);
 }
示例#12
0
 protected virtual void ParseWait(AdvColumnName columnName)
 {
     if (base.IsEmptyCell(columnName))
     {
         base.WaitType = AdvCommandWaitType.ThisAndAdd;
     }
     else
     {
         AdvCommandWaitType type;
         if (!ParserUtil.TryParaseEnum <AdvCommandWaitType>(base.ParseCell <string>(columnName), out type))
         {
             base.WaitType = AdvCommandWaitType.NoWait;
             Debug.LogError(base.ToErrorString("UNKNOWN WaitType"));
         }
         else
         {
             base.WaitType = type;
         }
     }
 }
示例#13
0
        /// <summary>
        /// 宴用のカスタムインポート設定を強制するSpriteアセットかチェック
        /// </summary>
        public TextureType ParseCustomImportTextureType(AssetImporter importer)
        {
            string assetPath = importer.assetPath;

            foreach (Object folderAsset in CustomInportSpriteFolders)
            {
                string floderPath = AssetDatabase.GetAssetPath(folderAsset);
                if (assetPath.StartsWith(floderPath))
                {
                    string      name = System.IO.Path.GetFileName(floderPath);
                    TextureType type;
                    if (ParserUtil.TryParaseEnum <TextureType>(name, out type))
                    {
                        return(type);
                    }
                    return(TextureType.Unknown);
                }
            }
            return(TextureType.Unknown);
        }
 private void Parse()
 {
     try
     {
         int length = this.OriginalText.Length;
         this.currentTextIndex = 0;
         while (this.currentTextIndex < length)
         {
             if (!this.ParseEscapeSequence())
             {
                 Func <string, string, bool> func;
                 if (this.isParseParamOnly)
                 {
                     func = new Func <string, string, bool>(this.ParseTagParamOnly);
                 }
                 else
                 {
                     func = new Func <string, string, bool>(this.ParseTag);
                 }
                 int num2 = ParserUtil.ParseTag(this.OriginalText, this.currentTextIndex, func);
                 if (this.currentTextIndex == num2)
                 {
                     this.AddChar(this.OriginalText[this.currentTextIndex]);
                     this.currentTextIndex++;
                 }
                 else
                 {
                     this.currentTextIndex = num2 + 1;
                 }
             }
         }
     }
     catch (Exception exception)
     {
         this.AddErrorMsg(exception.Message + exception.StackTrace);
     }
 }
示例#15
0
 //ウェイトタイプを解析
 protected virtual void ParseWait(AdvColumnName columnName)
 {
     //第6引数でウェイトタイプの設定
     if (IsEmptyCell(columnName))
     {
         //設定なしの場合
         this.WaitType = AdvCommandWaitType.Default;
     }
     else
     {
         string             waitString = ParseCell <string>(columnName);
         AdvCommandWaitType waitType;
         if (!ParserUtil.TryParaseEnum <AdvCommandWaitType>(waitString, out waitType))
         {
             //何のタイプか不明
             this.WaitType = AdvCommandWaitType.NoWait;
             Debug.LogError(ToErrorString("UNKNOWN WaitType"));
         }
         else
         {
             this.WaitType = waitType;
         }
     }
 }
/*
 *              /// <summary>
 *              /// ラベルからファイルパスを取得
 *              /// </summary>
 *              /// <param name="name">キャラ名</param>
 *              /// <param name="label">ラベル</param>
 *              /// <returns>ファイルパス</returns>
 *              public string LabelToPath(string name, string label)
 *              {
 *                      //既に絶対URLならそのまま
 *                      if (UtageToolKit.IsAbsoluteUri(label))
 *                      {
 *                              return label;
 *                      }
 *                      else
 *                      {
 *                              string key = ToFileKey(name, label);
 *                              AdvCharacterSettingData data = FindData(key);
 *                              if (data == null)
 *                              {
 *                                      //ラベルをそのままファイル名扱いに
 *                                      return label;
 *                              }
 *                              else
 *                              {
 *                                      return data.FilePath;
 *                              }
 *                      }
 *              }
 */

        public AdvCharacterInfo GetCharacterInfo(string nameText, string patternLabel)
        {
            string characterTag = "";
            bool   isHide       = false;
            Func <string, string, bool> callbackTagParse = (tagName, arg) =>
            {
                switch (tagName)
                {
                case "Off":
                    isHide = true;
                    return(true);

                case "Character":
                    characterTag = arg;
                    return(true);

                default:
                    return(false);
                }
            };

            patternLabel = ParserUtil.ParseTagTextToString(patternLabel, callbackTagParse);
            return(GetCharacterInfoSub(nameText, characterTag, patternLabel, isHide));
        }
示例#17
0
        public static string ParsePatternOnly(AdvCommand command)
        {
            return(ParserUtil.ParseTagTextToString(
                       command.ParseCellOptional <string>(AdvColumnName.Arg2, ""),
                       (tagName, arg) =>
            {
                bool failed = false;
                switch (tagName)
                {
                case "Off":
                    //非表示タグ
                    break;

                case "Character":
                    //キャラクターラベルの指定タグ
                    break;

                default:
                    failed = true;
                    break;
                }
                return !failed;
            }));
        }
示例#18
0
        public AdvGraphicInfo(string dataType, int index, string key, StringGridRow row, IAdvSettingData advSettindData)
        {
            this.DataType    = dataType;
            this.Index       = index;
            this.Key         = key;
            this.SettingData = advSettindData;
            this.RowData     = row;

            switch (DataType)
            {
            case AdvGraphicInfo.TypeParticle:
                this.FileType = AdvGraphicInfo.FileTypeParticle;
                break;

            default:
                this.FileType = AdvParser.ParseCellOptional <string>(row, AdvColumnName.FileType, "");
                break;
            }

            this.FileName = AdvParser.ParseCell <string>(row, AdvColumnName.FileName);
            try
            {
                this.Pivot = ParserUtil.ParsePivotOptional(AdvParser.ParseCellOptional <string>(row, AdvColumnName.Pivot, ""), new Vector2(0.5f, 0.5f));
            }
            catch (System.Exception e)
            {
                Debug.LogError(row.ToErrorString(e.Message));
            }

            try
            {
                string pivot0String = AdvParser.ParseCellOptional <string>(row, AdvColumnName.Pivot0, "");
                this.EnablePivot0 = !string.IsNullOrEmpty(pivot0String) || pivot0String != "NoUse";
                if (this.EnablePivot0)
                {
                    this.Pivot0 = ParserUtil.ParsePivotOptional(pivot0String, new Vector2(0.5f, 0.5f));
                }
                else
                {
                    this.Pivot0 = new Vector2(0.5f, 0.5f);
                }
            }
            catch (System.Exception e)
            {
                Debug.LogError(row.ToErrorString(e.Message));
            }

            try
            {
                this.Scale = ParserUtil.ParseScale3DOptional(AdvParser.ParseCellOptional <string>(row, AdvColumnName.Scale, ""), Vector3.one);
            }
            catch (System.Exception e)
            {
                Debug.LogError(row.ToErrorString(e.Message));
            }

            Vector3 pos;

            pos.x         = AdvParser.ParseCellOptional <float>(row, AdvColumnName.X, 0);
            pos.y         = AdvParser.ParseCellOptional <float>(row, AdvColumnName.Y, 0);
            pos.z         = AdvParser.ParseCellOptional <float>(row, AdvColumnName.Z, 0);
            this.Position = pos;

            this.SubFileName    = AdvParser.ParseCellOptional <string>(row, AdvColumnName.SubFileName, "");
            this.AnimationState = AdvParser.ParseCellOptional <string>(row, AdvColumnName.AnimationState, "");

            this.ConditionalExpression = AdvParser.ParseCellOptional <string>(row, AdvColumnName.Conditional, "");
            this.RenderTextureSetting.Parse(row);

            this.Loop = row.ParseCellOptional <bool>("Loop", true);

            //アイコンファイルの設定
            this.Icon = new AdvFaceIconInfo(row);
        }
示例#19
0
        public static AdvCharacterInfo Create(AdvCommand command, AdvSettingDataManager dataManager)
        {
            if (command.IsEmptyCell(AdvColumnName.Arg1))
            {
                return(null);
            }

            //名前
            string nameText       = command.ParseCell <string>(AdvColumnName.Arg1);
            string characterLabel = nameText;
            //第二引数を解析
            //基本的にはパターン名だが
            //キャラクターラベルの指定タグがあったり、非表示タグする
            bool   isHide  = false;
            string erroMsg = "";
            string pattern = ParserUtil.ParseTagTextToString(
                command.ParseCellOptional <string>(AdvColumnName.Arg2, ""),
                (tagName, arg) =>
            {
                bool failed = false;
                switch (tagName)
                {
                case "Off":
                    //非表示タグ
                    isHide = true;
                    break;

                case "Character":
                    //キャラクターラベルの指定タグ
                    characterLabel = arg;
                    break;

                default:
                    erroMsg = "Unkownn Tag <" + tagName + ">";
                    failed  = true;
                    break;
                }
                return(!failed);
            });

            if (!string.IsNullOrEmpty(erroMsg))
            {
                Debug.LogError(erroMsg);
                return(null);
            }

            if (!dataManager.CharacterSetting.Contains(characterLabel))
            {
                //そもそもキャラ表示がない場合、名前表示のみになる
                return(new AdvCharacterInfo(characterLabel, nameText, pattern, isHide, null));
            }

            AdvCharacterSettingData data = dataManager.CharacterSetting.GetCharacterData(characterLabel, pattern);

            //キャラの表示情報の記述エラー
            if (data == null)
            {
                Debug.LogError(command.ToErrorString(characterLabel + ", " + pattern + " is not contained in Chactecter Sheet"));
                return(null);
            }
            //名前テキストをキャラクターシートの定義に変更
            if (!string.IsNullOrEmpty(data.NameText) && nameText == characterLabel)
            {
                nameText = data.NameText;
            }
            return(new AdvCharacterInfo(characterLabel, nameText, pattern, isHide, data.Graphic));
        }