Advertisement
CassataGames

Untitled

Feb 13th, 2022
805
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.00 KB | None | 0 0
  1. using System.Collections;
  2. using Sirenix.OdinInspector;
  3. using UnityEngine;
  4.  
  5. [System.Serializable, HideLabel]
  6. public class GunClip
  7. {
  8.     [SuffixLabel("Second(s)", Overlay = true)]
  9.     public float reloadLength;
  10.     [ShowInInspector, ReadOnly]
  11.     internal float reloadTime
  12.     {
  13.         get;
  14.         private set;
  15.     }
  16.     internal int ammoLeft
  17.     {
  18.         get { return _ammoCurrent; }
  19.         private set { _ammoCurrent = value; }
  20.     }
  21.     internal int ammoMax
  22.     {
  23.         get { return _ammoMax; }
  24.         set { _ammoMax = value; }
  25.     }
  26.  
  27.     [ShowInInspector]
  28.     internal int _ammoCurrent = 3;
  29.     internal int _ammoMax = 3;
  30.  
  31.     internal void ReduceClip(int i)
  32.     {
  33.         ammoLeft -= i;
  34.     }
  35.     internal IEnumerator IsReloading()
  36.     {
  37.         reloadTime = 0;
  38.         while (reloadTime < reloadLength)
  39.         {
  40.             reloadTime += Time.deltaTime;
  41.             yield return null;
  42.         }
  43.         _ammoCurrent = _ammoMax;
  44.         yield return null;
  45.     }
  46. }
  47.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement