public void Start()    //Used to determine default values and grab references.
    {
        if (isLocalPlayer) //Checks whether or not the player script is attached to the local player.
        {
            isDowned   = false;
            playerDead = false;
            curHealth  = maxHealth;
            controller = gameObject.GetComponent <CharacterController>();
            camera.SetActive(true);
            //hand = GameObject.Find("Hand");
            curWeapons.Add(WeaponType.AddWeapon("Pistol"));
            Instantiate(curWeapons[0].Gun, hand.transform.position, Quaternion.identity, hand.transform);
            shotCooldown    = curWeapons[0].FireRate;
            hud             = GameObject.FindGameObjectWithTag("UI").GetComponent <HUD>();
            hud.localPlayer = this;

            Cursor.lockState = CursorLockMode.Locked;
            rifleSound       = GetComponent <AudioSource>(); // Gets the audio source
        }
    }
 public void CmdInteractions()        //Used to check all interactions between the player and the environment/entities.
 {
     if (Input.GetKeyDown(KeyCode.E)) //Checks whether or not the player is attempting to interact and shoots a raycast out.
     {
         Vector3    mousePosition = camera.GetComponentInChildren <Camera>().ViewportToWorldPoint(new Vector3(0.5f, 0.5f, 0));
         RaycastHit hit;
         if (Physics.Raycast(mousePosition, camera.transform.forward, out hit, interactRange)) //Checks whether or not the raycast has hit anything.
         {
             if (hit.collider.tag == "Player")                                                 //If the raycast hits another player while they are downed, begin reviving.
             {
                 hit.collider.GetComponent <Player>().beingRevived = true;
                 revivingPlayer = true;
             }
             if (hit.collider.tag == "PerkMachine") //If the raycast hits a PerkMachine, check whether or not the player is able to buy said perk and add it to the curPerk list if they can.
             {
                 PerkMachine perkHitRef = hit.collider.GetComponent <PerkMachine>();
                 if (PerkCheck(perkHitRef.Perk) == false) //Checks whether or not the player has already received this perk.
                 {
                     if (money >= perkHitRef.Cost)        //Checks if the player has enough money for the perk.
                     {
                         money -= perkHitRef.Cost;
                         curPerks.Add(PerkData.AddPerk(perkHitRef.Perk));
                         curPerks[curPerks.Count - 1].ApplyStats(this);
                     }
                 }
             }
             if (hit.collider.tag == "GunVendor") //If the raycast hits a GunVendor, check whether or not the player does not already have said gun and either allow the player to buy said gun or refill ammo.
             {
                 WeaponVendor weaponHitRef = hit.collider.GetComponent <WeaponVendor>();
                 Debug.Log("Registered Weapon Vendor");
                 if (WeaponCheck(weaponHitRef.WeaponName) == false) //Checks whether or not the player already has the gun.
                 {
                     Debug.Log("Name Check Complete Weapon Vendor");
                     if (money >= weaponHitRef.Cost) //Checks whether or not the player has enough money for the gun and if they do, buys it.
                     {
                         money -= weaponHitRef.Cost;
                         curWeapons.Add(WeaponType.AddWeapon(weaponHitRef.WeaponName));
                     }
                 }
                 else //If the player alreay has the gun, allows the player to buy a ammo refill.
                 {
                     if (money >= weaponHitRef.Cost) //Checks whether or not the player has enough money for the refill.
                     {
                         money -= weaponHitRef.Cost;
                         for (int i = 0; i < curWeapons.Count; i++) //Checks whether or not the weapon is in the current weapon slot and applies the ammo refill.
                         {
                             if (curWeapons[i].Name == weaponHitRef.WeaponName)
                             {
                                 curWeapons[i].Ammo = curWeapons[i].AmmoMax;
                             }
                         }
                     }
                 }
             }
             if (hit.collider.tag == "Door") //If the raycast hits a Door, check whether or not the player has enough money to open said door
             {
                 Door doorHitRef = hit.collider.GetComponentInParent <Door>();
                 int  doorIndex  = GetNumberFromString(hit.collider.name);
                 if (doorHitRef.doorOpen[doorIndex] == false) //Checks whether or not the door has already been openned.
                 {
                     if (money >= doorHitRef.cost[doorIndex]) //If the player has enough money for the door, buys the door and opens it.
                     {
                         money -= doorHitRef.cost[doorIndex];
                         doorHitRef.OpenDoor(doorIndex);
                     }
                 }
             }
         }
     }
 }