예제 #1
0
    protected override void Refresh(object sender, string propertyChanged)
    {
        base.Refresh(sender, propertyChanged);

        //If the ship is at 100HP already, then let's not worry about giving the player the costs--we'll replace the costs by an X
        //	--and disable the repair buttons
        if (Mathf.CeilToInt(Model.shipHealth.Value) == 100)
        {
            CostOneHp.Bind(ValueModel.New("X"));
            CostAllHp.Bind(ValueModel.New("X"));

            RepairOneButton.GetComponent <Button>().interactable = false;
            RepairAllButton.GetComponent <Button>().interactable = false;
        }
        else
        {
            CostOneHp.Bind(ValueModel.New(Model.costToRepair)
                           .Select(cost => Mathf.CeilToInt(cost))
                           .AsString());

            CostAllHp.Bind(ValueModel.New(Model.costToRepair)
                           .Select(cost => (Mathf.CeilToInt(100 - Mathf.CeilToInt(Globals.GameVars.playerShipVariables.ship.health)) * cost))
                           .AsString());

            RepairOneButton.GetComponent <Button>().interactable = true;
            RepairAllButton.GetComponent <Button>().interactable = true;
        }

        // TODO: Flesh out upgrade system? For now, you can only upgrade once and it just gives you the main ship. You start out with a smaller one.
        UpgradeButton.GetComponent <Button>().interactable = Model.shipLevel.Value == 0;
    }
예제 #2
0
    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
        }));

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

        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)));
    }
예제 #3
0
    protected override void Refresh(object sender, string propertyChanged)
    {
        base.Refresh(sender, propertyChanged);

        Amount.Bind(ValueModel.New(Model.NewLoan.amount.ToString()));
        Due.Bind(ValueModel.New(Model.NewLoan.numOfDaysUntilDue.ToString()));
        TotalOwed.Bind(ValueModel.New(Model.NewLoan.GetTotalAmountDueWithInterest().ToString()));
        InterestRate.Bind(ValueModel.New(Model.NewLoan.interestRate.ToString()));
    }
예제 #4
0
    public override void Bind(PortViewModel model)
    {
        base.Bind(model);

        Hire?.Bind(model.CrewManagement.AvailableCrew);
        Fire?.Bind(model.CrewManagement.MyCrew);

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

        Town?.Bind(ValueModel.New(new ButtonViewModel {
            Label   = "Town",
            OnClick = model.GoToTown
        }));
        Town.Interactable = model.allowTownAccess;

        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
            })
        }));

        Loans?.Bind(ValueModel.New(new ButtonViewModel {
            Label   = "Loans",
            OnClick = () => Globals.UI.Show <LoanView, LoanViewModel>(new LoanViewModel())
        }));

        Tavern?.Bind(ValueModel.New(new ButtonViewModel {
            Label = "Tavern",
            //OnClick = () => Globals.UI.Show<TavernView, TavernViewModel>(new TavernViewModel())
        }));

        Repairs?.Bind(ValueModel.New(new ButtonViewModel {
            Label   = "Shipyard",
            OnClick = () => Globals.UI.Show <RepairsView, RepairsViewModel>(new RepairsViewModel())
        }));

        PortIcon?.Bind(new BoundModel <Sprite>(model, nameof(model.PortIcon)));

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

        Capacity.Bind(Model.CrewManagement.CrewCapacity
                      .AsString()
                      .Select(Model.CrewManagement.CrewCount, (cap, count) => count + " / " + cap + " crew"));

        Money.Bind(ValueModel.Wrap(Model.CrewManagement.Money)
                   .AsString()
                   .Select(s => s + " dr")
                   );
    }
예제 #5
0
    public override void Bind(ShrineOptionModel model)
    {
        base.Bind(model);

        Name.Bind(ValueModel.New(model.Name));
        BenefitHint.Bind(ValueModel.New(model.BenefitHint));
        Buy.Bind(ValueModel.New(new ButtonViewModel {
            Label   = model.Cost + " dr",
            OnClick = model.Buy
        }));
    }
    protected override void Refresh(object sender, string propertyChanged)
    {
        base.Refresh(sender, propertyChanged);

        // this is null when you first pay back a loan and Model.Loan gets nulled out
        if (Model.Loan != null)
        {
            Amount.Bind(ValueModel.New(Model.Loan.amount.ToString()));
            Due.Bind(ValueModel.New(Model.Loan.numOfDaysUntilDue.ToString()));
        }
    }
예제 #7
0
    public override void Bind(DashboardViewModel model)
    {
        base.Bind(model);

        CaptainsLogButton.Bind(ValueModel.New(new ButtonViewModel {
            OnClick = () => Globals.UI.Show(CaptainsLogScreen,
                                            new MessageBoxViewModel {
                Message = Model.CaptainsLog,
                Cancel  = new ButtonViewModel {
                    Label = "Close", OnClick = () => Globals.UI.Hide(CaptainsLogScreen)
                }
            })
        }));

        CargoButton.Bind(ValueModel.New(new ButtonViewModel {
            OnClick = () => Globals.UI.Show(CargoList, Model.CargoList)
        }));
        CrewButton.Bind(ValueModel.New(new ButtonViewModel {
            OnClick = () => Globals.UI.Show(CrewList, Model.CrewList)
        }));

        MainMenuButton.Bind(ValueModel.New(new ButtonViewModel {
            OnClick = () => Globals.UI.Show <MainMenuScreen, GameViewModel>(new GameViewModel())
        }));
        CloutButton.Bind(ValueModel.New(new ButtonViewModel {
            OnClick = () => Globals.UI.Show <CrewDetailsScreen, CrewManagementMemberViewModel>(
                new CrewManagementMemberViewModel(model.Jason, model.OnCrewClicked, model.OnCrewCityClicked)
                )
        }));

        // TODO: make 5000 max clout a const somewhere
        CloutSlider.Bind(Model.Clout.Select(c => c / 5000f));
        CloutTitle.Bind(ValueModel.Wrap(Model.Clout)
                        .Select(c => Globals.GameVars.GetCloutTitleEquivalency((int)c)));

        FoodInventory.Bind(Model.FoodInventory);
        WaterInventory.Bind(Model.WaterInventory);

        AnchorButton?.Bind(ValueModel.New(new ButtonViewModel {
            OnClick = Model.GUI_dropAnchor
        }));
        SailsButton?.Bind(model.SailsAreUnfurled.Select(b => new ButtonViewModel {
            Label   = b ? "Furl Sails" : "Unfurl Sails",
            OnClick = model.GUI_furlOrUnfurlSails
        }));

        Objective.Bind(Model.Objective);
    }
    public override void Bind(CityViewModel model)
    {
        base.Bind(model);

        Name?.Bind(new BoundModel <string>(Model, nameof(Model.PortName)));

        Ask?.Bind(ValueModel.New(new ButtonViewModel {
            Label   = CityModel.CostForHint + " dr",
            OnClick = CityModel.GUI_BuyHint
        }));

        Hire?.Bind(ValueModel.New(new ButtonViewModel {
            Label   = CityModel.CostToHire + " dr",
            OnClick = CityModel.GUI_HireANavigator
        }));
    }
예제 #9
0
    public override void Bind(CargoItemTradeViewModel model)
    {
        base.Bind(model);

        Interactable = GetComponent <InteractableBehaviour>();

        Amount?.Bind(new BoundModel <int>(Model, nameof(Model.AmountKg)).AsString());
        Name?.Bind(new BoundModel <string>(Model, nameof(Model.Name)));
        Icon?.Bind(new BoundModel <Sprite>(Model, nameof(Model.Icon)));
        Price?.Bind(new BoundModel <string>(Model, nameof(Model.PriceStr)));
        Hint?.Bind(new BoundModel <string>(Model, nameof(Model.HintStr)));

        if (SelectedHandle != null)
        {
            Unsubscribe(SelectedHandle);
        }
        SelectedHandle = Subscribe(() => model.Parent.PropertyChanged += OnSelectedChanged, () => model.Parent.PropertyChanged -= OnSelectedChanged);
        RefreshSelection();
    }
예제 #10
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>();
            }
        }));
    }
예제 #11
0
    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)
        }));
    }
예제 #12
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
        }));
    }
예제 #13
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
         * }));*/
    }
예제 #14
0
    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
        }));
    }
예제 #15
0
    public override void Bind(IValueModel <float> model)
    {
        base.Bind(model);

        Message?.Bind(model.Select(days => "Day " + string.Format("{0:0.00}", days)));
    }