Beispiel #1
0
        private List <IGameOption> GetOptionList(IGameOptionSet options)
        {
            List <IGameOption> renderList = new List <IGameOption>();

            if (null == options)
            {
                return(renderList);
            }
            foreach (IGameOption opt in options)
            {
                // Only one level for now, and just flatten.
                if (null == opt.SubOptions)
                {
                    renderList.Add(opt);
                }
                else
                {
                    foreach (IGameOption o2 in opt.SubOptions)
                    {
                        renderList.Add(o2);
                    }
                }
            }
            return(renderList);
        }
Beispiel #2
0
 private void _readyOptionSet(
     PageComponentType pcType,
     IGameOptionSet opts,
     EventHandler PressFunc = null
     )
 {
     if (null == opts)
     {
         return;
     }
     foreach (IGameOption opt in opts)
     {
         _readyOption(pcType, opt, PressFunc);
     }
 }
Beispiel #3
0
        /* Update Page */
        public void UpdatePage(IPage Source)
        {
            /* Current Page */
            System.Web.UI.HtmlControls.HtmlInputHidden cpage =
                (System.Web.UI.HtmlControls.HtmlInputHidden)(ControlLookup["CurrentPage"]);
            cpage.Value = Source.MainType.ToString();

            /* Select Limit */
            IGameOptionSet options = Source.PrimaryOptions;

            if (null != options.SelectionLimit)
            {
                System.Web.UI.HtmlControls.HtmlInputHidden sellim =
                    (System.Web.UI.HtmlControls.HtmlInputHidden)(ControlLookup["SelectLimit"]);
                sellim.Value = options.SelectionLimit.ToString();
            }
        }
Beispiel #4
0
        /* Option Set Transformations ===================================================================== */
        private IGameOptionSet _renderOptionSet(IGameOptionSet opts)
        {
            if (null == opts)
            {
                return(null);
            }
            FlorineSkiaOptionSet newSet = new FlorineSkiaOptionSet()
            {
                SelectionLimit = opts.SelectionLimit,
            };

            if (opts.Finalizer != null)
            {
                newSet.Finalizer = _renderOption(opts.Finalizer, newSet);
            }
            foreach (IGameOption opt in opts)
            {
                newSet.Add(_renderOption(opt, newSet));
            }

            return(newSet);
        }
Beispiel #5
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
                        )
                    );
            }
        }
Beispiel #6
0
        public System.Web.UI.Control RenderOptions(IGameOptionSet options, bool Selectable)
        {
            int OptionCount  = 0;
            int OptionColumn = 0;

            System.Web.UI.HtmlControls.HtmlTable OptTab =
                new System.Web.UI.HtmlControls.HtmlTable();
            List <IGameOption> renderList = GetOptionList(options);

            foreach (IGameOption opt in renderList)
            {
                ++OptionCount;
                System.Web.UI.WebControls.Panel optionPanel =
                    RenderOption(opt, Selectable);

                if (OptionColumn == 0)
                {
                    OptTab.Rows.Add(new System.Web.UI.HtmlControls.HtmlTableRow());
                    OptionColumn++;
                }
                else
                {
                    OptionColumn = 0;
                }

                OptTab.Rows[OptTab.Rows.Count - 1].Cells.Add(
                    new System.Web.UI.HtmlControls.HtmlTableCell()
                {
                    Controls = { optionPanel }
                }
                    );
            }

            System.Web.UI.WebControls.Panel panel = new System.Web.UI.WebControls.Panel();
            if (OptionCount > 0)
            {
                panel.Controls.Add(OptTab);
            }
            if (Selectable)
            {
                if (null != options.SelectionLimit)
                {
                    ControlLookup["SelectLimit"] = new System.Web.UI.HtmlControls.HtmlInputHidden()
                    {
                        ID            = "SelectLimit",
                        Value         = options.SelectionLimit.ToString(),
                        ViewStateMode = System.Web.UI.ViewStateMode.Disabled
                    };
                    panel.Controls.Add(ControlLookup["SelectLimit"]);
                }

                if (null != options.Finalizer)
                {
                    panel.Controls.Add(new System.Web.UI.HtmlControls.HtmlInputSubmit()
                    {
                        ID            = "Finalizer",
                        Value         = options.Finalizer.OptionName,
                        ViewStateMode = System.Web.UI.ViewStateMode.Disabled
                    });
                }
            }
            return(panel);
        }
        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);
        }
 public DescriptionUpdater(IGameOptionSet parent)
 {
     _parent = parent;
 }