예제 #1
0
    //decides what the attack the boss will do next
    private void WhatDoNext()
    {
        _currAttackTime = (Time.time - _startAttackTime) / _realTimeBetweenAttacks;
        //Debug.Log("thinking");

        if (_currAttackTime >= 1)
        {
            float _nextAttack = Random.Range(0, _totalPercentage);

            if (_nextAttack > 0 && _nextAttack <= _realFollowPercentage)
            {
                //Debug.Log("follow Chosen");
                _startAttackTime = Time.time;
                _MyAttack        = SPINSTRATS.FOLLOW;
            }
            else if (_nextAttack > _realFollowPercentage && _nextAttack <= (_realFollowPercentage + _realSpinAttackPercentage))
            {
                //Debug.Log("spin Chosen");

                _enemyAgent.enabled = false;
                _startAttackTime    = Time.time;
                _startSpawnTime     = Time.time;
                _MyAttack           = SPINSTRATS.SPIN;
            }
            else
            {
                //Debug.Log("pinball Chosen");
                _tellPinballing     = true;
                _enemyAgent.enabled = false;
                _startAttackTime    = Time.time;
                _MyAttack           = SPINSTRATS.PINBALL;
            }
        }
    }
예제 #2
0
    //once the boss is done with their attack
    //will do nothing for an amount of time
    private void Stunned()
    {
        _currAttackTime = (Time.time - _startAttackTime) / _realStunnedDuration;

        //Debug.Log("stunned");

        if (_currAttackTime >= 1)
        {
            _MyAttack        = SPINSTRATS.DOWNTIME;
            _startAttackTime = Time.time;
        }
    }
예제 #3
0
    //Attack
    //Boss will spin in place
    //Boss will spawn and shoot ghosts out in random directions
    private void SpinInPlace()
    {
        _currAttackTime = (Time.time - _startAttackTime) / _realSpinAttackDuration;
        _currSpawnTime  = (Time.time - _startSpawnTime) / _realSpawnDelayDuration;

        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;

        transform.Rotate(Vector3.up, _realSpinningSpeed);
        //Debug.Log("spinning");

        if (_currAttackTime >= 1)
        {
            //Debug.Log("spinning Done");
            _invincible         = false;
            _enemyAgent.enabled = true;
            _MyAttack           = SPINSTRATS.STUNNED;
            _startAttackTime    = Time.time;
        }

        if (_currSpawnTime >= 1)
        {
            _currSpawnTime = 1;
            GameObject _newEnemy = Instantiate <GameObject>(_enemyToSpawn, transform.position, transform.rotation);
            _newEnemy.GetComponent <BaseEnemy>().Init(_myRoom, Mechanic.BOSS);
            _startSpawnTime = Time.time;
        }
    }
예제 #4
0
    //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 = SPINSTRATS.FOLLOW;
            _init     = false;
        }
    }
예제 #5
0
    //Attack
    //Enemy just follows the player for a certain amount of time
    private void FollowPlayer()
    {
        _enemyAgent.SetDestination(_playerRef.transform.position);

        _currAttackTime = (Time.time - _startAttackTime) / _realFollowDuration;

        //Debug.Log("following");

        if (_currAttackTime >= 1)
        {
            _enemyAgent.SetDestination(transform.position);

            _MyAttack        = SPINSTRATS.DOWNTIME;
            _startAttackTime = Time.time;
        }

        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;
    }
예제 #6
0
    public override void MyReset()
    {
        if (_init)
        {
            gameObject.SetActive(true);
            _mySkinRenderer.enabled = true;
            _myColor.a                   = 1;
            _myMaterial.color            = _myColor;
            _mySkinRenderer.materials[1] = _myMaterial;

            _enemyAgent.enabled = false;
            //Debug.Log("Boss Reset");
            transform.position = _startPos;
            transform.rotation = _startRot;

            _currBossHealth = _actualMaxHealth;
            _laggedBossHealthBar.fillAmount = 1;
            _actualBossHealthBar.fillAmount = 1;

            _bossBar.SetActive(false);
            _cameraInPosition = false;
            _spinAroundStart  = false;
            _spinAroundScreen = false;
            _spinAroundEnd    = false;

            _endingPlaying  = false;
            _laggingHealth  = false;
            _updatingHealth = false;
            _dead           = false;
            _amHit          = false;
            _invincible     = false;

            _myAI     = BossAI.NONE;
            _MyAttack = SPINSTRATS.FOLLOW;
            _init     = false;
        }
    }
예제 #7
0
    //Attack
    //Boss will spin
    //Boss will shoot out towards the player and richochet off of walls for a duration
    private void PlaySomePinball()
    {
        if (_tellPinballing)
        {
            _currAttackTime = (Time.time - _startAttackTime) / _realPinballTellDuration;

            if (_currAttackTime >= 1)
            {
                _currAttackTime  = 1;
                _tellPinballing  = false;
                _moveDir         = (_playerRef.transform.position - transform.position).normalized;
                _moveDir.y       = 0;
                _startAttackTime = Time.time;
            }

            _currSpinningSpeed = _realSpinningSpeed * _currAttackTime;

            transform.Rotate(Vector3.up, _currSpinningSpeed);
        }
        else
        {
            _currAttackTime = (Time.time - _startAttackTime) / _realPinballAttackDuration;

            //Debug.Log("pinballing");

            for (int i = 0; i <= _pinballNumOfCasts; 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 += _pinballDetectionAngle / _pinballNumOfCasts;

                if (Physics.Raycast(transform.position + (Vector3.up * _vertDetectOffset), RayDir, out hit, _bossCollisionDetectDistance))
                {
                    if (hit.collider.GetComponent <PlayerController>())
                    {
                        hit.collider.GetComponent <PlayerController>().TakeDamage(_bossDamage);
                    }
                }
            }

            if (_debug)
            {
                Debug.DrawLine(transform.position + (Vector3.up * _vertDetectOffset), transform.position + (Vector3.up * _vertDetectOffset) + (_moveDir * _bossCollisionDetectDistance), Color.blue);
            }

            if (Physics.Raycast(transform.position + (Vector3.up * _vertDetectOffset), _moveDir, out hit, _bossCollisionDetectDistance + 1f))
            {
                Vector3    checkDir = _moveDir;
                GameObject thingHit = hit.collider.gameObject;

                //Debug.Log("reflected");
                if (!thingHit.GetComponent <BaseEnemy>() && !thingHit.GetComponent <BossEnemy>() && !thingHit.GetComponent <PlayerController>())
                {
                    _moveDir = Vector3.Reflect(checkDir, hit.normal);
                }
            }

            _calcAngle = 0;

            transform.Rotate(Vector3.up, _realSpinningSpeed);
            transform.position += _moveDir * _realSpeedWhilePinballing * Time.deltaTime;

            if (_currAttackTime >= 1)
            {
                _invincible         = false;
                _enemyAgent.enabled = true;
                checkIfOffMap();
                _MyAttack        = SPINSTRATS.STUNNED;
                _startAttackTime = Time.time;
                return;
            }
        }
    }