Exemplo n.º 1
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)));
    }
Exemplo n.º 2
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")
                   );
    }
Exemplo n.º 3
0
 public ShrinesViewModel()
 {
     Options = ValueModel.Wrap(new ObservableCollection <ShrineOptionModel>(new[]
     {
         new ShrineOptionModel("Votive", BaseCost / 200, 1, "+1 Clout"),
         new ShrineOptionModel("Feast", BaseCost / 10, 10, "+10 Clout"),
         new ShrineOptionModel("Statue", BaseCost / 3, 30, "+30 Clout"),
         new ShrineOptionModel("Shrine", BaseCost / 3 * 50, 50, "+50 Clout"),
         new ShrineOptionModel("Temple", BaseCost / 3 * 50 * 20, 100, "+100 Clout")
     }));
 }
Exemplo n.º 4
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);
    }
Exemplo n.º 5
0
    public CrewManagementViewModel(Settlement settlement)
    {
        GameVars   = Globals.GameVars;
        Settlement = settlement;

        Money        = new BoundModel <int>(GameVars.playerShipVariables.ship, nameof(GameVars.playerShipVariables.ship.currency));
        CrewCapacity = new BoundModel <int>(GameVars.playerShipVariables.ship, nameof(GameVars.playerShipVariables.ship.crewCapacity));

        CrewCount = ValueModel.Wrap(GameVars.playerShipVariables.ship.crewRoster)
                    .Select(c => c.Count());

        AvailableCrew = ValueModel.Wrap(settlement.availableCrew)
                        .Where(crew => !GameVars.playerShipVariables.ship.crewRoster.Contains(crew))
                        .Select(crew => new CrewManagementMemberViewModel(crew, OnCrewClicked, null));

        MyCrew = ValueModel.Wrap(GameVars.playerShipVariables.ship.crewRoster)
                 .Select(crew => new CrewManagementMemberViewModel(crew, OnCrewClicked, null));
    }
    public DashboardViewModel()
    {
        Clout = new BoundModel <float>(Globals.GameVars.playerShipVariables.ship, nameof(Globals.GameVars.playerShipVariables.ship.playerClout));

        var water = GameVars.playerShipVariables.ship.cargo.FirstOrDefault(r => r.name == Resource.Water);

        WaterInventory = new CargoInventoryViewModel(water);

        var food = GameVars.playerShipVariables.ship.cargo.FirstOrDefault(r => r.name == Resource.Provisions);

        FoodInventory = new CargoInventoryViewModel(food);

        CargoList = ValueModel.Wrap(new ObservableCollection <CargoInventoryViewModel>(GameVars.playerShipVariables.ship.cargo.Select(c => new CargoInventoryViewModel(c))));

        CrewList = ValueModel.Wrap(GameVars.playerShipVariables.ship.crewRoster)
                   .Select(c => new CrewManagementMemberViewModel(c, OnCrewClicked, OnCrewCityClicked));

        SailsAreUnfurled = new BoundModel <bool>(GameVars.playerShipVariables.ship, nameof(GameVars.playerShipVariables.ship.sailsAreUnfurled));

        Objective = new BoundModel <string>(GameVars.playerShipVariables.ship, nameof(GameVars.playerShipVariables.ship.objective));
    }
Exemplo n.º 7
0
    public CityDetailsViewModel(Settlement city, Action <CityViewModel> onClick) : base(city, onClick)
    {
        Crew = ValueModel.Wrap(new ObservableCollection <CrewManagementMemberViewModel>(
                                   GameVars.Network.CrewMembersWithNetwork(city, true)
                                   .OrderBy(c => GameVars.Network.GetCrewMemberNetwork(c).Count())
                                   .Take(5)
                                   .Select(crew => new CrewManagementMemberViewModel(crew, OnCrewClicked, OnCrewCityClicked))
                                   ));

        Buy = ValueModel.Wrap(new ObservableCollection <CargoInventoryViewModel>(
                                  PriceInfos
                                  .OrderBy(o => o.Price - o.AvgPrice)
                                  .Take(5)
                                  .Select(o => new CargoInventoryViewModel(o.Resource))
                                  ));

        Sell = ValueModel.Wrap(new ObservableCollection <CargoInventoryViewModel>(
                                   PriceInfos
                                   .OrderByDescending(o => o.Price - o.AvgPrice)
                                   .Take(5)
                                   .Select(o => new CargoInventoryViewModel(o.Resource))
                                   ));
    }
Exemplo n.º 8
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
        }));
    }
Exemplo n.º 9
0
 public TavernViewModel()
 {
     Cities = ValueModel.Wrap(GameVars.playerShipVariables.ship.playerJournal.knownSettlements)
              .Where(id => id != GameVars.currentSettlement.settlementID)
              .Select(id => new TavernCityViewModel(GameVars.GetSettlementFromID(id)) as CityViewModel);
 }