Exemple #1
0
        public HudScene(ScreenSpace screen, NumberFactory numberFactory)
        {
            var view   = screen.Viewport;
            var center = view.Width / 2f;
            var left   = view.Left;
            var top    = view.Top;
            var right  = view.Right;

            pointsNumber = numberFactory.CreateNumber(this, left, top, 0.05f, Alignment.Left, 0,
                                                      DefaultColors.Gray);
            levelCaption = new Sprite("LevelCaption",
                                      Rectangle.FromCenter(center, top + 0.02f, 0.07f, 0.03f));
            levelCaption.Color = DefaultColors.Yellow;
            // ReSharper disable DoNotCallOverridableMethodsInConstructor
            Add(levelCaption);
            levelNumber = numberFactory.CreateNumber(this, center, levelCaption.DrawArea.Bottom, 0.022f,
                                                     Alignment.Center, 2, DefaultColors.Gray);
            var offsets = new[, ] {
                { 0.108f, 0.025f }, { 0.083f, 0.033f }, { 0.05f, 0.05f }
            };

            errorIcons = new Sprite[3];
            for (int i = 0; i < errorIcons.Length; i++)
            {
                Add(errorIcons[i] = new Sprite("ErrorIcon",
                                               new Rectangle(right - offsets[i, 0], top, offsets[i, 1], offsets[i, 1])));
            }
            foreach (var control in Controls.FindAll(x => x is Sprite))
            {
                control.RenderLayer = (int)GameRenderLayer.Hud;
            }
        }
Exemple #2
0
        public override InterpreterState MoveToNextState(Symbol symbol, ILexemesStack stack, ExecutorContext context)
        {
            switch (symbol.Type)
            {
            case SymbolType.Number:
                _numberBuilder.Append(symbol);
                return(this);

            case SymbolType.Identifier:
                return(new ErrorState(symbol));

            case SymbolType.Operator:
                var @operator = OperatorFactory.CreateOperator(symbol);
                var number    = NumberFactory.CreateNumber(_numberBuilder);

                stack.Push(number);
                stack.Push(@operator);

                switch (@operator)
                {
                case OpeningBracket _:
                case AssignmentOperator _:
                case CommaOperator _:
                    return(new ErrorState(symbol));

                case ClosingBracket _:
                    return(new ClosingBracketOperatorState());

                default:
                    return(new BinaryOperatorState());
                }

            default:
                return(new ErrorState(symbol));
            }
        }