Exemplo n.º 1
0
        public Flamethrower(Game game, int x, int y)
            : base(game, x, y, "flamethrower")
        {
            MaxAngleVelocity = 30;

            var u = game.Config.GetBuildableUpgrade (TypeId, 0);
            _weapon = new Sprite (u.SpriteTemplates["weapon"], 0, Priority.TowerWeapon);
            _flame = new Sprite (_flameTemplate, 0, Priority.TowerWeaponOverlay);
        }
Exemplo n.º 2
0
        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;
        }
Exemplo n.º 3
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,
            };
        }
Exemplo n.º 4
0
        public Bullet(Game game, float x, float y, float targetX, float targetY, int damage)
            : base(game,0,"bullet")
        {
            X = x;
            Y = y;
            _damage = damage;

            float d = Util.Distance(x,y,targetX,targetY);
            _sourceX = x;
            _sourceY = y;
            _targetX = targetX;
            _targetY = targetY;
            _k = 0.0f;
            _v = 12.0f / d;

            _sprite = new Sprite(_bulletTmp, 0, 2);
        }
Exemplo n.º 5
0
        public Explosion(Game game, float x, float y, ExplosionType type)
            : base(game, 0, "explosion")
        {
            X = x;
            Y = y;
            _animSpeed = 4f;
            _type = type;

            switch (_type) {

            case ExplosionType.Smoky:
                _template = new SpriteTemplate () { TilemapName = "units", Rectangle = new Rectangle(0, 832, 96, 96) };
                _frameCount = 16;
                _animSpeed = 4f;
                _lifeTime = -6;
                break;
            }

            _sprite = new Sprite(_template, 0, Priority.Explosion);
            _sprite[0].Angle = (ushort)Util.RandomInt(0,4095);
            _sprite[0].Scale = Util.Random(0.6f, 1.0f);
        }
Exemplo n.º 6
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);
        }
Exemplo n.º 7
0
        public ToolbarEntry(Game game, string buildTypeId, int priority)
        {
            _game = game;

            if(!string.IsNullOrEmpty(buildTypeId))
            {
                //BuildTypeId = buildTypeId;
                Buildable = _game.Config.GetBuildableUpgrade(buildTypeId,0);

                SpriteTemplate st;
                if(Buildable.SpriteTemplates.TryGetValue("weapon", out st))
                {
                    WeaponIcon = new Sprite(st, Drawable.Flags.NoScroll | Drawable.Flags.Colorize, priority);
                }
            }
        }