Esempio n. 1
0
    private void UnlockWindowInitialization()
    {
        unlockWindow.gameObject.SetActive(false);
        var cancelEv = new Button.ButtonClickedEvent();

        cancelEv.AddListener(UnlockCancel);
        var unlockEv = new Button.ButtonClickedEvent();

        unlockEv.AddListener(UnlockConfirm);
        unlockWindow.cancel.onClick = cancelEv;
        unlockWindow.unlock.onClick = unlockEv;
    }
Esempio n. 2
0
    private void Start()
    {
        me = FindObjectOfType <PlayerManager>().me;
        UnlockWindowInitialization();
        generatedCells = new List <ShipCell>();
        var buttonEvent = new Button.ButtonClickedEvent();

        buttonEvent.AddListener(StartGame);
        startButton.onClick = buttonEvent;
        unitList            = new List <Unit>();


        foreach (var availableUnit in availableUnits)
        {
            unitList.Add(Instantiate(availableUnit));
        }
        foreach (var unit in unitList)
        {
            var cell     = Instantiate(itemCellPrefab, content.transform);
            var shipCell = cell.GetComponent <ShipCell>();
            generatedCells.Add(shipCell);
            shipCell.relatedUnit         = unit;
            shipCell.contentImage.sprite = unit.sprite;
            shipCell.unitName.SetText(unit.unitName);

            if (unit.isLocked)
            {
                shipCell.unitCost.SetText(unit.cost.ToString());
            }
            else
            {
                shipCell.unitCost.enabled = false;
            }

            Toggle.ToggleEvent ev = new Toggle.ToggleEvent();
            ev.AddListener(OnClickHandler);
            shipCell.toggle.onValueChanged = ev;
        }
        LockAllUnits();
        RefreshStates();
        moneyText.SetText($"gold: {me.availableMoney}");
        OnClickHandler(false);
    }