Example #1
0
 public void back_button_press()
 {
     hp        = null;
     remaining = null;
     setReset(false);
     //saveData();
     SceneManager.LoadScene(sceneName: "LevelScene");
 }
Example #2
0
    // Use this for initialization
    public void Start()
    {
        Debug.Log("Start!");
        FirebaseAnalytics.SetAnalyticsCollectionEnabled(true);
        Firebase.Analytics.FirebaseAnalytics.LogEvent(
            Firebase.Analytics.FirebaseAnalytics.EventLogin,
            new Firebase.Analytics.Parameter[] {
            new Firebase.Analytics.Parameter(
                Firebase.Analytics.FirebaseAnalytics.ParameterMethod, SystemInfo.deviceUniqueIdentifier),
        }
            );
        hp = GameObject.FindGameObjectWithTag("hint_button").GetComponent <hints_panel>();

        /* for button */
        //Button btn = yourButton.GetComponent<Button>();
        //Button btn = Instantiate(UnityEngine.Object)yourButton).GetComponent<Button>();
        //btn.onClick.AddListener(TaskOnClick);
        //set to false on start, may not be necessary, I just can't remember if C# will return 1 or 0 for undefined booleans
        buttonisclicked = false;
        forceFile       = new force();

        dots     = new List <Vector2> ();
        dotsPool = new List <GameObject> ();

        var i          = 0;
        var alpha      = 1.0f / maxDots;
        var startAlpha = 1.0f;

        while (i < maxDots)
        {
            var dot = Instantiate(dotPrefab) as GameObject;
            var sp  = dot.GetComponent <SpriteRenderer> ();
            var c   = sp.color;

            c.a         = startAlpha - alpha;
            startAlpha -= alpha;
            sp.color    = c;

            dot.SetActive(false);
            dotsPool.Add(dot);
            i++;
        }

        //select initial type
        SetNextType();
        //wordCreated = GameObject.FindGameObjectWithTag("wordCreated").GetComponent<Text>();
    }
Example #3
0
    void Start()
    {
        // GetComponent<AudioSource>().playOnAwake = false;
        // GetComponent<AudioSource>().clip = bubblepop;

        AnalyticsEvent.Custom("Level", new Dictionary <string, object>
        {
            { "level", level },
            { "word", actual_word }
        });



        Analytics.CustomEvent("Level", new Dictionary <string, object>
        {
            { "level", level },
            { "word", actual_word }
        });
        Firebase.Analytics.FirebaseAnalytics.LogEvent("word", "string", actual_word);

        if (gameObject.tag == "restart_Button" || gameObject.tag == "exit_button")
        {
            return;
        }
        Random.seed = System.DateTime.Now.Millisecond;
        if (letter_sort.Count == 0)
        {
            letter_sort.Add(new int[] { 1, 2, 3, 4 });
            letter_sort.Add(new int[] { 2, 1, 3, 4 });
            letter_sort.Add(new int[] { 3, 1, 2, 4 });
            letter_sort.Add(new int[] { 1, 3, 2, 4 });
            letter_sort.Add(new int[] { 2, 3, 1, 4 });
            letter_sort.Add(new int[] { 3, 2, 1, 4 });
            letter_sort.Add(new int[] { 3, 2, 4, 1 });
            letter_sort.Add(new int[] { 2, 3, 4, 1 });
            letter_sort.Add(new int[] { 4, 3, 2, 1 });
            letter_sort.Add(new int[] { 3, 4, 2, 1 });
            letter_sort.Add(new int[] { 2, 4, 3, 1 });
            letter_sort.Add(new int[] { 4, 2, 3, 1 });
            letter_sort.Add(new int[] { 4, 1, 3, 2 });
            letter_sort.Add(new int[] { 1, 4, 3, 2 });
            letter_sort.Add(new int[] { 3, 4, 1, 2 });
            letter_sort.Add(new int[] { 4, 3, 1, 2 });
            letter_sort.Add(new int[] { 1, 3, 4, 2 });
            letter_sort.Add(new int[] { 3, 1, 4, 2 });
            letter_sort.Add(new int[] { 2, 1, 4, 3 });
            letter_sort.Add(new int[] { 1, 2, 4, 3 });
            letter_sort.Add(new int[] { 4, 2, 1, 3 });
            letter_sort.Add(new int[] { 2, 4, 1, 3 });
            letter_sort.Add(new int[] { 1, 4, 2, 3 });
            letter_sort.Add(new int[] { 4, 1, 2, 3 });
        }
        GameObject.FindGameObjectWithTag("level").GetComponent <Text>().text         = "Level : " + level;
        GameObject.FindGameObjectWithTag("hint_button").GetComponent <Image>().color = Color.white;
        Debug.Log("1");
        //hp.paused = false;
        h1 = GameObject.FindGameObjectWithTag("heart1");
        h2 = GameObject.FindGameObjectWithTag("heart2");
        h3 = GameObject.FindGameObjectWithTag("heart3");
        // game object reference put using unity ui only
        //Debug.Log("2");
        if (hp == null)
        {
            hp = GameObject.FindGameObjectWithTag("hint_button").GetComponent <hints_panel>();
        }
        //gameObject.SetActive(true);


        if (remaining == null)
        {
            level      = EasyScript.temp_level;
            levelTimer = 0.0f;
            Debug.Log("21");
            Incorrect           = new List <char>();
            Correct             = new List <char>();
            CorrectandIncorrect = new List <char>();
            guessed_wordset     = new HashSet <string>();
            //List<Dictionary<string, object>> data = CSVReader.Read("data");
            string level_status = "";
            if (level >= 1 && level <= 5)
            {
                level_status = "Easy";
            }
            else if (level >= 6 && level <= 12)
            {
                level_status = "Medium";
            }
            else
            {
                level_status = "Hard";
                if (level > 21)
                {
                    level        = 1;
                    level_status = "Easy";
                }
            }

            List <Dictionary <string, object> > data = CSVReader.Read(level_status);
            var random_index_1 = Random.Range(0, data.Count);
            //Debug.Log("3");

            actual_word = data[random_index_1]["word"].ToString();
            while (guessed_wordset.Contains(actual_word.ToUpper()))
            {
                random_index_1 = Random.Range(0, data.Count);
                actual_word    = data[random_index_1]["word"].ToString();
            }
            guessed_wordset.Add(actual_word.ToUpper());
            Debug.Log(guessed_wordset);
            hint_1   = data[random_index_1]["Hint 1"].ToString();
            hint_2   = data[random_index_1]["Hint 2"].ToString();
            hint_3   = data[random_index_1]["Hint 3"].ToString();
            category = data[random_index_1]["Category"].ToString();
            category = string.Join(" ", category.Split(' ').Select(i => i.Substring(0, 1).ToUpper() + i.Substring(1).ToLower()).ToArray());;

            //Debug.Log("4");
            Text cat = GameObject.FindGameObjectWithTag("category").GetComponent <Text>();
            cat.text     = "Category : " + (category);
            word1        = actual_word.ToUpper();
            word_formed  = new string(word1.Distinct().ToArray());
            word_formed1 = word1;
            word_length  = word_formed.Length;
            word_length1 = word_formed1.Length;
            char_arr     = word_formed.ToCharArray();
            remaining    = new string(allCharacters.Except(char_arr).ToArray()).ToCharArray();
            Debug.Log("5");
            //Comment an entire block
            for (int j = 0; j < word_length + 3; j++)
            {
                if (j >= word_length)
                {
                    var random_index = Random.Range(0, remaining.Length);
                    CorrectandIncorrect.Add(remaining[random_index]);
                }
                else
                {
                    CorrectandIncorrect.Add(char_arr[j]);
                }
            }
            //Random index selected to be filled
            var random_letter_selected = Random.Range(0, word_length);
            var random_letter          = char_arr[random_letter_selected];
            //Till here
            for (int j = 0; j < word_length; j++)
            {
                if (word1[j] != random_letter)
                {
                    Correct.Add(char_arr[j]);
                }
            }
            for (int j = 0; j < remaining.Length; j++)
            {
                Incorrect.Add(remaining[j]);
            }

            Debug.Log(new string(remaining.ToArray()));


            string s           = "";
            int    totalLength = 0;
            while (totalLength != word_length1)
            {
                Debug.Log("Step 1");
                if (word1[totalLength] != random_letter)
                {
                    s += "_ ";
                }
                else
                {
                    s += random_letter + " ";
                }
                totalLength += 1;
            }
            Debug.Log("Step 2");
            wordCreated.text = s;
            // i++;
            Debug.Log(new string(Incorrect.ToArray()));
            Debug.Log(new string(Correct.ToArray()));

            //else if (i == char_arr.Length)
            // else if (i == CorrectandIncorrect.Count)

            updateLetters();
            if (hp == null)
            {
                hp = GameObject.FindGameObjectWithTag("hint_button").GetComponent <hints_panel>();
            }
            hp.OpenPanelInit("1. " + hint_1);
        }


        //Text t = gameObject.GetComponentInChildren<Text>();
        //Debug.Log(t.text);
        //if (i < char_arr.Length)
        Debug.Log(CorrectandIncorrect.Count);
        //if (i < CorrectandIncorrect.Count)
        {
            if (hp == null)
            {
                hp = GameObject.FindGameObjectWithTag("hint_button").GetComponent <hints_panel>();
            }
        }
        /* load previous save data */
        if (gameObject.tag == "Letter1") // because I want only one object to do file IO
        {
            loadData();
            //level = previousBestLevel +1;
            /* loads from previous best */
            //if(level >=21)
            {
                //    previousBestLevel = 1;
                //    level = 1;
            }
        }
        /* end */
    }
Example #4
0
    public void Reset()
    {
        updateTimer = true;
        GameObject.FindGameObjectWithTag("confetti").GetComponent <ParticleSystem>().Stop();
        Debug.Log("Stopping confetti");
        AnalyticsEvent.Custom("Level", new Dictionary <string, object>
        {
            { "level", level },
            { "word", actual_word }
        });

        Firebase.Analytics.FirebaseAnalytics.LogEvent("level", "number", level);

        if (gameover != null)
        {
            gameover.SetActive(false);
        }
        reset_canvas.SetActive(false);
        //hp = GameObject.FindGameObjectWithTag("hint_button").GetComponent<hints_panel>();
        hint_shown = 1;
        setReset(false);
        health = 3;
        GameObject.FindGameObjectWithTag("level").GetComponent <Text>().text         = "Level : " + level;
        GameObject.FindGameObjectWithTag("hint_button").GetComponent <Image>().color = Color.white;
        gameObject.SetActive(false);
        //if (bullet != null)
        //   bullet.SetActive(true);
        Incorrect           = new List <char>();
        Correct             = new List <char>();
        CorrectandIncorrect = new List <char>();
        //hp.paused = false;
        h1 = GameObject.FindGameObjectWithTag("heart1");
        h1.GetComponentInChildren <SpriteRenderer>().color = opaque;
        h2 = GameObject.FindGameObjectWithTag("heart2");
        h2.GetComponentInChildren <SpriteRenderer>().color = opaque;
        h3 = GameObject.FindGameObjectWithTag("heart3");
        h3.GetComponentInChildren <SpriteRenderer>().color = opaque;
        //h1.SetActive(true);
        //h2.SetActive(true);
        //h3.SetActive(true);
        string level_status = "";


        if (level >= 1 && level <= 5)
        {
            level_status = "Easy";
        }
        else if (level >= 6 && level <= 12)
        {
            level_status = "Medium";
        }
        else
        {
            level_status = "Hard";
            if (level > 21)
            {
                level        = 1;
                level_status = "Easy";
            }
        }

        List <Dictionary <string, object> > data = CSVReader.Read(level_status);
        var random_index_1 = Random.Range(0, data.Count);

        Debug.Log("3");

        actual_word = data[random_index_1]["word"].ToString();

        while (guessed_wordset.Contains(actual_word.ToUpper()))
        {
            random_index_1 = Random.Range(0, data.Count);
            actual_word    = data[random_index_1]["word"].ToString();
        }
        guessed_wordset.Add(actual_word.ToUpper());
        hint_1   = data[random_index_1]["Hint 1"].ToString();
        hint_2   = data[random_index_1]["Hint 2"].ToString();
        hint_3   = data[random_index_1]["Hint 3"].ToString();
        category = data[random_index_1]["Category"].ToString();
        category = string.Join(" ", category.Split(' ').Select(i => i.Substring(0, 1).ToUpper() + i.Substring(1).ToLower()).ToArray());;

        Debug.Log("4");
        Text cat = GameObject.FindGameObjectWithTag("category").GetComponent <Text>();

        cat.text     = "Category : " + (category);
        word1        = actual_word.ToUpper();
        word_formed  = new string(word1.Distinct().ToArray());
        word_formed1 = word1;
        word_length  = word_formed.Length;
        word_length1 = word_formed1.Length;
        char_arr     = word_formed.ToCharArray();
        remaining    = new string(allCharacters.Except(char_arr).ToArray()).ToCharArray();
        Debug.Log("5");
        //Comment an entire block
        for (int j = 0; j < word_length + 3; j++)
        {
            if (j >= word_length)
            {
                var random_index = Random.Range(0, remaining.Length);
                CorrectandIncorrect.Add(remaining[random_index]);
            }
            else
            {
                CorrectandIncorrect.Add(char_arr[j]);
            }
        }
        //Random index selected to be filled
        var random_letter_selected = Random.Range(0, word_length);
        var random_letter          = char_arr[random_letter_selected];

        //Till here
        for (int j = 0; j < word_length; j++)
        {
            if (char_arr[j] != random_letter)
            {
                Correct.Add(char_arr[j]);
            }
        }
        for (int j = 0; j < remaining.Length; j++)
        {
            Incorrect.Add(remaining[j]);
        }

        Debug.Log(new string(remaining.ToArray()));


        // i++;
        Debug.Log(new string(Incorrect.ToArray()));
        Debug.Log(new string(Correct.ToArray()));
        string s           = "";
        int    totalLength = 0;

        while (totalLength != word_length1)
        {
            Debug.Log("Step 1");
            if (word1[totalLength] != random_letter)
            {
                s += "_ ";
            }
            else
            {
                s += random_letter + " ";
            }
            totalLength += 1;
        }
        Debug.Log("Step 2");
        wordCreated.text = s;
        //else if (i == char_arr.Length)
        // else if (i == CorrectandIncorrect.Count)

        updateLetters();
        if (hp == null)
        {
            hp = GameObject.FindGameObjectWithTag("hint_button").GetComponent <hints_panel>();
        }

        hp.OpenPanel();
    }
Example #5
0
    void Update()
    {
        if (updateTimer)
        {
            levelTimer += Time.deltaTime;
        }
        if (extra_showing && (levelTimer - timerStart > 5))
        {
            extra_showing = false;
            GameObject.FindGameObjectWithTag("extralife").GetComponent <CanvasGroup>().alpha = 0f;
            GameObject.FindGameObjectWithTag("extrahint").GetComponent <CanvasGroup>().alpha = 0f;
        }
        //hp = gameObject.AddComponent<hints_panel>();s
        //Debug.Log(hp.getPaused());
        if (gameObject.tag == "restart_Button" || gameObject.tag == "exit_button")
        {
            return;
        }
        if (!getPaused())
        {
            Time.timeScale = 1;
            //Debug.Log(gameObject.transform.position);
            if (level > 20)
            {
                if (gameObject.tag == "Letter1")
                {
                    transform.Translate(Time.deltaTime * 0.35f * 20 * direction, 0, 0);
                }
                if (gameObject.tag == "Letter2")
                {
                    transform.Translate(Time.deltaTime * 0.25f * 20 * direction, 0, 0);
                }
                if (gameObject.tag == "Letter3")
                {
                    transform.Translate(Time.deltaTime * 0.3f * 20 * direction, 0, 0);
                }
                if (gameObject.tag == "Letter4")
                {
                    transform.Translate(Time.deltaTime * 0.2f * 20 * direction, 0, 0);
                }
                if (gameObject.tag == "Letter5")
                {
                    transform.Translate(Time.deltaTime * 0.4f * 20 * direction, 0, 0);
                }
            }
            else
            {
                if (gameObject.tag == "Letter1")
                {
                    transform.Translate(Time.deltaTime * 0.35f * level * direction, 0, 0);
                }
                if (gameObject.tag == "Letter2")
                {
                    transform.Translate(Time.deltaTime * 0.25f * level * direction, 0, 0);
                }
                if (gameObject.tag == "Letter3")
                {
                    transform.Translate(Time.deltaTime * 0.3f * level * direction, 0, 0);
                }
                if (gameObject.tag == "Letter4")
                {
                    transform.Translate(Time.deltaTime * 0.2f * level * direction, 0, 0);
                }
                if (gameObject.tag == "Letter5")
                {
                    transform.Translate(Time.deltaTime * 0.4f * level * direction, 0, 0);
                }
            }
        }
        else
        {
            Time.timeScale = 0;
            RayCastShooter bull = GameObject.FindGameObjectWithTag("ball").GetComponent <RayCastShooter>();
            //bull.gameObject.SetActive(false);
            bull.bullet.gameObject.SetActive(false);
            foreach (var d in bull.dotsPool)
            {
                d.SetActive(false);
            }
            bull.dots.Clear();
            bull.bulletProgress = 0.0f;
        }
        //Trail
        if (Application.platform == RuntimePlatform.Android)
        {
            // Check if Back was pressed this frame
            if (Input.GetKeyDown(KeyCode.Escape))
            {
                // Quit the application
                hp        = null;
                remaining = null;
                setReset(false);

                SceneManager.LoadScene(sceneName: "LevelScene");
            }
        }
        //Till here
    }