public void Refresh() { foreach (Transform item in ScrollContent) { item.gameObject.SetActive(false); } var levels = LevelManager.Instance.SelectedChapterLevels; for (int i = 0; i < levels.Length; i++) { var button = ObjectPool.Instantiate(Button, Vector3.zero); AddEventListener(button, i); button.GetComponentInChildren <Text>().text = (i + 1).ToString(); button.transform.SetParent(ScrollContent); button.transform.localScale = new Vector3(1, 1, 1); if (LevelManager.Instance.CanPlayLevel(i)) { button.GetComponent <Button>().interactable = true; button.GetComponentInChildren <Text>().text = (i + 1).ToString(); } else { button.GetComponent <Button>().interactable = Debug.isDebugBuild; int starsNeeded = LevelManager.Instance.SelectedChapterLevels[i].StarsToUnlock; button.GetComponentInChildren <Text>().text = LivesManager.Instance.LivesRemaining == 0 ? "NO CREDITS": starsNeeded + " STARS"; } button.GetComponentInChildren <StarPanel>().Configure(LevelManager.Instance.GetStarAchievedOnLevel(i)); } }
private void SetupAvaiblePowerups() { for (int i = 0; i < Grid.childCount; i++) { Grid.GetChild(i).gameObject.SetActive(false); } PowerupSlot first = null; foreach (IPowerup powerup in PowerupFactory.GetAllPowerups()) { var obj = ObjectPool.Instantiate(PowerupIcon, Vector3.zero); obj.transform.localScale = new Vector3(1, 1, 1); obj.transform.SetParent(Grid); obj.GetComponent <PowerupSlot>().Setup(powerup); if (first == null || SelectedPowerup != null && powerup.GetType() == SelectedPowerup.GetType()) { first = obj.GetComponent <PowerupSlot>(); } } SelectPowerup(first); }
public void Show(int points, Vector3 spawnPosition, Color colour) { var position = RectTransformUtility.WorldToScreenPoint(Camera.main, spawnPosition); var gameObject = ObjectPool.Instantiate(GameResources.GameObjects["Animated Text"], position); gameObject.GetComponent <RectTransform>().SetParent(transform); gameObject.transform.localScale = new Vector3(1, 1, 1); gameObject.transform.SetSiblingIndex(transform.childCount - 1); var aniamtedText = gameObject.GetComponent <AnimatedText>(); aniamtedText.TextHidden += AniamtedText_TextHidden; aniamtedText.Show($"+{points}", colour); CountOfScoreOnShow++; }
public void ProduceBolt(object key, Vector3 position) { if (MenuProvider.Instance.OnDisplay) { return; } GameObject bolt = null; if (currentBolts.ContainsKey(key)) { bolt = currentBolts[key]; } else { bolt = ObjectPool.Instantiate(GameResources.GameObjects["LightningBolt"], new Vector3(0, 0, 0)); currentBolts.Add(key, bolt); } var line = bolt.GetComponent <LineRenderer>(); line.SetPositions(new Vector3[] { new Vector3(0, -5), position }); }
private void ShowPiecesCollected(string chapter, int level, int star, int score, GameResult result, bool dailyChallenge) { foreach (var ingameProgress in pieceCollectionInProgress) { GameObject obj = null; var currentProgressBars = ObjectPool.GetActivePool(PieceProgress); if (currentProgressBars != null) { obj = currentProgressBars.FirstOrDefault(x => x.GetComponent <PieceCollectionProgress>().colour == ingameProgress.Key); } if (obj == null) { obj = ObjectPool.Instantiate(PieceProgress, Vector3.zero); } obj.transform.SetParent(this.transform); obj.transform.localScale = new Vector3(1.3f, 1.3f, 1.3f); obj.GetComponent <PieceCollectionProgress>().Setup(ingameProgress.Key, ingameProgress.Value.Previous, ingameProgress.Value.Gained); obj.GetComponentInChildren <Button>().enabled = false; } }
private void ShootStar() { var position = new Vector3(Random.Range(Min.x, Max.x), Random.Range(Min.y, Max.y)); ObjectPool.Instantiate(GameResources.ParticleEffects["Star Shot"], position); }