void OnTriggerEnter(Collider other) { tagSubject.setOther(other); tagSubject.setPlayer(this); if (other.gameObject.tag == "coin") { tagSubject.setTag("coin"); Debug.Log("Before123" + score); //IScoreCalculator scoreCalculator1 = new CoinScoreDecorator (new ScoreCalculator (score)); //score = scoreCalculator1.getScore (); //Debug.Log("After"+score); ////Increase the Score by one point and add sound ////Also destroy the coin //Debug.Log("Collision with Coin"); ////score += 2; //scoreText.text = "score: " + score.ToString(); this.GetComponent <AudioSource> ().PlayOneShot(coinClip); //Disapperaing the Coin when collected //destroyObject(other); } if (other.gameObject.tag == "Enemy") { tagSubject.setTag("Enemy"); //Debug.Log("collision"); //killPlayer(); } if (other.gameObject.tag == "obstacle") { Debug.Log("hit an obstacle"); tagSubject.setTag("obstacle"); float offsetUpDown = 0; float offsetLeftRight = 0; // todo: if (isJumpingDown) { offsetUpDown = -2.0f; } else if (isJumpingUp) { offsetUpDown = 2.0f; } else if (isJumpingRight) { offsetLeftRight = -2.0f; } else if (isJumpingLeft) { offsetLeftRight = 2.0f; } transform.position = new Vector3(transform.position.x + offsetUpDown, initialPositionY, transform.position.z + offsetLeftRight); isJumpingUp = isJumpingRight = isJumpingLeft = isJumpingDown = false; } }