Esempio n. 1
0
    // Start is called before the first frame update
    void Start()
    {
        for (int i = 0; i < gunPrefabs.Length; i++)
        {
            GameObject lane  = Instantiate(lanePrefab, transform.position + new Vector3(0, 2.5f * (i + 1), 0), Quaternion.identity, transform);
            GameObject stand = Instantiate(gunPrefabs[i], transform.position + new Vector3(-1.0f, 2.5f * (i + 1) + 0.15f), Quaternion.identity, lane.transform);

            gameObject.name += stand.name;

            WeaponStand weaponStand = stand.GetComponent <WeaponStand>();
            weaponStand.spawnRate    = 1.0f;
            weaponStand.spawnAtStart = true;
        }
    }
Esempio n. 2
0
    public void SetAvailability(bool newAvailability)
    {
        if (!newAvailability && onStand)
        {
            WeaponStand ws = transform.parent.GetComponent <WeaponStand>();
            ws.hasItem       = false;
            onStand          = false;
            gameObject.layer = 11;
        }

        numCollisions = 0;
        Available     = newAvailability;
        if (gun.currentAmmo <= 0)
        {
            Available = false;
        }

        TogglePhysics(newAvailability);

        if (newAvailability)
        {
            transform.SetParent(origParent);
            if (gun.currentAmmo <= 0)
            {
                StartCoroutine(DropWeapon(emptyRemovalTimer));
            }
            else
            {
                StartCoroutine(DropWeapon(droppedRemovalTimer));
            }
        }
        else
        {
            StopAllCoroutines();
            transform.localScale = Vector3.one;
        }
    }