Beispiel #1
0
    public override void Bind(CrewManagementMemberViewModel model)
    {
        base.Bind(model);

        CrewMember?.Bind(model);
        Cities?.Bind(model.CitiesInNetwork);                            // TODO: This is null because we passed the model down from the tooltip which doesn't have this...
        FlavorText?.Bind(ValueModel.New(model.BackgroundInfo));

        CloseButton?.Bind(ValueModel.New(new ButtonViewModel {
            OnClick = () => {
                // the city tooltip might be up from clicking a city in a crew member's network
                if (Globals.UI.IsShown <CityView>())
                {
                    Globals.UI.Hide <CityView>();
                }

                Globals.UI.Hide <CrewDetailsScreen>();
            }
        }));
    }
    public override void Bind(CityViewModel model)
    {
        base.Bind(model);

        if (model is CityDetailsViewModel)
        {
            var details = model as CityDetailsViewModel;
            Buy?.Bind(details.Buy);
            Sell?.Bind(details.Sell);
            Crew?.Bind(details.Crew);
        }

        PortName?.Bind(ValueModel.New(model.PortName));
        Distance?.Bind(ValueModel.New(model.Distance)
                       .Select(d => string.Format("{0} km away", Mathf.RoundToInt(d)))
                       );

        ActionButton?.Bind(ValueModel.New(new ButtonViewModel {
            OnClick = () => model.OnClick?.Invoke(Model)
        }));
    }
    public override void Bind(TradeViewModel model)
    {
        base.Bind(model);

        Available?.Bind(model.Available);
        Mine?.Bind(model.Mine);

        Port?.Bind(ValueModel.New(new ButtonViewModel {
            Label   = "Port",
            OnClick = model.BackToPort
        }));
        Port.Interactable = model.allowPortAccess;

        Monuments?.Bind(ValueModel.New(new ButtonViewModel {
            Label   = "Monuments",
            OnClick = () => Globals.UI.Show <ShrinesView, ShrinesViewModel>(new ShrinesViewModel())
        }));
        Monuments.Interactable = model.monuments;

        Sail?.Bind(ValueModel.New(new ButtonViewModel {
            Label   = "Sail",
            OnClick = model.GUI_Button_TryToLeavePort
        }));

        Info?.Bind(ValueModel.New(new ButtonViewModel {
            OnClick = () => Globals.UI.Show <InfoScreen, InfoScreenModel>(new InfoScreenModel {
                Icon     = model.PortCoin,
                Title    = model.PortName,
                Subtitle = model.PortPopulationRank,
                Message  = model.PortDescription
            })
        }));

        Money.Bind(ValueModel.Wrap(Model.Money)
                   .AsString()
                   .Select(s => s + " dr")
                   );

        BuiltMonuments.Bind(new BoundModel <string>(Model.Ship, nameof(Model.Ship.builtMonuments)));
    }
Beispiel #4
0
    protected override void Refresh(object sender, string propertyChanged)
    {
        base.Refresh(sender, propertyChanged);

        PortName.Bind(ValueModel.New(Model.PortName));
        Capacity.Bind(ValueModel.New(Model.Capacity));

        SmallTxn.Bind(ValueModel.New(new ButtonViewModel {
            Label   = Model.TradeAction == TradeAction.Buy ? ">" : "<",
            OnClick = Model.SmallTxn
        }));

        LargeTxn.Bind(ValueModel.New(new ButtonViewModel {
            Label   = Model.TradeAction == TradeAction.Buy ? ">>" : "<<",
            OnClick = Model.LargeTxn
        }));

        AllTxn.Bind(ValueModel.New(new ButtonViewModel {
            Label   = Model.TradeAction == TradeAction.Buy ? "All>" : "<All",
            OnClick = Model.AllTxn
        }));
    }
Beispiel #5
0
    public override void Bind(CityViewModel model)
    {
        base.Bind(model);
        ds = CityModel.GetDS;
        Name?.Bind(new BoundModel <string>(Model, nameof(Model.PortName)));

        Ask?.Bind(ValueModel.New(new ButtonViewModel {
            Label   = "Select",
            OnClick = () =>
            {
                //CityModel.GUI_BuyHint
                ds.Storage.SetValue("$known_city", Model.PortName);
                ds.Storage.SetValue("$known_city_ID", Model.City.settlementID);
                Debug.Log("We have clicked on button.");
                Globals.UI.Hide <TavernView>();
            }
        }));

        /*Hire?.Bind(ValueModel.New(new ButtonViewModel {
         *      Label = CityModel.CostToHire + " dr",
         *      OnClick = CityModel.GUI_HireANavigator
         * }));*/
    }
    public override void Bind(RepairsViewModel model)
    {
        base.Bind(model);

        ShipHealth.Bind(ValueModel.Wrap(model.shipHealth)
                        .Select(h => Mathf.CeilToInt(Globals.GameVars.playerShipVariables.ship.health))
                        .AsString()
                        );

        RepairOneButton.Bind(ValueModel.New(new ButtonViewModel {
            Label   = "Repair",
            OnClick = Model.GUI_RepairShipByOneHP
        }));

        RepairAllButton.Bind(ValueModel.New(new ButtonViewModel {
            Label   = "Repair",
            OnClick = Model.GUI_RepairShipByAllHP
        }));

        UpgradeButton.Bind(ValueModel.New(new ButtonViewModel {
            Label   = "Buy",
            OnClick = model.GUI_BuyNewShip
        }));
    }