Ejemplo n.º 1
0
        public static View RenderView(int Amount, bool Background = true)
        {
            Grid moneyGrid = new Grid();

            for (int i = 0; i < 10; ++i)
            {
                moneyGrid.RowDefinitions.Add(new RowDefinition {
                    Height = new GridLength(1, GridUnitType.Star)
                });
            }
            for (int i = 0; i < 16; ++i)
            {
                moneyGrid.ColumnDefinitions.Add(new ColumnDefinition {
                    Width = new GridLength(1, GridUnitType.Star)
                });
            }
            ImageText MoneyText = new ImageText(Amount.ToString())
            {
                Overflow = ImageText.WrapType.None,
                FontSize = 48f,
            };

            FlOval MoneyBackground = new FlOval()
            {
                backgroundColor = new SKPaint()
                {
                    Color = new SKColor(0, 80, 190, 230)
                },
                Shape          = FlOval.OvalType.Rectangle,
                ovalRatio      = float.NaN,
                innerHighlight = new SKColor(100, 250, 250, 255),
            };
            SKCanvasView MoneyRing = new SKCanvasView();

            MoneyRing.PaintSurface += MoneyRing_PaintSurface;
            if (Background)
            {
                moneyGrid.Children.Add(new FlorineSkiaCVWrap(MoneyBackground),
                                       0,
                                       moneyGrid.ColumnDefinitions.Count,
                                       0,
                                       moneyGrid.RowDefinitions.Count);
            }
            moneyGrid.Children.Add(MoneyRing, 1, 6, 0, 10);
            moneyGrid.Children.Add(new FlorineSkiaCVWrap(MoneyText), 6, 14, 0, 8);
            return(moneyGrid);
        }
Ejemplo n.º 2
0
        private void _readyIPage(IPage Source, GameState gameState)
        {
            if (null != Source.Background)
            {
                SKCanvasView            Header = new SKCanvasView();
                IFlorineSkiaConnectable iconn  = Source.Background as IFlorineSkiaConnectable;
                if (null != iconn)
                {
                    iconn.ConnectCanvasView(Header);
                }
                _components.Add(
                    new PageComponent(
                        _inc(PageComponentType.Background),
                        Header
                        )
                    );
            }
            if (null != Source.Title)
            {
                SKCanvasView Message = new SKCanvasView();
                ImageText    itconn  = new ImageText(Source.Title);
                itconn.ConnectCanvasView(Message);
                _components.Add(
                    new PageComponent(
                        _inc(PageComponentType.Title),
                        Message
                        )
                    );
            }
            if (null != Source.Message && "" != Source.Message)
            {
                SKCanvasView Message = new SKCanvasView();
                ImageText    itconn  = new ImageText(Source.Message)
                {
                    Overflow       = ImageText.WrapType.WordWrap,
                    FontSize       = 48.0f,
                    AutoBackground = (
                        Source.MainType == GameState.PageType.Summarize_Activity
                        )
                };

                itconn.ConnectCanvasView(Message);
                _components.Add(
                    new PageComponent(
                        _inc(PageComponentType.Message),
                        Message
                        )
                    );
            }

            IGameOptionSet DescriptionSet = Source.AppliedOptions;

            _readyOptionSet(
                PageComponentType.PickedOption,
                Source.AppliedOptions
                );

            PrimaryOptions = Source.PrimaryOptions;
            _readyOptionSet(
                PageComponentType.Option,
                PrimaryOptions
                );

            if (null != Source.PrimaryOptions)
            {
                if (PrimaryOptions.Count > 0)
                {
                    DescriptionSet = PrimaryOptions;
                }

                _readyOption(
                    PageComponentType.Footer,
                    Source.PrimaryOptions.Finalizer,
                    Continue_Handler
                    );
            }
            if (null != DescriptionSet)
            {
                FlorineSkiaOptionSet FSO = DescriptionSet as FlorineSkiaOptionSet;
                if (FSO != null)
                {
                    SKCanvasView Desc = new SKCanvasView();
                    FSO.UpdaterHook.ConnectCanvasView(Desc);
                    _components.Add(
                        new PageComponent(
                            _inc(PageComponentType.Description),
                            Desc
                            )
                        );
                }
            }
            SourcePage = Source;

            if (null != gameState.Player)
            {
                SKCanvasView            avatar = new SKCanvasView();
                IFlorineSkiaConnectable itconn = gameState.Player.Avatar.Picture as IFlorineSkiaConnectable;
                itconn.ConnectCanvasView(avatar);
                _components.Add(
                    new PageComponent(
                        _inc(PageComponentType.Player),
                        avatar
                        )
                    );
            }
        }
Ejemplo n.º 3
0
        //Allow for post-component rendering layout
        public override void PostLayout(
            bool IsTall,
            Grid grid,
            Controller GameController,
            IPlatformFoundry GameFoundry,
            IPage CurrentPage
            )
        {
            Player PC = GameController.CurrentState.Player;

            if (IsTall)
            {
                grid.Children.Add(FlOval.AsView(),
                                  0, grid.ColumnDefinitions.Count,
                                  0, grid.RowDefinitions.Count);
                Food f = FindFood("Mexican Rice", GameController);

                List <string> Ingredients = new List <string>()
                {
                    "1 Medium tomato",
                    "1/4 small onion",
                    "1 cup rice",
                    "1 clove garlic",
                    "2 tbsp corn oil",
                    "2 cups water"
                };
                List <string> Steps = new List <string>()
                {
                    "Mince the tomato, garlic, and onion",
                    "Put pot on stove over medium heat",
                    "Once pot is hot, add oil",
                    "Once oil is hot, add rice",
                    "Stir rice constantly until toasted (not burnt)",
                    "Add the vegetables to the rice and stir, then add the water and stir",
                    "Add salt and pepper to taste",
                    "Once water starts to boil, turn heat to low and put lid on pot. Wait ~20 minutes, or until water is almost all absorbed",
                    "Remove from heat and rest 5 minutes",
                    "Fluff with spoon and serve!"
                };
                grid.Children.Add(ImageText.AsView(f.Name),
                                  0, grid.ColumnDefinitions.Count,
                                  2, 4);



                for (int i = 0; i < Ingredients.Count; ++i)
                {
                    int VShift = 1 * (int)(i / 2);
                    int Shift  = (i % 2) * grid.ColumnDefinitions.Count / 2 + 3 * (1 - (i % 2));
                    grid.Children.Add(ImageText.AsView(
                                          Ingredients[i],
                                          32f,
                                          ImageText.WrapType.Shrink,
                                          ImageText.HorizontalAlignment.Left
                                          ),
                                      Shift, grid.ColumnDefinitions.Count / 2 + Shift,
                                      7 + VShift, 9 + VShift);
                }


                String StepCounts = "1.\n2.\n3.\n4.\n5.\n\n6.\n\n7.\n8.\n\n\n\n9.\n10.\n";

                grid.Children.Add(
                    ImageText.AsView(
                        string.Join("\n", StepCounts),
                        32f,
                        ImageText.WrapType.WordWrap,
                        ImageText.HorizontalAlignment.Left),
                    3, grid.ColumnDefinitions.Count - 1,
                    (int)(6 + Ingredients.Count / 2), grid.RowDefinitions.Count - 1);

                grid.Children.Add(
                    ImageText.AsView(
                        string.Join("\n", Steps),
                        32f,
                        ImageText.WrapType.WordWrap,
                        ImageText.HorizontalAlignment.Left),
                    5, grid.ColumnDefinitions.Count,
                    (int)(6 + Ingredients.Count / 2), grid.RowDefinitions.Count - 1);

                int TX1 = 10;
                int TX2 = 15;
                int BR1 = TX2;
                int BR2 = 27;
                grid.Children.Add(FoodPic(f), 2, 11, 4, 7);
                // Calories
                grid.Children.Add(ImageText.AsView("Calories", 24f, ImageText.WrapType.Shrink), TX1, TX2, 4, 5);
                View CalorieView = ImageGradient.AsView(
                    0,
                    2000,
                    4000,
                    325.5985,
                    true,
                    false
                    );

                grid.Children.Add(CalorieView, BR1, BR2, 4, 5);
                SortedDictionary <float, SKColor> WhiteBar = new SortedDictionary <float, SKColor>()
                {
                    { 0f, new SKColor(255, 255, 255, 60) },
                    { 1f, new SKColor(255, 255, 255, 60) },
                };
                SortedDictionary <float, SKColor> MicroNutrients = new SortedDictionary <float, SKColor>();
                SortedDictionary <float, SKColor> MicroPotential = new SortedDictionary <float, SKColor>();
                SortedDictionary <float, SKColor> MacroNutrients = new SortedDictionary <float, SKColor>();
                float microNut = 0f;
                float microPot = 0f;
                float macroNut = 0f;

                foreach (KeyValuePair <Nutrient, NutrientAmount> kvp in f.Nutrients)
                {
                    FlorineSkiaNutrient AdjNut = new FlorineSkiaNutrient(kvp.Key);
                    float curRatio             = kvp.Key.RatioRDV(kvp.Value);

                    switch (kvp.Key.Class)
                    {
                    case Nutrient.NutrientType.Macro:
                        if (curRatio > 2f)
                        {
                            curRatio = 2f;
                        }
                        if (curRatio <= 0f)
                        {
                            continue;
                        }
                        curRatio /= 8f;
                        macroNut += curRatio;
                        MacroNutrients.Add(macroNut, AdjNut.RingColor);
                        break;

                    case Nutrient.NutrientType.Mineral:
                    case Nutrient.NutrientType.Vitamin:
                        if (curRatio > 1f)
                        {
                            curRatio = 1f;
                        }
                        float fRestRatio = float.NaN;
                        if (curRatio < 1f)
                        {
                            fRestRatio  = 1f - curRatio;
                            fRestRatio /= 7f;
                        }
                        curRatio /= 7f;
                        microPot += 1f / 7f;

                        if (curRatio > float.Epsilon)
                        {
                            microNut += curRatio;
                            MicroNutrients.Add(microNut, AdjNut.RingColor);
                        }
                        if (!float.IsNaN(fRestRatio))
                        {
                            microNut += fRestRatio;
                            MicroNutrients.Add(microNut, SKColors.Transparent);
                        }
                        SKColor newCol = new SKColor(
                            AdjNut.RingColor.Red,
                            AdjNut.RingColor.Green,
                            AdjNut.RingColor.Blue,
                            80
                            );
                        MicroPotential.Add(microPot, newCol);
                        break;
                    }
                }
                grid.Children.Add(ImageText.AsView("Vitamins", 24f, ImageText.WrapType.Shrink), TX1, TX2, 5, 6);


                grid.Children.Add(ImageGradient.AsDivBar(WhiteBar), BR1, BR2, 5, 6);
                grid.Children.Add(ImageGradient.AsDivBar(MicroPotential), BR1, BR2, 5, 6);
                float gridSize = 5;
                grid.Children.Add(ImageGradient.AsDivBar(MicroPotential,
                                                         new SKPaint()
                {
                    PathEffect = SKPathEffect.Create2DLine(1,
                                                           MatrixMultiply(SKMatrix.MakeScale(gridSize, gridSize),
                                                                          SKMatrix.MakeRotationDegrees(45))),
                    Style       = SKPaintStyle.Stroke,
                    StrokeWidth = 1,
                    Color       = new SKColor(0, 0, 0, 20)
                }), BR1, BR2, 5, 6);

                grid.Children.Add(ImageGradient.AsDivBar(MicroPotential,
                                                         new SKPaint()
                {
                    PathEffect = SKPathEffect.Create2DLine(1,
                                                           MatrixMultiply(SKMatrix.MakeScale(gridSize, gridSize),
                                                                          SKMatrix.MakeRotationDegrees(-45))),
                    Style       = SKPaintStyle.Stroke,
                    StrokeWidth = 1,
                    Color       = new SKColor(0, 0, 0, 20)
                }), BR1, BR2, 5, 6);

                grid.Children.Add(ImageGradient.AsDivBar(MicroNutrients), BR1, BR2, 5, 6);


                grid.Children.Add(ImageText.AsView("Nutrients", 24f, ImageText.WrapType.Shrink), TX1, TX2, 6, 7);
                grid.Children.Add(ImageGradient.AsDivBar(MacroNutrients), BR1, BR2, 6, 7);
            }

            base.PostLayout(IsTall, grid, GameController, GameFoundry, CurrentPage);
            return;
        }