private void OnTriggerEnter2D(Collider2D collision) { sfxManager.PlaySound(7); uiManager.score += 200; coinsManager.AddCoin(); Destroy(gameObject); }
// Start is called before the first frame update void Start() { GameObject constantManagers = GameObject.FindGameObjectWithTag("ConstantManagers"); coinsManager = constantManagers.GetComponentInChildren <CoinsManager>(); GameObject managers = GameObject.FindGameObjectWithTag("Managers"); uiManager = managers.GetComponentInChildren <UIManager>(); rigidBody = GetComponent <Rigidbody2D>(); coinsManager.AddCoin(); uiManager.score += 200; rigidBody.gravityScale = 2; rigidBody.velocity = new Vector2(0, velocity); }
private void HitBlock() { if (itemInBox == Item.Coin) { sfxManager.PlaySound(7); Debug.Log("coin spawn"); Instantiate(coin, new Vector2(transform.position.x, transform.position.y + 0.2f), Quaternion.identity); coinsManager.AddCoin(); } else if (itemInBox == Item.Powerup) { sfxManager.PlaySound(8); if (playerController.GetMarioState() == PlayerController.MarioState.SMALL) { createdObject = Instantiate(mushroom, transform.position, Quaternion.identity); //StartCoroutine(MoveItem()); } else { createdObject = Instantiate(flower, transform.position, Quaternion.identity); //StartCoroutine(MoveItem()); } } else if (itemInBox == Item.Star) { createdObject = Instantiate(star, transform.position, Quaternion.identity); //StartCoroutine(MoveItem()); } else if (itemInBox == Item.Life) { sfxManager.PlaySound(8); createdObject = Instantiate(life, transform.position, Quaternion.identity); //StartCoroutine(MoveItem()); } Instantiate(emptyBox, transform.position, Quaternion.identity); Destroy(gameObject); }