Пример #1
0
        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);
        }
Пример #2
0
        public override void PostLayout(bool IsTall, Grid grid, Controller GameController, IPlatformFoundry GameFoundry, IPage SourcePage)
        {
            ActualPlayerBase = GameController.CurrentState.Player;
            ActualPlayer     = GameController.CurrentState.Player.Avatar.Picture as PlayerAvatar;
            Entry NameEntry = new Entry()
            {
                Text = "Faerina",
                HorizontalTextAlignment = TextAlignment.Center,
//                FontSize = 8f,
                VerticalOptions = new LayoutOptions()
                {
                    Alignment = LayoutAlignment.End
                },
            };

            NameEntry.TextChanged += NameEntry_TextChanged;
            grid.Children.Add(NameEntry, 0, 30, 0, 4);
            SKPointI ClothesStart = new SKPointI(5, 22);
            SKPointI WingStart    = new SKPointI(15, 16);
            SKPointI HairStart    = new SKPointI(5, 16);
            SKPointI FaceStart    = new SKPointI(15, 22);

            OvalLookup["Box"] = OvalT(0, 0, 200, 120, 2f);
            OvalLookup["Box"].Item2.innerHighlight = new SKColor(100, 250, 250, 255);
            OvalLookup["Pear"]  = OvalT(0, 0, 200, 120, 2f);
            OvalLookup["Round"] = OvalT(0, 0, 200, 120, 2f);
            grid.Children.Add(OvalLookup["Pear"].Item1, 0, 10, 2, 15);
            grid.Children.Add(OvalLookup["Box"].Item1, 10, 20, 2, 15);
            grid.Children.Add(OvalLookup["Round"].Item1, 20, 30, 2, 15);
            grid.Children.Add(ColorSelector("body", new SKColor[] {
                new SKColor(253, 196, 179), // 1
                new SKColor(245, 185, 158), // 2
                new SKColor(228, 131, 86),  // 3
                new SKColor(217, 118, 76),  // 4
                new SKColor(182, 88, 34),   // 5
                new SKColor(143, 70, 29),   // 6
                new SKColor(113, 50, 20),   // 6
            }), 4, 26, 14, 16);

            grid.Children.Add(Oval(0, 0, 200, 120, 1f), ClothesStart.X, ClothesStart.X + 10, ClothesStart.Y, ClothesStart.Y + 6);
            grid.Children.Add(Oval(0, 0, 200, 120, 1f), WingStart.X, WingStart.X + 10, WingStart.Y, WingStart.Y + 6);
            grid.Children.Add(Oval(0, 0, 200, 120, 1f), HairStart.X, HairStart.X + 10, HairStart.Y, HairStart.Y + 6);

            grid.Children.Add(SetupSelector("clothes"), ClothesStart.X, ClothesStart.X + 10, ClothesStart.Y, ClothesStart.Y + 6);
            grid.Children.Add(SetupSelector("wings"), WingStart.X, WingStart.X + 10, WingStart.Y, WingStart.Y + 6);
            grid.Children.Add(SetupSelector("hair"), HairStart.X, HairStart.X + 10, HairStart.Y, HairStart.Y + 6);
            grid.Children.Add(ColorSelector("hair", new SKColor[] {
                new SKColor(202, 191, 177),
                new SKColor(255, 208, 115, 120),
                new SKColor(255, 240, 225),
            }), 1, 6, HairStart.Y + 1, HairStart.Y + 2);//21, 29, 22, 23);
            grid.Children.Add(ColorSelector("hair", new SKColor[] {
                new SKColor(230, 206, 168),
                new SKColor(222, 188, 153),
                new SKColor(143, 70, 29),
            }), 1, 6, HairStart.Y + 2, HairStart.Y + 3);//21, 29, 22, 23);

            grid.Children.Add(ColorSelector("hair", new SKColor[] {
                new SKColor(106, 78, 66),
                new SKColor(83, 61, 53),
                new SKColor(9, 8, 6),
            }), 1, 6, HairStart.Y + 3, HairStart.Y + 4);//21, 29, 22, 23);

            grid.Children.Add(ColorSelector("hair", new SKColor[] {
                new SKColor(145, 75, 67),
                new SKColor(181, 82, 57),
                new SKColor(205, 75, 67)
            }), 1, 6, HairStart.Y + 4, HairStart.Y + 5);//21, 29, 22, 23);


            grid.Children.Add(Oval(0, 0, 200, 120, 1f), FaceStart.X, FaceStart.X + 10, FaceStart.Y, FaceStart.Y + 6);
            grid.Children.Add(SetupSelector("face"), FaceStart.X, FaceStart.X + 10, FaceStart.Y, FaceStart.Y + 6);
            UpdateRefColor("body", PaintFor(new SKColor(217, 118, 76)));
            UpdateRefColor("hair", PaintFor(new SKColor(83, 61, 53)));
            //
            FlorineSkiaCVWrap PearView  = new FlorineSkiaCVWrap(BodyLookups["Pear"]);
            FlorineSkiaCVWrap RoundView = new FlorineSkiaCVWrap(BodyLookups["Round"]);

            BodyViews.Add(PlayerView);
            BodyViews.Add(PearView);
            BodyViews.Add(RoundView);

            //innerHighlight = new SKColor(100, 250, 250, 255),

            grid.Children.Add(PlayerView, 11, 19, 3, 14);
            grid.Children.Add(PearView, 1, 9, 3, 14);
            grid.Children.Add(RoundView, 21, 29, 3, 14);

            FlorineSkiaTapWrap.Associate(PlayerView, BoxSelect);
            FlorineSkiaTapWrap.Associate(PearView, PearSelect);
            FlorineSkiaTapWrap.Associate(RoundView, RoundSelect);
            //FlorineSkiaTapWrap.Associate(OvalLookup["Box"].Item1, BoxSelect);
            //FlorineSkiaTapWrap.Associate(OvalLookup["Pear"].Item1, PearSelect);
            //FlorineSkiaTapWrap.Associate(OvalLookup["Round"].Item1, RoundSelect);
        }