Example #1
0
        //キャラクターのパターン変更をキーフレームアニメーションから呼ぶためのメソッド
        public virtual void ChangePatternAnimation(string paraString)
        {
            if (LastResource == null)
            {
                Debug.LogError("ChangePatternAnimationError  LastResource is null");
                return;
            }
            AdvCharacterSettingData characterData = LastResource.SettingData as AdvCharacterSettingData;

            if (characterData == null)
            {
                Debug.LogError("ChangePatternAnimationError  characterData is null");
                return;
            }

            string[] after = paraString.Split(new char[] { ',' });
            float    fadeTime;

            if (after.Length <= 0)
            {
                Debug.LogError("ChangePatternAnimationError  argString = " + paraString);
                return;
            }
            else if (after.Length == 1)
            {
                fadeTime = 0;
            }
            else
            {
                if (!WrapperUnityVersion.TryParseFloatGlobal(after[1], out fadeTime))
                {
                    Debug.LogError("ChangePatternAnimationError  " + after[1] + " is not float string");
                    return;
                }
            }
            //0秒だと、DestroyImmediateが呼ばれてしまうが
            //AnimationClip中でそれが許可されていないため
            fadeTime = Mathf.Max(fadeTime, 0.001f);

            string pattern = after[0];
            AdvCharacterSettingData newPatternData = Engine.DataManager.SettingDataManager.CharacterSetting.GetCharacterData(characterData.Name, pattern);

            if (newPatternData == null)
            {
                Debug.LogError("ChangePatternAnimationError  pattern is not pattern name");
                return;
            }

            //Graphicのロードは考慮しない
            var graphic = newPatternData.Graphic.Main;

            //描画
            DrawSub(graphic, Engine.Page.ToSkippedTime(fadeTime));
            //モーション変更
            if (!string.IsNullOrEmpty(graphic.AnimationState))
            {
                TargetObject.ChangeAnimationState(graphic.AnimationState, fadeTime);
            }
        }