void OnTriggerEnter2D(Collider2D other) { //Bætir við ammo þegar player snertir ammo pickup if (other.CompareTag("Ammo")) { pickup = other.gameObject.GetComponentInParent <pickups>(); ammo_after_pickup = Weapons[WeaponType]["Bullets"] + Weapons[WeaponType]["Bullet Pack"]; if (Weapons[WeaponType]["Bullets"] == Weapons[WeaponType]["Max Ammo"]) { pickup.pickupAnim.SetBool("Item", true); } else if (ammo_after_pickup >= Weapons[WeaponType]["Max Ammo"]) { Destroy(other.gameObject); Weapons[WeaponType]["Bullets"] = Weapons[WeaponType]["Max Ammo"]; pickup.pickupAnim.SetBool("Item", false); pickup.pickupCount -= 1; pickup.ExtendNextSpawn(); } else { Destroy(other.gameObject); Weapons[WeaponType]["Bullets"] = ammo_after_pickup; pickup.pickupAnim.SetBool("Item", false); pickup.pickupCount -= 1; pickup.ExtendNextSpawn(); } } //Pistol pickup í Facility2B if (other.CompareTag("Pistol")) { pistolPickup.SetBool("pickup", true); Destroy(other.gameObject); pistolUnlock.hasGun = true; } //Health pickup if (other.CompareTag("Health")) { pickup = other.gameObject.GetComponentInParent <pickups>(); health_after_pickup = health + 25; if (health_after_pickup >= MaxHealth && health != MaxHealth) { health = MaxHealth; Destroy(other.gameObject); pickup.pickupAnim.SetBool("Item", false); pickup.pickupCount -= 1; pickup.ExtendNextSpawn(); } else if (health_after_pickup < MaxHealth) { health = health_after_pickup; Destroy(other.gameObject); pickup.pickupAnim.SetBool("Item", false); pickup.pickupCount -= 1; pickup.ExtendNextSpawn(); } } //Fer í næsta scene þegar player fer í hurð if (other.CompareTag("Door")) { doorCon = other.gameObject.GetComponent <DoorControls>(); if (!doorCon.doorLocked) { LoadByIndex(doorCon.nextLevelIndex); } } //Endar leikinn þegar player fer í vortex if (other.CompareTag("Vortex")) { health = 1000000; stopGame.finished = true; } }