Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- public class Switch : MonoBehaviour
- {
- public GameObject riffle;
- public GameObject shotgun;
- public GameObject pistol;
- int level = 1;
- void Start()
- {
- switch (level)
- {
- case 1:
- ChooseWeapon("Пистолет");
- break;
- case 2:
- ChooseWeapon("Дробовик");
- break;
- case 3:
- ChooseWeapon("Автомат");
- break;
- default:
- print("Для этого уровня не подготовлено оружие");
- break;
- }
- }
- private void Update()
- {
- if(Input.GetKeyDown(KeyCode.Alpha1))
- ChooseWeapon("Пистолет");
- if(Input.GetKeyDown(KeyCode.Alpha2))
- ChooseWeapon("Дробовик");
- }
- private void ChooseWeapon(string weaponName)
- {
- switch (weaponName)
- {
- case "Пистолет":
- riffle.SetActive(false);
- shotgun.SetActive(false);
- pistol.SetActive(true);
- break;
- case "Дробовик":
- riffle.SetActive(false);
- shotgun.SetActive(true);
- pistol.SetActive(false);
- break;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement