private void OnCollisionEnter(Collision collision) { if (collision.gameObject.CompareTag("Wood") && _isScoreTaken == false) { gameObject.transform.SetParent(collision.transform); var temp = collision.gameObject.GetComponentInParent <Wood>(); if (!_isKnifeInWood) { Vibration.Vibrate(100); temp.MinusScore(); _rigidbody.isKinematic = true; _isScoreTaken = true; ScoreAndStage.AddScore(1); _scoreText.UpdateText(); AddMoney(); } } if (collision.gameObject.CompareTag("Knife") && _isScoreTaken == false) { ScoreAndStage.CheckRecords(); ScoreAndStage.Reset(); Vibration.Vibrate(); GameState.GameOver(); GameState.GameFreeze(true); var menu = FindObjectOfType <Wood>(); menu.Menu.SetActive(true); } }
private void OnTriggerEnter(Collider other) { if (other.gameObject.CompareTag("Apple")) { AddMoney(); ScoreAndStage.AddScore(1); Destroy(other.gameObject); } }