예제 #1
0
 public void SetNextAction(Script action)
 {
     nextAction = action;
 }
예제 #2
0
        void ControlCharacter(Script line)
        {
            

            if (charactersN.Any(obj => obj.GetId() ==line.GetId()))
            {
                //Debug.Log(charactersN.Find(obj => obj.GetId() == line.GetId()).GetObject().GetComponent<Image>().color);
                switch (line.GetTitle())
                {
                    case "_fadein": // 이런 느낌으로 제어문 추가
                                    // characters[line.GetId()].GetComponent<Image>().CrossFadeColor(Color.white, 0.5f, false, true);
                        LeanTween.color(charactersN.Find(obj => obj.GetId() == line.GetId()).GetObject().GetComponent<RectTransform>(), Color.white, 0.5f);
                        //Debug.Log(charactersN.Find(obj => obj.GetId() == line.GetId()).GetObject().GetComponent<Image>().color);
                        //charactersN.Find(obj => obj.GetId() == line.GetId()).GetObject().GetComponent<Image>().CrossFadeColor(Color.white, 0.5f, false, true);
                        //characters[line.GetId()].GetComponent<Image>().CrossFadeAlpha(1.0f, 0.5f, false);

                        break;
                    case "_fadeout":
                        //  characters[line.GetId()].GetComponent<Image>().CrossFadeColor(Color.gray, 0.5f, false, true);
                        LeanTween.color(charactersN.Find(obj => obj.GetId() == line.GetId()).GetObject().GetComponent<RectTransform>(), Color.gray, 0.5f);
                        //charactersN.Find(obj => obj.GetId() == line.GetId()).GetObject().GetComponent<Image>().CrossFadeColor(Color.white, 0.5f, false, true);

                        break;
                    case "_wiggle":


                        break;
                    case "_remove":
                        StartCoroutine(RemoveCharacter(line.GetId()));
                       
                        break;
                    case "_change":
                        ChangeSprite(line.GetId(), line.GetMainText());
                        break;


                    default:
                        break;
                }//id:컨트롤 방법(_로 시작):
            }

        }
예제 #3
0
        public void InterpretLine(Script topLine)
        {
            
            {                
                if (topLine.GetId() == "background")
                {
                    switch (topLine.GetTitle())
                    {
                        case "change":

                            backgroundImage.sprite = Resources.Load<Sprite>(topLine.GetMainText().Trim());
                            break;
                        case "clear":
                            backgroundImage.sprite = null;
                            break;

                        default:
                            break;
                    }
                    return;

                }//배경 조절. background:change:경로 background:clear:
                else if (topLine.GetId().Contains("spawn"))
                {
                    SpawnCharacter(topLine);
                }
                else if (topLine.GetId() == "sound")
                {
                    
                    gameObject.GetComponent<AudioSource>().clip = Resources.Load(topLine.GetTitle()) as AudioClip;
                    gameObject.GetComponent<AudioSource>().Play();
                }//sound:경로명: or (sound:경로명:bgm 이쪽은 아직 미구현..)
                else
                {
                    if (topLine.GetTitle().StartsWith("_"))
                    {
                        ControlCharacter(topLine);

                    }//id:컨트롤 방법(_로 시작):
                    else
                    {
                        //id가 같으면 white, 다르면 lightgray.
                        foreach (Character character in charactersN)
                        {
                            if (character.GetId() == topLine.GetId())
                            {
                                LeanTween.color(character.GetObject().GetComponent<RectTransform>(), Color.white, 0.2f);
                            }
                            else
                            {
                                LeanTween.color(character.GetObject().GetComponent<RectTransform>(), new Color(0.8f, 0.8f, 0.8f, 1), 0.2f);
                            }
                        }
                        title.text = topLine.GetTitle();
                        mainText.text = topLine.GetMainText();

                    }//id:제목:대사 
                }
            }

        }//파이선에서의 readline과 같이 작동하도록 설계.
예제 #4
0
        }//파이선에서의 readline과 같이 작동하도록 설계.

        void SpawnCharacter(Script topLine) //spawn_replace_left
        {

            {
                bool spawnToLeft = false;
                bool isReplace = false;
                bool isSlide = false;
                GameObject newCharacter = Instantiate(Resources.Load(topLine.GetTitle()) as GameObject, new Vector3(640, 0, 0), Quaternion.identity) as GameObject;
                newCharacter.transform.SetParent(characterSpawnPosition.transform, false);
                //move from left, right, top, bottom
                //spawn_from_left....
                if (topLine.GetId().Contains("to_left"))
                {
                    spawnToLeft = true;
                }
                if (topLine.GetId().Contains("replace"))
                {
                    isReplace = true;
                }

                if (topLine.GetId().Contains("from_left"))
                {
                    newCharacter.GetComponent<RectTransform>().anchoredPosition = new Vector3(-200, 0);
                    isSlide = true;
                }
                else if (topLine.GetId().Contains("from_right"))
                {
                    newCharacter.GetComponent<RectTransform>().anchoredPosition = new Vector3(1500, 0);
                    isSlide = true;
                }
                else if (topLine.GetId().Contains("from_top"))
                {
                    newCharacter.GetComponent<RectTransform>().anchoredPosition = new Vector3(640, 700);
                    isSlide = true;
                }
                else if (topLine.GetId().Contains("from_bottom"))
                {
                    newCharacter.GetComponent<RectTransform>().anchoredPosition = new Vector3(640, -750);
                    isSlide = true;
                }
                if (!isSlide)
                {
                    newCharacter.GetComponent<CanvasRenderer>().SetAlpha(0);
                    newCharacter.GetComponent<Image>().CrossFadeAlpha(1.0f, 0.5f, false);
                }
                //newCharacter.GetComponent<RectTransform>().transform;
                if (isReplace)
                {
                    if (spawnToLeft)
                    {
                        Destroy(charactersN[0].GetObject());
                        charactersN[0] = new Character(topLine.GetMainText().Trim(), newCharacter);
                    }
                    else
                    {
                        var lastObj = charactersN.Last();
                        Destroy(lastObj.GetObject());
                        lastObj = new Character(topLine.GetMainText().Trim(), newCharacter);
                    }
                }
                else
                {
                    if (spawnToLeft)
                    {
                        charactersN.Insert(0, new Character(topLine.GetMainText().Trim(), newCharacter));
                    }
                    else
                    {
                        charactersN.Add(new Character(topLine.GetMainText().Trim(), newCharacter));
                    }
                    SortCharactersPosition();
                }

                //  characters.Add(topLine.GetMainText().Trim(), newCharacter); //좌측에서 spawn되는 경우 맨 첫번째에 spawn해야 한다.

            }
        }
예제 #5
0
 public List<Script> ScriptFileToList(string scriptName)
 {
     List<Script> scripts = new List<Script>();
     try
     {
         TextAsset rawScript = Resources.Load(scriptName) as TextAsset;
         List<string> rawScriptList = rawScript.text.Split('\n').ToList();
         foreach (string line in rawScriptList)
         {
             if (line.StartsWith("initial"))//initial:시작 시 일어날 동작들
             {
                 string[] scriptLine = line.Split(':');
                 Debug.Log(scriptLine.Length);
                 Script _script = new Script(scriptLine[1], scriptLine[2], scriptLine[3]);
                 if (scriptLine.Length == 7)
                 {
                     Script nextScript = new Script(scriptLine[4], scriptLine[5], scriptLine[6]);
                     _script.SetNextAction(nextScript);
                 }
                 initialScripts.Add(_script);
             }
             else
             {
                 string[] scriptLine = line.Split(':');
                 Debug.Log(scriptLine.Length);
                 Script _script = new Script(scriptLine[0], scriptLine[1], scriptLine[2]);
                 if (scriptLine.Length == 6)
                 {
                     Script nextScript = new Script(scriptLine[3], scriptLine[4], scriptLine[5]);
                     _script.SetNextAction(nextScript);
                 }
                 scripts.Add(_script);
             }
         }
     }
     catch (System.Exception)
     {
         Debug.Log("script not found");
         throw;
     }
     return scripts;
 }