private IEnumerator updateCollectibleDisplay() { coroutineActive = true; Service.Get <EventDispatcher>().DispatchEvent(default(HudEvents.CoinAdditionStart)); state = CollectibleHudState.adding; showCollectibleAdding(); if (remainingCollectibles == 1) { CollectibleParticles.Emit(2); } while (remainingCollectibles > 0) { collectibleCount++; remainingCollectibles--; CountText.text = collectibleCount.ToString(); CollectibleParticles.Emit(1); if (remainingCollectibles > 0) { yield return(new WaitForSeconds(Mathf.Min(1f / (float)remainingCollectibles, 0.5f))); } } stopCollectibleAdding(); state = CollectibleHudState.waitingToClose; wrapperInvoke("hideCollectibleHud", CloseTime); coroutineActive = false; }
private bool onAddCollectible(CollectibleEvents.CollectibleAdd evt) { currentCollectibleDefinition = definitionService.Get(evt.Type); int amount = evt.Amount; if (evt.Type != previousType || state == CollectibleHudState.closed) { setCollectibleImage(); remainingCollectibles = 0; if (Service.Get <CPDataEntityCollection>().TryGetComponent <CollectiblesData>(localPlayerHandle, out var component)) { collectibleCount = component.GetCollectibleTotal(evt.Type); } } switch (state) { case CollectibleHudState.closed: remainingCollectibles += amount; showCollectibleHud(); state = CollectibleHudState.opening; break; case CollectibleHudState.opening: case CollectibleHudState.adding: remainingCollectibles += amount; if (remainingCollectibles > 1) { showCollectibleHud(); state = CollectibleHudState.reopen; } break; case CollectibleHudState.reopen: remainingCollectibles += amount; if (!coroutineActive) { CoroutineRunner.Start(updateCollectibleDisplay(), this, "updateCollectibleDisplay"); state = CollectibleHudState.adding; } break; case CollectibleHudState.waitingToClose: wrapperCancelInvoke(); remainingCollectibles += amount; if (!coroutineActive) { CoroutineRunner.Start(updateCollectibleDisplay(), this, "updateCollectibleDisplay"); } break; } previousType = evt.Type; if (!ShouldShowCollectibleTutorial) { numCollectiblesSinceTutorial += amount; checkTutorial(); } return(false); }
private void showCollectibleHud() { setVisible(isVisible: true); base.transform.localScale = Vector3.one; CollectibleImage.transform.localRotation = Quaternion.identity; base.gameObject.SetActive(value: true); animatorSetBool("isShown", value: true); if (state == CollectibleHudState.closed && this.HudOpened != null) { this.HudOpened(base.gameObject); } CountText.text = collectibleCount.ToString(); state = CollectibleHudState.opening; }
public void Start() { state = CollectibleHudState.closed; animator = GetComponent <Animator>(); definitionService = Service.Get <CollectibleDefinitionService>(); loadedSprites = new Dictionary <string, Sprite>(); previousType = ""; base.gameObject.SetActive(value: false); Service.Get <EventDispatcher>().AddListener <CollectibleEvents.CollectibleAdd>(onAddCollectible); localPlayerHandle = Service.Get <CPDataEntityCollection>().LocalPlayerHandle; if (PlayerPrefs.HasKey("CollectiblesTutorialCount")) { numCollectiblesSinceTutorial = PlayerPrefs.GetInt("CollectiblesTutorialCount"); } if (PlayerPrefs.HasKey("CollectiblesTutorialsShown")) { numTutorialsShown = PlayerPrefs.GetInt("CollectiblesTutorialsShown"); } if (PlayerPrefs.HasKey("CollectiblesShowTutorial")) { ShouldShowCollectibleTutorial = PlayerPrefs.GetInt("CollectiblesShowTutorial") == 1; } }
private void hideCollectibleHud() { invokeActive = false; animatorSetBool("isShown", value: false); state = CollectibleHudState.closed; }