Exemplo n.º 1
0
 public bool InsertProjectile(Firable projectile)
 {
     if (projectile && index > 0)
     {
         projectile.transform.parent = transform;
         projectile.transform.SetAsFirstSibling();
         index              = index - 1;
         inStorage          = inStorage + 1;
         projectiles[index] = projectile;
         if (visibleProjectiles > 0)
         {
             int nextVisible = index + visibleProjectiles;
             if (nextVisible < projectiles.Length)
             {
                 Firable nextVisibleProjectile = projectiles[nextVisible];
                 if (nextVisibleProjectile)
                 {
                     nextVisibleProjectile.gameObject.SetActive(false);
                 }
             }
         }
         return(true);
     }
     return(false);
 }
Exemplo n.º 2
0
 public Firable PullProjectile(Transform parent)
 {
     if (index < projectiles.Length)
     {
         Firable projectile = projectiles[index];
         projectile.transform.parent = parent;
         projectiles[index]          = null;
         if (visibleProjectiles > 0)
         {
             int nextVisible = index + visibleProjectiles;
             if (nextVisible < projectiles.Length)
             {
                 Firable nextVisibleProjectile = projectiles[nextVisible];
                 if (nextVisibleProjectile)
                 {
                     nextVisibleProjectile.gameObject.SetActive(true);
                 }
             }
         }
         index     = index + 1;
         inStorage = inStorage - 1;
         return(projectile);
     }
     return(null);
 }
Exemplo n.º 3
0
 private void ExecutionHandler()
 {
     if (lastVisibleProjectiles != visibleProjectiles)
     {
         if (visibleProjectiles == 0)
         {
             for (int a = 0, A = projectiles.Length; a < A; a++)
             {
                 Firable projectile = projectiles[a];
                 if (!projectile)
                 {
                     continue;
                 }
                 projectile.gameObject.SetActive(false);
             }
         }
         else if (visibleProjectiles > 0)
         {
             for (int a = 0, A = projectiles.Length; a < A; a++)
             {
                 Firable projectile = projectiles[a];
                 if (!projectile)
                 {
                     continue;
                 }
                 projectile.gameObject.SetActive(a < index + visibleProjectiles);
             }
         }
         else
         {
             for (int a = 0, A = projectiles.Length; a < A; a++)
             {
                 Firable projectile = projectiles[a];
                 if (!projectile)
                 {
                     continue;
                 }
                 projectile.gameObject.SetActive(true);
             }
         }
         lastVisibleProjectiles = visibleProjectiles;
     }
     else
     {
         for (int a = 0, A = projectiles.Length; a < A; a++)
         {
             Firable projectile = projectiles[a];
             if (!projectile)
             {
                 continue;
             }
         }
     }
 }
Exemplo n.º 4
0
		//[RPC]
		public void Chamber ()
		{
			if(!inChamber && storage)
			{
				inChamber = storage.PullProjectile(transform);
				if(inChamber && chamberPoint)
				{
					inChamber.transform.position = chamberPoint.position;
					inChamber.transform.rotation = chamberPoint.rotation;
				}
			}
		}
Exemplo n.º 5
0
 private void Update()
 {
     ValidationHandler();
                 #if UNITY_EDITOR
     if (!Application.isPlaying)
     {
         return;
     }
                 #endif
     if (insert)
     {
         insert.rigidbody.isKinematic = true;
         InsertProjectile(insert);
         insert = null;
     }
     ExecutionHandler();
 }
Exemplo n.º 6
0
		private void FireHandler ()
		{
			if(fireCounter >= fireDuration)
			{
				if(inChamber)
				{
					onFire.Invoke();
					//Eject the case, and fire the head (bullet) itself.
					inChamber.Fire();
					inChamber = null;
					Chamber();
					firedShots += 1;
					if(firedShots >= shotsPerFire)firedShots = 0;
					//if(!inChamber)onEmpty.Invoke();
				}
				else
				{
					onEmpty.Invoke();
					firedShots = 0;
				}
				fireCounter = 0F;
			}
		}
Exemplo n.º 7
0
 void Awake()
 {
     input       = GetComponent <InputManager>();
     fireTrigger = GetComponent <Firable>();
     animManager = GetComponent <AnimationManager>();
 }
Exemplo n.º 8
0
 private void Awake()
 {
     if (inStorage < 0)
     {
         inStorage = 0;
         for (int a = 0, A = projectiles.Length; a < A; a++)
         {
             Firable projectile = projectiles[a];
             if (!projectile)
             {
                 continue;
             }
             inStorage = inStorage + 1;
         }
     }
                 #if UNITY_EDITOR
     if (!Application.isPlaying)
     {
         return;
     }
                 #endif
     if (lastVisibleProjectiles != visibleProjectiles)
     {
         if (visibleProjectiles == 0)
         {
             for (int a = 0, A = projectiles.Length; a < A; a++)
             {
                 Firable projectile = projectiles[a];
                 if (!projectile)
                 {
                     continue;
                 }
                 projectile.gameObject.SetActive(false);
             }
         }
         else if (visibleProjectiles > 0)
         {
             for (int a = 0, A = projectiles.Length; a < A; a++)
             {
                 Firable projectile = projectiles[a];
                 if (!projectile)
                 {
                     continue;
                 }
                 projectile.gameObject.SetActive(a < index + visibleProjectiles);
             }
         }
         else
         {
             for (int a = 0, A = projectiles.Length; a < A; a++)
             {
                 Firable projectile = projectiles[a];
                 if (!projectile)
                 {
                     continue;
                 }
                 projectile.gameObject.SetActive(true);
             }
         }
         lastVisibleProjectiles = visibleProjectiles;
     }
 }
Exemplo n.º 9
0
 public void InsertProjectile(ref List <Firable> projectiles)
 {
     if (index > 0)
     {
         if (visibleProjectiles > 0)
         {
             for (int count = projectiles.Count; count > 0; count--)
             {
                 Firable projectile = projectiles[0];
                 if (projectile)
                 {
                     projectile.gameObject.SetActive(true);
                     projectile.transform.parent = transform;
                     projectile.transform.SetAsFirstSibling();
                 }
                 projectiles.RemoveAt(0);
                 index     = index - 1;
                 inStorage = inStorage + 1;
                 this.projectiles[index] = projectile;
                 int nextVisible = index + visibleProjectiles;
                 if (nextVisible < this.projectiles.Length)
                 {
                     Firable nextVisibleProjectile = this.projectiles[nextVisible];
                     if (nextVisibleProjectile)
                     {
                         nextVisibleProjectile.gameObject.SetActive(false);
                     }
                 }
                 if (index == 0)
                 {
                     return;
                 }
             }
         }
         else if (visibleProjectiles == 0)
         {
             for (int count = projectiles.Count; count > 0; count--)
             {
                 Firable projectile = projectiles[0];
                 if (projectile)
                 {
                     projectile.gameObject.SetActive(false);
                     projectile.transform.parent = transform;
                     projectile.transform.SetAsFirstSibling();
                 }
                 projectiles.RemoveAt(0);
                 index     = index - 1;
                 inStorage = inStorage + 1;
                 this.projectiles[index] = projectile;
                 if (index == 0)
                 {
                     return;
                 }
             }
         }
         else if (visibleProjectiles == -1)
         {
             for (int count = projectiles.Count; count > 0; count--)
             {
                 Firable projectile = projectiles[0];
                 if (projectile)
                 {
                     projectile.gameObject.SetActive(true);
                     projectile.transform.parent = transform;
                     projectile.transform.SetAsFirstSibling();
                 }
                 projectiles.RemoveAt(0);
                 index     = index - 1;
                 inStorage = inStorage + 1;
                 this.projectiles[index] = projectile;
                 if (index == 0)
                 {
                     return;
                 }
             }
         }
         else
         {
             for (int count = projectiles.Count; count > 0; count--)
             {
                 Firable projectile = projectiles[0];
                 if (projectile)
                 {
                     projectile.transform.parent = transform;
                     projectile.transform.SetAsFirstSibling();
                 }
                 projectiles.RemoveAt(0);
                 index     = index - 1;
                 inStorage = inStorage + 1;
                 this.projectiles[index] = projectile;
                 if (index == 0)
                 {
                     return;
                 }
             }
         }
     }
 }
Exemplo n.º 10
0
 public int InsertProjectile(ref Firable[] projectiles)
 {
     if (index > 0)
     {
         int A = projectiles.Length;
         if (visibleProjectiles > 0)
         {
             for (int a = 0; a < A; a++)
             {
                 Firable projectile = projectiles[a];
                 if (projectile)
                 {
                     projectile.gameObject.SetActive(true);
                     projectile.transform.parent = transform;
                     projectile.transform.SetAsFirstSibling();
                 }
                 projectiles[a]          = null;
                 index                   = index - 1;
                 inStorage               = inStorage + 1;
                 this.projectiles[index] = projectile;
                 int nextVisible = index + visibleProjectiles;
                 if (nextVisible < this.projectiles.Length)
                 {
                     Firable nextVisibleProjectile = this.projectiles[nextVisible];
                     if (nextVisibleProjectile)
                     {
                         nextVisibleProjectile.gameObject.SetActive(false);
                     }
                 }
                 if (index == 0)
                 {
                     return(a + 1);
                 }
             }
         }
         else if (visibleProjectiles == 0)
         {
             for (int a = 0; a < A; a++)
             {
                 Firable projectile = projectiles[a];
                 if (projectile)
                 {
                     projectile.gameObject.SetActive(false);
                     projectile.transform.parent = transform;
                     projectile.transform.SetAsFirstSibling();
                 }
                 projectiles[a]          = null;
                 index                   = index - 1;
                 inStorage               = inStorage + 1;
                 this.projectiles[index] = projectile;
                 if (index == 0)
                 {
                     return(a + 1);
                 }
             }
         }
         else if (visibleProjectiles == -1)
         {
             for (int a = 0; a < A; a++)
             {
                 Firable projectile = projectiles[a];
                 if (projectile)
                 {
                     projectile.gameObject.SetActive(true);
                     projectile.transform.parent = transform;
                     projectile.transform.SetAsFirstSibling();
                 }
                 projectiles[a]          = null;
                 index                   = index - 1;
                 inStorage               = inStorage + 1;
                 this.projectiles[index] = projectile;
                 if (index == 0)
                 {
                     return(a + 1);
                 }
             }
         }
         else
         {
             for (int a = 0; a < A; a++)
             {
                 Firable projectile = projectiles[a];
                 if (projectile)
                 {
                     projectile.transform.parent = transform;
                     projectile.transform.SetAsFirstSibling();
                 }
                 projectiles[a]          = null;
                 index                   = index - 1;
                 inStorage               = inStorage + 1;
                 this.projectiles[index] = projectile;
                 if (index == 0)
                 {
                     return(a + 1);
                 }
             }
         }
         return(A);
     }
     return(0);
 }