Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- using System.Collections;
- namespace GearCore
- {
- public interface IItem
- {
- string Name { get; set; }
- int Durrability { get; set; }
- float Weight { get; set; }
- bool Enabled { get; set; }
- IEnumerator LeftClick();
- IEnumerator RightClick();
- IEnumerator ContextUse();
- }
- public abstract class Gun : MonoBehaviour, IItem
- {
- public string Name { get; set; }
- public int Durrability { get; set; }
- public float Weight { get; set; }
- public int TotalAmmo { get; set; }
- public int AmmoOutOfClip { get; set; }
- public int ClipSize { get; set; }
- public int ClipAmount { get; set; }
- public bool Scope { get; private set; }
- public bool Enabled { get; set; }
- public bool Started { get; set; }
- //Fire
- public IEnumerator LeftClick()
- {
- if (Input.GetMouseButton(0))
- {
- Debug.Log("Firing");
- yield return new WaitForSeconds(100000);
- }
- StartCoroutine(LeftClick());
- }
- //Scope
- public IEnumerator RightClick()
- {
- if (Input.GetMouseButton(1))
- {
- Debug.Log("Scoping");
- yield return new WaitForSeconds(1);
- }
- StartCoroutine(RightClick());
- }
- //Reload
- public IEnumerator ContextUse()
- {
- if (Input.GetKeyDown(KeyCode.R))
- {
- Debug.Log("Reloading");
- if (ClipSize != 0)
- {
- AmmoOutOfClip = TotalAmmo % ClipSize;
- ClipAmount = (int)TotalAmmo / ClipSize;
- }
- //Play Reload Animation
- yield return new WaitForSeconds(3);
- }
- StartCoroutine(ContextUse());
- }
- public virtual void Update()
- {
- if (Enabled && !Started)
- {
- Debug.Log("Starting COroutines");
- StartCoroutine(LeftClick());
- StartCoroutine(RightClick());
- StartCoroutine(ContextUse());
- Started = true;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement