Beispiel #1
0
            public void Render(DwarfTime time, SpriteBatch batch)
            {
                bool isResearched     = Spell.IsResearched;
                bool parentResearched = Spell.Parent == null || Spell.Parent.IsResearched;

                if (!isResearched && parentResearched)
                {
                    float progress = Spell.ResearchProgress / Spell.ResearchTime;
                    Drawer2D.FillRect(batch, new Rectangle(ImageButton.GlobalBounds.X, ImageButton.GlobalBounds.Y - 12, (int)(ImageButton.GlobalBounds.Width * progress), 10), Color.Cyan);
                    Drawer2D.DrawRect(batch, new Rectangle(ImageButton.GlobalBounds.X, ImageButton.GlobalBounds.Y - 12, ImageButton.GlobalBounds.Width, 10), Color.Black, 1);
                }

                Vector2 line1 = new Vector2(ImageButton.GlobalBounds.X + ImageButton.GlobalBounds.Width, ImageButton.GlobalBounds.Y + ImageButton.GlobalBounds.Height / 2);

                foreach (SpellButton child in Children)
                {
                    Color drawColor = Color.DarkGray;
                    if (isResearched)
                    {
                        drawColor = Color.DarkCyan;
                    }

                    Vector2 line2 = new Vector2(child.ImageButton.GlobalBounds.X, child.ImageButton.GlobalBounds.Y + child.ImageButton.GlobalBounds.Height / 2);

                    Drawer2D.DrawLine(batch, line1, line2, drawColor, 4);
                }
            }
Beispiel #2
0
        public override void Render(DwarfTime time, SpriteBatch batch)
        {
            int x = DrawSurface.GlobalBounds.X;
            int y = DrawSurface.GlobalBounds.Y;
            int w = DrawSurface.GlobalBounds.Width;
            int h = DrawSurface.GlobalBounds.Height;

            for (int i = 0; i < Window; i++)
            {
                int     tick  = (w / (Window + 1)) * (i + 1);
                Vector2 start = new Vector2(x + tick, y + h);
                Vector2 end   = new Vector2(x + tick, y);
                Drawer2D.DrawLine(batch, start, end, TickColor, 1);
            }

            if (SelectedIndustry == "Average")
            {
                RenderAverage(time, batch);
            }
            else
            {
                RenderCompanies(time, batch);
            }

            float midStock = (MaxStock + MinStock) * 0.5f;

            Drawer2D.DrawAlignedText(batch, MinStock.ToString("C"), GUI.SmallFont, GUI.DefaultTextColor, Drawer2D.Alignment.Left, new Rectangle(x - 10, y + h - 30, 30, 30));
            Drawer2D.DrawAlignedText(batch, midStock.ToString("C"), GUI.SmallFont, GUI.DefaultTextColor, Drawer2D.Alignment.Left, new Rectangle(x - 10, y + (h / 2) - 30, 30, 30));
            Drawer2D.DrawAlignedText(batch, MaxStock.ToString("C"), GUI.SmallFont, GUI.DefaultTextColor, Drawer2D.Alignment.Left, new Rectangle(x - 10, y, 30, 30));
            base.Render(time, batch);
        }
        public override void Render(SpriteBatch batch, Camera camera, Viewport viewport)
        {
            if (Points.Count <= 1)
            {
                return;
            }

            for (int i = 0; i < Points.Count - 1; i++)
            {
                Drawer2D.DrawLine(batch, Points[i], Points[i + 1], LineColor, LineWidth);
            }

            if (IsClosed && Points.Count > 2)
            {
                Drawer2D.DrawLine(batch, Points.Last(), Points.First(), LineColor, LineWidth);
            }
        }
Beispiel #4
0
        public void RenderAverage(DwarfTime time, SpriteBatch batch)
        {
            int x = DrawSurface.GlobalBounds.X;
            int y = DrawSurface.GlobalBounds.Y;
            int w = DrawSurface.GlobalBounds.Width;
            int h = DrawSurface.GlobalBounds.Height;

            MaxStock = 0;
            MinStock = 9999;

            foreach (float stock in FilteredCompanies.SelectMany(company => company.StockHistory))
            {
                MaxStock = Math.Max(stock, MaxStock);
                MinStock = Math.Min(stock, MinStock);
            }

            MaxStock *= (FilteredCompanies.Count / 2);
            MinStock *= (FilteredCompanies.Count / 2);

            for (int i = 1; i < Window; i++)
            {
                int   tick        = (w / (Window + 1)) * (i + 1);
                int   prevtick    = (w / (Window + 1)) * (i);
                float prevAverage = 0.0f;
                float currAverage = 0.0f;

                foreach (Company company in FilteredCompanies)
                {
                    if (company.StockHistory.Count < i + 1)
                    {
                        continue;
                    }
                    prevAverage += company.StockHistory[i];
                    currAverage += company.StockHistory[i - 1];
                }

                float normalizedPrice1 = (currAverage - MinStock) / (MaxStock - MinStock);
                float normalizedPrice0 = (prevAverage - MinStock) / (MaxStock - MinStock);

                if (currAverage > 0)
                {
                    Drawer2D.DrawLine(batch, new Vector2(x + tick, y + h - normalizedPrice0 * h),
                                      new Vector2(x + prevtick, y + h - normalizedPrice1 * h), Color.Black, 2);
                }
            }
        }
Beispiel #5
0
        public void RenderCompanies(DwarfTime time, SpriteBatch batch)
        {
            int x = DrawSurface.GlobalBounds.X;
            int y = DrawSurface.GlobalBounds.Y;
            int w = DrawSurface.GlobalBounds.Width;
            int h = DrawSurface.GlobalBounds.Height;

            MaxStock = 0;
            MinStock = 9999;

            foreach (float stock in FilteredCompanies.SelectMany(company => company.StockHistory))
            {
                MaxStock = Math.Max(stock, MaxStock);
                MinStock = Math.Min(stock, MinStock);
            }

            for (int i = 1; i < Window; i++)
            {
                int tick     = (w / (Window + 1)) * (i + 1);
                int prevtick = (w / (Window + 1)) * (i);
                foreach (Company company in FilteredCompanies)
                {
                    if (company.StockHistory.Count < i + 1 || (company != SelectedCompany && SelectedCompany != null))
                    {
                        continue;
                    }
                    float price1           = company.StockHistory[i - 1];
                    float normalizedPrice1 = (price1 - MinStock) / (MaxStock - MinStock);
                    float price0           = company.StockHistory[i];
                    float normalizedPrice0 = (price0 - MinStock) / (MaxStock - MinStock);

                    Drawer2D.DrawLine(batch, new Vector2(x + tick, y + h - normalizedPrice0 * h), new Vector2(x + prevtick, y + h - normalizedPrice1 * h), new Color(company.Information.LogoBackgroundColor), 2);
                }
            }

            foreach (StockIcon icon in Icons)
            {
                if (icon.Company != SelectedCompany && SelectedCompany != null)
                {
                    continue;
                }

                // Todo: Change in company logo broke stock ticker.
                //batch.Draw(icon.Company.Logo.Image, icon.DestRect, icon.Company.Logo.SourceRect, icon.Company.SecondaryColor);
            }
        }