//decides what the attack the boss will do next (Currently Out of Use but setup fordifferent attacks. private void WhatDoNext() { float _nextAttack = Random.Range(0, _totalPercentageFireTrap); Debug.Log("Next attack: " + _nextAttack); if (currentTrap.GetComponent <SpikeTrap>()) { _MyAttack = TRAPSTRATS.SPIKETRAP; } else if (currentTrap.GetComponent <DartTrap>()) { _MyAttack = TRAPSTRATS.DARTTRAP; } else if (currentTrap.GetComponent <BossFireStatueTrap>()) { if (_nextAttack > 0 && _nextAttack <= _realQuadFirePercentage) { Debug.Log("Quad Fire"); _MyAttack = TRAPSTRATS.QUADFIRE; } else { Debug.Log("XATTACK"); _MyAttack = TRAPSTRATS.XATTACK; } } }
private void DartMachineGun() { for (int i = 0; i <= _numOfCasts; i++) { float Xpos = Mathf.Cos(_calcAngle * Mathf.Deg2Rad) * _bossCollisionDetectDistance; float Zpos = Mathf.Sin(_calcAngle * Mathf.Deg2Rad) * _bossCollisionDetectDistance; Vector3 RayDir = (transform.forward * Zpos) + (transform.right * Xpos); if (_debug) { Debug.DrawLine(transform.position + (Vector3.up * _vertDetectOffset), transform.position + (Vector3.up * _vertDetectOffset) + (RayDir * _bossCollisionDetectDistance), Color.red); } if (Physics.Raycast(transform.position + Vector3.up, RayDir, out hitObj, _bossCollisionDetectDistance)) { GameObject hitObject = hitObj.collider.gameObject; if (hitObject == currentTrap) { DartTrap possessedTrap = hitObject.GetComponent <DartTrap>(); possessedTrap.BecomePossessed(this, _realDartPossessTime, _realDartFireDelay, _realDartSpawnDelay, _realDartShooterMoveSpeed, _DartXMin, _DartXMax, _DartZMin, _DartZMax); trapComplete = false; _MyAttack = TRAPSTRATS.INSIDETRAP; } } } _calcAngle = _startAngle; }
//Detects when he gets to the targeted tower and starts the quad fire attack on the pillar. private void QuadFireBeams() { for (int i = 0; i <= _numOfCasts; i++) { float Xpos = Mathf.Cos(_calcAngle * Mathf.Deg2Rad) * _bossCollisionDetectDistance; float Zpos = Mathf.Sin(_calcAngle * Mathf.Deg2Rad) * _bossCollisionDetectDistance; Vector3 RayDir = (transform.forward * Zpos) + (transform.right * Xpos); if (_debug) { Debug.DrawLine(transform.position + (Vector3.up * _vertDetectOffset), transform.position + (Vector3.up * _vertDetectOffset) + (RayDir * _bossCollisionDetectDistance), Color.red); } _calcAngle += _detectionAngle / _numOfCasts; if (Physics.Raycast(transform.position + (Vector3.up * _vertDetectOffset), RayDir, out hit, _bossCollisionDetectDistance)) { if (hit.collider.GetComponent <PlayerController>()) { hit.collider.GetComponent <PlayerController>().TakeDamage(_bossDamage); } } } _calcAngle = _startAngle; if (Physics.Raycast(transform.position + Vector3.up, this.transform.forward, out hitObj, _detectDistance)) { GameObject hitObject = hitObj.collider.gameObject; if (hitObject == currentTrap) { //Moves all the variables from the boss to each fire trap gameobject for (int z = 0; z < 4; z++) { BossFireStatueTrap possessedTrap = hitObject.GetComponent <Transform>().GetChild(z).GetComponent <BossFireStatueTrap>(); if (_xAttack) { possessedTrap.transform.eulerAngles += new Vector3(0, 45f, 0); possessedTrap.GetXAttack = true; } possessedTrap.GetBossEntity = this.gameObject; possessedTrap.GetFireDelay = _realQuadFireStartDelay; possessedTrap.GetFireDistance = _realQuadShootDist; possessedTrap.GetMaxDetectDistance = _realQuadDetectDist; possessedTrap.GetStartDelay = _quadStartDelay; possessedTrap.GetBurningDuration = _realQuadBurnDuration; possessedTrap.GetFireDamage = _realQuadTrapDamage; possessedTrap.StartingDelay(); trapComplete = false; } _MyAttack = TRAPSTRATS.INSIDETRAP; } } }
//Attack //Boss possesses trap by disabling his own mesh and collider. (Room for animation) //When the trap finishes its attack he will be reinabled and find a new trap private void possessTrap() { gameObject.GetComponent <MeshRenderer>().enabled = false; gameObject.GetComponent <CapsuleCollider>().enabled = false; if (trapComplete) { _xAttack = false; gameObject.GetComponent <MeshRenderer>().enabled = true; gameObject.GetComponent <CapsuleCollider>().enabled = true; _MyAttack = TRAPSTRATS.FINDTRAP; } }
//decides what the attack the boss will do next (Currently Out of Use but setup fordifferent attacks. private void WhatDoNext() { float _nextAttack = Random.Range(0, _totalPercentageFireTrap); Debug.Log("Next attack: " + _nextAttack); if (_nextAttack > 0 && _nextAttack <= _realQuadFirePercentage) { Debug.Log("Quad Fire"); _MyAttack = TRAPSTRATS.QUADFIRE; } else { Debug.Log("XATTACK"); _MyAttack = TRAPSTRATS.XATTACK; } }
//Reset function public override void MyReset() { if (_init) { gameObject.SetActive(true); _myRenderer.enabled = true; _myColor.a = 1; _myMaterial.color = _myColor; _myRenderer.materials[1] = _myMaterial; _enemyAgent.enabled = false; //Debug.Log("Boss Reset"); transform.position = _startPos; transform.rotation = _startRot; /* * _enemiesToCrush.SetActive(true); * for (int i = 0; i < _GlhostsUnderMe.Count; i++) * { * _GlhostsUnderMe[i].ResetCutscene(); * } */ _currBossHealth = _actualMaxHealth; _laggedBossHealthBar.fillAmount = 1; _actualBossHealthBar.fillAmount = 1; _bossBar.SetActive(false); _cameraInPosition = false; //_fallFinished = false; //_turnToPlayerFinished = false; //_glhostsCrushed = false; _endingPlaying = false; _laggingHealth = false; _updatingHealth = false; _dead = false; _amHit = false; _invincible = false; _myAI = BossAI.NONE; _MyAttack = TRAPSTRATS.FINDTRAP; _init = false; } }
//Attack //Boss possesses trap by disabling his own mesh and collider. (Room for animation) //When the trap finishes its attack he will be reinabled and find a new trap private void PossessTrap() { gameObject.GetComponent <MeshRenderer>().enabled = false; gameObject.GetComponent <CapsuleCollider>().enabled = false; Vector3 possessPosition = currentTrap.transform.localPosition; possessPosition.y = transform.position.y; transform.position = possessPosition; if (trapComplete) { _xAttack = false; gameObject.GetComponent <MeshRenderer>().enabled = true; gameObject.GetComponent <CapsuleCollider>().enabled = true; _enemyAgent.SetDestination(transform.position); _MyAttack = TRAPSTRATS.FINDTRAP; } }
private void SpikeFollow() { if (_debug) { Debug.DrawRay(transform.position + (Vector3.up * _vertDetectOffset), Vector3.down * _bossCollisionDetectDistance); } if (Physics.Raycast(transform.position + Vector3.up, Vector3.down, out hitObj, _bossCollisionDetectDistance)) { GameObject hitObject = hitObj.collider.gameObject; if (hitObject == currentTrap) { BossSpikeTrap possessedTrap = hitObject.GetComponent <BossSpikeTrap>(); possessedTrap.BecomePossessed(this, _realSpikePossessTime, _realSpikeAttackSpeed, _realSpikeAttackDelay, _realSpikeRetreatSpeed, _realSpikeFollowSpeed); trapComplete = false; _MyAttack = TRAPSTRATS.INSIDETRAP; } } }