void OnTriggerEnter(Collider hit)
    {
        StarController isStar = hit.GetComponent <StarController>();

        if (isStar)
        {
            if (lastStar != null && lastStar.theStarType != isStar.theStarType)
            {
                Camera.main.GetComponent <CameraController>().DoScreenShake();
                GameController.TriggerCometBoost();
                constManager.BreakConstellation();
                isStar.FadeOutStar();
                ChangeColor(GameData.StarType.None);
                lastStar = null;
            }
            else
            {
                lastStar = isStar;
                isStar.StopMovement();
                //isStar.starBoing.GetComponent<StarBoingController>().StartGrowing();
                isStar.starBoing.gameObject.SetActive(true);//active the star boing

                StarController isStarStarCont = isStar.GetComponent <StarController>();
                isStarStarCont.delayBeforeSecondBoingTimer = isStarStarCont.delayBeforeSecondBoingTimerBase;//start the timer for the 2nd star boing

                isStar.starData.Position = isStar.transform.position;
                ChangeColor(isStar.theStarType);
                constManager.AddStar(isStar.starData);
                AudioController.Instance.PlaySfx(SoundBank.SoundEffects.StarGood);

                isStar.DoBoing();
                isStar.DoGotHitAnim();

                FindAllStarsOfSameTypeAndBoingThem(isStar);
            }
        }

        if (hit.gameObject.tag == cometTag)
        {
            //KILL THE WORLD
            GameController.TriggerEndGame();


            //spawn fireworks
            Instantiate(fireworksPrefab, transform.position, Quaternion.identity);
            Instantiate(fireworksPrefab, new Vector3(-3, 0, 0), Quaternion.identity);
            Instantiate(fireworksPrefab, new Vector3(3, 0, 0), Quaternion.identity);
            Instantiate(fireworksPrefab, new Vector3(0, 0, 0), Quaternion.identity);

            AudioController.Instance.PlaySfx(SoundBank.SoundEffects.ConstellationBroken);

            var colliders = gameObject.GetComponents <Collider>();
            lastStar = null;
            canMove  = false;
            constManager.BreakConstellation();
            AudioController.Instance.PlaySfx(SoundBank.SoundEffects.ConstellationComplete, (int)SoundBank.SoundEffects.ConstellationBroken);
            for (int i = 0; i < colliders.Length; i++)
            {
                colliders[i].enabled = false;
            }

            //gameObject.SetActive(false);
        }
    }
Ejemplo n.º 2
0
    void Update()
    {
        if (PlayerController.Instance.isGameStarted)
        {
            if (Input.GetMouseButtonDown(1) && LensGlassController.CanCameraZoom)
            {
                _panelController.ClearTextFields();
                if (_zoomedIn)
                {
                    if (_starViewController.CurrentStarController != null)
                    {
                        _starViewController.CurrentStarController.HideMarker();
                    }

                    _panelController.UpdateLightIndicators();
                    _audioController.PlaySound("Zoom Out");
                    _starViewController.DisplayBookmarks();
                    foreach (GameObject obj in MainViewObjects)
                    {
                        if (obj != null)
                        {
                            if (_starViewController.GetNumberOfBookmarks() > 0)
                            {
                                obj.SetActive(true);
                            }
                            else
                            {
                                if (obj.name != "Bookmarks Panel")
                                {
                                    obj.SetActive(true);
                                }
                            }
                        }
                    }
                    foreach (GameObject obj in ZoomedViewObjects)
                    {
                        if (obj != null)
                        {
                            obj.SetActive(false);
                        }
                    }
                }
                else
                {
                    _panelController.UpdateLightIndicators();
                    _audioController.PlaySound("Zoom In");
                    _starViewController.DisplayBookmarks();
                    foreach (GameObject obj in MainViewObjects)
                    {
                        if (obj != null)
                        {
                            obj.SetActive(false);
                        }
                    }
                    foreach (GameObject obj in ZoomedViewObjects)
                    {
                        if (obj != null)
                        {
                            obj.SetActive(true);
                        }
                    }
                }
                _zoomedIn = !_zoomedIn;
            }

            Vector3 mousePosition = Input.mousePosition;
            if ((mousePosition.x > -Mathf.Abs(ConsoleDisplay.rectTransform.anchoredPosition.x) &&
                 mousePosition.x < ConsoleDisplay.rectTransform.sizeDelta.x) &&
                ((mousePosition.y > -Mathf.Abs(ConsoleDisplay.rectTransform.anchoredPosition.y) + 80 &&
                  mousePosition.y < ConsoleDisplay.rectTransform.sizeDelta.y)))
            {
                if (Input.GetMouseButtonDown(0) && _zoomedIn == false && _isErrorIconBlinking == false)
                {
                    _audioController.PlaySound("Zooming Error");
                    StartCoroutine(BlinkIcon());
                    _isErrorIconBlinking = true;
                }
                if (Input.GetMouseButtonDown(0) && _zoomedIn == true)
                {
                    _panelController.ClearTextFields();
                    Vector3 pointerPosition = _zoomCamera.ScreenToWorldPoint(Input.mousePosition);
                    Vector2 origin          = new Vector2(pointerPosition.x, pointerPosition.y);
                    Vector2 direction       = Vector2.one;

                    RaycastHit2D hit = Physics2D.Raycast(pointerPosition, direction, Mathf.Infinity);

                    if (hit && hit.transform.tag == "Space Object")
                    {
                        StarController starController = hit.collider.GetComponent <StarController>();
                        if (starController != null)
                        {
                            // Sound effect
                            AudioController audioController = starController.GetComponent <AudioController>();
                            audioController.PlaySound(Random.Range(0, audioController.CountOfSounds()));

                            starController.ToggleMarker();
                            _panelController.LoadDetails(starController, false);
                        }
                        //ObjectDetailsManager.Instance.InitializePanelOf(hit.collider.GetComponent<StarController>(), pointerPosition);
                    }

                    _panelController.UpdateLightIndicators();
                }
            }
        }
    }