public void Setup(EventInfo eventInfo, DistrVotingState state) { _state = state; _eventInfo = eventInfo; BasePopup.Setup(eventInfo.Title, eventInfo.Description); if (Timer != null) { Timer.Timer = state.Timer; } if (state.Options.Count != 2) { throw new InvalidOperationException("Only votes with 2 options are supported by this component"); } var optionNames = state.Options.Keys.ToArray(); _option1 = optionNames[0]; _option2 = optionNames[1]; if (Option1Name != null) { Option1Name.text = _option1; } if (Option2Name != null) { Option2Name.text = _option2; } }
public override void StateEnded() { UIManager.Instance.HidePopup(); Context.Company.ActiveContract = null; _votingState = null; _reward = 0; }
public UIDualVotingPopup ShowDualOptionsVotingPopup(EventInfo eventInfo, DistrVotingState state) { var popupObj = ShowPopup(DualVotingPopup); var popup = popupObj.GetComponent <UIDualVotingPopup>(); popup.Setup(eventInfo, state); return(popup); }
public override void StateStarted() { /* * 1. открываем UI голосовалки распределения доходов (и начинаем принимать голоса) * в UI пишем reward или в чат? * начинаем таймер голосования * * 2. выполняем SuccessAction * 3. Context.Company.ActiveContract.Earnings = GetRewardAction()? */ if (!Context.Company.HasContract) { return; } var activeContract = Context.Company.ActiveContract; activeContract.Info.SuccessAction?.Call(Context); var options = new OptionsVotingInfo.Option[] { new OptionsVotingInfo.Option { Name = CompanyOption }, new OptionsVotingInfo.Option { Name = InvestorsOption }, }; var votingInfo = new OptionsVotingInfo(true, options, Common.DefaultVotingDuration); _votingState = new DistrVotingState(votingInfo); _event = new EventInfo( "Split the money!", $"You got an <b>$ {Context.Company.ActiveContract.Info.Reward:N0}</b> for finishing your last contract. Divide the money between the workers and the company - part of the earned money will go to the company's account, and part will be credited to your personal balance."); _reward = Context.Company.ActiveContract.Info.Reward; Context.Company.ActiveContract = null; UIManager.Instance.ShowDualOptionsVotingPopup(_event, _votingState); SoundManager.Instance.Play(SoundBank.Instance.ContractFinished); }