예제 #1
0
        public void SwapWeapon(GameObject newWeapon)
        {
            // Check the new weapon is valid
            if (newWeapon == null)
            {
                Debug.Log("Cannot swap to a NULL weapon");
                return;
            }

            // If we have a weapon already, destroy it
            if (CurrentWeapon != null)
            {
                Pooling.SendToPool(CurrentWeapon.gameObject);
                CurrentWeapon = null;
            }

            // Assign the new weapon
            AssignWeapon(newWeapon);
        }
예제 #2
0
 /// <summary>
 /// Assigns a new weapon to use
 /// </summary>
 /// <param name="newWeapon"></param>
 private void AssignWeapon(GameObject newWeapon)
 {
     CurrentWeapon = Pooling.GetFromPool(newWeapon, BarrelEndTransform.position, transform.rotation).GetComponent <BaseTankWeapon>();
     CurrentWeapon.transform.SetParent(transform);
     CurrentWeapon.transform.localScale = Vector3.one;
 }