protected void AplicaDano(int quanto)
    {
        Dados.AplicaDano(quanto);

        if (Dados.PontosDeVida <= 0)
        {
            OnDefeated();
        }
    }
Exemplo n.º 2
0
    private void OnHeroDamage(IGameEvent obj)
    {
        StandardSendGameEvent ssge = (StandardSendGameEvent)obj;

        if ((!piscaI.Invuneravel || ssge.MyObject.Length > 2) && Dados.PontosDeVida > 0)
        {
            Dados.AplicaDano((int)ssge.MyObject[1]);
            EventAgregator.Publish(new StandardSendGameEvent(gameObject, EventKey.changeLifePoints, Dados.PontosDeVida, Dados.MaxVida));
            EventAgregator.Publish(new StandardSendGameEvent(EventKey.requestShakeCam, ShakeAxis.y, 3, 1f));

            RetornarComponentesAoPAdrao();
            emDano.Start(transform.position, new Vector3((bool)ssge.MyObject[0] ? -1 : 1, 1, 0));

            if (dados.PontosDeVida > 0)
            {
                if (GameController.g.MyKeys.VerificaAutoShift("equiped_" + NomesEmblemas.suspiroLongo))
                {
                    piscaI.Start(2);
                }
                else
                {
                    piscaI.Start(1);
                }

                estado = EstadoDePersonagem.emDano;
                EventAgregator.Publish(new StandardSendGameEvent(EventKey.disparaSom, somDoDano));

                if (ssge.MyObject.Length > 2)
                {
                    tDamage.agendado = true;
                    tDamage.pos      = (Vector3)ssge.MyObject[2];
                }
            }
            else
            {
                InvokeDerrota(ssge.Sender.transform.position);
            }

            Destroy(
                Instantiate(heroParticleDamage, transform.position, Quaternion.identity), 5);
        }
        else if (dados.PontosDeVida <= 0 && estado != EstadoDePersonagem.derrotado)
        {
            InvokeDerrota(ssge.Sender.transform.position);
        }
    }