Exemple #1
0
    IEnumerator RunCommand(string commandLine)
    {
        string command = commandLine.Split('(', ')')[0];

        string[] p = commandLine.Split('(', ')')[1].Split(',');

        switch (command)
        {
            #region Dialogue
        case "delay":
        {
            yield return(new WaitForSeconds(float.Parse(p[0])));
        } break;

        case "db_fadeIO":
        {
            yield return(StartCoroutine(SpriteController.FadeOut(dialogueBox, 1.5f)));

            yield return(new WaitForSeconds(0.75f));

            charNameText.text = "";
            sentenceText.text = "";
            yield return(StartCoroutine(SpriteController.FadeIn(dialogueBox, 1.5f)));
        }
        break;

            #endregion



            #region Cam

        case "cam_move":
        {
            yield return(StartCoroutine(cameraController.Move(p[0], p[1], p[2], p[3])));
        }
        break;


        case "cam_set_pos":
        {
            cameraController.SetCamPos(p[0], p[1], p[2]);
        }
        break;

        case "cam_shake":
        {
            yield return(StartCoroutine(cameraController.Shake(p[0])));
        } break;


            #endregion



            #region Background

        case "bg_set_posX":
        {
            backgroundController.SetPosX(p[0]);
        }
        break;

        case "bg_set_scale":
        {
            backgroundController.SetScale(p[0]);
        }
        break;

        case "fadein":
        {
            yield return(StartCoroutine(backgroundController.RunFadeIn(p[0], p[1])));
        }
        break;

        case "swipe":
        {
            yield return(StartCoroutine(backgroundController.RunSwipe(p[0], p[1])));
        }
        break;

        case "crossfade":
        {
            yield return(StartCoroutine(backgroundController.RunCrossFade(p[0], p[1])));
        }
        break;
            #endregion



            #region Video

        case "video_play":
        {
            yield return(StartCoroutine(GetComponent <VideoController>().PlayVideo(p[0])));
        } break;

        case "video_rewind":
        {
            yield return(StartCoroutine(SpriteController.FadeOut(dialogueBox, 0.75f)));

            charNameText.text = "";
            sentenceText.text = "";

            yield return(StartCoroutine(soundController.FadeOutBgm("1")));

            VideoPlayer vp = GetComponent <VideoPlayer>();
            StartCoroutine(GetComponent <VideoController>().PlayVideo("prologue_rewind"));

            while (!vp.isPlaying)
            {
                yield return(new WaitForSeconds(0.25f));
            }

            backgroundController.ShowBackground("street1_t2");
            characterController.Hide("sb");



            while (vp.isPlaying)
            {
                yield return(new WaitForSeconds(0.25f));
            }

            yield return(StartCoroutine(SpriteController.FadeIn(dialogueBox, 1)));
        }
        break;


            #endregion



            #region Character Basic Function

        case "create":
        {
            characterController.CreateCharacter(p[0], p[1], p[2], p[3]);
        } break;

        case "distance":
        {
            characterController.SetDistance(p[0], p[1]);
        } break;

        case "posX":
        {
            characterController.SetPosX(p[0], p[1]);
        } break;

        case "show":
        {
            yield return(StartCoroutine(characterController.RunShow(p[0])));
        } break;

        case "show_all":
        {
            Transform characters = GameObject.Find("Characters").transform;

            for (int i = 0; i < characters.childCount; i++)
            {
                if (i == characters.childCount - 1)
                {
                    yield return(StartCoroutine(characterController.RunShow(characters.GetChild(i).name)));
                }
                else
                {
                    StartCoroutine(characterController.RunShow(characters.GetChild(i).name));
                }
            }
        } break;

        case "hide":
        {
            yield return(StartCoroutine(characterController.RunHide(p[0])));
        } break;

        case "hide_all":
        {
            Transform characters = GameObject.Find("Characters").transform;

            for (int i = 0; i < characters.childCount; i++)
            {
                if (i == characters.childCount - 1)
                {
                    yield return(StartCoroutine(characterController.RunHide(characters.GetChild(i).name)));
                }
                else
                {
                    StartCoroutine(characterController.RunHide(characters.GetChild(i).name));
                }
            }
        }
        break;

        case "e":
        {
            yield return(StartCoroutine(characterController.RunChangeExpression(p[0], p[1], p[2])));
        } break;

        case "move":
        {
            if (p.Length == 3)
            {
                yield return(StartCoroutine(characterController.RunMove(p[0], p[1], p[2])));
            }
            else if (p[4] == "show")
            {
                StartCoroutine(characterController.RunShow(p[0]));
                yield return(StartCoroutine(characterController.RunMove(p[0], p[1], p[2])));
            }
            else if (p[4] == "hide")
            {
                StartCoroutine(characterController.RunMove(p[0], p[1], p[2]));
                yield return(StartCoroutine(characterController.RunHide(p[0])));
            }
        } break;



            #endregion


            //not yet
            #region Character Extra Function

        case "shake":
        {
            yield return(StartCoroutine(characterController.RunShake(p[0], p[1], p[2], p[3])));
        } break;


        case "rabbitear_show":
        {
            yield return(StartCoroutine(characterController.RunRabbitEar()));
        } break;

        case "rabbitear_set":
        {
            characterController.SetRabbitEar();
        } break;


        case "glasses":
        {
        } break;

        case "hat":
        {
        } break;

            #endregion



            #region Sound

        case "bgm_play":
        {
            soundController.PlayBgm(p[0]);
        } break;

        case "bgm_stop":
        {
            soundController.StopBgm();
        } break;

        case "bgm_fadeout":
        {
            StartCoroutine(soundController.FadeOutBgm(p[0]));
        }
        break;

        case "effect_play":
        {
            soundController.PlayEffect(p[0]);
        } break;

        case "effect_stop":
        {
            soundController.StopEffect();
        } break;

            #endregion


            #region Keyword
        case "keyword":
        {
            keywordController.ShowKeyword(p[0]);
        } break;

            #endregion
        }
    }