Spaces:
Running
Running
| using System; | |
| using System.Collections.Generic; | |
| using UnityEngine; | |
| using UnityEngine.UI; | |
| using UnityEngine.Events; | |
| public class EquipmentController : MonoBehaviour | |
| { | |
| public enum EquipmentType | |
| { | |
| None, | |
| Weapon, | |
| Tool, | |
| Objective, | |
| } | |
| [] | |
| [] | |
| public string EquipmentName; | |
| [] | |
| public Image EquipmentIcon; | |
| [] | |
| public GameObject EquipmentRoot; | |
| [] | |
| public Transform EquipmentOffset; | |
| [] | |
| public Transform WeaponMuzzle; | |
| [] | |
| public EquipmentType EquipType; | |
| [] | |
| public bool Equipped; | |
| [] | |
| public int MaxAmmo = 6; | |
| public float CurrentAmmo = 6; | |
| [] public GameObject ProjectilePrefab; | |
| private StarterAssetsInputs _input; | |
| // Start is called once before the first execution of Update after the MonoBehaviour is created | |
| void Start() | |
| { | |
| _input = FindObjectOfType<StarterAssetsInputs>(); | |
| } | |
| // Update is called once per frame | |
| void Update() | |
| { | |
| switch (EquipType) | |
| { | |
| case EquipmentType.None: | |
| // Maybe do nothing or add idle behavior | |
| break; | |
| case EquipmentType.Weapon: | |
| if (Equipped) | |
| { | |
| // Example: Shooting logic, checking for input, etc. | |
| Debug.Log("Weapon equipped."); | |
| // if (_input.shoot) { Fire(); } | |
| } | |
| break; | |
| case EquipmentType.Tool: | |
| if (Equipped) | |
| { | |
| // Example: Use tool logic, maybe scanning or interacting | |
| Debug.Log("Tool equipped."); | |
| if (_input.aim) { | |
| Instantiate(ProjectilePrefab, transform); | |
| } | |
| } | |
| break; | |
| case EquipmentType.Objective: | |
| if (Equipped) | |
| { | |
| // Example: Carry or activate objective | |
| Debug.Log("Objective equipped."); | |
| } | |
| break; | |
| default: | |
| Debug.LogWarning("Unknown EquipmentType"); | |
| break; | |
| } | |
| } | |
| } | |