Exemplo n.º 1
0
        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));
            }
        }
Exemplo n.º 2
0
        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);
        }
Exemplo n.º 3
0
        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++;
        }
Exemplo n.º 4
0
        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 });
        }
Exemplo n.º 5
0
        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;
            }
        }
Exemplo n.º 6
0
        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);
        }