private void SpawnSpring() { animator.SetTrigger("Spawn"); SoundEvents.Play("ItemDrop"); var newSpring = Instantiate(spring, GetSpawnPosition(), spawnTransform.rotation); newSpring.spawn = transform; }
private void SpawnParachute() { animator.SetTrigger("Spawn"); SoundEvents.Play("ItemDrop"); var newParachute = Instantiate(parachute, GetSpawnPosition(), spawnTransform.rotation); newParachute.spawn = transform; }
private void OnTriggerEnter2D(Collider2D collision) { if (!lever && collision.CompareTag("Character")) { lever = true; animator.SetBool("Switch", true); resetTime = TimeKeeper.GetTime() + resetDelay; SoundEvents.Play("Switch"); PotatoSwitchEvents.SwitchTriggered(); } }
private void SpawnPotatoIfNeeded() { if (potatoesLeft > 0 && TimeKeeper.GetTime() > nextPotato) { animator.SetTrigger("Spawn"); SoundEvents.Play("ItemDrop"); var newPotato = Instantiate(potatoes[3 - potatoesLeft], GetSpawnPosition(), spawnTransform.rotation); newPotato.velocity = new Vector2(ConveyorSpeed.GetSpeed(), 0); newPotato.angularVelocity = UnityEngine.Random.Range(40, 180); potatoesLeft--; nextPotato = TimeKeeper.GetTime() + timeBetweenPotatoes; } }
private void OnCollisionEnter2D(Collision2D collision) { if (collision.gameObject.CompareTag("Bumper")) { SoundEvents.Play("Bumper"); var vector = (transform.position - collision.transform.position).normalized; var launchVector = NearestVector(vector) * 20.0f; SpringLaunch(launchVector.x, launchVector.y); } if (collision.gameObject.CompareTag("Hazard")) { SoundEvents.Play("Death"); stageManager.Death(); } }
private void OnTriggerEnter2D(Collider2D collider) { var collectible = collider.gameObject.GetComponent<Collectible>(); if (collectible != null) { stageManager.AddScore(Mathf.RoundToInt(collectible.Collect() * scoreMultiplier)); scoreMultiplier += .2f; multiplier.text = $"x{scoreMultiplier:f1}"; } if (collider.gameObject.CompareTag("Hazard")) { SoundEvents.Play("Death"); stageManager.Death(); } }
public int Collect() { SoundEvents.Play("ChipCrunch"); Destroy(gameObject); return(value); }