コード例 #1
0
    private IEnumerator SpawnLetters(List <Letter> letterList, LevelInfo data)
    {
        foreach (var item in letterList)
        {
            item.gameObject.GetComponent <Image>().enabled          = true;
            item.gameObject.GetComponentInChildren <Text>().enabled = true;
            item.gameObject.GetComponent <Animation>().Play("FadeIn");
            yield return(new WaitForSeconds(0.06f)); //Wait a bit to make a dominoes effect for letters
        }
        yield return(new WaitForSeconds(0.4f));

        //Handle if some hints already been used earlier
        if (data.lettersOppened != 0)
        {
            int i = data.lettersOppened;
            do
            {
                StaticBehaviors.RevealLetter(letterFieldsList, letterList, LevelManager.rightAnswerList);
                i--;
            } while (i != 0);
        }
        if (data.isLettersRemoved)
        {
            StaticBehaviors.RemoveWrongLetters(letterFieldsList, letterList, LevelManager.rightAnswerList);
        }

        LevelManager.isPaused = false;
    }
コード例 #2
0
    private IEnumerator Pixelate(int hintCase) //Try to use hint
    {
        if (StaticBehaviors.EnoughCoinsForHint(3))
        {
            MusicManager.instance.PlaySound("pixelate");

            float delay = animationSpeed / 0.2f / Mathf.Abs(arrayOfValues[hintCase] - arrayOfValues[hintCase + 1]);
            pixelateButton.interactable = false;

            for (int i = 1; i < 10; i++) //Animation of decreasing pixel grid
            {
                yield return(new WaitForSeconds(animationSpeed));

                SetPixelGrid(arrayOfValues[hintCase] - i);
            }

            for (int i = 1; i < Mathf.Abs(arrayOfValues[hintCase] - arrayOfValues[hintCase + 1]) + 10; i++) //Animation of encreasing pixel grid
            {
                yield return(new WaitForSeconds(delay));

                SetPixelGrid(arrayOfValues[hintCase] - 9 + i);
            }

            pixelateButton.interactable = hintCase == arrayOfValues.Length - 2 ? false : true; //Check is hint button should be disabled
            openedPics++;

            UIManager.HintEvent(3, null);
        }
    }
コード例 #3
0
 void ProvideHintsCost(HintPopup popup) //Provide hints buttons with related cost
 {
     for (int i = 0; i < popup.buttons.Length - 1; i++)
     {
         StaticBehaviors.SetUpCost(popup.buttons[i].transform, hintsCost[i]);
     }
 }
コード例 #4
0
    List <LetterField> CreateLetterFields(List <char> arr) //Instantiate letter fields and add their scripts to collection
    {
        List <LetterField> letterArr = new List <LetterField>();

        foreach (char item in arr)
        {
            GameObject go = Instantiate(letterFieldPrefab.gameObject, lettersFields);
            if (item != ' ')
            {
                LetterField _this = go.GetComponent <LetterField>();
                letterArr.Add(_this);
                if (DataManager.Instance.RemoveClearButtons)
                {
                    Button temp = go.AddComponent <Button>();
                    temp.transition = Selectable.Transition.None;
                    temp.onClick.AddListener(() => StaticBehaviors.Clear(_this));
                }
            }
            else
            {
                go.GetComponent <Image>().enabled = false;
            }
        }
        return(letterArr);
    }
コード例 #5
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();
 }
コード例 #6
0
ファイル: HintPopup.cs プロジェクト: wearefury-boop/QuizGame
    public static event UnityAction <HintPopup> OnHintPopupClicked; //Event is fired when popup created

    private void OnEnable()
    {
        //Is 'Remove letters' button should be disabled
        if (LevelManager.GetCurrentState().isLettersRemoved&& buttons[1].interactable == true)
        {
            StaticBehaviors.DisableButton(buttons[1]);
        }
        LevelManager.isPaused = true;
        MusicManager.instance.PlaySound("menus");
    }
コード例 #7
0
    private void SaveGameData() //Saving localized data to json file
    {
        string filePath = EditorUtility.SaveFilePanel("Save localization data file", path, "", "json");

        if (!string.IsNullOrEmpty(filePath))
        {
            string dataAsJson = JsonUtility.ToJson(localizationData, true);
            File.WriteAllText(filePath, dataAsJson);
            StaticBehaviors.CheckAndWriteFilenames();
        }
    }
コード例 #8
0
    private void LoadGameData()//Loading localized data to json file
    {
        string filePath = EditorUtility.OpenFilePanel("Select localization data file", path, "json");

        if (!string.IsNullOrEmpty(filePath))
        {
            string dataAsJson = File.ReadAllText(filePath);

            localizationData = JsonUtility.FromJson <LocalizationData>(dataAsJson);
            StaticBehaviors.CheckAndWriteFilenames();
        }
        localizationDataIsReady = true;
    }
コード例 #9
0
    List <Letter> CreateLetterList(List <char> arr) //Instantiate letter prefabs and add their scripts to collection
    {
        List <Letter> letterList = new List <Letter>();

        foreach (char item in arr)
        {
            GameObject go = Instantiate(letterPrefab.gameObject, lettersBoard);
            go.GetComponent <Image>().color = levelColor;
            string letter = item.ToString().ToUpper();
            Letter script = go.GetComponent <Letter>();
            script.textField.text = letter;
            script.Clicked       += x => StaticBehaviors.LetterClick(x, letterFieldsList);
            letterList.Add(script);
        }
        return(letterList);
    }
コード例 #10
0
    private void Initialize()
    {
        spawnPoints = new Vector3[]
        {
            new Vector3(0.03f, -2.669f, 0),
            new Vector3(2f, -2.569f, 0),
            new Vector3(-2f, -2.569f, 0)
        };

        //Set up the victory event data
        image.sprite = GameObject.FindGameObjectWithTag("winImage").GetComponent <Image>().sprite;
        GetComponent <Image>().color = UIManager.levelColor;
        answer.text = LevelManager.rightAnswer.ToUpper();
        cost.text   = "+" + LevelManager.completeLvlCoins.ToString();
        continueButton.onClick.AddListener(() => StaticBehaviors.OnLevelComplete(LevelManager.GetCurrentState()));
        MusicManager.instance.PlaySound("finish");
    }
コード例 #11
0
    private void Initialize()
    {
        //Read registry keys to setup buttons activity
        if (!MusicManager.instance.isMusic)
        {
            music.GetComponent <Image>().color -= new Color(0, 0, 0, 0.5f);
        }
        if (!MusicManager.instance.isSounds)
        {
            sound.GetComponent <Image>().color -= new Color(0, 0, 0, 0.5f);
        }

        //Attach OnClick methods to menu buttons
        music.onClick.AddListener(() => StaticBehaviors.MusicClick(music));
        sound.onClick.AddListener(() => StaticBehaviors.SoundsClick(sound));
        backToGame.onClick.AddListener(() => gameObject.SetActive(false));
        backToMainMenu.onClick.AddListener(() => StaticBehaviors.LoadScene(0));
        exit.onClick.AddListener(() => Application.Quit());
    }
コード例 #12
0
    private void TryToDraw()
    {
        if (tempPoint == Vector3.zero)
        {
            tempPoint = moveToPoint;
        }
        if (tempPoint != moveToPoint) //If there is new point to move
        {
            if (StaticBehaviors.EnoughCoinsForHint(5, false))
            {
                DrawOnMask();

                if (!spatula.activeSelf)
                {
                    spatula.SetActive(true);
                }
            }
        }
    }
コード例 #13
0
 private void HitPlank(int number) //When the plank is clicked or shooted
 {
     if (StaticBehaviors.EnoughCoinsForHint(4))
     {
         GameObject currentPlank = planks[number];
         if (currentPlank.GetComponent <Image>().enabled)
         {
             currentPlank.GetComponent <Image>().enabled = false;
             planksOppened.Add(number);
             Destroy(Instantiate(puffPrefab, currentPlank.transform.position, Quaternion.identity, transform), 2); //Particles
             MusicManager.instance.PlaySound("shot");
         }
         else
         {
             MusicManager.instance.PlaySound("miss");
         }
         UIManager.HintEvent(4, planksOppened.ToArray());
     }
 }
コード例 #14
0
 private void SubscribeForEvents()
 {
     try
     {
         LevelManager.OnLevelStart    += SpawnTask;
         HintPopup.OnHintPopupClicked += AddButtonsListeneres;
         letterDeleteButton.onClick.AddListener(() => StaticBehaviors.ClearField(letterFieldsList));
         letterClearButton.onClick.AddListener(() => StaticBehaviors.ClearAll(letterFieldsList));
         hintsButton.onClick.AddListener(() => hintsPopup.gameObject.SetActive(true));
         menuButton.onClick.AddListener(() => menuPopup.gameObject.SetActive(true));
         OnHintUsed += DataManager.Instance.SpendCoins;
     }
     catch (System.NullReferenceException newEx)
     {
         Debug.LogError("There is no reference to " + newEx.Source);
     }
     catch (System.Exception)
     {
         Debug.LogError("You should start the game from 'StartMenu' scene. Or some references are broken");
     }
 }
コード例 #15
0
    //Provide each directory with data
    private void SetDirectoryData(GameObject go, string dirName)
    {
        currentTask = DataManager.Instance.GetData(dirName); //Get saved data for directory
        currentInfo = currentTask.savedData;
        int completeLevels = currentInfo.currentLevel - 1;
        int dirLength      = currentTask.dirLength;

        go.transform.Find("Image").GetComponent <Image>().sprite = completeLevels == 0 ? defaultPicture : CreateSprite(dirName);

        //Set up directory view
        go.transform.Find("Text1").GetComponent <Text>().text = currentTask.localizedDir.ToUpper();


        //Should it be unlocked?
        if (CheckIsLocked(dirName))
        {
            go.transform.Find("Text2").GetComponent <Text>().text = DataManager.Instance.GetLocalizedValue(ElementType.locked_text).ToUpper();
            go.GetComponent <Button>().onClick.AddListener(() => MusicManager.instance.PlaySound("wrong"));
            go.transform.GetComponent <Image>().color -= new Color(0, 0, 0, 0.4f);
        }
        else
        {
            go.transform.Find("Text2").GetComponent <Text>().text = completeLevels + "\u002f" + dirLength;

            //Set up progress bar
            float         barPercent = (float)completeLevels / (float)dirLength;
            RectTransform bar        = go.transform.Find("Bar/ProgressBar").GetComponent <RectTransform>();
            bar.anchoredPosition += new Vector2((bar.sizeDelta.x * barPercent), 0);
            if (barPercent < 1)
            {
                //Add OnClick methods to directory buttons if there are not completed yet
                go.GetComponent <Button>().onClick.AddListener(() => DataManager.Instance.currentDir = dirName);
                go.GetComponent <Button>().onClick.AddListener(() => StaticBehaviors.LoadScene(1));
            }
            else
            {
                go.GetComponent <Button>().onClick.AddListener(() => SpawnGallery(dirName));
            }
        }
    }
コード例 #16
0
    //Hints handler
    private void UseHint(int index)
    {
        if (StaticBehaviors.EnoughCoinsForHint(index))
        {
            switch (index)
            {
            case 0:
                StaticBehaviors.RevealOneLetter(letterFieldsList, letterList, LevelManager.rightAnswerList);
                break;

            case 1:
                StaticBehaviors.RemoveWrongLetters(letterFieldsList, letterList, LevelManager.rightAnswerList);
                break;

            case 2:
                StaticBehaviors.SolveTask(letterFieldsList, letterList, LevelManager.rightAnswerList);
                break;
            }
            HintEvent(index, null);
            hintsPopup.gameObject.SetActive(false);
        }
    }
コード例 #17
0
    void Initialize() //Levels data constructor
    {
        hintsCost = new int[6];

        try
        {
            CurrentTask temp = DataManager.Instance.GetData();
            type                = temp.gameType;
            infoTosave          = temp.savedData;
            rightAnswer         = temp.rightAnswer.ToLower();
            rightAnswerNoSpaces = rightAnswer.Replace(" ", string.Empty);
            imageText           = temp.imageText;
            completeLvlCoins    = temp.levelCost;
            int letterCount = rightAnswerNoSpaces.ToCharArray().Length;
            hintsCost[2] = DataManager.Instance.solveTaskCost;
            hintsCost[3] = DataManager.Instance.pixelateCost;
            hintsCost[4] = DataManager.Instance.plankCost;
            hintsCost[5] = DataManager.Instance.erasureCost;

            //Calculations to balance hints cost depending on the words length
            if (hintsCost[2] >= 100)
            {
                hintsCost[1] = Mathf.CeilToInt((hintsCost[2] / 1.8f) / 10) * 10;
                hintsCost[0] = Mathf.CeilToInt((hintsCost[2] * 2.5f / letterCount) / 10) * 10;
            }
            else
            {
                hintsCost[1] = Mathf.CeilToInt(hintsCost[2] / 1.8f);
                hintsCost[0] = Mathf.CeilToInt(hintsCost[2] * 2.5f / letterCount);
            }
            fullList = CreateListOfLetters(DataManager.Instance.randomLetters);
            StaticBehaviors.Shuffle(fullList);
        }
        catch (Exception)
        {
            Debug.LogError("You should start the game from 'StartMenu' scene. Or some references are broken");
        }
    }
コード例 #18
0
    private IEnumerator Initialize()
    {
        yield return(new WaitUntil(() => MusicManager.instance != null)); //Make sure that MusicManager is loaded

        directorys.gameObject.SetActive(false);

        //Set up sounds buttons color
        if (!MusicManager.instance.isMusic)
        {
            music.GetComponent <Image>().color -= new Color(0, 0, 0, 0.5f);
        }
        if (!MusicManager.instance.isSounds)
        {
            sounds.GetComponent <Image>().color -= new Color(0, 0, 0, 0.5f);
        }
        //Add OnClick methods to all buttons
        play.onClick.AddListener(PlayHandler);
        info.onClick.AddListener(() => { gameinfo.gameObject.SetActive(true); MusicManager.instance.PlaySound("blup"); });
        exit.onClick.AddListener(() => Application.Quit());
        back.onClick.AddListener(BackHandler);
        music.onClick.AddListener(() => StaticBehaviors.MusicClick(music));
        sounds.onClick.AddListener(() => StaticBehaviors.SoundsClick(sounds));

        if (DataManager.Instance.adsSettings.GDPRconsent) //Add GDPR button to the settings panel
        {
            gdpr.gameObject.SetActive(true);
            gdpr.onClick.AddListener(() => Instantiate(gdprPrefab, mainTransform));
        }

        if (DataManager.Instance.Languages.Count() > 1) //Reveal Language popup if there is more than one language
        {
            language.gameObject.SetActive(true);
            language.onClick.AddListener(() => languagePopup.gameObject.SetActive(true));
            language.onClick.AddListener(() => MusicManager.instance.PlaySound("blup"));
        }
    }
コード例 #19
0
ファイル: Welcome.cs プロジェクト: wearefury-boop/QuizGame
 private static void CheckLanguages()
 {
     EditorApplication.update -= CheckLanguages;
     StaticBehaviors.CheckAndWriteFilenames();
 }
コード例 #20
0
 public void SpendCoins(int hint, object obj) //Set coins count when hints are used
 {
     coins -= LevelManager.GetCostValues()[hint];
     saveInstance.SetCoinsData(coins);
     StaticBehaviors.SetCoinsText();
 }
コード例 #21
0
 public void ClearAll()
 {
     StaticBehaviors.ClearAll(letterFieldsList);
 }
コード例 #22
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");
    }