Пример #1
0
 public void Damage(int damageCount)
 {
     if (damageCount > 0)
     {
     }
     //伤害特效
     //       FindObjectOfType<AudioManager>().Play("Player_Hit");
     if (anim && !IsElite)
     {
         anim.SetTrigger("Hit");
     }
     Hp -= damageCount;
     //击退
     DamageTextControler.CreatDamageText(damageCount.ToString(), gameObject.transform, 2);
 }
Пример #2
0
    // private Animator animator;

    public void Damage(int damageCount)
    {
        //Debug.Log("执行了哟");
        if (this.name == "HitBox")
        {
            FindObjectOfType <AudioManager>().Play("Enemy_Hit");
        }
        else
        {
            FindObjectOfType <AudioManager>().Play("Boss_Hit");
        }

        DamageTextControler.CreatDamageText(damageCount.ToString(), mainObject.transform, 2);
        hp -= damageCount;
    }
Пример #3
0
    public void Damage2(int damageCount, int DMGtype)
    {
        float MinimumX  = minimumX / maxmumX;
        float MinimumY  = minimumY / maxmumY;
        float xisedaoju = Random.Range(0, 100);

        if (damageCount > 0)
        {
        }
        //伤害特效
        //       FindObjectOfType<AudioManager>().Play("Player_Hit");
        //anim.SetTrigger("Hit");
        if (DMGtype != 3)
        {
            if (anim && !IsElite)
            {
                anim.SetTrigger("Hit");
            }
        }
        Hp -= damageCount;
        //击退
        DamageTextControler.CreatDamageText(damageCount.ToString(), gameObject.transform, DMGtype);
        {
            float rand_VelocityX = -Mathf.Abs(Mathf.Sqrt(-2 * Mathf.Log(Random.value)) * Mathf.Sin(2 * Mathf.PI * Random.value));
            float rand_VelocityY = Mathf.Abs(Mathf.Sqrt(-2 * Mathf.Log(Random.value)) * Mathf.Sin(2 * Mathf.PI * Random.value));
            if (xisedaoju > 0 && xisedaoju < YellowPos)
            {
                var ins1 = Instantiate(xise[0], transform.position, Quaternion.identity);
                ins1.GetComponent <Rigidbody2D>().velocity = new Vector2((rand_VelocityX * (1 - MinimumX) + MinimumX) * (Random.value > 0.5f ? maxmumX : -maxmumX), (rand_VelocityY * (1 - MinimumY) + MinimumY) * maxmumY);
            }
            if (xisedaoju > 25 && xisedaoju < 25 + GreenPos)
            {
                var ins2 = Instantiate(xise[1], transform.position, Quaternion.identity);
                ins2.GetComponent <Rigidbody2D>().velocity = new Vector2((rand_VelocityX * (1 - MinimumX) + MinimumX) * (Random.value > 0.5f ? maxmumX : -maxmumX), (rand_VelocityY * (1 - MinimumY) + MinimumY) * maxmumY);
            }
            if (xisedaoju > 50 && xisedaoju < 50 + BluePos)
            {
                var ins3 = Instantiate(xise[2], transform.position, Quaternion.identity);
                ins3.GetComponent <Rigidbody2D>().velocity = new Vector2((rand_VelocityX * (1 - MinimumX) + MinimumX) * (Random.value > 0.5f ? maxmumX : -maxmumX), (rand_VelocityY * (1 - MinimumY) + MinimumY) * maxmumY);
            }
            if (xisedaoju > 75 && xisedaoju < 75 + RedPos)
            {
                var ins4 = Instantiate(xise[3], transform.position, Quaternion.identity);
                ins4.GetComponent <Rigidbody2D>().velocity = new Vector2((rand_VelocityX * (1 - MinimumX) + MinimumX) * (Random.value > 0.5f ? maxmumX : -maxmumX), (rand_VelocityY * (1 - MinimumY) + MinimumY) * maxmumY);
            }
        }
    }
Пример #4
0
 public void Damage(int damageCount)
 {
     if (!Shield)
     {
         if (damageCount > 0)
         {
             ps.Play();
         }
         TargetHp -= damageCount;
         TargetHp  = Mathf.Clamp(TargetHp, 0, HpMax);
         if (bossTransform != null)
         {
             DamageTextControler.CreatDamageText(damageCount.ToString(), bossTransform, 2);
         }
         else
         {
             DamageTextControler.CreatDamageText(damageCount.ToString(), gameObject.transform, 2);
         }
     }
     else
     {
         if (damageCount > 0)
         {
             ps.Play();
         }
         TargetHp -= 1;
         TargetHp  = Mathf.Clamp(TargetHp, 0, HpMax);
         if (bossTransform != null)
         {
             DamageTextControler.CreatDamageText(1.ToString(), bossTransform, 2);
         }
         else
         {
             DamageTextControler.CreatDamageText(1.ToString(), gameObject.transform, 2);
         }
     }
 }
Пример #5
0
    public void Damage2(int damageCount)
    {
        float MinimumX  = minimumX / maxmumX;
        float MinimumY  = minimumY / maxmumY;
        float xisedaoju = Random.Range(0, 100);

        if (!Shield)
        {
            if (damageCount > 0)
            {
                ps.Play();
            }
            TargetHp -= damageCount;
            TargetHp  = Mathf.Clamp(TargetHp, 0, HpMax);
            if (bossTransform != null)
            {
                DamageTextControler.CreatDamageText(damageCount.ToString(), bossTransform, 2);
            }
            else
            {
                DamageTextControler.CreatDamageText(damageCount.ToString(), gameObject.transform, 2);
            }
        }
        else
        {
            if (damageCount > 0)
            {
                ps.Play();
            }
            TargetHp -= 1;
            TargetHp  = Mathf.Clamp(TargetHp, 0, HpMax);
            if (bossTransform != null)
            {
                DamageTextControler.CreatDamageText(1.ToString(), bossTransform, 2);
            }
            else
            {
                DamageTextControler.CreatDamageText(1.ToString(), gameObject.transform, 2);
            }
        }
        //生成吸色道具
        {
            float rand_VelocityX = -Mathf.Abs(Mathf.Sqrt(-2 * Mathf.Log(Random.value)) * Mathf.Sin(2 * Mathf.PI * Random.value));
            float rand_VelocityY = Mathf.Abs(Mathf.Sqrt(-2 * Mathf.Log(Random.value)) * Mathf.Sin(2 * Mathf.PI * Random.value));
            if (xisedaoju > 0 && xisedaoju < YellowPos)
            {
                var ins1 = Instantiate(xise[0], transform.position, Quaternion.identity);
                ins1.GetComponent <Rigidbody2D>().velocity = new Vector2((rand_VelocityX * (1 - MinimumX) + MinimumX) * (Random.value > 0.5f ? maxmumX : -maxmumX), (rand_VelocityY * (1 - MinimumY) + MinimumY) * maxmumY);
            }
            if (xisedaoju > 25 && xisedaoju < 25 + GreenPos)
            {
                var ins2 = Instantiate(xise[1], transform.position, Quaternion.identity);
                ins2.GetComponent <Rigidbody2D>().velocity = new Vector2((rand_VelocityX * (1 - MinimumX) + MinimumX) * (Random.value > 0.5f ? maxmumX : -maxmumX), (rand_VelocityY * (1 - MinimumY) + MinimumY) * maxmumY);
            }
            if (xisedaoju > 50 && xisedaoju < 50 + BluePos)
            {
                var ins3 = Instantiate(xise[2], transform.position, Quaternion.identity);
                ins3.GetComponent <Rigidbody2D>().velocity = new Vector2((rand_VelocityX * (1 - MinimumX) + MinimumX) * (Random.value > 0.5f ? maxmumX : -maxmumX), (rand_VelocityY * (1 - MinimumY) + MinimumY) * maxmumY);
            }
            if (xisedaoju > 75 && xisedaoju < 75 + RedPos)
            {
                var ins4 = Instantiate(xise[3], transform.position, Quaternion.identity);
                ins4.GetComponent <Rigidbody2D>().velocity = new Vector2((rand_VelocityX * (1 - MinimumX) + MinimumX) * (Random.value > 0.5f ? maxmumX : -maxmumX), (rand_VelocityY * (1 - MinimumY) + MinimumY) * maxmumY);
            }
        }
    }