Esempio n. 1
0
        /// <summary>
        /// Gets executed once when game program is started
        /// </summary>
        public void Init(MenuNavigator nav)
        {
            MenuNavigator = nav;

            // Buttons
            StartGameButton.onClick.AddListener(StartGameButton_OnClick);
            BackButton.onClick.AddListener(BackButton_OnClick);

            // Slots
            for (int i = 0; i < UiSlots.Count; i++)
            {
                LobbySlot slot = new LobbySlot(i, LobbySlotType.Free);
                Slots.Add(slot);
                UiSlots[i].Init(this, slot);
            }

            // Rules

            foreach (GameSettings.TurnLengthOptions option in Enum.GetValues(typeof(GameSettings.TurnLengthOptions)))
            {
                Rules[0].options.Add(new Dropdown.OptionData(option.ToString()));
            }

            foreach (Dropdown rule in Rules)
            {
                rule.value = 1; rule.value = 0;
            }

            for (int i = 0; i < Rules.Count; i++)
            {
                int j = i; // needed to to make sure call is made by value and not reference
                Rules[j].onValueChanged.AddListener((x) => OnRuleChanged(j, x));
            }
        }
Esempio n. 2
0
 public void Init(MenuNavigator nav)
 {
     MenuNavigator = nav;
     SingleplayerButton.onClick.AddListener(CreateSingleplayerGame);
     HostGameButton.onClick.AddListener(HostGame);
     JoinGameButton.onClick.AddListener(JoinGame);
     ExitButton.onClick.AddListener(() => Application.Quit());
 }