private void EvaluateMeasurement(InputField input)
    {
        float approximatedBugLength = float.Parse(input.text);
        float actualBugLength       = currentBugScript.lengthInMM;

        measurementDistance += Mathf.Abs(actualBugLength - approximatedBugLength);
        float minBound   = 0;
        float maxBound   = actualBugLength * 2;
        int   scoreValue = 0;

        if (approximatedBugLength >= maxBound)
        {
            //Do nothing
        }
        else if (approximatedBugLength >= actualBugLength)
        {
            float distance        = maxBound - approximatedBugLength;
            float accuracyPercent = distance / actualBugLength;
            scoreValue = (int)Mathf.Round(accuracyPercent * (float)currentBugScript.points);
        }
        else if (approximatedBugLength > minBound)
        {
            float distance        = approximatedBugLength;
            float accuracyPercent = distance / actualBugLength;
            scoreValue = (int)Mathf.Round(accuracyPercent * (float)currentBugScript.points);
        }

        /*StartCoroutine(Utilities.PopupMessage("Actual size: " + actualBugLength + "mm" + "\n" +
         *                                    "Your measurement: " + approximatedBugLength + "mm" + "\n" +
         *                                  "Points awarded: " + scoreValue, 3));*/
        measurementGiven = true;
        ScoreScript.AddScore(scoreValue);
        input.text = "Length";
        input.DeactivateInputField();
    }
示例#2
0
    private IEnumerator ClickOnTile(Vector2Int position, float wait)
    {
        yield return(new WaitForSeconds(wait));

        map.ClickOnTile(position.x, position.y);
        score.AddScore(10);
    }
示例#3
0
 public override void OnEated()
 {
     ScoreScript.DotsEated++;
     txt.text = "Dots Eated: " + ScoreScript.DotsEated;
     ScoreScript.AddScore(10);
     base.OnEated();
 }
    //Checks if user correctly identified the highlighted bug. Displays the result as a text popup
    public void BugSelectionUI(string bugName)
    {
        if (selectedBug != null && currentBugScript != null)
        {
            if (selectedBug == bugName)
            {
                bugsCorrectlyIdentified++;
                ScoreScript.AddScore(currentBugScript.points);
                currentBugScript.SetCorrectColor();
                StartCoroutine(Utilities.PopupMessage("Correct!", 2));
                HandleLengthUI();
            }
            else if (bugName == "Other")
            {
                bugButtons.SetActive(false);
                bugSelectionText.SetActive(false);
                otherUI.SetActive(true);

                InputField other = otherUI.GetComponentInChildren <InputField>();

                otherUI.GetComponentInChildren <Button>().onClick.AddListener(() => OtherSubmit(other));
            }
            else
            {
                currentBugScript.SetIncorrectColor();
                StartCoroutine(Utilities.PopupMessage("Incorrect. The right answer was " + selectedBug, 3));
                HandleLengthUI();
            }
        }

        bugHasBeenCategorized = true;
        bugButtons.SetActive(false);
        bugSelectionText.SetActive(false);
    }
示例#5
0
 public override void OnEated()
 {
     //Tornar os fantasmas azuis
     FindObjectOfType <SceneScript>().SetGhostMode(Mode.Fright);
     ScoreScript.AddScore(50);
     base.OnEated();
 }
示例#6
0
    private void OnDestroy()
    {
        Transform stain = Instantiate(stainPrefab, gameObject.transform.position, Quaternion.identity);

        switch (owner)
        {
        case 2:
            stain.GetComponent <SpriteRenderer>().color = new Color(0.35f, 0.73f, 0.37f, 1.0f);
            break;

        case 3:
            stain.GetComponent <SpriteRenderer>().color = new Color(0.73f, 0.4f, 0.35f, 1.0f);
            break;

        case 4:
            stain.GetComponent <SpriteRenderer>().color = new Color(0.73f, 0.6f, 0.2f, 1.0f);
            break;
        }
        stain.GetComponent <VacuumScript>().setOwner(owner);

        scoreScript.AddScore(owner);
        scoreScript.ReduceScore(1);

        //scoreScript.printScores();
    }
示例#7
0
 void OnCollisionEnter(Collision collision)
 {
     if (collision.gameObject.tag == "Player")
     {
         ScoreScript.AddScore();
         Destroy(gameObject);
     }
 }
示例#8
0
 private void DestroyBlock()
 {
     winScript.DecreaseBlockNumber();
     _scoreScript.AddScore(scoreAmount);
     AudioSource.PlayClipAtPoint(destroyAudio, transform.position);
     DeathParticles();
     Destroy(gameObject);
 }
示例#9
0
 private static void LoseGame()
 {
     PanelManager.b_PlayerLost = true;
     ScoreScript.AddScore(InGamePanel.m_Score);
     SceneManager.LoadScene("MainMenu");
     InGamePanel.m_Money = 0;
     FlyManager.s_Level  = 1;
 }
示例#10
0
 void Update()
 {
     if (zombie <= 0)
     {
         SoundManager.instance.PlaySoundFX(dead[Random.Range(0, shootClips.Length)]);
         ScoreScript.AddScore(lastPlayerHit, originalHealth);
         Destroy(gameObject);
     }
     print(lastPlayerHit);
 }
示例#11
0
 public void OnTriggerEnter2D(Collider2D other)
 {
     if (other.tag == "Player")
     {
         //use reference
         score.AddScore(add);
         health.curHealth = health.curHealth + 2;
         Object.Destroy(gameObject);
     }
 }
示例#12
0
    /// <summary>
    /// This function checks to see if the number of chosen ingredients is equal to the number of total ingredients in the recipe
    /// </summary>
    /// <returns></returns>
    public bool CheckRecipeCompletion()
    {
        bool enoughIngredients = false;

        if (chosenIngredients.Count == generatedRecipe.Count)
        {
            enoughIngredients = true;
        }

        if (enoughIngredients)
        {
            // Calculate this Recipe's score and add it to our final score
            SS.AddScore(generatedRecipe, chosenIngredients, generatedRecipeName);
        }

        GenerateRecipeName();

        return(enoughIngredients);
    }
示例#13
0
 public override void Interact()
 {
     if (_inventory.Contains(Inventory.Items.Paper))
     {
         int nb = _inventory.GetAllItemInstances(Inventory.Items.Paper);
         MakeSound(binSound);
         _score.AddScore(-10);
         _particles.Trigger();
         Debug.Log("Throwed " + nb + " papers to bin.");
     }
 }
示例#14
0
 public void OnTriggerEnter2D(Collider2D other)
 {
     if (other.tag == "Player")
     {
         //use reference
         score.AddScore(add);
         health.curHealth = (health.curHealth - 22);
         camera.ShakeCamera(0.1f, 1);
         Object.Destroy(gameObject);
     }
 }
示例#15
0
 private void OnTriggerEnter2D(Collider2D other)
 {
     if (other.GetComponent <PlayerControl>() == true)
     {
         if (other.GetComponent <PlayerControl>().playerNumber == 1)
         {
             scoreScript.ReduceScore(owner);
             scoreScript.AddScore(1);
             gameObject.SetActive(false);
         }
     }
 }
示例#16
0
 private void Update()
 {
     if (_state)
     {
         _timer -= Time.deltaTime;
         if (_timer < 0)
         {
             _timer = _initialTimer;
             _score.AddScore(1);
         }
     }
 }
示例#17
0
 // Update is called once per frame
 void Update()
 {
     if (!_dayLight.IsDay())
     {
         _malusTimer -= Time.deltaTime;
         if (_malusTimer < 0)
         {
             _malusTimer = _malusTimerInitializer;
             _score.AddScore(10);
         }
     }
 }
示例#18
0
    //Update is called once per frame
    void Update()
    {
        if (Time.deltaTime > timeCounter)
        {
            InitiateLevel.IntroLevel(RandomLevelScript.NextLevel());
            score.AddScore(10);
        }

        if (Input.anyKeyDown)
        {
            Application.LoadLevel(1);
        }
    }
 void OnTriggerEnter2D(Collider2D other)
 {
     if (other.tag == "PlayerBullet")
     {
         hp--;
     }
     if (hp <= 0)
     {
         Destroy(this.gameObject);
         scoreBoard = GameObject.Find("Score").GetComponent <ScoreScript>();
         scoreBoard.AddScore();
     }
 }
示例#20
0
    private void OnTriggerEnter2D(Collider2D col)
    {
        if (col.tag == "Player" && !ballHasHit)
        {
            for (int i = 0; i < renderersInChildren.Length; i++)
            {
                renderersInChildren[i].sprite = newSprite[i];
            }

            audioSource.Play();
            images.RemoveImage();
            scoreScript.AddScore(1);
            ballHasHit = true;
        }
    }
示例#21
0
    void OnTriggerEnter2D(Collider2D HitObject)                                                         // This function will be called when the object collides with other objests.
    {
        if (HitObject.tag == gameObject.tag)
        {
            SS.AddScore();                                                                                                      // Score is increased if collected in correct box.
            Destroy(gameObject);
        }
        else if (HitObject.tag != "ObjectSpawner")
        {
            Instantiate(Blast, transform.position, Quaternion.identity);                // Game over if collected in wrong box.
            gameObject.GetComponent <Renderer>().enabled = false;

            SceneManager.LoadScene(3);                                                                          // Game over if a reward video is already seen.
            Destroy(gameObject);
        }
    }
示例#22
0
    private void EvaluateMeasurement(InputField input)
    {
        GameObject[] rulers = GameObject.FindGameObjectsWithTag("Ruler");
        foreach (GameObject ruler in rulers)
        {
            GameObject.Destroy(ruler);
        }

        float approximatedBugLength = float.Parse(input.text);
        float actualBugLength       = Mathf.Round(currentBugScript.lengthInMM);
        float measurementError      = Mathf.Abs(Mathf.Round(approximatedBugLength - actualBugLength));

        measurementDistance += Mathf.Abs(actualBugLength - approximatedBugLength);
        measurementDistance += measurementError;

        float minBound   = 0;
        float maxBound   = actualBugLength * 2;
        int   scoreValue = 0;

        if (approximatedBugLength >= maxBound)
        {
            //Do nothing
        }
        else if (approximatedBugLength >= actualBugLength)
        {
            float distance        = maxBound - approximatedBugLength;
            float accuracyPercent = distance / actualBugLength;
            scoreValue = (int)Mathf.Round(accuracyPercent * (float)currentBugScript.points);
        }
        else if (approximatedBugLength > minBound)
        {
            float distance        = approximatedBugLength;
            float accuracyPercent = distance / actualBugLength;
            scoreValue = (int)Mathf.Round(accuracyPercent * (float)currentBugScript.points);
        }

        StartCoroutine(Utilities.PopupMessage("Actual size: " + actualBugLength + "mm" + "\n" +
                                              "Your measurement: " + approximatedBugLength + "mm" + "\n" +
                                              "Points awarded: " + scoreValue, 3));
        measurementGiven = true;

        input.text = "Length";
        input.DeactivateInputField();
        measurementInput = null;
        ScoreScript.AddScore(scoreValue);
    }
示例#23
0
    private void OnTriggerEnter2D(Collider2D target)
    {
        if (target.tag == "Bullet")
        {
            scoreScript.AddScore(scoreValue);

            canMove = false;

            if (canShoot)
            {
                canShoot = false;
                CancelInvoke("StartShooting");
            }

            Invoke("TurnOffGameObject", 0f);
        }
    }
示例#24
0
    IEnumerator DeathAnimation()
    {
        yield return(new WaitForSeconds(0.5f));

        if (player)
        {
            Collider2D[] cols = Physics2D.OverlapCircleAll(player.transform.position, 20);
            int          len  = cols.Length;
            for (int i = 0; i < len; i++)
            {
                if (cols[i].gameObject.tag == "Enemy")
                {
                    scorescript.AddScore(50);
                    cols[i].gameObject.GetComponent <EnemyBehavior>().Kill();
                }
            }
        }
    }
示例#25
0
    void Die()
    {
        // Debuggen
        Debug.Log("Enemy died!");

        // Update score
        scoreUI.AddScore();

        // Spawn een nieuwe enemy
        enemySpawner.newEnemy();

        // uitzetten
        GetComponent <Collider2D>().enabled = false;
        Destroy(this.gameObject);
        Debug.Log(GameObject.Find("Enemy(Clone)"));
        Destroy(GameObject.Find("Enemy(Clone)"));
        this.enabled = false;
    }
 void OtherSubmit(InputField other)
 {
     lengthUI.SetActive(false);
     if (other.text == selectedBug)
     {
         bugsCorrectlyIdentified++;
         ScoreScript.AddScore(currentBugScript.points);
         StartCoroutine(Utilities.PopupMessage("Correct!", 2));
         otherUI.SetActive(false);
         currentBugScript.SetCorrectColor();
     }
     else
     {
         StartCoroutine(Utilities.PopupMessage("Incorrect. The right answer was " + selectedBug, 3));
         otherUI.SetActive(false);
         currentBugScript.SetIncorrectColor();
     }
     HandleLengthUI();
 }
示例#27
0
    void OnTriggerEnter2D(Collider2D other)
    {
        if (other.tag == "ground")
        {
            inAir = false;
        }


        if (inAir && other.tag == "Finish")
        {
            score.AddScore(10);
            InitiateLevel.IntroLevel(RandomLevelScript.NextLevel());
            Debug.Log("win");
        }
        else if (other.tag == "Finish")
        {
            Application.LoadLevel(1);
            Debug.Log("lose");
        }
    }
示例#28
0
    void OnCollisionEnter2D(Collision2D col)
    {
        if (col.gameObject.tag == "Bullet")
        {
            gameObject.GetComponent <SpriteRenderer>().color = Color.red;
            Invoke("ResetColor", 0.3f);

            health -= 50;
            if (health <= 0)
            {
                GameObject  SK    = GameObject.Find("ScoreKeeper");
                ScoreScript score = SK.GetComponent <ScoreScript>();
                score.AddScore(value);
                Destroy(gameObject);
            }
        }

        if (col.gameObject.tag == "Wall")
        {
            if (increasing == true)
            {
                increasing = false;
            }
            else
            {
                increasing = true;
            }
            float y = 0;
            while (y < 2f)
            {
                myTransform.position += new Vector3(0, (float)-.01f, 0);
                y += .01f;
            }
        }

        if (col.gameObject.tag == "Player")
        {
            Destroy(gameObject);
        }
    }
示例#29
0
    // Destroys objects that collide with it
    void OnTriggerEnter2D(Collider2D collision)
    {
        int GemIndex;

        Debug.Log("Destroyed collided with " + collision.gameObject);

        //Makes adding future gems to the system much easier.
        string GemType = collision.gameObject.GetComponent <SpriteRenderer>().sprite.name;

        switch (GemType)
        {
        case "Purple Heart Gem Plain":
            GemIndex = 1;
            break;

        case "Orange Oval Gem Plain":
            GemIndex = 3;
            break;

        //Best Gem.
        case "Red Circle Gem Plain":
            GemIndex = 5;
            break;

        case "LightBlue Heart Gem Plain":
            GemIndex = 4;
            break;

        case "Green Teardrop Gem Plain":
            GemIndex = 2;
            break;

        //Cheapest Gem
        case "Blue Square Gem Plain":
            GemIndex = 0;
            break;

        default:
            GemIndex = 0;
            break;
        }


        if (this.tag == leftTag)
        {
            //If its false add score, if its true subtract.
            if (!GemSide[GemIndex])
            {
                ScoreScript.AddScore((GemIndex * 50) + 50);
                //Added the switch statement to account for all gem possiblities, tried and failed to move it into Scorescript.
                switch (GemIndex)
                {
                case 0:
                    SoundManager.PlaySound("plusPoints");
                    Instantiate(plus50, new Vector3(x, y), Quaternion.identity);
                    break;

                case 1:
                    SoundManager.PlaySound("plusPoints");
                    Instantiate(plus100, new Vector3(x, y), Quaternion.identity);
                    break;

                case 2:
                    SoundManager.PlaySound("plusPoints");
                    Instantiate(plus150, new Vector3(x, y), Quaternion.identity);
                    break;

                case 3:
                    SoundManager.PlaySound("plusPoints");
                    Instantiate(plus200, new Vector3(x, y), Quaternion.identity);
                    break;

                case 4:
                    SoundManager.PlaySound("plusPoints");
                    Instantiate(plus250, new Vector3(x, y), Quaternion.identity);
                    break;

                case 5:
                    SoundManager.PlaySound("plusPoints");
                    Instantiate(plus300, new Vector3(x, y), Quaternion.identity);
                    break;

                default:
                    SoundManager.PlaySound("plusPoints");
                    Instantiate(plus50, new Vector3(x, y), Quaternion.identity);
                    break;
                }
            }
            else
            {
                ScoreScript.SubtractScore(2 * ((GemIndex * 50) + 50));
                //Added in text pop-ups to subtract/addscore functions.
                switch (GemIndex)
                {
                case 0:
                    SoundManager.PlaySound("losePoints");
                    Instantiate(minus100, new Vector3(x, y), Quaternion.identity);
                    break;

                case 1:
                    SoundManager.PlaySound("losePoints");
                    Instantiate(minus200, new Vector3(x, y), Quaternion.identity);
                    break;

                case 2:
                    SoundManager.PlaySound("losePoints");
                    Instantiate(minus300, new Vector3(x, y), Quaternion.identity);
                    break;

                case 3:
                    SoundManager.PlaySound("losePoints");
                    Instantiate(minus400, new Vector3(x, y), Quaternion.identity);
                    break;

                case 4:
                    SoundManager.PlaySound("losePoints");
                    Instantiate(minus500, new Vector3(x, y), Quaternion.identity);
                    break;

                case 5:
                    SoundManager.PlaySound("losePoints");
                    Instantiate(minus600, new Vector3(x, y), Quaternion.identity);
                    break;

                default:
                    SoundManager.PlaySound("losePoints");
                    Instantiate(minus100, new Vector3(x, y), Quaternion.identity);
                    break;
                }
            }
        }
        else if (this.tag == rightTag)
        {
            if (GemSide[GemIndex])
            {
                ScoreScript.AddScore((GemIndex * 50) + 50);
                switch (GemIndex)
                {
                case 0:
                    SoundManager.PlaySound("plusPoints");
                    Instantiate(plus50, new Vector3(x, y), Quaternion.identity);
                    break;

                case 1:
                    SoundManager.PlaySound("plusPoints");
                    Instantiate(plus100, new Vector3(x, y), Quaternion.identity);
                    break;

                case 2:
                    SoundManager.PlaySound("plusPoints");
                    Instantiate(plus150, new Vector3(x, y), Quaternion.identity);
                    break;

                case 3:
                    SoundManager.PlaySound("plusPoints");
                    Instantiate(plus200, new Vector3(x, y), Quaternion.identity);
                    break;

                case 4:
                    SoundManager.PlaySound("plusPoints");
                    Instantiate(plus250, new Vector3(x, y), Quaternion.identity);
                    break;

                case 5:
                    SoundManager.PlaySound("plusPoints");
                    Instantiate(plus300, new Vector3(x, y), Quaternion.identity);
                    break;

                default:
                    SoundManager.PlaySound("plusPoints");
                    Instantiate(plus50, new Vector3(x, y), Quaternion.identity);
                    break;
                }
            }
            else
            {
                ScoreScript.SubtractScore(2 * ((GemIndex * 50) + 50));
                switch (GemIndex)
                {
                case 0:
                    SoundManager.PlaySound("losePoints");
                    Instantiate(minus100, new Vector3(x, y), Quaternion.identity);
                    break;

                case 1:
                    SoundManager.PlaySound("losePoints");
                    Instantiate(minus200, new Vector3(x, y), Quaternion.identity);
                    break;

                case 2:
                    SoundManager.PlaySound("losePoints");
                    Instantiate(minus300, new Vector3(x, y), Quaternion.identity);
                    break;

                case 3:
                    SoundManager.PlaySound("losePoints");
                    Instantiate(minus400, new Vector3(x, y), Quaternion.identity);
                    break;

                case 4:
                    SoundManager.PlaySound("losePoints");
                    Instantiate(minus500, new Vector3(x, y), Quaternion.identity);
                    break;

                case 5:
                    SoundManager.PlaySound("losePoints");
                    Instantiate(minus600, new Vector3(x, y), Quaternion.identity);
                    break;

                default:
                    SoundManager.PlaySound("losePoints");
                    Instantiate(minus100, new Vector3(x, y), Quaternion.identity);
                    break;
                }
            }
        }
        Destroy(collision.gameObject);
    }
示例#30
0
 void OnTriggerEnter(Collider col)
 {
     audioscript.playToken();
     this.gameObject.SetActive(false);
     scoreScript.AddScore(1);
 }