Inheritance: MonoBehaviour
Exemplo n.º 1
0
    // Update is called once per frame
    void Update()
    {
        if (GoToScene.GetSceneName() != "Menu")
        {
            if (input.text != "" && child.text.StartsWith(input.text))
            {
                string modified = tempHolder.Insert(input.text.Length, rtCloseTag);
                test2 = modified.Insert(0, rtOpenTag);
                if (test2 != "" && test2 != enemyText.text)
                {
                    enemyText.text = test2;
                }
            }
            if (input.text == "")
            {
                enemyText.text = child.text;
            }

            if (sf2 != null)
            {
                if (sf2.speed > 0)
                {
                    gameObject.GetComponent <SpriteRenderer>().flipX = false;
                }
                else
                {
                    gameObject.GetComponent <SpriteRenderer>().flipX = true;
                }
            }
            if (collided)
            {
                transform.localScale -= new Vector3(1, 1, 1) * Time.deltaTime * 10;
                if (transform.localScale.x <= 0)
                {
                    Destroy(gameObject);
                }
                WordCheck.existingWords.Remove(child.text);
                child.text = "";
            }
            if (child.text == "" || Global.killAll)
            {
                died = true;
                anim.SetInteger("State", 1);
                if (Global.health <= 0)
                {
                    Destroy(gameObject);
                }
                if (!isPlaying)
                {
                    Global.multiplier = 2;
                    audio.PlayOneShot(dead);
                    isPlaying = true;
                }
                if (anim.GetCurrentAnimatorStateInfo(0).IsName("Empty"))
                {
                    Destroy(gameObject);
                }
            }
        }
    }
Exemplo n.º 2
0
 private void OnCollisionExit2D(Collision2D collision)
 {
     if (collision.gameObject.tag == "Player")
     {
         GoToScene.ChangeScene(SceneType.none, this);
     }
 }
Exemplo n.º 3
0
 private void OnCollisionEnter2D(Collision2D collision)
 {
     if (collision.gameObject.tag == "Player")
     {
         GoToScene.ChangeScene(type, this);
     }
 }
Exemplo n.º 4
0
    private void Update()
    {
        if (finish)
        {
            text.text = finalText;
            rI.color  = blackColor;

            elapse += Time.deltaTime;
            if (elapse >= timeTransition)
            {
                elapse = 0f;
                //Finish the scene and go to next one
                if (sceneName != "")
                {
                    GoToScene goToScene = new GoToScene();
                    goToScene.ChangeScene(sceneName);
                }
            }
            else
            {
                //increment visibility
                blackColor = new Color(0f, 0f, 0f, elapse / timeTransition);
                whiteColor = new Color(1f, 1f, 1f, elapse / timeTransition);
            }
        }
    }
Exemplo n.º 5
0
    void SpawnMonsters()
    {
        if (timertospawn > 0)
        {
            timertospawn -= Time.deltaTime;
        }

        else if (timertospawn <= 0 && Global.numberOfMonsters > 0 && waveStart <= -1)
        {
            if (Global.difficultyLevel < 2)
            {
                timertospawn = Random.Range(1f, 2f);
            }

            else if (Global.difficultyLevel >= 2 && Global.difficultyLevel < 3)
            {
                timertospawn = Random.Range(1f, 2f);
            }

            else
            {
                timertospawn = Random.Range(1f, 1.3f);
            }

            if (GoToScene.GetSceneName() != "3")
            {
                int     spawner = Random.Range(0, spawnPoints.Length);
                Vector3 spawnLocation;

                spawnLocation = spawnPoints[spawner].transform.localPosition;

                GameObject myRoadInstance;
                if (monsterSpawn.Length <= 0)
                {
                    myRoadInstance =
                        Instantiate(Resources.Load(ToSpawn)) as GameObject;
                }
                else
                {
                    myRoadInstance =
                        Instantiate(Resources.Load(monsterSpawn[Random.Range(0, monsterSpawn.Length)])) as GameObject;
                }


                myRoadInstance.transform.localPosition = spawnLocation;

                if (myRoadInstance.transform.position.x > player.transform.position.x)
                {
                    myRoadInstance.GetComponent <SpriteRenderer>().flipX = true;
                }

                myRoadInstance.transform.SetParent(canvas.transform, false);

                Global.wordLimit--;
            }
        }
    }
Exemplo n.º 6
0
 public void BackToMenu()
 {
     GoToScene.GoTo("Menu");
     gameObject.SetActive(false);
     Global.wordLimit  = Global.wordLimitSet;
     Global.health     = 100;
     Global.bossHealth = 300;
     Time.timeScale    = 1;
 }
Exemplo n.º 7
0
 public void RestartGame()
 {
     GoToScene.GoTo(GoToScene.GetSceneName());
     Global.health     = 100;
     Global.wordLimit  = Global.wordLimitSet;
     Global.bossHealth = 300;
     Global.score     -= 100;
     Time.timeScale    = 1;
 }
Exemplo n.º 8
0
    private void Start()
    {
        WebSocketListener.Instance().Subscribe(this);
        LobbyInfoController lobbyInfo = LobbyInfoController.Instance();

        updatePlayers(lobbyInfo.msg.players.ToArray(), lobbyInfo.msg.readyStatus);
        WebSocketListener.Instance().StartListening(lobbyInfo.msg.id, lobbyInfo.playerName, () => {});
        Goto = FindObjectOfType <GoToScene>();
    }
Exemplo n.º 9
0
    void Start()
    {
        goToScene  = GameObject.Find("GoToScene").GetComponent(typeof(GoToScene)) as GoToScene;
        cronometro = GameObject.Find("Cronometro").GetComponent(typeof(Cronometro)) as Cronometro;

        textLevel.text = "Nivel " + GlobalVariables.nivelActual;
        walk           = GameObject.Find("Player").GetComponent <Autowalk>();

        //cuando se ponga en boton borrar
        GlobalVariables.GameIsPause = true;
        walk.enabled = false;
        valoresPanel();
    }
Exemplo n.º 10
0
    void CheckWord()
    {
        foreach (GameObject o in objects)
        {
            if (o.GetComponentInChildren <Text>().text == input.text && o.GetComponentInChildren <Text>().text != "")
            {
                if (!trigger)
                {
                    wordsCleared--;
                    Global.numberOfMonsters--;
                    trigger = true;
                    if (GoToScene.GetSceneName() != "3")
                    {
                        existingWords.Remove(o.GetComponentInChildren <Text>().text);
                    }

                    multiplerTimer = 2;

                    if (multiplerTimer > 0)
                    {
                        Global.enemyKilledWithinMultipler++;
                        Global.score += 10 * Global.enemyKilledWithinMultipler;
                    }
                    else
                    {
                        Global.score += 10;
                    }
                }
                if (trigger)
                {
                    timer -= Time.deltaTime;
                    o.GetComponentInChildren <Text>().color = Color.red;

                    if (timer <= 0.1f)
                    {
                        o.GetComponentInChildren <Text>().text = "";
                        trigger    = false;
                        input.text = "";
                        timer      = 0.2f;
                    }
                }
            }
            else
            {
                o.GetComponentInChildren <Text>().color = Color.white;
            }
        }
    }
Exemplo n.º 11
0
    void Start()
    {
        textLevel.text = "Nivel  " + GlobalVariables.nivelActual + " superado";
        goToScene      = GameObject.Find("GoToScene").GetComponent(typeof(GoToScene)) as GoToScene;
        CalcularTiempo();
        DibujarGemas();

        if (GlobalVariables.nivelActual == 6)
        {
            btns.SetActive(false);
            btnfin.SetActive(true);
        }
        CalcularValoracion();
        DesbloquearNivel();
        ClearLevel();
    }
Exemplo n.º 12
0
    // Update is called once per frame
    void Update()
    {
        if (anim.GetCurrentAnimatorStateInfo(0).IsName("Empty"))
        {
            if (GoToScene.GetSceneName() == "1")
            {
                Global.difficultyLevel += 0.1f;
                GoToScene.GoTo("2");
            }
            if (GoToScene.GetSceneName() == "2")
            {
                Global.difficultyLevel += 0.1f;
                GoToScene.GoTo("3");
            }

            Destroy(gameObject);
        }
    }
Exemplo n.º 13
0
    void CheckBossWord()
    {
        if (bossText.GetComponentInChildren <Text>().text == input.text && bossText.GetComponentInChildren <Text>().text != "")
        {
            if (!trigger)
            {
                trigger = true;
                Global.numberOfMonsters--;
            }
            if (trigger)
            {
                timer -= Time.fixedDeltaTime;
                bossText.GetComponentInChildren <Text>().color = Color.blue;

                if (timer <= 0)
                {
                    bossText.GetComponentInChildren <Text>().text = "";

                    if (GoToScene.GetSceneName() == "1")
                    {
                        Global.bossHealth -= 10;
                        Global.health     += 5;
                    }
                    else
                    {
                        Global.bossHealth -= 10;
                        Global.health     += 3;
                    }
                    trigger    = false;
                    input.text = "";
                    timer      = 0.1f;
                    Instantiate(Resources.Load("Gain health"), new Vector3(bossText.transform.localPosition.x, 0, -56), Quaternion.identity);
                    audio.PlayOneShot(bossHurt);
                }
            }
        }
        else
        {
            bossText.GetComponentInChildren <Text>().color = Color.white;
        }
    }
Exemplo n.º 14
0
    void Start()
    {
        if (GoToScene.GetSceneName() == "1")
        {
            Global.health = 100;
            Global.score  = 0;
        }
        Global.killAll = false;
        blood          = GameObject.FindGameObjectWithTag("Blood").GetComponent <Canvas>();
        defeatCanvas.SetActive(false);
        defeatC = defeatCanvas.GetComponent <Canvas>();
        if (GoToScene.GetSceneName() == "3")
        {
            wonCanvas.SetActive(false);
        }
        if (wonCanvas != null)
        {
            wonC = wonCanvas.GetComponent <Canvas>();
            wonC.GetComponent <CanvasGroup>().alpha = 0;
        }

        defeatC.GetComponent <CanvasGroup>().alpha = 0;
        blood.enabled           = false;
        timertospawn            = 1f;
        trigger                 = false;
        timer                   = 0f;
        waveStart               = 3.5f;
        cooldownText            = cooldownText.GetComponent <Text>();
        previousTimer           = -1;
        audio                   = GameObject.FindGameObjectWithTag("SFX").GetComponent <AudioSource>();
        bgm                     = GameObject.FindGameObjectWithTag("Audio").GetComponent <AudioSource>();
        player                  = GameObject.FindGameObjectWithTag("Player");
        playCountdown2          = false;
        Global.wordLimit        = PlayerPrefs.GetInt("WordLimit");
        wordsCleared            = Global.wordLimit;
        Global.numberOfMonsters = Global.wordLimit;
        cleared.enabled         = false;
        spawnPoints             = GameObject.FindGameObjectsWithTag("SpawnPlatform");
    }
Exemplo n.º 15
0
    string rtCloseTag = "</color>"; //Rich text closing tag

    // Use this for initialization
    void Start()
    {
        died      = false;
        rtOpenTag = "<color=" + clearTextColor + ">";
        cam       = GameObject.FindGameObjectWithTag("MainCamera").GetComponent <Camera>();
        player    = GameObject.FindGameObjectWithTag("Player");
        anim      = gameObject.GetComponent <Animator>();
        audio     = GameObject.FindGameObjectWithTag("SFX").GetComponent <AudioSource>();
        if (GoToScene.GetSceneName() != "Menu")
        {
            input = GameObject.FindGameObjectWithTag("Input").GetComponent <InputField>();
        }
        speed     = Random.Range(13, 20);
        child     = transform.GetChild(0).GetComponentInChildren <Text>();
        enemyText = transform.GetChild(0).GetChild(0).GetComponent <Text>();

        if (ListOFWords.words.Count > 0)
        {
            int    random     = Random.Range(0, ListOFWords.words.Count);
            string randomText = ListOFWords.words[random];
            if (child.text != randomText)
            {
                child.text     = randomText;
                enemyText.text = randomText;
            }
            ListOFWords.words.RemoveAt(random);
            WordCheck.existingWords.Add(child.text);
        }

        child.color = Color.white;
        if (enemyText.text == "")
        {
            enemyText.text = child.text;
        }
        isPlaying  = false;
        collided   = false;
        tempHolder = enemyText.text;
    }
Exemplo n.º 16
0
 void Start()
 {
     iclickable = new GoToScene(sceneName);
     Initialize();
 }
Exemplo n.º 17
0
 void Start()
 {
     goToScene  = GameObject.Find("GoToScene").GetComponent(typeof(GoToScene)) as GoToScene;
     cronometro = GameObject.Find("Cronometro").GetComponent(typeof(Cronometro)) as Cronometro;
 }
Exemplo n.º 18
0
 private void Start()
 {
     Api  = FindObjectOfType <RestApi>();
     Goto = FindObjectOfType <GoToScene>();
 }
Exemplo n.º 19
0
    // Update is called once per frame
    void Update()
    {
        Global.health = Mathf.Clamp(Global.health, 0, 100);
        if (Input.GetKeyUp(KeyCode.Delete) || Input.GetKeyUp(KeyCode.Tab))
        {
            input.text = "";
        }

        if (Time.timeScale != 0)
        {
            input.ActivateInputField();
        }
        else
        {
            input.DeactivateInputField();
        }

        if (Global.health <= 0)
        {
            Global.health = 0;
        }

        if (Global.health <= 0 && !defeatCanvas.active)
        {
            defeatCanvas.SetActive(true);
            if (defeat != null)
            {
                audio.PlayOneShot(defeat);
            }
        }

        if (Global.bossHealth <= 0 && !wonCanvas.active)
        {
            wonCanvas.SetActive(true);
            if (victory != null)
            {
                audio.PlayOneShot(victory);
            }
            Time.timeScale = 0;
        }
        playerHealth.text = "Health: " + Global.health.ToString();

        if (Global.numberOfMonsters >= 0)
        {
            wordsLeft.text = Global.numberOfMonsters.ToString() + " Words Left";
        }

        if (GoToScene.GetSceneName() == "3" && Global.bossHealth <= 0)
        {
            cleared.enabled = true;
            cleared.text    = " ";
            if (cleared.GetComponent <Text>().fontSize < 40)
            {
                cleared.GetComponent <Text>().fontSize += 1;
            }
            else
            {
                if (wonC.GetComponent <CanvasGroup>().alpha <= 1)
                {
                    wonC.GetComponent <CanvasGroup>().alpha += 0.02f;
                }
            }
        }

        if (Global.health <= 0)
        {
            cleared.enabled = true;
            cleared.text    = "Defeated!";

            if (cleared.GetComponent <Text>().fontSize < 40)
            {
                cleared.GetComponent <Text>().fontSize += 1;
            }
            else
            {
                if (defeatC.GetComponent <CanvasGroup>().alpha <= 1)
                {
                    defeatC.GetComponent <CanvasGroup>().alpha += 0.02f;
                }
                Time.timeScale = 0;
            }
        }
        if (wordsCleared <= 0 && GoToScene.GetSceneName() != "3")
        {
            ChangeWave();
        }

        ShowBlood();
        SpawnMonsters();

        Global.timer += Time.deltaTime;

        if (GoToScene.GetSceneName() == "1")
        {
            StartCountdown();
        }

        else if (waveStart != -1)
        {
            waveStart = -1;
        }

        objects = GameObject.FindGameObjectsWithTag("Monster");

        if (GoToScene.GetSceneName() == "3")
        {
            bossText = GameObject.FindGameObjectWithTag("Boss");
        }

        myText = input.text;

        if (GoToScene.GetSceneName() != "3")
        {
            AutoCompleteHint();
        }

        scoreText.text = "Score: " + Global.score.ToString();
        if (wonText != null)
        {
            wonText.text = "You defeated the boss!" + '\n' + "You score was " + Global.score.ToString();
        }

        posY += Time.deltaTime * 10;
        ComboMultiplier();
        CheckWord();

        if (GoToScene.GetSceneName() == "3")
        {
            CheckBossWord();
        }
    }
Exemplo n.º 20
0
    void SetWords()
    {
        Regex r = new Regex("^[a-zA-Z0-9]*$");

        if (loadedWords.Count >= 1)
        {
            lowestWordCount = loadedWords[0].Length;
        }
        foreach (string word in loadedWords)
        {
            int           n  = word.Length;
            StringBuilder sb = new StringBuilder(word);

            //Easy
            if (Global.difficultyLevel < 2)
            {
                if (GoToScene.GetSceneName() == "1")
                {
                    if (n >= 1 && n <= 2)
                    {
                        if (!Global.allowUpperCase)
                        {
                            if (word == word.ToLower())
                            {
                                words.Add(word);
                            }
                        }
                        else
                        {
                            words.Add(word);
                            for (int i = 0; i < n; i++)
                            {
                                int random = Random.Range(0, 100);
                                if (random < 20)
                                {
                                    sb[i] = char.ToUpper(word[i]);
                                }
                            }
                            words.Add(sb.ToString());
                        }
                    }
                }

                if (GoToScene.GetSceneName() == "2")
                {
                    if (n >= 2 && n <= 5)
                    {
                        if (!Global.allowUpperCase)
                        {
                            if (word == word.ToLower())
                            {
                                words.Add(word);
                            }
                        }
                        else
                        {
                            for (int i = 0; i < n; i++)
                            {
                                int random = Random.Range(0, 100);
                                if (random < 20)
                                {
                                    sb[i] = char.ToUpper(word[i]);
                                }
                            }
                            words.Add(sb.ToString());
                        }
                    }
                }

                if (GoToScene.GetSceneName() == "3")
                {
                    if (n >= 6 && n <= 8)
                    {
                        bossWords.Add(word);
                    }
                    if (n >= 5 && n <= 7)
                    {
                        if (!Global.allowUpperCase)
                        {
                            words.Add(word);
                        }
                        else if (Global.allowUpperCase)
                        {
                            words.Add(word);
                            {
                                for (int i = 0; i < n; i++)
                                {
                                    int random = Random.Range(0, 100);
                                    if (random < 20)
                                    {
                                        sb[i] = char.ToUpper(word[i]);
                                    }
                                }
                                words.Add(sb.ToString());
                            }
                        }
                    }
                }
            }
            //Normal
            if (Global.difficultyLevel >= 2 && Global.difficultyLevel < 3)
            {
                if (GoToScene.GetSceneName() == "1")
                {
                    if (n >= 4 && n <= 6)
                    {
                        if (!Global.allowUpperCase)
                        {
                            words.Add(word);
                        }
                        else
                        {
                            words.Add(word);
                            {
                                for (int i = 0; i < n; i++)
                                {
                                    int random = Random.Range(0, 100);
                                    if (random < 40)
                                    {
                                        sb[i] = char.ToUpper(word[i]);
                                    }
                                }
                                words.Add(sb.ToString());
                            }
                        }
                    }
                }
                if (GoToScene.GetSceneName() == "2")
                {
                    if (n >= 6 && n <= 8)
                    {
                        if (!Global.allowUpperCase)
                        {
                            words.Add(word);
                        }
                        else
                        {
                            words.Add(word);
                            {
                                for (int i = 0; i < n; i++)
                                {
                                    int random = Random.Range(0, 100);
                                    if (random < 40)
                                    {
                                        sb[i] = char.ToUpper(word[i]);
                                    }
                                }
                                words.Add(sb.ToString());
                            }
                        }
                    }
                }
                if (GoToScene.GetSceneName() == "3")
                {
                    if (n >= 6 && n <= 8)
                    {
                        if (!Global.allowUpperCase)
                        {
                            words.Add(word);
                        }
                        else
                        {
                            words.Add(word);
                            {
                                for (int i = 0; i < n; i++)
                                {
                                    int random = Random.Range(0, 100);
                                    if (random < 40)
                                    {
                                        sb[i] = char.ToUpper(word[i]);
                                    }
                                }
                                words.Add(sb.ToString());
                            }
                        }
                        if (n >= 4)
                        {
                            bossWords.Add(word);
                        }
                    }
                }
            }

            //Hard
            if (Global.difficultyLevel >= 3)
            {
                if (GoToScene.GetSceneName() == "1")
                {
                    if (n >= 5 && n <= 7)
                    {
                        if (!Global.allowUpperCase)
                        {
                            if (word == word.ToLower())
                            {
                                words.Add(word);
                            }
                        }
                        else
                        {
                            words.Add(word);
                            {
                                for (int i = 0; i < n; i++)
                                {
                                    int random = Random.Range(0, 100);
                                    if (random < 70)
                                    {
                                        sb[i] = char.ToUpper(word[i]);
                                    }
                                }
                                words.Add(sb.ToString());
                            }
                        }
                    }
                }

                if (GoToScene.GetSceneName() == "2")
                {
                    if (n >= 6 && n <= 9)
                    {
                        if (!Global.allowUpperCase)
                        {
                            if (word == word.ToLower())
                            {
                                words.Add(word);
                            }
                        }
                        else
                        {
                            words.Add(word);
                            {
                                for (int i = 0; i < n; i++)
                                {
                                    int random = Random.Range(0, 100);
                                    if (random < 70)
                                    {
                                        sb[i] = char.ToUpper(word[i]);
                                    }
                                }
                                words.Add(sb.ToString());
                            }
                        }
                    }
                }
                if (GoToScene.GetSceneName() == "3")
                {
                    if (n >= 6)
                    {
                        if (!Global.allowUpperCase)
                        {
                            if (word == word.ToLower())
                            {
                                words.Add(word);
                            }
                        }
                        else
                        {
                            words.Add(word);
                            {
                                for (int i = 0; i < n; i++)
                                {
                                    int random = Random.Range(0, 100);
                                    if (random < 70)
                                    {
                                        sb[i] = char.ToUpper(word[i]);
                                    }
                                }
                                words.Add(sb.ToString());
                            }
                        }

                        if (n >= 6)
                        {
                            bossWords.Add(word);
                        }
                    }
                }
            }
        }
    }