Beispiel #1
0
 void Awake()
 {
     if (Instance3 == null)
     {
         DontDestroyOnLoad(gameObject);
         Instance3 = this;
     }
     else if (Instance3 != this)
     {
         Destroy(gameObject);
     }
 }
Beispiel #2
0
        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> ();
            }
        }
Beispiel #3
0
        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());
            }
        }