示例#1
0
文件: Hud.cs 项目: cadahl/defense
        public Hud(Game game)
        {
            _game = game;
            Renderer r = game.Application.Renderer;
            //			_msgLine = new TextLine(r, r.Width-200, r.Height-PanelHeight/2-10, _basePriority);
            _gameLine = new TextLine(r, 8, 8, _basePriority);
            _rendererLine = new TextLine(r, 8, 28, _basePriority);
            _nextWaveLine = new TextLine(r, r.Width/2, r.Height/2-11, _basePriority+100);
            _showNextWaveLine = false;

            _toolbar = new HudToolbar(_game, r, _basePriority);

            _cursors[0] = new Sprite(_game.Config.GetWidgetTemplate("buildcursor"), Drawable.Flags.Colorize, _basePriority+40);
            _cursors[1] = new Sprite(null, Drawable.Flags.Colorize, _basePriority+41);
            _cursors[1][0].Frame = (byte)0;

            _selectionHighlight = new Sprite(_game.Config.GetWidgetTemplate("selhighlight"), 0, _basePriority);

            _upgradeButton = new Widget(_game.Config.GetWidgetTemplate("upgradebutton"), _game, _basePriority+1);
            _upgradeButton.SetFlags(WidgetFlags.LevelCoordinates);
            _sellButton = new Widget(_game.Config.GetWidgetTemplate("sellbutton"), _game, _basePriority+1);
            _sellButton.SetFlags(WidgetFlags.LevelCoordinates);

            _upgradeButton[0].Color = new Color4(1.0f, 1.0f, 1.0f, 0.65f);
            _upgradeButton[1].Color = new Color4(1.0f, 1.0f, 1.0f, 0.0f);
            _sellButton[0].Color = new Color4(1.0f, 1.0f, 1.0f, 0.65f);
            _sellButton[1].Color = new Color4(1.0f, 1.0f, 1.0f, 0.0f);

            _pointerCircle = new Circle(0, 0, 0, 300);
            _pointerCircle.Color.A = 0.4f;
            _selectedCircle = new Circle(0,0,0, _basePriority-2);
            _selectedCircle.Color.A = 0.4f;

            _bpullout = new HudBuildablePullout(_game, r,_basePriority);

            _mousePointerCollider = Collider.Point(	0,
                                                   	0,
                                                   	delegate(Collider c, IEnumerable<ObjectAndDistance> objects)
                                                   	{
                                                        var o = objects.FirstOrDefault();
                                                        if(o != null)
                                                            _hoverObject = o.Object;
                                                    },
                                                    null );
            _mousePointerCollider.FilterType = typeof(Buildable);

            game.Application.Input.MouseDown += HandleMouseDown;
            game.Application.Input.KeyDown += HandleKeyDown;
        }
示例#2
0
        public HudToolbar(Game game, Renderer r, int basePriority)
        {
            _game = game;
            _basePriority = basePriority;

            _toolbarPanel = new Panel(_basePriority-2);
            _toolbarPanel.X = 0;
            _toolbarPanel.Y = r.Height-Height;
            _toolbarPanel.Width = r.Width;
            _toolbarPanel.Height = Height;
            _toolbarPanel.Color = PanelColor;
            _toolbarPanel.Corners = 0;

            _baseIcon = new Sprite(_game.Config.GetWidgetTemplate("baseicon"), Drawable.Flags.NoScroll|Drawable.Flags.Colorize, _basePriority+1);
            _baseIcon.Resize((int)ToolbarEntries.Count);

            _cashText = new TextLine(r,0,0,basePriority+1);
            _cashText.Font = TextLine.CashFont;
            _cashText.Color = Color4.LightGoldenrodYellow;

            Icons = new ToolbarEntry[(int)ToolbarEntries.Count];
            Icons[(int)ToolbarEntries.None] = new ToolbarEntry(_game, null, _basePriority+2)
            {
                CursorFrame = 0,
                PulloutOptions = BuildablePulloutOptions.ShowCaption|BuildablePulloutOptions.ShowIconTab
            };
            Icons[(int)ToolbarEntries.Wall] = new ToolbarEntry(_game, "wall", _basePriority+2)
            {
                CursorFrame = 2,
                PulloutOptions = BuildablePulloutOptions.ShowCaption|BuildablePulloutOptions.ShowPrice|BuildablePulloutOptions.ShowIconTab
            };
            Icons[(int)ToolbarEntries.Machinegun] = new ToolbarEntry(_game, "machinegun", _basePriority+2)
            {
                CursorFrame = 1,
                PulloutOptions = BuildablePulloutOptions.ShowAllRows|BuildablePulloutOptions.ShowIconTab,
            };
            Icons[(int)ToolbarEntries.Cannon] = new ToolbarEntry(_game, "cannon", _basePriority+2)
            {
                CursorFrame = 1,
                PulloutOptions = BuildablePulloutOptions.ShowAllRows|BuildablePulloutOptions.ShowIconTab,
            };
            Icons[(int)ToolbarEntries.Flamethrower] = new ToolbarEntry(_game, "flamethrower", _basePriority+2)
            {
                CursorFrame = 1,
                PulloutOptions = BuildablePulloutOptions.ShowAllRows|BuildablePulloutOptions.ShowIconTab,
            };
        }
示例#3
0
        public HudBuildablePullout(Game game, Renderer r, int basePriority)
        {
            _game = game;
            _basePriority = basePriority;

            _stayUpTimer = new Timer(TimerMode.CountDown, 60*3);
            _stayUpTimer.Elapsed += HandleStayUpTimerElapsed;
            _foldingTimer = new Timer(TimerMode.CountDown, 100);
            _foldingTimer.Ticked += HandleFoldingTimerTicked;

            _panel = new Panel(_basePriority-1);
            _panel.Width = 96;
            _panel.Corners = Corners.Top|Corners.BottomRight;
            _panel.Color = Color;

            _iconPanel = new Panel(_basePriority-1);
            _iconPanel.Y = r.Height-HudToolbar.Height;
            _iconPanel.Width = 56;
            _iconPanel.Height = HudToolbar.Height;
            _iconPanel.Corners = Corners.Bottom;
            _iconPanel.Color = Color;

            //_captionIcon = new Sprite(_captionIcons, Drawable.Flags.NoScroll, _basePriority+2);

            _icons = new Sprite(_game.Config.GetWidgetTemplate("bpinfoicons"), Drawable.Flags.NoScroll, _basePriority+2);
            _icons.Resize(4);
            _icons[0].Frame = 3;
            _icons[1].Frame = 0;
            _icons[2].Frame = 2;
            _icons[3].Frame = 1;

            _text[0] = new TextLine(r,0,0,_basePriority+2);
            _text[1] = new TextLine(r,0,0,_basePriority+2);
            _text[2] = new TextLine(r,0,0,_basePriority+2);
            _text[3] = new TextLine(r,0,0,_basePriority+2);
            _text[4] = new TextLine(r,0,0,_basePriority+2);
        }