Advertisement
Guest User

Untitled

a guest
Nov 7th, 2015
133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.30 KB | None | 0 0
  1. using UnityEngine;
  2. using System.Collections;
  3.  
  4. namespace GearCore
  5. {
  6.     public interface IItem
  7.     {
  8.         string Name { get; set; }
  9.         int Durrability { get; set; }
  10.         float Weight { get; set; }
  11.         bool Enabled { get; set; }
  12.  
  13.         IEnumerator LeftClick();
  14.         IEnumerator RightClick();
  15.         IEnumerator ContextUse();
  16.     }
  17.  
  18.     public abstract class Gun : MonoBehaviour, IItem
  19.     {
  20.         public string Name { get; set; }
  21.         public int Durrability { get; set; }
  22.         public float Weight { get; set; }
  23.  
  24.         public int TotalAmmo { get; set; }
  25.         public int AmmoOutOfClip { get; set; }
  26.         public int ClipSize { get; set; }
  27.         public int ClipAmount { get; set; }
  28.  
  29.         public bool Scope { get; private set; }
  30.         public bool Enabled { get; set; }
  31.         public bool Started { get; set; }
  32.  
  33.  
  34.         //Fire
  35.         public IEnumerator LeftClick()
  36.         {
  37.             if (Input.GetMouseButton(0))
  38.             {
  39.                 Debug.Log("Firing");
  40.                 yield return new WaitForSeconds(100000);
  41.             }
  42.             StartCoroutine(LeftClick());
  43.         }
  44.  
  45.         //Scope
  46.         public IEnumerator RightClick()
  47.         {
  48.             if (Input.GetMouseButton(1))
  49.             {
  50.                 Debug.Log("Scoping");
  51.                 yield return new WaitForSeconds(1);
  52.             }
  53.             StartCoroutine(RightClick());
  54.         }
  55.  
  56.         //Reload
  57.         public IEnumerator ContextUse()
  58.         {
  59.             if (Input.GetKeyDown(KeyCode.R))
  60.             {
  61.                 Debug.Log("Reloading");
  62.                 if (ClipSize != 0)
  63.                 {
  64.                     AmmoOutOfClip = TotalAmmo % ClipSize;
  65.                     ClipAmount = (int)TotalAmmo / ClipSize;
  66.                 }
  67.                 //Play Reload Animation
  68.                 yield return new WaitForSeconds(3);
  69.             }
  70.             StartCoroutine(ContextUse());
  71.         }
  72.  
  73.         public virtual void Update()
  74.         {
  75.             if (Enabled && !Started)
  76.             {
  77.                 Debug.Log("Starting COroutines");
  78.                 StartCoroutine(LeftClick());
  79.                 StartCoroutine(RightClick());
  80.                 StartCoroutine(ContextUse());
  81.                 Started = true;
  82.             }
  83.         }
  84.     }
  85. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement