コード例 #1
0
ファイル: PlayerController.cs プロジェクト: andesob/MineroBio
    //Lets the player choose which weapon to use
    private void ChooseWeapon()
    {
        if (Nr1Pressed && gameManager.HasPistol())
        {
            activeWeapon = "Pistol";
        }

        if (Nr2Pressed && gameManager.HasSniper())
        {
            activeWeapon = "Sniper";
        }

        foreach (GameObject weapon in weaponList)
        {
            if (weapon.name == activeWeapon)
            {
                weapon.SetActive(true);
                shootingScript.SetGun(weapon);
            }
            else
            {
                weapon.SetActive(false);
            }
        }
    }
コード例 #2
0
    public void PickUpWeapon(string weaponName)
    {
        switch (weaponName)
        {
        case "PistolPickup":
            pistolPickedUp = true;
            shootingScript.SetGun(pistol);
            playerControllerScript.AddWeapon(pistol);
            break;

        case "SniperPickup":
            sniperPickedUp = true;
            shootingScript.SetGun(sniper);
            playerControllerScript.AddWeapon(sniper);
            break;
        }
    }