示例#1
0
    public override void TakeDamage(float amount, Vector2 knockBackForce, bool flinch, HealthScript attacker = null, float freezeDelay = 0.0f, Collider2D gotHitCollider = null)
    {
        currentHealth -= amount;

        if (gotHitCollider)                                                                                                                                       // Pass attacker (their health scripts) and 'this object's collider that was hit' as argument for hiteffect instantiation.
        {
            Vector3    hitPos         = gotHitCollider.bounds.ClosestPoint(new Vector3(attacker.transform.position.x, attacker.transform.position.y + 0.86f, 0)); // 0.86f is the shoulder height of yasushi.
            GameObject hitEffectInst  = Instantiate(hitEffect, hitPos, attacker.transform.rotation);
            Vector3    hitEffectScale = hitEffectInst.transform.localScale;
            hitEffectScale.x *= Mathf.Sign(attacker.transform.position.x - gotHitCollider.transform.position.x);
            hitEffectInst.transform.localScale = hitEffectScale;
        }

        float bossHealthPercentage = (currentHealth / MaxHealth) * 100;

        if (bossHealthPercentage % 15 == 0) // Divided by 15 and has no remainder -> multiple of 15.
        {
            if (takoyaki == null)           // Make sure there's no other takoyaki.
            {
                takoyaki = Instantiate(TakoyakiPrefab);
            }
        }

        if (bossHealthPercentage < 50) // If bossHealthPercentage is lower than 50% -> FEVER?
        // GetComponent<Animator>().SetBool("fever", true);
        {
            bossAI.attackInterval = 0.0f;
        }

        StartCoroutine(SpriteFlashRed());

        healthBar.value = currentHealth;

        if (flinch)
        {
            bossAI.ChangeState(BossStates.FLINCHED);
            sound.PlayBossFlinch();
        }

        if (attacker != null)
        {
            attacker.FreezeFrames(freezeDelay);
            FreezeFrames(freezeDelay);
        }

        if (currentHealth <= 0 && canDie)
        {
            vulnerable = false;
            bossAI.ChangeState(BossStates.DEAD); // Dead state plays death animation.
            //playerController.enabled = false;
            sound.PlayBossDeath();
            sound.PlayVictory();
            sound.fading3 = true;
            StartCoroutine(AfterFade(sound));
            isDead = true;
        }
    }
示例#2
0
    public override void TakeDamage(float amount, Vector2 knockBackForce, bool flinch, HealthScript attacker = null, float freezeDelay = 0.0f, Collider2D gotHitCollider = null)
    {
        if (playerFever.feverMode == false && consuming.consuming == false)
        {
            currentHealth -= amount;

            GetComponent <PlayerController>().AddForce(knockBackForce.x, knockBackForce.y);

            if (flinch)
            {
                anim.Play("Player_Flinch");
                GetComponent <PlayerSkill>().resetSkillTimer();
            }

            if (gotHitCollider)
            {                                                                                                                                                         // Pass attacker (their health scripts) and 'this object's collider that was hit' as argument for hiteffect instantiation.
                Vector3    hitPos         = gotHitCollider.bounds.ClosestPoint(new Vector3(attacker.transform.position.x, attacker.transform.position.y + 0.86f, 0)); // 0.86f is the shoulder height of yasushi.
                GameObject hitEffectInst  = Instantiate(hitEffect, hitPos, attacker.transform.rotation);
                Vector3    hitEffectScale = hitEffectInst.transform.localScale;
                hitEffectScale.x *= Mathf.Sign(attacker.transform.position.x - gotHitCollider.transform.position.x);
                hitEffectInst.transform.localScale = hitEffectScale;
            }

            if (attacker != null && freezeDelay > 0)
            {
                attacker.FreezeFrames(freezeDelay);
                FreezeFrames(freezeDelay);
            }

            comboUI.ComboReset();
            hitBoxes.DeactivateRightHitBox1();
            hitBoxes.DeactivateRightHitBox2();
            hitBoxes.DeactivateRightHitBox3();
            hitBoxes.DeactivateRightChargebox();
            takeDamage = true;
            GetComponent <PlayerAttack> ().attacking   = false;
            GetComponent <PlayerAttack> ().chargeTimer = 0;
            anim.SetBool("chargingup", false);
            anim.SetBool("charged", false);
            camShake.Shake(0.1f, 0.1f);
            sfx.PlayFlinch();
        }
        else
        {
            return;
        }
    }
示例#3
0
    /*====================FORMAT IN PROGRESS====================*/
    public override void TakeDamage(float amount, Vector2 knockBackForce, bool flinch, HealthScript attacker = null, float freezeDelay = 0.0f, Collider2D gotHitCollider = null)
    {
        currentHealth -= amount;
        enemyAI.AddForce(knockBackForce.x, knockBackForce.y);

        if (flinch)
        {
            enemyAI.ChangeState(AIStates.FLINCHED);
        }

        if (gotHitCollider)
        {                                                                                                                                                         // Pass attacker (their health scripts) and 'this object's collider that was hit' as argument for hiteffect instantiation.
            Vector3    hitPos         = gotHitCollider.bounds.ClosestPoint(new Vector3(attacker.transform.position.x, attacker.transform.position.y + 0.86f, 0)); // 0.86f is the shoulder height of yasushi.
            GameObject hitEffectInst  = Instantiate(hitEffect, hitPos, attacker.transform.rotation);
            Vector3    hitEffectScale = hitEffectInst.transform.localScale;
            hitEffectScale.x *= Mathf.Sign(attacker.transform.position.x - gotHitCollider.transform.position.x);
            hitEffectInst.transform.localScale = hitEffectScale;
        }

        if (attacker != null && freezeDelay > 0)
        {
            attacker.FreezeFrames(freezeDelay);
            FreezeFrames(freezeDelay);
        }

        if (currentHealth <= 0 && canDie)
        {
            vulnerable = false;
            canConsume = false;
            consumeIndicator.gameObject.SetActive(false); // Turn off the consumeIndicator why dying anim is playing so that it won't confuse the player.
            enemyAI.ChangeState(AIStates.DEAD);           // Dead state plays death animation and call DestroyEnemy() at the end of its anim.
        }
        else if (currentHealth <= (MaxHealth * 0.2))      // When health fell under 20%, enemies became consumable.
        {
            enemyAI.ChangeState(AIStates.CONSUMABLE);
            canConsume = true;
            consumeIndicator.gameObject.SetActive(true);
            if (this.name == "Tempura1" || this.name == "MakiRoll1" || this.name == "Chuka1")
            {
                vulnerable  = false;
                this.canDie = false;
            }
        }
    }