Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- public class Playercontroller : MonoBehaviour {
- //Активный тип оружия
- private Shootstype.ShootType activePlayerShootType = Shootstype.ShootType.BulletShoot;
- //Объявляем делегат
- private delegate void ActivePlayerShootType();
- //Переменная делегата с оружием по дефолту
- ActivePlayerShootType del = Shootstype.RockShoot;
- void Start()
- {
- //Проверка типа оружия
- switch (activePlayerShootType)
- {
- case Shootstype.ShootType.RockShoot:
- {
- Debug.Log("RockShoot");
- //Если оружие RockShoot, del вызывает метод RockShoot
- del = Shootstype.RockShoot;
- }
- break;
- case Shootstype.ShootType.BulletShoot:
- {
- Debug.Log("BulletShoot");
- //Если оружие BulletShoot, del вызывает метод BulletShoot
- del = Shootstype.BulletShoot;
- }
- break;
- default:
- {
- }
- break;
- }
- }
- void Update ()
- {
- if (Input.GetButtonDown("Fire1")) del();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement