Beispiel #1
0
 public ActorEnter(string actorName, GameObject actorPrefab, CutscenePosition position)
 {
     this.actorPrefab = actorPrefab;
     this.position    = position;
     this.actorName   = actorName;
 }
Beispiel #2
0
        private CutsceneElement BuildObject(string segment)
        {
            //need to get each individual line in a segment
            string[] subSegments = segment.Split(new[] { "\r\n", "\r", "\n" }, StringSplitOptions.None);
            string   header      = subSegments[0];

            string[] tokens = header.Split(' ');

            if (tokens[0].Substring(0, 2).Equals("//"))
            {
                // Comment, exclude
                return(null);
            }
            else if (tokens[0].Contains("Scene:"))
            {
                //Scene transition
                if (tokens.Length == 2)
                {
                    string sceneName  = tokens[1];
                    Sprite background = null;
                    try {
                        background = backgroundPrefabs[sceneName];
                    } catch (KeyNotFoundException) {
                        throw new InvalidScreenplaySyntaxException("Unrecognized background", segment);
                    }

                    if (firstBackgroundAssigned)
                    {
                        return(new CutsceneTransition(background, false));
                    }
                    else
                    {
                        firstBackgroundAssigned = true;
                        return(new CutsceneTransition(background, true));
                    }
                }
                else
                {
                    throw new InvalidScreenplaySyntaxException("Invalid number of tokens for Scene Transition", segment);
                }
            }
            else if (tokens[0].Equals("Enter"))
            {
                // New actor
                CutscenePosition position = CutscenePosition.Center;
                switch (tokens[1].ToLower())
                {
                case "left:":
                    position = CutscenePosition.Left;
                    break;

                case "center:":
                    position = CutscenePosition.Center;
                    break;

                case "right:":
                    position = CutscenePosition.Right;
                    break;

                default:
                    throw new InvalidScreenplaySyntaxException("Unrecognized entry side", segment);
                }
                string actorName = tokens[2];

                GameObject actorPrefab = null;
                try {
                    actorPrefab = actorPrefabs[actorName];
                } catch (KeyNotFoundException) {
                    throw new InvalidScreenplaySyntaxException("Unrecognized actor", segment);
                }
                return(new ActorEnter(actorName, actorPrefab, position));
            }
            else if (tokens[0].Equals("Exit:"))
            {
                // actor leaving
                return(new ActorExit(tokens[1]));
            }
            else
            {
                //Actor Line
                string actorName = tokens[0];
                string pose;
                string line = "";

                if ((tokens.Length == 2) || (tokens.Length == 1))
                {
                    if (tokens.Length == 2)
                    {
                        //Pose is given
                        if ((tokens[1].IndexOf('(') == -1) || (tokens[1].IndexOf(')') == -1))
                        {
                            throw new InvalidScreenplaySyntaxException("missing one or more paranthesis in Actor Line", segment);
                        }
                        else
                        {
                            pose = tokens[1].Substring(tokens[1].IndexOf('(') + 1, tokens[1].IndexOf(')') - tokens[1].IndexOf('(') - 1);
                        }
                    }
                    else
                    {
                        //Pose is default
                        pose = "Neutral";
                    }

                    if (subSegments.Length > 1)
                    {
                        //A line exists (otherwise line is just "")
                        for (int i = 1; i < subSegments.Length; i++)
                        {
                            line += subSegments[i] + '\n';
                        }
                    }

                    return(new ActorLine(actorName, pose, line));
                }
                else
                {
                    throw new InvalidScreenplaySyntaxException("Invalid number of tokens for Actor Line", segment);
                }
            }
        }
Beispiel #3
0
 public IEnumerator addActor(Actor actor, CutscenePosition position)
 {
     yield return(null);
     //TODO
 }