Exemple #1
0
        private void RenderNavigationMap(Renderer r)
        {
            _navDebugSprite.Resize(Map.Width * Map.Height);

            int i = 0;
            for(int mapy = 0; mapy < Map.Height; ++mapy)
            {
                for(int mapx = 0; mapx < Map.Width; ++mapx, ++i)
                {
                    int arrowIndex = 4;
                    int nextx, nexty;

                    if(Navigation.IsTarget(mapx, mapy))
                    {
                        arrowIndex = 9;
                    }
                    else
                        if(Navigation.GetNext(mapx, mapy, out nextx, out nexty))
                        {
                            arrowIndex = 1 + Math.Sign(nextx-mapx) + (Math.Sign(nexty-mapy) + 1) * 3;
                        }

                    _navDebugSprite[i].X = mapx*32;
                    _navDebugSprite[i].Y = mapy*32;
                    _navDebugSprite[i].Frame = (byte)arrowIndex;
                    _navDebugSprite[i].Color = new OpenTK.Graphics.Color4(128,128,128,128);
                }
            }

            r.AddDrawable(_navDebugSprite);
        }
        public void Render(Renderer r)
        {
            _stayUpTimer.Tick();
            _foldingTimer.Tick();

            const int minWidth = 96;
            const int leftMargin = 12;
            const int rightMargin = 12;
            const int topMargin = 12;
            const int bottomMargin = 8;
            const int leftTextMargin = 28;
            const int topTextMargin = 5;
            const int lineHeight = 24;

            int height = topMargin;
            if((Options & BuildablePulloutOptions.ShowCaption) != 0) height += lineHeight;
            if((Options & BuildablePulloutOptions.ShowPrice) != 0) height += lineHeight;
            if((Options & BuildablePulloutOptions.ShowDamage) != 0) height += lineHeight;
            if((Options & BuildablePulloutOptions.ShowReloadTime) != 0) height += lineHeight;
            if((Options & BuildablePulloutOptions.ShowRange) != 0) height += lineHeight;
            height += bottomMargin;

            int px = X;
            int py = Y - height;
            _panel.X = px;
            _panel.Y = py;
            _panel.Color = Color;
            _panel.Corners = Corners.Top | ((Options & BuildablePulloutOptions.ShowIconTab) != 0 ? Corners.BottomRight : Corners.Bottom);
            _panel.Height = height;
            r.AddDrawable(_panel);

            _iconPanel.X = px;
            _iconPanel.Y = py+height;
            _iconPanel.Color = Color;
            if((Options & BuildablePulloutOptions.ShowIconTab) != 0)
                r.AddDrawable(_iconPanel);

            var u = Upgrade;
            if(u != null)
            {
                r.AddDrawable(_icons);

                _text[0].Text = u.Price > 0 ? ""+u.Price : "";
                _text[1].Text = u.Damage > 0 ? u.Damage+" hp" : "";
                _text[2].Text = u.ReloadTime > 0 ? String.Format("{0:0.0}",((float)u.ReloadTime)/60.0f) + " s" : "";
                _text[3].Text = u.Range > 0 ? ""+u.Range : "";
                _text[4].Text = Caption ?? u.Caption;

                int y = 1;
                for(int i = 0; i < 4; ++i)
                {
                    _icons[i].X = px+leftMargin;
                    _icons[i].Y = py+topMargin+lineHeight*y;
                    _text[i].X = px+leftMargin+leftTextMargin;
                    _text[i].Y = py+topMargin+topTextMargin+lineHeight*y;

                    if(((int)Options & (1<<i)) != 0)
                    {
                        r.AddDrawable(_text[i]);
                        if(i<4) _icons[i].Flags &= ~SpriteFlags.Disable;
                        y++;
                    }
                    else
                    {
                        if(i<4) _icons[i].Flags |= SpriteFlags.Disable;
                    }
                }

                bool tooExpensive = !_game.CanAfford(u);
                _icons[0].Color = u.Price <= 0 ? Color4.Gray : (tooExpensive ? Color4.Gray : LineColor);
                _icons[1].Color = u.Damage <= 0 || tooExpensive ? Color4.Gray : LineColor;
                _icons[2].Color = u.ReloadTime <= 0 || tooExpensive ? Color4.Gray : LineColor;
                _icons[3].Color = u.Range <= 0 || tooExpensive ? Color4.Gray : LineColor;
                _text[0].Color = tooExpensive ? PulseColor(_TooExpensiveTextColor) : LineColor;
                _text[1].Color = tooExpensive ? Color4.Gray : LineColor;
                _text[2].Color = tooExpensive ? Color4.Gray : LineColor;
                _text[3].Color = tooExpensive ? Color4.Gray : LineColor;
                _text[4].Color = tooExpensive ? Color4.Gray : CaptionColor;

                _panel.Width = Math.Max(minWidth,_text[4].Width + leftMargin+rightMargin);
                //_panel.Corners = Corners.Top|Corners.BottomRight;
            }
            else
            {
                px--;
                _text[4].Text = "Select";
                _panel.Corners = Corners.Top;
                _panel.Width = _iconPanel.Width;
            }

            if(CaptionIcon >= 0)
            {
                _captionIcon[0].X = px+leftMargin+4;
                _captionIcon[0].Y = py+topMargin-2;
                _captionIcon[0].Frame = (byte)CaptionIcon;
                _captionIcon[0].Color.A = 0.0f;
                r.AddDrawable(_captionIcon);
                _text[4].X = (int)_captionIcon[0].X+22;
                _text[4].Y = py+topMargin;
            //	_text[4].Color = new Color4(246,233,185,255);

                _panel.Width += 28;
            }
            else
            {
                _text[4].X = px+leftMargin;
                _text[4].Y = py+topMargin;
            }
            r.AddDrawable(_text[4]);
        }
Exemple #3
0
        public void Render(Renderer r)
        {
            r.AddDrawable(_toolbarPanel);

            _cashText.Text = "$"+_game.Cash;
            _cashText.X = r.Width-_cashText.Width-16;
            _cashText.Y = r.Height-Height/2-11;
            r.AddDrawable(_cashText);

            for(int iconi = 0; iconi < Icons.Length; ++iconi)
            {
                var icon = Icons[iconi];
                var b = icon.Buildable;
                var u = b != null ? _game.Config.GetBuildableUpgrade(b.TypeId,0) : null;

                bool isSelected = SelectedIconIndex == iconi;

                Color4 c = isSelected ? (iconi == 0 ? SelectedMarkerIconColor : SelectedBuildableIconColor) : Color4.Black;
                c = _game.CanAfford(b) ? c : TooExpensiveBuildableIconColor;

                _baseIcon[iconi].X = IconLeft + IconSpacing * iconi;
                _baseIcon[iconi].Y = _toolbarPanel.Y + Height/2;
                _baseIcon[iconi].Frame = (byte)icon.CursorFrame;
                _baseIcon[iconi].Color = c;

                if(icon.WeaponIcon != null)
                {
                    icon.WeaponIcon[0].X = _baseIcon[iconi].X;
                    icon.WeaponIcon[0].Y = _baseIcon[iconi].Y;
                    icon.WeaponIcon[0].Color = c;
                    r.AddDrawable(icon.WeaponIcon);
                }
            }

            r.AddDrawable(_baseIcon);
        }