/// <summary> /// Start is called on the frame when a script is enabled just before /// any of the Update methods is called the first time. /// </summary> private void Start() { refineryOutModel = new RefineryModel(); capacity = refineryOutView.GetCapacity(); refineryOutModel.Initialize(capacity); isOnboarding = false; ctaController.StopCtaAnimation(); onboardMessage = MessageBroker.Default.Receive <OnboardingCTAMessage>().Subscribe(message => { if (message.Instruction == Onboarding.RefineryOut) { ctaController.StartCtaAnimation(); isOnboarding = true; } else { ctaController.StopCtaAnimation(); } }).AddTo(this); //emptying MessageBroker.Default.Receive <AppStateMessage>().Subscribe(message => { if (message.AppState == AppState.ResetGame) { Reset(); } else if (message.AppState == AppState.PlayGame) { } else if (message.AppState == AppState.EndGame) { hitMessage?.Dispose(); } }).AddTo(this); areaTrigger.OnTriggerEnterAsObservable().Subscribe(_ => { hitMessage = MessageBroker.Default.Receive <RaycastHitMessage>().Subscribe(message => { if (message.Hit.transform == refineryOutTransform) { if (isOnboarding) { MessageBroker.Default.Publish(new OnboardingMessage() { Instruction = Onboarding.Residence }); isOnboarding = false; onboardMessage?.Dispose(); } MessageBroker.Default.Publish(new CargoRequestMessage() { Cargo = OnCargoReceived }); } }).AddTo(this); }).AddTo(this); areaTrigger.OnTriggerExitAsObservable().Subscribe(_ => { hitMessage?.Dispose(); }).AddTo(this); MessageBroker.Default.Receive <RefineryInMessage>().Subscribe(message => { MessageBroker.Default.Publish(new RefineryStateMessage() { Open = false }); refineryOutView.TurnOn(); float delay = 0.0f; float progress = 0.0f; processMessage = MessageBroker.Default.Receive <TimerMessage>().Subscribe(_ => { if (delay >= duration) { for (int i = 0; i < capacity; i++) { FillData(i); } processMessage?.Dispose(); } delay++; progress = delay / duration; for (int i = 0; i < capacity; i++) { Fill(i, progress); } }).AddTo(this); }).AddTo(this); }
/// <summary> /// Start is called on the frame when a script is enabled just before /// any of the Update methods is called the first time. /// </summary> private void Start() { refineryModel = new RefineryModel(); amount = refineryInView.GetAmount(); refineryModel.Initialize(amount); refineryOpen = true; isOnboarding = false; ctaController.StopCtaAnimation(); onboardMessage = MessageBroker.Default.Receive <OnboardingCTAMessage>().Subscribe(message => { if (message.Instruction == Onboarding.RefineryIn) { ctaController.StartCtaAnimation(); isOnboarding = true; } else { ctaController.StopCtaAnimation(); } }).AddTo(this); //emptying MessageBroker.Default.Receive <AppStateMessage>().Subscribe(message => { if (message.AppState == AppState.ResetGame) { EmptyAll(); } else if (message.AppState == AppState.PlayGame) { } else if (message.AppState == AppState.EndGame) { hitMessage?.Dispose(); } }).AddTo(this); areaTrigger.OnTriggerEnterAsObservable().Subscribe(_ => { hitMessage = MessageBroker.Default.Receive <RaycastHitMessage>().Subscribe(message => { if (message.Hit.transform == refineryInTransform) { if (refineryOpen) { MessageBroker.Default.Publish(new CargoRequestMessage() { Cargo = OnCargoReceived }); } } }).AddTo(this); }).AddTo(this); MessageBroker.Default.Receive <RefineryStateMessage>().Subscribe(message => { refineryOpen = message.Open; if (refineryOpen) { refineryInView.TurnOn(); } else { refineryInView.TurnOff(); } }) .AddTo(this); areaTrigger.OnTriggerExitAsObservable().Subscribe(_ => { hitMessage?.Dispose(); }).AddTo(this); }