private void ShieldAttack() { transform.Find("Shield").gameObject.SetActive(true); _isShielded = true; _myAtk = whichAttack.None; _waiting = false; _attacking = false; _showingTheTell = false; _myCurrState = AIState.ALERTED; }
private void RingAttack() { if (!_DotGameObj) { _DotGameObj = Instantiate(DOTObj, transform.position + (Vector3.down / 2), DOTObj.transform.rotation, null); } _waiting = false; _attacking = false; _showingTheTell = false; _myCurrState = AIState.ALERTED; _myAtk = whichAttack.None; }
private void MeleeAttack() { if (_waiting) { //Debug.Log("waiting"); _currentAttackTime = (Time.time - _startAttackTime) / _durationBetweenAttacks; if (_currentAttackTime > 1) { _currentAttackTime = 1; _waiting = false; _attacking = false; _showingTheTell = false; _myCurrState = AIState.ALERTED; } Vector3 p01; p01 = (1 - _currentAttackTime) * c0 + _currentAttackTime * c1; transform.position = p01; } else { //Debug.Log("attacking"); //transform.LookAt(_player.transform.position); _currentAttackTime = (Time.time - _startAttackTime) / _attackSwingDuration; if (_currentAttackTime > 1) { _currentAttackTime = 1; _waiting = true; c0 = transform.position; c1 = transform.position; _startAttackTime = Time.time; _myAtk = whichAttack.None; } else { transform.LookAt(c1); if (Physics.Raycast(transform.position, transform.forward, out hit, _damageDistance)) { if (hit.collider.GetComponent <PlayerStats>()) { hit.collider.GetComponent <PlayerStats>().PDamage(_enemyDamage); //Debug.Log("hit player"); _waiting = true; c0 = transform.position; c1 = transform.position; _startAttackTime = Time.time; _myAtk = whichAttack.None; } } } Vector3 p01; p01 = (1 - _currentAttackTime) * c0 + _currentAttackTime * c1; transform.position = p01; } }
private void RangedAttack() { if (_waiting) { //Debug.Log("waiting"); _currentAttackTime = (Time.time - _startAttackTime) / _durationBetweenAttacks; if (_currentAttackTime > 1) { _currentAttackTime = 1; _waiting = false; _attacking = false; _showingTheTell = false; _myCurrState = AIState.ALERTED; } Vector3 p01; p01 = (1 - _currentAttackTime) * c0 + _currentAttackTime * c1; transform.position = p01; } else { //Debug.Log("attacking"); //transform.LookAt(_player.transform.position); _currentAttackTime = (Time.time - _startAttackTime) / _attackSwingDuration; if (_currentAttackTime > 1) { _currentAttackTime = 1; _waiting = true; c0 = transform.position; c1 = transform.position; _startAttackTime = Time.time; } else { transform.LookAt(c1); projectileRanged _proj = Instantiate <GameObject>(_projectile, _launchPos.position, transform.rotation, null).GetComponent <projectileRanged>(); projectileRanged _proj2 = Instantiate <GameObject>(_projectile, _launchPos.position, transform.rotation * Quaternion.Euler(0, _shotSpread, 0), null).GetComponent <projectileRanged>(); projectileRanged _proj3 = Instantiate <GameObject>(_projectile, _launchPos.position, transform.rotation * Quaternion.Euler(0, -_shotSpread, 0), null).GetComponent <projectileRanged>(); _proj._speed = _projSpeed; _proj._maxRange = _maxRange; _proj._damage = _enemyDamage; _proj2._speed = _projSpeed; _proj2._maxRange = _maxRange; _proj2._damage = _enemyDamage; _proj3._speed = _projSpeed; _proj3._maxRange = _maxRange; _proj3._damage = _enemyDamage; _waiting = true; c0 = transform.position; c1 = transform.position; _startAttackTime = Time.time; _myAtk = whichAttack.None; } Vector3 p01; p01 = (1 - _currentAttackTime) * c0 + _currentAttackTime * c1; transform.position = p01; } }
protected override void CombatStrats() { if (Vector3.Distance(transform.position, _player.transform.position) <= _followDistanceThreshold) { if (!_sword.activeInHierarchy) { _sword.SetActive(true); } if (Vector3.Distance(transform.position, _player.transform.position) <= _attackDistanceThreshold) { if (_myAtk == whichAttack.None) { float atk = Random.Range(0, 100); float chance = _percentMelee; for (int i = 0; i < 5; i++) { if (atk < chance) { _myAtk = (whichAttack)i; break; } else { switch (i) { case 0: chance += _percentRanged; break; case 1: chance += _percentRing; break; case 2: chance += _percentShield; break; case 3: chance += _percentHeal; break; case 4: Debug.Log("Something Went Wrong With Boss Attack Selection"); break; } } } } if (!_attacking) { AttackTell(); } else { switch (_myAtk) { case whichAttack.Melee: Debug.Log("Melee"); MeleeAttack(); break; case whichAttack.Ranged: Debug.Log("Ranged"); RangedAttack(); break; case whichAttack.Ring: Debug.Log("Ring"); RingAttack(); break; case whichAttack.Shield: Debug.Log("Shield"); ShieldAttack(); break; case whichAttack.Heal: if (_currEnemyHealth < _enemyHealth) { Debug.Log("Heal"); HealAttack(); } else { _waiting = false; _attacking = false; _showingTheTell = false; _myCurrState = AIState.ALERTED; _myAtk = whichAttack.None; } break; case whichAttack.None: Debug.Log("Something Went Wrong With Boss Attack Selection"); break; } } } else { FollowPlayer(); } } else { LostSightOfPlayer(); } }