void Explode() { //Screenshake camera.GetComponent <FollowTarget>().TriggerShake(); SMScript.PlaySound("explode"); SMScript.PlaySound("song"); //Change position transform.position = new Vector3(transform.position.x, transform.position.y - 1, 0); //Instantiate prefabs for (int i = 0; i < fragments.Length; i++) { int x = Random.Range(-5, 5); int y = Random.Range(-1, -10); Vector3 randomPos = new Vector3(transform.position.x + x, transform.position.y + y, 0); Instantiate(fragments[i], randomPos, Quaternion.identity); } camera.GetComponent <GameManager>().start = true; player.GetComponent <PlayerController>().started = true; //Instantiate Leave Arrows //Delete door Destroy(this.gameObject); }
void OnTriggerEnter2D(Collider2D col) { if (col.tag == "Player") { SMScript.PlaySound("explode"); gm.GetComponent <GameManager>().ended = true; gm.GetComponent <FollowTarget>().TriggerShake(); } }
// Update is called once per frame void Update() { if (started) { colorChangeTimer -= Time.deltaTime; if (!jazz.isEmitting) { jazz.Play(); } } speed = fastSpeed; //GET INPUT x = Input.GetAxisRaw("Horizontal"); y = Input.GetAxisRaw("Vertical"); dir = new Vector2(x, y); Vector3 mousePosition = Input.mousePosition; mousePosition = Camera.main.ScreenToWorldPoint(mousePosition); faceDir = new Vector2(mousePosition.x - transform.position.x, mousePosition.y - transform.position.y); transform.up = -faceDir; if (colorChangeTimer <= 0) { ChangeColor(); kazooChanger += 1; colorChangeTimer = colorChangeCooldown; } sprRend.color = selectedColor; if (Input.GetMouseButton(0)) { if (kazooTimer <= 0) { SMScript.PlaySound("" + kazooChanger); kazooTimer = kazooCD; } speed = slowSpeed; if (shootTimer <= 0) { Shoot(); shootTimer = shootCoolDown; } } shootTimer -= Time.deltaTime; kazooTimer -= Time.deltaTime; }
void OnTriggerEnter2D(Collider2D col) { if (col.tag == "Player") { SMScript.PlaySound("coin"); gm.GetComponent <GameManager>().money += 1; Destroy(this.gameObject); } }
void OnTriggerEnter2D(Collider2D col) { if (col.tag == "Note") { Color check = col.GetComponent <SpriteRenderer>().color; if (check == spr.color) { var projectile = Instantiate(moneyPrefab, this.transform); projectile.GetComponent <Rigidbody2D>().AddForce(Random.insideUnitSphere * 900f); projectile = Instantiate(moneyPrefab, this.transform); projectile.GetComponent <Rigidbody2D>().AddForce(Random.insideUnitSphere * 900f); projectile = Instantiate(moneyPrefab, this.transform); projectile.GetComponent <Rigidbody2D>().AddForce(Random.insideUnitSphere * 900f); SMScript.PlaySound("happy"); happy.Play(); gm.GetComponent <GameManager>().peopleHappy += 1; spr.color = Color.white; } } }
void ChangeColor() { SMScript.PlaySound("color"); if (colors.Count != 0) { int r = Random.Range(0, colors.Count); if (selectedColor != colors[r]) { selectedColor = colors[r]; colors.Remove(colors[r]); } else if (r != 0) { selectedColor = colors[r - 1]; colors.Remove(colors[r - 1]); } else { selectedColor = colors[r + 1]; colors.Remove(colors[r + 1]); } } }