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 Awake()
    {
        backButton.onClick.AddListener(OpenPreviousView);

        buttons.Add(aboutGameButton);
        buttons.Add(creatingTournamentButton);
        buttons.Add(howToPlayButton);
        buttons.Add(payoutsButton);
        buttons.Add(tournamentHistoryButton);
        buttons.Add(settingButton);

        foreach (var button in buttons)
        {
            button.OnButtonClick += SwitchButton;
        }

        aboutGameButton.GetComponent <Button>().onClick.AddListener(ScrollToAboutGameText);
        creatingTournamentButton.GetComponent <Button>().onClick.AddListener(ScrollToCreatingTournamentText);
        howToPlayButton.GetComponent <Button>().onClick.AddListener(ScrollToHowToPlayText);
        payoutsButton.GetComponent <Button>().onClick.AddListener(delegate { ScrollToTheEnd(payoutsButton); });
        tournamentHistoryButton.GetComponent <Button>().onClick.AddListener(delegate { ScrollToTheEnd(tournamentHistoryButton); });
        settingButton.GetComponent <Button>().onClick.AddListener(delegate { ScrollToTheEnd(settingButton); });
        scrollView.onValueChanged.AddListener(UpdateScrollPosition);
        Clear();
    }
示例#3
0
        private void AddButton <T>(Cell cell) where T : IBuyable, IPlaceable, IProgressive, new()
        {
            var button = _listMenuViewInstance.AddButton(_buttonViewPrefab.GetComponent <Button>(), () =>
            {
                var value = GameManager.Instance.TradeService.TryBuy <T>();
                if (value == null)
                {
                    return;
                }

                cell.SetContent(value);
                value.ProgressChanged += f =>
                {
                    cell.SetProgressBarValue(f);
                };

                Destroy(_listMenuViewInstance.gameObject);
            });

            var buttonView = button.GetComponent <ButtonView>();

            if (buttonView != null)
            {
                buttonView.SetContentImage(GameManager.Instance.ImageManager.GetImage(typeof(T).Name));
            }
        }
示例#4
0
    public override void Awake()
    {
        dashboardBtn.GetComponent <Button>().onClick.AddListener(DashboardBtn_Click);
        gamesBtn.GetComponent <Button>().onClick.AddListener(GamesBtn_Click);
        settingsBtn.GetComponent <Button>().onClick.AddListener(SettingsBtn_Click);
        accountButton.onClick.AddListener(AccountBtn_Click);
        noticeButton.GetComponent <Button>().onClick.AddListener(NoticesBtn_Click);

        allHeaderButtons.Add(gamesBtn);
        allHeaderButtons.Add(dashboardBtn);
        allHeaderButtons.Add(settingsBtn);
        allHeaderButtons.Add(noticeButton);

        UIController.Instance.OnDashboardButton += ShowDashboardBtn;
        UIController.Instance.OnGamesButton     += ShowGamesBtn;

        OnDashboardClick += ShowDashboardBtn;
        OnSettingsClick  += ShowSettingsButton;
        OnGamesClick     += ShowGamesBtn;
    }