void Awake() { if (weapons == null) { weapons = this; } else if (weapons != this) { } }
void Awake() { gunSlot = FindObjectOfType <SwitchingWeapon>(); gunSlot.WeaponHaveSwitched.AddListener(WeaponSwitching); if (gunSlot != null) { weaponDataBase = gunSlot.GetComponentInChildren <WeaponDataBase>(); } }
void Start() { fpsc = GetComponentInParent <FirstPersonController>(); armesUI = FindObjectOfType <ArmesUIScript>(); controller = GetComponentInChildren <WeaponDataBase>(); audioSource = GetComponent <AudioSource>(); if (WeaponHaveSwitched == null) { WeaponHaveSwitched = new UnityEvent(); } InstantiateWeapon(0); }
public static WeaponDataBase GetInstance() { if (instance == null) // 如果没有找到 { { GameObject go = new GameObject("WeaponDataBase"); // 创建一个新的GameObject DontDestroyOnLoad(go); // 防止被销毁 instance = go.AddComponent <WeaponDataBase>(); // 将实例挂载到GameObject上 } } return instance; }
void Start() { gunSlot = FindObjectOfType <SwitchingWeapon>(); gunSlot.WeaponHaveSwitched.AddListener(WeaponSwitching); if (gunSlot != null) { weaponDataBase = gunSlot.GetComponentInChildren <WeaponDataBase>(); } shootMecanics = gunSlot.GetComponentInChildren <ShootMecanics>(); shootMecanics.BulletShot.AddListener(BulletShot); shootMecanics.ReloadGun.AddListener(ReloadGun); }
public WeaponFactory(WeaponDataBase _weaponDB) { weaponDB = _weaponDB; }
private void InitWeaponDB() { weaponDataBase = new WeaponDataBase(); }