using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.InputSystem; public class Weapon : MonoBehaviour { // Get player object [SerializeField] GameObject playerObject; // Components Player player; void Start() { // Get player component player = playerObject.GetComponent(); } // If something enters weapon trigger, weapon is marked as player as its attached to player // This is to fix bugs with the weapon triggering stuff even though the player hasn't triggered it void OnTriggerEnter2D(Collider2D col) { // If enters potion decrease potion count if (col.gameObject.tag == "Potion") { player.potionCount--; } // If enters cauldron decrease potion count if (col.gameObject.tag == "Cauldron") { player.cauldronCount--; } // If enters a teleport trigger, it wont teleport if (col.gameObject.tag == "HiddenRoomEnter") { player.trueTeleport = false; } if (col.gameObject.tag == "StorageRoomEnter" || col.gameObject.tag == "StorageRoomLeave") { player.trueTeleport = false; } if (col.gameObject.tag == "SewerRoomEnter" || col.gameObject.tag == "SewerRoomLeave") { player.trueTeleport = false; } if (col.gameObject.tag == "AbandonedRoomEnter") { player.trueTeleport = false; } if (col.gameObject.tag == "WinCondition") { player.trueTeleport = false; } } }