Exemple #1
0
        private static IEnumerable <StageAction> ParseStageActions(string currentCharacterDevName, string[] cues)
        {
            List <StageAction> results = new List <StageAction>();
            var charMoves = new List <CharacterMove>();

            string characterName = currentCharacterDevName;

            foreach (string cue in cues)
            {
                if (!int.TryParse(cue, out int newStagePos))
                {
                    string      expression       = cue;
                    StageAction expressionAction = StageActionFactory.NewExpressionAction(characterName, expression);
                    results.Add(expressionAction);
                    // yield return expressionAction;
                }
                else
                {
                    charMoves.Add(new CharacterMove(characterName, newStagePos));
                    StageAction stageAction = StageActionFactory.NewStageMoveAction(charMoves);
                    // yield return stageAction;
                    results.Add(stageAction);
                }
            }

            return(results);
        }
Exemple #2
0
        public static IEnumerable <StageAction> ParseStageActions(int a, string lastCharacterDevName, string[] cues)
        {
            List <StageAction>   results   = new List <StageAction>();
            List <CharacterMove> charMoves = new List <CharacterMove>();

            // int charIdx;
            // int actionIdx ;
            for (int charIdx = -1, actionIdx = 0; charIdx < a; charIdx += 2, actionIdx += 2)
            {
                string characterName;
                if (charIdx == -1)
                {
                    characterName = lastCharacterDevName;
                }
                else
                {
                    characterName = cues[charIdx].Trim();
                }

                string cueMeta = cues[actionIdx].Trim();

                string expression;

                if (int.TryParse(cueMeta, out int newStagePos))
                {
                    // ZLog.Info($"[MOVE] {characterName} to pos: {newStagePos}");
                    charMoves.Add(new CharacterMove(characterName, newStagePos));
                    continue;
                    // throw new ArgumentException($"Failed to parse: {cueMeta} as a numeric stage position");
                }

                expression = cueMeta;
                StageAction expressionAction = StageActionFactory.NewExpressionAction(characterName, expression);

                results.Add(expressionAction);
                return(results);
                // yield return expressionAction;
                // yield break;
            }

            if (charMoves.Count == 0)
            {
                // yield break;
                return(results);
            }
            StageAction stageAction = StageActionFactory.NewStageMoveAction(charMoves);

            results.Add(stageAction);

            return(results);
            // yield return stageAction;
        }