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(); }
private IEnumerator ClickOnTile(Vector2Int position, float wait) { yield return(new WaitForSeconds(wait)); map.ClickOnTile(position.x, position.y); score.AddScore(10); }
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); }
public override void OnEated() { //Tornar os fantasmas azuis FindObjectOfType <SceneScript>().SetGhostMode(Mode.Fright); ScoreScript.AddScore(50); base.OnEated(); }
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(); }
void OnCollisionEnter(Collision collision) { if (collision.gameObject.tag == "Player") { ScoreScript.AddScore(); Destroy(gameObject); } }
private void DestroyBlock() { winScript.DecreaseBlockNumber(); _scoreScript.AddScore(scoreAmount); AudioSource.PlayClipAtPoint(destroyAudio, transform.position); DeathParticles(); Destroy(gameObject); }
private static void LoseGame() { PanelManager.b_PlayerLost = true; ScoreScript.AddScore(InGamePanel.m_Score); SceneManager.LoadScene("MainMenu"); InGamePanel.m_Money = 0; FlyManager.s_Level = 1; }
void Update() { if (zombie <= 0) { SoundManager.instance.PlaySoundFX(dead[Random.Range(0, shootClips.Length)]); ScoreScript.AddScore(lastPlayerHit, originalHealth); Destroy(gameObject); } print(lastPlayerHit); }
public void OnTriggerEnter2D(Collider2D other) { if (other.tag == "Player") { //use reference score.AddScore(add); health.curHealth = health.curHealth + 2; Object.Destroy(gameObject); } }
/// <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); }
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."); } }
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); } }
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); } } }
private void Update() { if (_state) { _timer -= Time.deltaTime; if (_timer < 0) { _timer = _initialTimer; _score.AddScore(1); } } }
// Update is called once per frame void Update() { if (!_dayLight.IsDay()) { _malusTimer -= Time.deltaTime; if (_malusTimer < 0) { _malusTimer = _malusTimerInitializer; _score.AddScore(10); } } }
//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(); } }
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; } }
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); } }
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); }
private void OnTriggerEnter2D(Collider2D target) { if (target.tag == "Bullet") { scoreScript.AddScore(scoreValue); canMove = false; if (canShoot) { canShoot = false; CancelInvoke("StartShooting"); } Invoke("TurnOffGameObject", 0f); } }
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(); } } } }
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(); }
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"); } }
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); } }
// 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); }
void OnTriggerEnter(Collider col) { audioscript.playToken(); this.gameObject.SetActive(false); scoreScript.AddScore(1); }