Spaces:
Running
Running
File size: 2,875 Bytes
c80142e |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 |
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,
}
[Header("Information")]
[Tooltip("The name that will be displayed in the UI for this Equipment")]
public string EquipmentName;
[Tooltip("The image that will be displayed in the UI for this Equipment")]
public Image EquipmentIcon;
[Tooltip("The root object for the weapon, this is what will be deactivated when the weapon isn't active")]
public GameObject EquipmentRoot;
[Tooltip("The transform for the correct hand positioning of the equipment")]
public Transform EquipmentOffset;
[Tooltip("Tip of the Equipment, where the projectiles are shot (If a weapon")]
public Transform WeaponMuzzle;
[Tooltip("The type of Equipment wil affect how it is utilized")]
public EquipmentType EquipType;
[Tooltip("Check if Equipment is equipped")]
public bool Equipped;
[Tooltip("Maximum amount of ammo in the gun")]
public int MaxAmmo = 6;
public float CurrentAmmo = 6;
[Tooltip("The projectile prefab")] 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;
}
}
}
|