Ejemplo n.º 1
0
    void Start()
    {
        animator = GetComponent <Animator>();
        GameObject audioController;

        audioController = GameObject.FindGameObjectWithTag("MusicHandler");
        audioController.GetComponent <AudioController>().PlayMusic(2);
        foreach (GameObject obj in Resources.FindObjectsOfTypeAll(typeof(GameObject)) as GameObject[])
        {
            if (obj.name == "BossHPBar")
            {
                BossHPBar = obj;
            }
            if (obj.name == "BossHPBorder")
            {
                BossHPBorder = obj;
            }
            if (obj.name == "BossName")
            {
                BossName = obj;
            }
            if (obj.name == "GolemCharge")
            {
                GolemChargeText = obj;
            }
        }
        if (BossHPBar != null)
        {
            BossHPBar.SetActive(true);
        }
        if (BossHPBorder != null)
        {
            BossHPBorder.SetActive(true);
        }
        if (BossName != null)
        {
            BossName.SetActive(true);
        }
        if (GolemChargeText != null)
        {
            GolemChargeText.SetActive(false);
        }
        attackSpeedTimer = DEFAULT_ATTACK_SPEED;
        currentHP        = MAX_HP;
        ui         = GameObject.Find("UIHandler").GetComponent <UIController>();
        playerLook = GameObject.Find("playerLook");
        i          = GetComponent <Rigidbody>();
    }
Ejemplo n.º 2
0
    bool playerHit = false; //Used in damage check.



    void FixedUpdate()
    {
        if (UI == null)
        {
            UI = GameObject.Find("UIHandler");
        }
        if (UI != null)
        {
            if (ui.GetIsPaused())
            {
                BossHPBar.SetActive(false);
                BossHPBorder.SetActive(false);
                BossName.SetActive(false);
            }
            else
            {
                BossHPBar.SetActive(true);
                BossHPBorder.SetActive(true);
                BossName.SetActive(true);
            }
            if (Input.GetKeyDown(KeyCode.F7))
            {
                StartCoroutine("GolemDeath");
            }
        }
        if (chargeVelocity) //When charging, constantly reapply the same velocity.
        {
            i.velocity    = transform.forward * 25;
            i.constraints = RigidbodyConstraints.FreezePositionY;
        }
        else
        {
            i.constraints &= ~RigidbodyConstraints.FreezePositionY;  //Remove the constraint on position, to ensure golem is firmly on the ground!
        }
        Vector3 forward = transform.TransformDirection(Vector3.forward);

        Debug.DrawRay(transform.position + (Vector3.up * 3), forward * 5, Color.white);
        if (Physics.SphereCast(transform.position + (Vector3.up * 3), 1.5f, forward, out hit, 10))
        {
            Debug.Log("GOLEM HIT: " + hit.collider.gameObject.name);
            if (hit.collider.gameObject.name == "Player")
            {
                if (golemCharging == true)
                {
                    //Damage
                    playerHit = true;
                    Player         player  = hit.collider.gameObject.GetComponent <Player>();
                    MovementScript stunned = player.GetComponent <MovementScript>();
                    animator.SetBool("isCharging", false);
                    chargeVelocity = false;
                    stunned.StunPlayer(3f);
                    Invoke("DamagePlayerCharge", 3f);
                    i.velocity        = Vector3.zero;
                    i.angularVelocity = Vector3.zero;
                    golemCharging     = false;
                }
            }
            if (hit.collider.gameObject.layer != 12) //This prevents cancelling charge with a projectile.
            {
                golemCharging     = false;
                i.velocity        = Vector3.zero;
                i.angularVelocity = Vector3.zero;
                chargeVelocity    = false;
                animator.SetBool("isCharging", false);
            }
        }
        if (lookAtPlayer == true)
        {
            var playerRotation = Quaternion.LookRotation(GameObject.FindWithTag("MainCamera").transform.position - transform.position);
            transform.rotation = Quaternion.Slerp(transform.rotation, playerRotation, 2.5f * Time.deltaTime);
        }
        if (ui.GetIsPaused())
        {
            return;
        }
        if (attackTimerPause == true)
        {
            return;
        }
        if (transform.position.y < 0)
        {
            transform.position = new Vector3(transform.position.x, 0, transform.position.z);
        }

        attackSpeedTimer = attackSpeedTimer - Time.deltaTime;
        healthRemainingPercentage();
        if (attackSpeedTimer <= 0)
        {
            CURRENT_ATTACK_CYCLE = CURRENT_ATTACK_CYCLE + 1; //Iterate the cycle
            //Planned attack cycle:
            //Projectile -> Projectile -> Projectile
            //Spawn minions
            //Projectile -> Projectile -> Projectile
            //Charge at the player
            //Projectile x5
            //Spawn a mega minion
            //Projectile x3
            //Cycle from beginning
            switch (CURRENT_ATTACK_CYCLE)
            {
            case 1:
            {
                StartCoroutine("GolemThrowProjectile");
                attackSpeedTimer = DEFAULT_ATTACK_SPEED;
                return;
            }

            case 2:
            {
                StartCoroutine("GolemThrowProjectile");
                attackSpeedTimer = DEFAULT_ATTACK_SPEED;
                return;
            }

            case 3:
            {
                StartCoroutine("GolemThrowProjectile");
                attackSpeedTimer = DEFAULT_ATTACK_SPEED;
                return;
            }

            case 4:
            {
                if (enragedState)
                {
                    StartCoroutine("GolemThrowProjectile");
                }
                else
                {
                    StartCoroutine("GolemRoar");
                    MinionSpawn();
                }
                attackSpeedTimer = DEFAULT_ATTACK_SPEED;
                return;
            }

            case 5:
            {
                StartCoroutine("GolemThrowProjectile");
                attackSpeedTimer = DEFAULT_ATTACK_SPEED;
                return;
            }

            case 6:
            {
                StartCoroutine("GolemThrowProjectile");
                attackSpeedTimer = DEFAULT_ATTACK_SPEED;
                return;
            }

            case 7:
            {
                StartCoroutine("GolemThrowProjectile");
                attackSpeedTimer = DEFAULT_ATTACK_SPEED;
                return;
            }

            case 8:
            {
                ChargeAtPlayer();
                attackSpeedTimer = DEFAULT_ATTACK_SPEED;
                return;
            }

            case 9:
            {
                StartCoroutine("GolemThrowProjectile");
                attackSpeedTimer = DEFAULT_ATTACK_SPEED;
                return;
            }

            case 10:
            {
                StartCoroutine("GolemThrowProjectile");
                attackSpeedTimer = DEFAULT_ATTACK_SPEED;
                return;
            }

            case 11:
            {
                StartCoroutine("GolemThrowProjectile");
                attackSpeedTimer = DEFAULT_ATTACK_SPEED;
                return;
            }

            case 12:
            {
                StartCoroutine("GolemThrowProjectile");
                attackSpeedTimer = DEFAULT_ATTACK_SPEED;
                return;
            }

            case 13:
            {
                StartCoroutine("GolemThrowProjectile");
                attackSpeedTimer = DEFAULT_ATTACK_SPEED;
                return;
            }

            case 14:
            {
                //Spawn a mega minion
                MinionSpawn();
                StartCoroutine("GolemRoar");
                attackSpeedTimer = DEFAULT_ATTACK_SPEED;
                return;
            }

            case 15:
            {
                StartCoroutine("GolemThrowProjectile");
                attackSpeedTimer = DEFAULT_ATTACK_SPEED;
                return;
            }

            case 16:
            {
                StartCoroutine("GolemThrowProjectile");
                attackSpeedTimer = DEFAULT_ATTACK_SPEED;
                return;
            }

            case 17:
            {
                StartCoroutine("GolemThrowProjectile");
                attackSpeedTimer     = DEFAULT_ATTACK_SPEED;
                CURRENT_ATTACK_CYCLE = 0;         //Reset cycle
                return;
            }
            }
        }
    }