void Update() { if (Input.GetKeyDown(KeyCode.Space)) { Debug.Log("Player attacked!"); manager.Attack(entity); } }
protected override void FireWeapon() { //Debug.Log("Firing"); if (WeaponStats.BulletsInClip > 0 && !WeaponHolder.PlayerController.IsReloading && !WeaponHolder.PlayerController.IsRunning) { base.FireWeapon(); Ray screenRay = MainCamera.ScreenPointToRay(new Vector3(Crosshair.CurrentMousePosition.x, Crosshair.CurrentMousePosition.y, 0)); if (!Physics.Raycast(screenRay, out RaycastHit hit, WeaponStats.FireDistance, WeaponStats.WeaponHitLayer)) { return; } Entity hitEntity = hit.transform.GetComponent <Entity>(); if (hitEntity != null) { CombatManager.Attack(this.GetComponentInParent <Entity>(), hitEntity, this); } HitLocation = hit.point; Vector3 hitDirection = hit.point - MainCamera.transform.position; //Debug.DrawRay(MainCamera.transform.position, hitDirection * WeaponStats.FireDistance, Color.red); Debug.DrawLine(MainCamera.transform.position, HitLocation, Color.red, WeaponStats.FireRate); } else if (WeaponStats.BulletsInClip <= 0) { if (!WeaponHolder) { return; } WeaponHolder.StartReloading(); } }