void ResetAndLayout() { // Reset if (mainBubble == null) { mainBubble = this.GetComponentInChildren <GamesSelectorBubble>(); } foreach (GamesSelectorBubble bubble in bubbles) { if (bubble != mainBubble) { Destroy(bubble.gameObject); } } bubbles.Clear(); // Layout const float bubblesDist = 0.1f; int totBubbles = games.Count; float bubbleW = mainBubble.Main.GetComponent <Renderer>().bounds.size.x; float area = totBubbles * bubbleW + (totBubbles - 1) * bubblesDist; float startX = -area * 0.5f + bubbleW * 0.5f; for (int i = 0; i < totBubbles; ++i) { MiniGameData mgData = games[i]; GamesSelectorBubble bubble = i == 0 ? mainBubble : (GamesSelectorBubble)Instantiate(mainBubble, this.transform); bubble.Setup(mgData.GetIconResourcePath(), mgData.GetBadgeIconResourcePath(), startX + (bubbleW + bubblesDist) * i); bubbles.Add(bubble); } }
IEnumerator CO_AnimateEntrance() { foreach (GamesSelectorBubble bubble in bubbles) { bubble.gameObject.SetActive(false); } yield return(null); yield return(null); showTween = DOTween.Sequence(); for (int i = 0; i < bubbles.Count; ++i) { GamesSelectorBubble bubble = bubbles[i]; bubble.gameObject.SetActive(true); showTween.Insert(i * 0.05f, bubble.transform.DOScale(0.0001f, 0.6f).From().SetEase(Ease.OutElastic, 1, 0)) .InsertCallback(i * 0.1f, () => AudioManager.I.PlaySfx(Sfx.BalloonPop)); } yield return(showTween.WaitForCompletion()); if (totOpenedBubbles == 0) { tutorial.Play(bubbles); } }
void Start() { KeeperManager.I.PlayDialog(Db.LocalizationDataId.SelectGame_Tuto_2, false); if (mainBubble == null) { mainBubble = this.GetComponentInChildren <GamesSelectorBubble>(); mainBubble.gameObject.SetActive(false); } if (cam == null) { cam = Camera.main; camT = Camera.main.transform; } if (AudoLoadMinigamesOnStartup && games == null) { AutoLoadMinigames(); } }
void Update_CheckHitBubble(Vector3 _mouseP) { _mouseP += -camT.forward * 3; RaycastHit hit; if (!Physics.Raycast(new Ray(_mouseP, camT.forward), out hit)) { return; } GamesSelectorBubble hitBubble = null; foreach (GamesSelectorBubble bubble in bubbles) { if (hit.transform != bubble.Cover.transform) { continue; } hitBubble = bubble; break; } if (hitBubble == null) { return; } if (tutorial.isPlaying) { tutorial.Stop(); } hitBubble.Open(); totOpenedBubbles++; if (totOpenedBubbles == bubbles.Count) { // All bubbles opened: final routine cutAllowed = false; this.StartCoroutine(CO_EndCoroutine()); } }