Ejemplo n.º 1
0
    public void explode()
    {
        Collider[]    hitColliders   = Physics.OverlapSphere(this.transform.position, explosionRadius);
        List <Matter> affectedMatter = new List <Matter>();
        Matter        katamari       = null;

        foreach (Collider c in hitColliders)
        {
            var matter = c.GetComponentInParent <Matter>();

            if (matter == null)
            {
                matter = c.GetComponent <Matter>();
            }

            if (matter != null && !affectedMatter.Contains(matter) && matter != this)
            {
                if (matter.gameObject.tag == "Player")
                {
                    katamari = matter;
                }
                else
                {
                    affectedMatter.Add(matter);
                }
            }
        }

        foreach (var matter in affectedMatter)
        {
            matter.Damage(damage);
        }

        if (katamari != null)
        {
            katamari.Damage(damage);
        }

        if (this.gameObject.GetComponent <ParticleSystem>() != null)
        {
            this.gameObject.GetComponent <ParticleSystem>().Play();
        }
        base.CaptureCollider.gameObject.GetComponent <Renderer>().enabled = false;

        this.DestroyMatter(false);

        Destroy(this.gameObject, 1);
    }
Ejemplo n.º 2
0
    void OnTriggerEnter(Collider other)
    {
        Ship   ship   = other.transform.root.GetComponent <Ship>();
        Matter matter = other.GetComponentInParent <Matter>();

        if (matter != null)
        {
            if (!hitRecord.Contains(matter) && (ship == null || ship.currentTeam == Ship.Team.Neutral || ship.currentTeam != myTeam))
            {
                AudioManager.Instance.PlayClip(HitSound);
                matter.Damage(Damage);

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

            hitRecord.Add(matter);
        }
    }
Ejemplo n.º 3
0
    public void OnTriggerEnter(Collider other)
    {
        if (!Active || ParentKatamari == null)
        {
            return;
        }
        //Debug.Log("Matter Trigger Enter");
        Matter otherMatter = other.GetComponentInParent <Matter>();

        if (otherMatter == null || other.isTrigger)
        {
            return;
        }

        if (otherMatter.Attached || !otherMatter.Active)
        {
            return;
        }

        Ship ship = other.GetComponentInParent <Ship>();

        if (ship != null)
        {
            float momentum = (ParentKatamari.MasterRigidbody.mass * ParentKatamari.MasterRigidbody.velocity).magnitude * MomentumDamageMultiplier;
            Debug.Log($"{gameObject.name} hitting {otherMatter.name} with momentum {momentum}");

            otherMatter.Damage((int)(momentum));

            return;
        }


        if (ParentKatamari != null)
        {
            ParentKatamari.OnMatterTouch(otherMatter, this);
        }
    }