Beispiel #1
0
        // <tag>+spwalk <x>, <time>
        // +spwalk <tag>, <x>, <time>
        public IEnumerator SpWalkTo(string tag, string[] args)
        {
            string spTag;
            float  distance, time, x;

            NArgsAssert(args.Length >= 2);

            if (!string.IsNullOrEmpty(tag))
            {
                spTag = tag;
            }
            else
            {
                spTag = args[0];
                args  = args.Skip(1).ToArray();
            }
            var npc = this[spTag];

            if (npc == null)
            {
                throw new NRuntimeException($"NPC tag:{tag} は存在しません.");
            }

            NArgsAssert(args.Length == 2);

            x    = NovelHelper.TryParse(args[0]);
            time = NovelHelper.TryParse(args[1]);

            yield return(Walk(npc, x - npc.transform.position.x, time));
        }
Beispiel #2
0
        public IEnumerator Wait(string t, string[] a)
        {
            // wait		0.5
            // process	0.2
            // wait		0.3
            // process	0.7
            // wait		-0.2	skip
            // process
            float i;

            if (!float.TryParse(NovelHelper.CombineAll(a), out i))
            {
                throw new NRuntimeException("不正な数値です.");
            }
            if (!source.isPlaying)
            {
                yield return(Novel.Runtime.Wait(t, a));

                waitCache = 0;
            }
            else
            {
                if (waitCache != 0)
                {
                    var wt   = i - (source.time - waitCache) + waitQueue;
                    var time = source.time;
                    Debug.Log($"wt:{wt}\nwaitCache:{waitCache}\nsource.time:{source.time}\nwaitQueue:{waitQueue}");
                    waitQueue = 0;
                    if (wt < 0)
                    {
                        waitQueue = wt;
                        waitCache = source.time;
                    }
                    else
                    {
                        var prevTime = source.time;
                        while (source.time - prevTime < wt)
                        {
                            yield return(new WaitForEndOfFrame());
                        }
                        waitCache = prevTime + wt;
                    }
                }
                else
                {
                    Debug.Log("waitCache == 0");
                    var prevTime = source.time;
                    while (source.time - prevTime < i)
                    {
                        yield return(new WaitForEndOfFrame());
                    }
                    waitCache = prevTime + i;
                }
            }
        }
Beispiel #3
0
 public IEnumerator Stop(string t, string[] a)
 {
     if (a.Length == 0)
     {
         Stop();
     }
     else
     {
         float i = NovelHelper.TryParse(NovelHelper.CombineAll(a));
         yield return(Stop(i));
     }
 }
Beispiel #4
0
        public IEnumerator SwitchToFreeCamera(string _, string[] args)
        {
            if (args.Length < 2)
            {
                throw new NRuntimeException("引数が足りません.");
            }
            var x = NovelHelper.TryParse(args[0]);
            var y = NovelHelper.TryParse(args[1]);

            SwitchToFreeCamera(x, y);
            yield break;
        }
        public IEnumerator Say(string sprite, params string[] args)
        {
            var messageSource = I18n[NovelHelper.CombineAll(args)];
            var voice         = "system.saying";

            // 話者がいる場合は表示
            // hack 今後もっとUIをよくする
            buffer        = string.IsNullOrEmpty(sprite) ? "" : sprite + " : ";
            messageSource = TextUtility.RemoveTags(messageSource);
            TextElement[] mes;
            try
            {
                mes = new TextComponent(messageSource).Elements;
            }
            catch (FormatException ex)
            {
                mes = new TextComponent(string.Format(I18n["fts.error"], TextUtility.ToSafeString(ex.Message))).Elements;
            }
            foreach (var c in mes)
            {
                if (c.WaitTime > 0)
                {
                    yield return(new WaitForSeconds(c.WaitTime));
                }

                if (c.Nod)
                {
                    yield return(Nod());
                }

                if (!string.IsNullOrWhiteSpace(c.Voice))
                {
                    voice = c.Voice;
                }

                buffer += c.ToString();
                if (!quickEnabled && c.Speed != 0)
                {
                    Sfx.Play(voice);
                    // タッチ時は早くする
                    yield return(new WaitForSeconds(speed / Mathf.Abs(c.Speed) / (IsTouched ? 2 : 1)));
                }
            }

            yield return(Nod());

            buffer = "";
        }
Beispiel #6
0
        // <tag>+spofs <x>, <y>
        // +spofs <tag>, <x>, <y>
        public IEnumerator SpOfs(string tag, string[] args)
        {
            string spTag;

            NArgsAssert(args.Length >= 2);
            if (!string.IsNullOrEmpty(tag))
            {
                spTag = tag;
            }
            else
            {
                spTag = args[0];
                args  = args.Skip(1).ToArray();
            }
            NArgsAssert(args.Length == 2);
            var x = NovelHelper.TryParse(args[0]);
            var y = NovelHelper.TryParse(args[1]);

            SpOfs(spTag, new Vector2(x, y));
            yield break;
        }
Beispiel #7
0
        // +spset <tag>, <charId>[, <x>, <y>]
        public IEnumerator SpSet(string _, string[] args)
        {
            if (args.Length < 2)
            {
                throw new NRuntimeException("引数が足りません.");
            }
            var spTag = args[0];
            var id    = args[1];
            var pos   = Vector2.zero;

            if (args.Length > 2)
            {
                if (args.Length > 4)
                {
                    throw new NRuntimeException("引数が多すぎます.");
                }

                pos.x = NovelHelper.TryParse(args[2]);
                pos.y = NovelHelper.TryParse(args[3]);
            }
            SpSet(spTag, id, pos);
            yield break;
        }
Beispiel #8
0
 public IEnumerator Play(string t, string[] a)
 {
     Play(NovelHelper.CombineAll(a));
     yield break;
 }
Beispiel #9
0
 public IEnumerator Change(string t, string[] a)
 {
     Change(NovelHelper.CombineAll(a));
     yield break;
 }
Beispiel #10
0
 public IEnumerator Move(string _, params string[] args)
 {
     Move(NovelHelper.CombineAll(args));
     yield break;
 }