Exemplo n.º 1
0
 // Is called by animation event
 public void DealAttackDamage()
 {
     if (objectAttacking != null)
     {
         objectAttacking.DealDamage(attackDamage);
         ParticleSystem ps = attackPoint.GetComponentInChildren <ParticleSystem>();
         if (ps != null)
         {
             ps.Play();
             // ps.Emit(ps.emission.GetBurst(0).minCount);
             munch.PlayOneShot(munch.clip);
         }
     }
 }
Exemplo n.º 2
0
    private void Update()
    {
        RaycastHit hit;
        Vector3    dif     = transform.position - lastPosisiton;
        bool       success = Physics.Raycast(lastPosisiton, dif.normalized, out hit, dif.magnitude, LayerMask.GetMask(interactLayers));

        if (success)
        {
            if (Vector3.Distance(initialPosition, hit.point) >= inactiveDistance)
            {
                Creature           creature           = hit.collider.gameObject.GetComponentInParent <Creature>();
                DestructibleObject destructibleObject = hit.collider.gameObject.GetComponentInParent <DestructibleObject>();
                Hitbox             hitbox             = hit.collider.gameObject.GetComponent <Hitbox>();

                if (creature != null)
                {
                    int modifiedDamage = damage;
                    if (hitbox != null)
                    {
                        modifiedDamage = Mathf.RoundToInt(modifiedDamage * hitbox.damageMultiplier);
                    }
                    creature.DealDamage(modifiedDamage);
                }
                else if (destructibleObject != null)
                {
                    destructibleObject.DealDamage(damage);
                }

                if (!isPiercing)
                {
                    Destroy(this.gameObject);
                }
            }
        }

        UpdateLineRenderer();

        lastPosisiton = transform.position;
    }