Exemplo n.º 1
0
    public void GetDamage(int Damage, Vector2 Pos)
    {
        if (!IsHurt)
        {
            IsHurt = true;

            HP -= Damage;

            if (HP <= 0.0f)
            {
                /* GameOver */
                Destroy(gameObject);
            }
            else
            {
                float Dircetion = transform.position.x - Pos.x;

                if (Dircetion < 0)
                {
                    Dircetion = 1;
                }
                else
                {
                    Dircetion = -1;
                }

                StartCoroutine(KnockBack(Dircetion));
                StartCoroutine(CommonFunction.AlphaBlink(AlphaA, AlphaB, Renderer));
                StartCoroutine(SetHurt());
            }
        }
    }
Exemplo n.º 2
0
    public void GetDamage(int Damage, Vector2 Pos, bool LastAttack)
    {
        HP -= Damage;

        GameObject Hud = Instantiate(HudImage);

        Hud.GetComponent <HudText>().Alpha              = Color.red;
        Hud.GetComponent <HudText>().TargetString       = Damage.ToString();
        Hud.GetComponent <HudText>().transform.position = transform.position;

        if (HP <= 0.0f)
        {
            /* Mosnter Dead */

            //Dead();

            IsKnockBack = true;

            gameObject.GetComponent <BoxCollider2D>().enabled = false;
            gameObject.GetComponent <Rigidbody2D>().simulated = false;

            StartCoroutine(CommonFunction.FadeOut(gameObject, 0.5f, true));

            PlayerController.Instance.Gold += Gold;
        }
        else
        {
            if (LastAttack)
            {
                float x = transform.position.x - Pos.x;

                if (x < 0)
                {
                    x = 1;
                }
                else
                {
                    x = -1;
                }

                StartCoroutine(KnockBack(x));
            }

            if (!IsKnockBack)
            {
                StartCoroutine(CommonFunction.AlphaBlink(AlphaA, AlphaB, Renderer));
            }
            ;
        }
    }