Exemplo n.º 1
0
 public override void TakeDamage()
 {
     activeGerbong.dead = true;
     TWAudioController.PlaySFX("SFX_BOSS", "helicopter_damage");
     if (health > 1)
     {
         explosions.transform.position = activeGerbong.gerbong.transform.position;
         explosions.Play();
         CameraShake.instance.Shake(explosion.main.duration, 3, 10);
         DOTween.Sequence()
         .AppendCallback(() => { TWTransition.ScreenFlash(1, 0.2f); })
         .AppendInterval(0.1f)
         .AppendCallback(() => {
             DestroyGerbong();
         });
         health -= 1;
         InGameUI.instance.UpdateHpBos(health);
     }
     else
     {
         TWTransition.ScreenFlash(1, .2f);
         health -= 1;
         if (health < 1)
         {
             InGameUI.instance.UpdateHpBos(health);
             DOTween.Kill("BM_Missile");
             Die();
         }
     }
 }
    public void TakeDamage()
    {
        if (GameData.ActiveBossData.wasDie)
        {
            return;
        }

        if (!(GameVariables.PLAYER_IMMUNE || GameVariables.EFFECT_IMMUNE))
        {
            TWAudioController.PlaySFX("SFX_PLAYER", "player_damaged");
            sprite.material = whiteflash;
            DOVirtual.DelayedCall(flashDelay, () => { sprite.material = defaultMaterial; }).timeScale = GameTime.PlayerTimeScale;

            if (data.Hp >= 1)
            {
                GameVariables.PLAYER_IMMUNE = true;
                DOTween.Kill("ImmuneDamage");
                DOVirtual.DelayedCall(2f, () => { GameVariables.PLAYER_IMMUNE = false; }).SetId("ImmuneDamage").timeScale = GameTime.PlayerTimeScale;

                if (data.Shield > 0)
                {
                    data.Shield -= 1;
                    InGameUI.instance.UpdateShield();
                }
                else
                {
                    data.Hp -= 1;
                }

                InGameUI.instance.UpdateLive();

                if (data.Hp < 1)
                {
                    GameTrackRate.DeathCount  = 1;
                    GameTrackRate.EndTimePlay = Time.time;
                    GameTrackRate.CalculateTime();

                    GameData.ShiftItemList();
                    dead = true;
                    anim.SetBool("dead", true);
                    GameVariables.STILL_ALIVE = false;
                    GameVariables.GAME_OVER   = true;
                    TWTransition.ScreenFlash(1, 0.1f);
                    DOTween.Sequence()
                    .AppendInterval(1f)
                    .AppendCallback(() =>
                                    { InGameUI.instance.GameOver(); });
                }
            }
        }
    }