Example #1
0
        public override void StateStarted()
        {
            /*
             *  при условии что контракта активного нет
             *
             *  выбрать рандомный контракт
             *  открыть popup с названием описанием и reward?
             *
             *  делаем его активным
             */

            var selectedContracts = ContractGenerator.ReturnContracts(Context, Db);
            var contractOptions   = new List <OptionsVotingInfo.Option>();

            foreach (var contract in selectedContracts)
            {
                var option = new OptionsVotingInfo.Option
                {
                    Name      = contract.Name,
                    Action    = new SetContract(contract),
                    IsEnabled = contract.Level <= Context.Company.Level
                };
                contractOptions.Add(option);
            }

            var optionsVotingInfo = new OptionsVotingInfo(true, contractOptions, Common.DefaultVotingDuration);

            _activeVoting = new OptionsVotingState(optionsVotingInfo);

            UIManager.Instance.ShowOptionsVotingPopup(new EventInfo("Choose contract", "Every next contract is more complicated than the previous one! But the harder the contract, the more money you will make..."), _activeVoting);
            SoundManager.Instance.Play(SoundBank.Instance.ContractStarted);
        }
Example #2
0
        public OptionsVotingPopup ShowOptionsVotingPopup(EventInfo eventInfo, OptionsVotingState state)
        {
            var popupObj = ShowPopup(OptionsVotingPopup);
            var popup    = popupObj.GetComponent <OptionsVotingPopup>();

            popup.Setup(eventInfo, state);
            return(popup);
        }
        public override void StateStarted()
        {
            // Выводим окошко с OptionsVoting за название (выбираем рандомные 4), ставим таймер
            _event = new EventInfo(
                "Choose new name for company!",
                "Looks like the previous company wasn't as successful as we wanted it to be. But the new mysterious investor wants to try it all again! Even better, he wants to keep the previous board.");

            var randomNames   = RandomUtils.NRandom(_names, 4);
            var votingOptions = randomNames.Select(name => new OptionsVotingInfo.Option {
                Name = name
            });
            var votingInfo = new OptionsVotingInfo(allowMultipleVotes: true, votingOptions, Common.DefaultVotingDuration);

            _votingState = new OptionsVotingState(votingInfo);
            UIManager.Instance.ShowOptionsVotingPopup(_event, _votingState);
            SoundManager.Instance.Play(SoundBank.Instance.NewCompany);
        }
Example #4
0
        public void Setup(EventInfo eventInfo, OptionsVotingState state)
        {
            _state     = state;
            _eventInfo = eventInfo;
            BasePopup.Setup(eventInfo.Title, eventInfo.Description);

            if (Timer != null)
            {
                Timer.Timer = state.Timer;
            }

            ClearOptions();

            var idx = 1;

            foreach (var option in state.Options)
            {
                var uiOption = AddUiOption(idx++, option.Key, 0, option.Value.IsEnabled);
                _options.Add(option.Key, uiOption);
            }
        }
Example #5
0
        public override void StateStarted()
        {
            /*
             * 1. Выбираем рандомное доступное событие
             *  если оно есть
             *      открываем popup с событием
             *      ставим таймер на просмотр / голосование
             */

            _event = Context.GetRandomAvailableEvent();
            if (_event != null)
            {
                if (_event.Voting != null)
                {
                    // Если это голосование на деньги
                    if (_event.Voting is MoneyVotingInfo moneyVotingInfo)
                    {
                        _moneyVotingState = new MoneyVotingState(moneyVotingInfo);
                        _activeVoting     = _moneyVotingState;
                        UIManager.Instance.ShowMoneyVotingPopup(_event, _moneyVotingState);
                    }

                    // Если это голосование с выбором ответа
                    if (_event.Voting is OptionsVotingInfo optionsVotingInfo)
                    {
                        _optionsVotingState = new OptionsVotingState(optionsVotingInfo);
                        _activeVoting       = _optionsVotingState;
                        UIManager.Instance.ShowOptionsVotingPopup(_event, _optionsVotingState);
                    }
                }
                else
                {
                    _activeVoting = new NotificationVotingState(Common.InformationPopupDisplayTime);
                    UIManager.Instance.ShowNotificationPopup(_event);
                }

                SoundManager.Instance.Play(SoundBank.Instance.NewEvent);
            }
        }