Beispiel #1
0
    public void ClearPart(GameObject part)
    {
        if (part == PartToClear)
        {
            PlayerBrush playerBrush = GameObject.FindObjectOfType <PlayerBrush>();

            if (PlayerCanDraw && playerBrush.BrushSelected)
            {
                PartToClear.SetActive(false);

                if (PartToClear != endPart)
                {
                    if (startPart != null)
                    {
                        if (PartToClear == startPart)
                        {
                            GameObject star = currentGuid.GuideStars[0];
                            star.GetComponent <Animator>().Play("Star_Disappear");
                            //star.GetComponent<Image>().sprite = starCompleteSprite;
                            //star.SetActive(false);
                            star.AddComponent <AudioSource>();
                            star.GetComponent <AudioSource>().loop = false;
                            star.GetComponent <AudioSource>().clip = dingSound;
                            star.GetComponent <AudioSource>().Play();
                        }
                    }

                    if (partToClearIndex > -1)
                    {
                        partToClearIndex -= 1;
                        if (partToClearIndex >= 0)
                        {
                            PartToClear = manager.LetterParts[partToClearIndex];
                        }
                    }
                }
                else
                {
                    GameObject star;
                    if (currentGuid.GuideStars.Length > 1)
                    {
                        star = currentGuid.GuideStars[1];
                    }
                    else
                    {
                        star = currentGuid.GuideStars[0];
                    }

                    star.GetComponent <Animator>().Play("Star_Disappear");
                    //star.GetComponent<Image>().sprite = starCompleteSprite;
                    star.AddComponent <AudioSource>();
                    star.GetComponent <AudioSource>().loop = false;
                    star.GetComponent <AudioSource>().clip = dingSound;
                    star.GetComponent <AudioSource>().Play();
                    Invoke("ChangeGuide", 0.75f);
                }
            }
        }
    }
    private void ClearPoint()
    {
        cleared = true;
        brush   = GameObject.FindObjectOfType <PlayerBrush>();
        if (this.gameObject == writingSequence.guidePointToClear && brush.BrushSelected)
        {
            col                = this.GetComponent <PolygonCollider2D>();
            col.enabled        = false;
            audioSource        = this.GetComponent <AudioSource>();
            audioSource.clip   = dingSound;
            audioSource.volume = 0.5f;
            audioSource.Play();
            image       = this.GetComponent <Image>();
            image.color = new Color(0, 0, 0, 0);

            writingSequence.MoveOnGuidePoints();
        }
    }
    public void LoadLevelByName(string name)
    {
        loadingPanel.SetActive(true);

        if (MusicManager.musicManager != null)
        {
            MusicManager.musicManager.ChangeMusicVolume(0f, 0.75f);
        }

        if (name == "MainMenu")
        {
            PlayerBrush playerBrush = GameObject.FindObjectOfType <PlayerBrush>();
            if (playerBrush != null && playerBrush.gameObject.activeInHierarchy)
            {
                playerBrush.gameObject.SetActive(false);
            }
            StartCoroutine(PlayTransition(name));
        }

        if (SceneManager.GetActiveScene().name == "MainMenu")
        {
            string[] levelNames       = name.Split("@".ToCharArray());
            string   capitalLevelName = levelNames[0];
            string   smallLevelName   = levelNames[1];

            if (PlayerPrefs.HasKey("SmallLevelToActive"))
            {
                if (smallLevelName == PlayerPrefs.GetString("SmallLevelToActive"))
                {
                    StartCoroutine(PlayTransition(smallLevelName));
                }
                else
                {
                    StartCoroutine(PlayTransition(capitalLevelName));
                }
            }
            else
            {
                StartCoroutine(PlayTransition(capitalLevelName));
            }
        }
    }