void Awake() { if (Instance3 == null) { DontDestroyOnLoad(gameObject); Instance3 = this; } else if (Instance3 != this) { Destroy(gameObject); } }
void SetInitialReferences() { gunMaster = GetComponent <Gun_Master> (); if (GetComponent <Animator> () != null) { myAnimator = GetComponent <Animator> (); } if (GameManager_References._player != null) { playerMaster = GameManager_References._player.GetComponent <Player_Master> (); ammoBox = GameManager_References._player.GetComponent <Player_AmmoBoxZombie> (); } }
void OnEnable() { SetInitialReferences(); StartingSanityCheck(); CheckAmmoStatus(); ammoBox = GameObject.Find("SavePlayerPref").GetComponent <Player_AmmoBoxZombie>(); audio = GetComponent <AudioSource> (); gunMaster.EventPlayerInput += DeductAmmo; gunMaster.EventPlayerInput += CheckAmmoStatus; gunMaster.EventRequestReload += TryToReload; gunMaster.EventGunNotUsable += TryToReload; gunMaster.EventRequestGunReset += ResetGunReloading; if (playerMaster != null) { playerMaster.EventAmmoChanged += UIAmmoUpdateRequest; } if (ammoBox != null) { StartCoroutine(UpdateAmmoUIWhenEnabling()); } }