This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private void Start() | |
{ | |
_weaponAmmo = new WeaponAmmo(_weaponSettings); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private void OnEnable() | |
{ | |
_controller = GetComponentInParent<SteamVR_TrackedController>(); | |
_controller.TriggerClicked += HandleTriggerClicked; | |
_controller.Gripped += HandleGripClicked; | |
} | |
private void OnDisable() | |
{ | |
_controller.TriggerClicked -= HandleTriggerClicked; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private void HandleGripClicked(object sender, ClickedEventArgs e) | |
{ | |
_weaponAmmo.Reload(); | |
} | |
private void HandleTriggerClicked(object sender, ClickedEventArgs e) | |
{ | |
if (CanFire) | |
{ | |
if (_weaponAmmo.TryTakeBullet()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private void Fire() | |
{ | |
ResetWeaponRefreshTimer(); | |
RaycastHit hitInfo; | |
var takeDamage = RaycastHelper.TryHitTarget<ITakeDamage>(_muzzlePoint, _weaponSettings.MaxRange, out hitInfo); | |
if (takeDamage != null) | |
DealDamageToDamageTaker(takeDamage); | |
else |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private void ResetWeaponRefreshTimer() | |
{ | |
_nextFireTime = Time.deltaTime + _weaponSettings.FireDelay; | |
} | |
private void DealDamageToDamageTaker(ITakeDamage shootable) | |
{ | |
shootable.TakeDamage(GetDamage()); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private void OnDrawGizmos() | |
{ | |
Gizmos.color = Color.green; | |
Gizmos.DrawRay(_muzzlePoint.position, _muzzlePoint.forward); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
public class ShootableBox : MonoBehaviour, ITakeDamage | |
{ | |
[SerializeField] | |
private int _initialHealth = 2; | |
[SerializeField] | |
private ParticleSystem _explosionParticle; | |
private int _currentHealth; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public event ClickedEventHandler MenuButtonClicked; | |
public event ClickedEventHandler MenuButtonUnclicked; | |
public event ClickedEventHandler TriggerClicked; | |
public event ClickedEventHandler TriggerUnclicked; | |
public event ClickedEventHandler SteamClicked; | |
public event ClickedEventHandler PadClicked; | |
public event ClickedEventHandler PadUnclicked; | |
public event ClickedEventHandler PadTouched; | |
public event ClickedEventHandler PadUntouched; | |
public event ClickedEventHandler Gripped; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
public class PrimitiveCreator : MonoBehaviour | |
{ | |
private SteamVR_TrackedController _controller; | |
private PrimitiveType _currentPrimitiveType = PrimitiveType.Sphere; | |
private void OnEnable() | |
{ | |
_controller = GetComponent<SteamVR_TrackedController>(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private SteamVR_TrackedController _controller; | |
private PrimitiveType _currentPrimitiveType = PrimitiveType.Sphere; | |
private void OnEnable() | |
{ | |
_controller = GetComponent<SteamVR_TrackedController>(); | |
_controller.TriggerClicked += HandleTriggerClicked; | |
_controller.PadClicked += HandlePadClicked; | |
} |