protected override void HandleShotRelease() { if (_isReloading) { return; } _isReloading = true; weaponStatusImage.enabled = true; weaponStatusImage.fillAmount = 0f; weaponStatusImage.color = Color.white; var proj = PoolManager.Instance.ReuseObject(_projectile, transform.position, transform.rotation); var projectileCollision = proj.GetComponentInChildren <ProjectileCollisionBehaviour> (); projectileCollision.aoeRadius = settings.aoeRadius; projectileCollision.damage = settings.damage; projectileCollision.crashSound = settings.explodeSound; PlayerAudioBehaviour.PlaySound(settings.launchSound, transform.position); var target = _crossHair.transform.position; float shotHeight = target.magnitude * settings.multiplier; proj.GetComponent <Rigidbody> ().velocity = PhysicsHelpers.velocityForBasketBallThrow(transform.position, target, shotHeight); _timeChanneled = 0f; }
private void FireIfNeeded() { if (_fireRate <= 0f) { _fireRate = settings.projectileSpeed; var proj = PoolManager.Instance.ReuseObject(_projectile, transform.position, transform.rotation); var projectileCollision = proj.GetComponentInChildren <ProjectileCollisionBehaviour> (); projectileCollision.aoeRadius = settings.aoeRadius; projectileCollision.damage = settings.damage; projectileCollision.crashSound = settings.explodeSound; PlayerAudioBehaviour.PlaySound(settings.launchSound, transform.position); var target = _crossHair.transform.position; target.x += UnityEngine.Random.Range(-0.5f, 0.5f); target.z += UnityEngine.Random.Range(-0.5f, 0.5f); float shotHeight = target.magnitude * settings.multiplier; proj.GetComponent <Rigidbody> ().velocity = PhysicsHelpers.velocityForBasketBallThrow(transform.position, target, shotHeight); } _timeChanneled += Time.deltaTime; weaponStatusImage.fillAmount = _timeChanneled / settings.channelTime; weaponStatusImage.color = Color.Lerp(Color.white, Color.red, _timeChanneled / settings.channelTime); if (weaponStatusImage.fillAmount >= 1f) { _state = EMachineGunState.reloading; _timeChanneled = 0f; } _fireRate -= Time.deltaTime; }
private void OnCollisionEnter(Collision collision) { Explode(); gameObject.SetActive(false); PlayerAudioBehaviour.PlaySound(crashSound, transform.position); var health = collision.gameObject.GetComponentInChildren <HealthBehaviour> (); if (health != null) { health.SubstractHealth(damage); } if (aoeRadius > 0f) { var colliders = Physics.OverlapSphere(transform.position, aoeRadius); for (int i = 0; i < colliders.Length; i++) { health = colliders [i].gameObject.GetComponentInChildren <HealthBehaviour> (); if (health == null || health.tag == "Player") { continue; } health.SubstractHealth(damage); } } }
private void OnEnable() { _current = Instantiate(startState); _current.OnEnter(gameObject); if (UnityEngine.Random.value > 0.99f) { PlayerAudioBehaviour.PlaySound(EAudioEventType.zombieGrowl, transform.position); } }
private void SetWeapon() { PlayerAudioBehaviour.PlaySound(EAudioEventType.reload, transform.position); for (int i = 0; i < weapons.Length; i++) { weapons [i].SetActive(false); } weapons [_currentIndex].SetActive(true); }
private void OnControlInputWasPerformed(InputBroadcasterBaseBehaviour sender, MovementInputEventArgs args) { if (Mathf.Approximately(args.horisontalWorldInputValue, 0f) && Mathf.Approximately(args.verticalWorldInputValue, 0f)) { _quedVelocityGain = Vector3.zero; } if (_canPlayAccelerate) { PlayerAudioBehaviour.PlaySound(EAudioEventType.accelerate, transform.position); _canPlayAccelerate = false; } _quedVelocityGain.x += args.horisontalWorldInputValue; _quedVelocityGain.z += args.verticalWorldInputValue; }
public override void Update() { if (_agent.enabled) { _agent.isStopped = false; var playerPos = GameGlobalsBehaviour.player.transform.position; if (Vector3.Distance(playerPos, _prevDestination) > stoppingDistance) { _agent.SetDestination(playerPos); if (Random.value > 0.99f) { PlayerAudioBehaviour.PlaySound(EAudioEventType.zombieGrowl, _body.transform.position); } _prevDestination = playerPos; } } }
protected override void HandleShotRelease() { _isCharging = false; weaponStatusImage.enabled = false; weaponStatusImage.fillAmount = 0f; weaponStatusImage.color = Color.white; var proj = PoolManager.Instance.ReuseObject(_projectile, transform.position, transform.rotation); var projectileCollision = proj.GetComponentInChildren <ProjectileCollisionBehaviour> (); projectileCollision.aoeRadius = settings.aoeRadius; projectileCollision.damage = settings.damage * _timeChanneled; projectileCollision.crashSound = settings.explodeSound; PlayerAudioBehaviour.PlaySound(settings.launchSound, transform.position); _projectileStartPositions.Add(proj, transform.position); _activeProjectiles.Add(proj); _timeChanneled = 0f; }
private void Start() { _instance = this; PoolManager.Instance.CreatePool(prefab.gameObject, 40); }
private void OnDisable() { _current.OnLeave(); PlayerAudioBehaviour.PlaySound(EAudioEventType.zombieMoan, transform.position); GetComponent <NavMeshAgent> ().enabled = false; }
public override void OnAnimationCallback() { GameGlobalsBehaviour.playerHealth.SubstractHealth(damage); PlayerAudioBehaviour.PlaySound(EAudioEventType.zombieAttack, _body.transform.position); }