Ejemplo n.º 1
0
    // 攻击敌人,对敌人造成伤害
    private void Atk()
    {
        Ray ray = new Ray(hitPoint.position, transform.forward);

        RaycastHit[] hits = Physics.SphereCastAll(ray, 1f, hitDistance, LayerMask.GetMask("Enemy"));
        if (hits != null)
        {
            foreach (var hit in hits)
            {
                ILife life = hit.collider.GetComponent <ILife>();
                if (life != null)
                {
                    life.Reduce(gameObject, power);
                }
            }
        }
    }
Ejemplo n.º 2
0
    private void PowerHit()
    {
        Ray ray = new Ray(hitPoint.position, transform.forward);

        RaycastHit[] hits = Physics.SphereCastAll(ray, 1f, hitDistance, LayerMask.GetMask("Enemy"));
        if (hits != null)
        {
            foreach (var hit in hits)
            {
                ILife life = hit.collider.GetComponent <ILife>();
                if (life != null)
                {
                    life.Reduce(gameObject, power * 2);
                    cinemachineCollisionImpulseSource.GenerateImpulse(new Vector3(1, 2, 0));
                }
            }
        }
    }