void Awake() { //get references and set default values gameManager = GameObject.FindGameObjectWithTag("GameManager"); gm = gameManager.GetComponent <GameManager>(); player = GameObject.FindGameObjectWithTag("Player"); playerHealth = player.GetComponent <BS_Main_Health>(); anim = GetComponentInChildren <Animator>(); chaseTarget = player.transform; fromCombat = false; canMove = true; isAttacking = false; firstAttack = true; health = gameObject.GetComponent <BS_Main_Health>(); doneThrowing = false; keepDistance = false; startingHealth = health._health; oldHealth = startingHealth; if (gameObject.name.Contains("Screamer")) { isScreamer = true; enemyType = "Screamer"; timerTime = 4f; } else if (gameObject.name.Contains("Boss")) { isBoss = true; enemyType = "Boss"; bottle = GetComponentInChildren <BottleProjectile>(); navMeshAgent = GetComponent <NavMeshAgent>(); boxCollider = GetComponent <BoxCollider>(); } else if (gameObject.name.Contains("Grunt")) { isGrunt = true; enemyType = "Grunt"; navMeshAgent = GetComponent <NavMeshAgent>(); } //call audio sa = GetComponent <ScreamerAudio>(); }
public float overrideAmount; // Overrides recoverAmount by designated % chosen private void Awake() { pickupSound = GameObject.FindGameObjectWithTag("HealthAudio").GetComponent <AudioSource>(); playerHealth = GameObject.FindGameObjectWithTag("Player").GetComponent <BS_Main_Health>(); }
void Update() { if (_markersAreEnabled) { int i; for (i = 0; i < _markers.Length; i++) //Let's check what each marker hits, shall we? { if (_markers [i].HitCheck() != null) { //Each target in this marker's Hit Check get's checked for (int t = 0; t < _markers[i]._target.Count; t++) { if (_markers [i]._target[t].tag == _shieldTag && _Targets_Raw_Hit.Contains(_markers [i]._target[t]) == false && _Shields_Hit.Contains(_markers [i]._target[t].transform) == false && _Used_Targets.Contains(_markers [i]._target[t]) == false && _Used_Targets.Contains(_markers [i]._target[t].GetComponent <BS_Shield>()._ParentHealth.transform) == false) { BS_Shield TheS = _markers [i]._target[t].GetComponent <BS_Shield>(); if (_AdvancedShieldDetection) { dh = Vector3.Distance(_advShieldDetectionOrigin.position, TheS._ShieldBackSpot.transform.position); ds1 = Vector3.Distance(_advShieldDetectionOrigin.position, TheS._ShieldCenterSpot.transform.position); //center ds2 = Vector3.Distance(_advShieldDetectionOrigin.position, TheS._ShieldEdgeSpot1.transform.position); //Top ds3 = Vector3.Distance(_advShieldDetectionOrigin.position, TheS._ShieldEdgeSpot2.transform.position); //Top Left ds4 = Vector3.Distance(_advShieldDetectionOrigin.position, TheS._ShieldEdgeSpot3.transform.position); //Top Right ds5 = Vector3.Distance(_advShieldDetectionOrigin.position, TheS._ShieldEdgeSpot4.transform.position); //Bottom ds6 = Vector3.Distance(_advShieldDetectionOrigin.position, TheS._ShieldEdgeSpot5.transform.position); //Bottom Left ds7 = Vector3.Distance(_advShieldDetectionOrigin.position, TheS._ShieldEdgeSpot6.transform.position); //Bottom Right ds8 = Vector3.Distance(_advShieldDetectionOrigin.position, TheS._ShieldEdgeSpot7.transform.position); //Right ds9 = Vector3.Distance(_advShieldDetectionOrigin.position, TheS._ShieldEdgeSpot8.transform.position); //Left Debug.DrawRay(_advShieldDetectionOrigin.position, TheS._ShieldCenterSpot.transform.position - _advShieldDetectionOrigin.position, Color.red, 5); Debug.DrawRay(_advShieldDetectionOrigin.position, TheS._ShieldEdgeSpot7.transform.position - _advShieldDetectionOrigin.position, Color.blue, 5); Debug.DrawRay(_advShieldDetectionOrigin.position, TheS._ShieldEdgeSpot1.transform.position - _advShieldDetectionOrigin.position, Color.blue, 5); Debug.DrawRay(_advShieldDetectionOrigin.position, TheS._ShieldEdgeSpot2.transform.position - _advShieldDetectionOrigin.position, Color.blue, 5); Debug.DrawRay(_advShieldDetectionOrigin.position, TheS._ShieldEdgeSpot3.transform.position - _advShieldDetectionOrigin.position, Color.blue, 5); Debug.DrawRay(_advShieldDetectionOrigin.position, TheS._ShieldEdgeSpot4.transform.position - _advShieldDetectionOrigin.position, Color.blue, 5); Debug.DrawRay(_advShieldDetectionOrigin.position, TheS._ShieldEdgeSpot6.transform.position - _advShieldDetectionOrigin.position, Color.blue, 5); Debug.DrawRay(_advShieldDetectionOrigin.position, TheS._ShieldEdgeSpot5.transform.position - _advShieldDetectionOrigin.position, Color.blue, 5); Debug.DrawRay(_advShieldDetectionOrigin.position, TheS._ShieldEdgeSpot8.transform.position - _advShieldDetectionOrigin.position, Color.blue, 5); } if (((dh > ds1) || (dh > ds2) || (dh > ds3) || (dh > ds4) || (dh > ds5) || (dh > ds6) || (dh > ds7) || (dh > ds8) || (dh > ds9)) || (_AdvancedShieldDetection == false)) { _wallHitPositions.Add(_markers[i]._hit[t].point); _Shields_Hit.Add(_markers [i]._target[t].transform); HitShield = true; if (TheS._ParentHealth.transform != null) { _Used_Targets.Add(TheS._ParentHealth.transform); } } } if (_markers [i]._target[t].tag == _targetTag && _Targets_Raw_Hit.Contains(_markers [i]._target[t]) == false && _Used_Targets.Contains(_markers [i]._target[t]) == false) { _Blade_Direction.Add(_markers [i]._tempPos); _Blade_Startpoint.Add(_markers [i]._hit[t].point); HitFlesh = true; if (_markers [i]._target[t].GetComponent <BS_Main_Health>() != null) { _Raw_Target_Instance = _markers [i]._target[t].GetComponent <BS_Main_Health>(); } if (_markers [i]._target[t].GetComponent <BS_Limb_Hitbox>() != null) { _Raw_Target_Instance = _markers [i]._target[t].GetComponent <BS_Limb_Hitbox>().MainHealth; _Used_Targets.Add(_markers [i]._target[t].transform); } if (_Raw_Target_Instance != null) { _Targets_Raw_Hit.Add(_Raw_Target_Instance.transform); } if (_Raw_Target_Instance != null && _Raw_Target_Instance._shield != null) { _Used_Targets.Add(_Raw_Target_Instance._shield.transform); } } if (_markers [i]._target[t].tag != _targetTag && _markers [i]._target[t].tag != _shieldTag && _Used_Targets.Contains(_markers [i]._target[t]) == false) { _Used_Targets.Add(_markers [i]._target[t].transform); HitWall = true; _wallHitPositions.Add(_markers [i]._hit[t].point); } } } if (i > _markers.Length) { i = 0; } } // dealing damage and staggering if (HitShield) { for (int i1 = 0; i1 < _Shields_Hit.Count; i1++) { { if (!_Used_Targets.Contains(_Shields_Hit[i1])) { PlayShieldHitSound(); BS_Shield shield = _Shields_Hit[i1].GetComponent <BS_Shield>(); shield.BlockStagger(); _Used_Targets.Add(_Shields_Hit[i1]); } } } } if (HitWall || HitShield) { if (HitWall) { PlayWallHitSound(); } for (int i3 = 0; i3 < _wallHitPositions.Count; i3++) { if (_wallHitSparks != null) { _missSparks = Instantiate(_wallHitSparks, _wallHitPositions[i3], Quaternion.identity) as GameObject; _missSparks.transform.LookAt(_MarkersParent); } } if (StaggerOnShieldHit && HitShield) { Stagger(); } if (StaggerOnWallHit && HitWall) { Stagger(); } } if (HitFlesh) { for (int i2 = 0; i2 < _Targets_Raw_Hit.Count; i2++) { if (_Targets_Raw_Hit[i2] != null && _Targets_Raw_Hit[i2].GetComponent <BS_Main_Health> () != null && _Used_Targets.Contains(_Targets_Raw_Hit[i2]) == false) { BS_Main_Health TargetRawHealth = _Targets_Raw_Hit[i2].GetComponent <BS_Main_Health> (); TargetRawHealth.Bloodflood(_Blade_Direction[i2], _Blade_Startpoint[i2]); TargetRawHealth.ApplyDamage(_damage); PlayTargetHitSound(); if (Blood != null) { GameObject b = Instantiate(Blood, _Blade_Startpoint[i2], Quaternion.identity) as GameObject; b.transform.LookAt(_MarkersParent); } _Used_Targets.Add(_Targets_Raw_Hit[i2]); } if (_Targets_Raw_Hit[i2] != null && _Targets_Raw_Hit[i2].GetComponent <BS_Limb_Hitbox> () != null && _Used_Targets.Contains(_Targets_Raw_Hit[i2]) == false) { BS_Limb_Hitbox TargetRawLimb = _Targets_Raw_Hit[i2].GetComponent <BS_Limb_Hitbox> (); TargetRawLimb.MainHealth.Bloodflood(_Blade_Direction[i2], _Blade_Startpoint[i2]); TargetRawLimb.MainHealth.ApplyDamage(_damage); PlayTargetHitSound(); if (Blood != null) { GameObject b = Instantiate(Blood, _Blade_Startpoint[i2], Quaternion.identity) as GameObject; b.transform.LookAt(_MarkersParent); } _Used_Targets.Add(TargetRawLimb.MainHealth.transform); } } } } _Blade_Direction.Clear(); _Blade_Startpoint.Clear(); _Targets_Raw_Hit.Clear(); _wallHitPositions.Clear(); HitWall = false; HitFlesh = false; HitShield = false; if (ContinuousDamage) { _ContinuousDamage_Timer += Time.deltaTime; if (_ContinuousDamage_Timer >= ContinuousDamageInterval) { ClearTargets(); _ContinuousDamage_Timer = 0; } } }