JojikYT

EquipmentSystem

Feb 10th, 2022 (edited)
1,811
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.03 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4.  
  5. public class EquipmentSystem : MonoBehaviour
  6. {
  7.     [SerializeField] GameObject weaponHolder;
  8.     [SerializeField] GameObject weapon;
  9.     [SerializeField] GameObject weaponSheath;
  10.  
  11.  
  12.     GameObject currentWeaponInHand;
  13.     GameObject currentWeaponInSheath;
  14.     void Start()
  15.     {
  16.         currentWeaponInSheath = Instantiate(weapon, weaponSheath.transform);
  17.     }
  18.  
  19.     public void DrawWeapon()
  20.     {
  21.         currentWeaponInHand = Instantiate(weapon, weaponHolder.transform);
  22.         Destroy(currentWeaponInSheath);
  23.     }
  24.  
  25.     public void SheathWeapon()
  26.     {
  27.         currentWeaponInSheath = Instantiate(weapon, weaponSheath.transform);
  28.         Destroy(currentWeaponInHand);
  29.     }
  30.  
  31.     public void StartDealDamage()
  32.     {
  33.         currentWeaponInHand.GetComponentInChildren<DamageDealer>().StartDealDamage();
  34.     }
  35.     public void EndDealDamage()
  36.     {
  37.         currentWeaponInHand.GetComponentInChildren<DamageDealer>().EndDealDamage();
  38.     }
  39. }
  40.  
Add Comment
Please, Sign In to add comment