示例#1
0
文件: HitBox.cs 项目: Gmyth/D.I.V.E.
    protected virtual void OnHitEnemy(Collider2D other)
    {
        Enemy enemy = other.GetComponent <Enemy>();
        int   id    = enemy.gameObject.GetInstanceID();


        if (!enemy.isEvading && CheckHitObject(id))
        {
            if (GameUtility.ApplyDamage(enemy, hit, other) > 0)
            {
                TimeManager.Instance.startSlowMotionBlink(0.1f, 0.7f);

                CreateRandomEffect(enemy.transform);

                var trail = ObjectRecycler.Singleton.GetObject <SingleEffect>(8);
                trail.transform.position   = enemy.transform.position;
                trail.transform.right      = transform.right;
                trail.transform.localScale = new Vector3(7, 1, 1);
                trail.target = other.transform;
                trail.gameObject.SetActive(true);

                var trail1 = ObjectRecycler.Singleton.GetObject <SingleEffect>(8);
                trail1.transform.position   = enemy.transform.position;
                trail1.transform.right      = -transform.right;
                trail1.transform.localScale = new Vector3(7, 1, 1);
                trail1.target = other.transform;
                trail1.gameObject.SetActive(true);

                var spark = ObjectRecycler.Singleton.GetObject <SingleEffect>(23);
                spark.transform.position   = other.transform.position;
                spark.transform.right      = transform.right;
                spark.transform.localScale = Vector3.one;
                spark.target = other.transform;
                spark.gameObject.SetActive(true);

                CameraManager.Instance.Shaking(0.20f, 0.10f, true);

                if (enemy.Data.Id == 67)
                {
                    AudioManager.Singleton.PlayOnce("Boss_Hit");
                }
                else
                {
                    AudioManager.Singleton.PlayOnce("Hit");
                }
            }
        }
    }