Beispiel #1
0
 void Awake()
 {
     if (instance == null)
     {
         instance = this;
     }
 }
Beispiel #2
0
    void Start()
    {
        shaker = cam.GetComponent <CameraShaker>();
        Debug.Assert(shaker != null);

        deathEffect = cam.GetComponent <DeathEffectShader>();
        Debug.Assert(deathEffect != null);

        for (int i = 0; i < weaponsList.Length; i++)
        {
            gunScript gun = weaponsList[i].GetComponent <gunScript>();

            gunScriptList.Add(gun);
        }

        audioController = GetComponentInChildren <playerAudio>();
        Debug.Assert(audioController != null);
    }
    public void checkDeath()
    {
        if (health <= 0)
        {
            gameCont.playerDied(playerID);
            Destroy(weapon);
            gun            = null;
            gunGameObject  = null;
            weaponEquipped = false;

            if (weaponPickup != null)
            {
                weaponPickup.SetActive(true);
            }

            weaponPickup = null;

            respawn();
            //Destroy(this.gameObject);
        }
    }
    public void equipGun(GameObject item)
    {
        if (weaponEquipped == true)
        {
            Destroy(instanceRef);
        }
        gunGameObject  = item;
        gun            = item.GetComponent <gunScript>();
        shootInterval  = gun.fireRate;
        weaponEquipped = true;
        instanceRef    = Instantiate(gunGameObject, gunSpawnPoint);
        gunScript gunInfo = instanceRef.GetComponent <gunScript>();

        if (weaponPickup != null)
        {
            weaponPickup.SetActive(true);
        }

        weapon          = instanceRef;
        gun.bulletSpawn = currentPlayerController.pivotTransform.GetChild(currentPlayerController.mainCam.transform.GetSiblingIndex());
        gun.camTrans    = currentPlayerController.pivotTransform;
        gun.fpsCamera   = currentPlayerController.mainCam;
    }