Exemplo n.º 1
0
 public void EarnCoins(int value, bool sound) //Set coins count when earning coins
 {
     coins += value;
     if (sound)
     {
         MusicManager.instance.PlaySound("coins");
     }
     saveInstance.SetCoinsData(coins);
     StaticBehaviors.SetCoinsText();
 }
Exemplo n.º 2
0
    private void SpawnTask(LevelInfo data, GameType type) //Create a new level scene
    {
        if (DataManager.Instance.RemoveClearButtons)
        {
            letterDeleteButton.transform.parent.gameObject.SetActive(false);
            lettersFields.GetComponent <RectTransform>().sizeDelta += new Vector2(200f, 0f);
        }
        if (DataManager.Instance.isRatePopupNeeded && PlayerPrefs.GetInt("rate", 0) == 0 && (data.currentLevel - 1) != 0 &&
            (data.currentLevel - 1) % DataManager.Instance.afterEeachLevel == 0)
        {
            Instantiate(ratePrefab, main);
        }
        try
        {
            // Load and create new sprite from Resources in RAM optimization purpose
            Texture2D newtask = Resources.Load(data.directoryName + "\u002F" + data.currentLevel) as Texture2D;
            taskImage.sprite = Sprite.Create(newtask, new Rect(0, 0, newtask.width, newtask.height), new Vector2(0.5f, 0.5f));
        }
        catch (System.Exception)
        {
            Debug.LogError("You made a mistake in filenames in the Resources folder probably");
        }

        levelColor = DataManager.Instance.colors[Random.Range(0, DataManager.Instance.colors.Length - 1)];
        StaticBehaviors.SetCoinsText();

        //Provide requested manager with data and start its logic
        switch (type)
        {
        case GameType.Default:
            break;

        case GameType.Pixel:

            PixelManager pixel = taskImage.gameObject.GetComponent <PixelManager>();
            pixel.enabled = true;
            pixel.OnStart(data);
            break;

        case GameType.Erasure:

            ErasureManager erasure = taskImage.gameObject.GetComponent <ErasureManager>();
            erasure.enabled = true;
            erasure.OnStart(data);
            break;

        case GameType.Planks:

            PlanksManager planks = taskImage.gameObject.GetComponent <PlanksManager>();
            planks.OnStart(data);
            break;

        case GameType.ImageText:
            ImageTextManager imageText = taskImage.gameObject.GetComponent <ImageTextManager>();
            imageText.OnStart();
            break;

        default:
            break;
        }

        taskLevel.text   = data.currentLevel.ToString();
        letterList       = CreateLetterList(LevelManager.fullList);          //Instantiate letter prefabs and add their scripts to the collection
        letterFieldsList = CreateLetterFields(LevelManager.rightAnswerList); //Instantiate letter fields and add their scripts to the collection
        border.gameObject.GetComponent <Image>().color = levelColor;

        StartCoroutine(SpawnLetters(letterList, data)); //Spawn letters
        MusicManager.instance.PlaySound("start");
    }
Exemplo n.º 3
0
 public void SpendCoins(int hint, object obj) //Set coins count when hints are used
 {
     coins -= LevelManager.GetCostValues()[hint];
     saveInstance.SetCoinsData(coins);
     StaticBehaviors.SetCoinsText();
 }