示例#1
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)
            {
                // Calories
                grid.Children.Add(_Text("Calories"), 15, 20, 4, 6);
                View CalorieView = ImageGradient.AsView(
                    0,
                    PC.TargetCalories,
                    PC.TargetCalories * 2,
                    PC.Calories,
                    true,
                    false
                    );

                grid.Children.Add(CalorieView, 20, 29, 4, 6);
                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 PC.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(_Text("Vitamins"), 15, 20, 6, 8);


                grid.Children.Add(ImageGradient.AsDivBar(WhiteBar), 20, 29, 6, 8);
                grid.Children.Add(ImageGradient.AsDivBar(MicroPotential), 20, 29, 6, 8);
                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)
                }), 20, 29, 6, 8);

                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)
                }), 20, 29, 6, 8);

                grid.Children.Add(ImageGradient.AsDivBar(MicroNutrients), 20, 29, 6, 8);


                grid.Children.Add(_Text("Nutrients"), 15, 20, 8, 10);
                grid.Children.Add(ImageGradient.AsDivBar(MacroNutrients), 20, 29, 8, 10);

                int EnergyY = 20;
                int FocusY  = EnergyY + 3;
                if (CurrentPage.SubType != GameState.PageSubType.Dinner)
                {
                    grid.Children.Add(_Text("Energy"), 15, 20, EnergyY, EnergyY + 2);
                    grid.Children.Add(
                        ImageGradient.AsView(
                            0.0,
                            100.0,
                            100.0,
                            PC.Energy,
                            false,
                            true
                            ),
                        20, 29, EnergyY, EnergyY + 2
                        );

                    grid.Children.Add(_Text("Focus"), 15, 20, FocusY, FocusY + 2);
                    grid.Children.Add(
                        ImageGradient.AsView(
                            0.0,
                            100.0,
                            100.0,
                            PC.Focus,
                            false,
                            true
                            ),
                        20, 29, FocusY, FocusY + 2
                        );
                }
            }

            base.PostLayout(IsTall, grid, GameController, GameFoundry, CurrentPage);
            return;
        }
示例#2
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;
        }
        public override void PostLayout(bool IsTall, Grid grid, Controller GameController, IPlatformFoundry GameFoundry, IPage SourcePage)
        {
            Player PC = GameController.CurrentState.Player;

            // Calories
            if (GameController.GetCurrentPage().SubType == GameState.PageSubType.Dinner)
            {
                grid.Children.Add(_Text("Calories"), 1, 10, 4, 6);
                View CalorieView = ImageGradient.AsView(
                    0,
                    PC.TargetCalories,
                    PC.TargetCalories * 2,
                    PC.Calories,
                    true,
                    false
                    );

                grid.Children.Add(CalorieView, 10, 29, 4, 6);

                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 PC.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(_Text("Vitamins"), 1, 10, 6, 8);
                //grid.Children.Add(ImageGradient.AsDivBar(WhiteBar), 20, 29, 6, 8);
                grid.Children.Add(ImageGradient.AsDivBar(MicroPotential), 10, 29, 6, 8);
                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)
                }), 10, 29, 6, 8);

                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)
                }), 10, 29, 6, 8);
                grid.Children.Add(ImageGradient.AsDivBar(MicroNutrients), 10, 29, 6, 8);

                grid.Children.Add(_Text("Nutrients"), 1, 10, 8, 10);
                grid.Children.Add(ImageGradient.AsDivBar(MacroNutrients), 10, 29, 8, 10);
            }

            if (GameController.GetCurrentPage().SubType == GameState.PageSubType.Lunch)
            {
                IGameOptionSet iActivities = GameController.GetCurrentPage().AppliedOptions;
                int            Amount      = 0;
                foreach (IGameOption act in iActivities)
                {
                    Activity mainAct = act as Activity;
                    if (null != mainAct)
                    {
                        Amount += mainAct.Pay;
                    }
                    if (null != act.SubOptions)
                    {
                        foreach (IGameOption subopt in act.SubOptions)
                        {
                            Activity subAct = subopt as Activity;
                            if (subAct != null)
                            {
                                Amount += subAct.Pay;
                            }
                        }
                    }
                }

                if (Amount != 0)
                {
                    View moneyGrid = MoneyView.RenderView(Amount);
                    grid.Children.Add(moneyGrid, 10, 20, 15, 18);
                }
            }
            else if (GameController.GetCurrentPage().SubType == GameState.PageSubType.Dinner)
            {
                View BackView = new FlorineSkiaCVWrap(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),
                });
                View moneyGrid     = MoneyView.RenderView(PC.Money, false);
                View HappinessGrid = Happiness.RenderView(PC.Happiness, false);
                View TotalText     = new FlorineSkiaCVWrap(new ImageText("Total")
                {
                    FontSize = 48f, Overflow = ImageText.WrapType.None
                });


                View tdBackView = new FlorineSkiaCVWrap(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),
                });
                View tdmoneyGrid     = MoneyView.RenderView(PC.MoneyToDate, false);
                View tdHappinessGrid = Happiness.RenderView(PC.HappinessToDate, false);
                View tdTotalText     = new FlorineSkiaCVWrap(new ImageText("Today")
                {
                    FontSize = 48f, Overflow = ImageText.WrapType.None
                });

                int TotalY = 13;
                int TodayY = 10;
                //grid.Children.Add(BackView, 0, 30, 10, 14);
                grid.Children.Add(TotalText, 2, 9, TotalY + 1, TotalY + 3);
                grid.Children.Add(moneyGrid, 8, 17, TotalY, TotalY + 3);
                grid.Children.Add(HappinessGrid, 17, 28, TotalY, TotalY + 3);

                //grid.Children.Add(tdBackView, 0, 30, 14, 18);
                grid.Children.Add(tdTotalText, 2, 9, TodayY + 1, TodayY + 3);
                grid.Children.Add(tdmoneyGrid, 8, 17, TodayY, TodayY + 3);
                grid.Children.Add(tdHappinessGrid, 17, 28, TodayY, TodayY + 3);
            }

            int EnergyY = 20;
            int FocusY  = EnergyY + 3;

            grid.Children.Add(_Text("Energy"), 15, 20, EnergyY, EnergyY + 2);
            grid.Children.Add(
                ImageGradient.AsView(
                    0.0,
                    100.0,
                    100.0,
                    PC.Energy,
                    false,
                    true
                    ),
                20, 29, EnergyY, EnergyY + 2
                );

            grid.Children.Add(_Text("Focus"), 15, 20, FocusY, FocusY + 2);
            grid.Children.Add(
                ImageGradient.AsView(
                    0.0,
                    100.0,
                    100.0,
                    PC.Focus,
                    false,
                    true
                    ),
                20, 29, FocusY, FocusY + 2
                );

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