private void OnTriggerEnter2D(Collider2D collision)
    {
        // This deals with colliding thoughts:
        ThoughtScript other_thought;
        SizeControl   other_sc;
        ColorControl  other_cc;
        float         othersize;

        other_thought = collision.gameObject.GetComponent <ThoughtScript>();
        if (other_thought != null)
        {
            other_sc  = other_thought.GetComponent <SizeControl>();
            other_cc  = other_thought.GetComponent <ColorControl>();
            othersize = other_sc.GetSize();
            if (sc.GetSize() > othersize) // i.e. if I am bigger
            {
                sc.AddSize(othersize);    // larger sized thought "swallows" the othe thought

                cc.AddColor(other_cc.GetColor() * othersize * swallowfactor);

                SetSizeGrowth();

                GameObject pop = Instantiate(pop_prefab, other_thought.transform.position, Quaternion.identity);
                pop.GetComponent <ParticleSystem>().startColor = other_thought.cc.GetColor();
                Destroy(other_thought.gameObject);
            }
        }
    }
Exemple #2
0
    private void OnTriggerEnter2D(Collider2D collision)
    {
        // This deals with thoughts colliding with Aura:
        ThoughtScript other_thought;
        SizeControl   other_sc;
        ColorControl  other_cc;
        float         othersize;
        float         colorbalance;
        Color         newcolor;

        other_thought = collision.gameObject.GetComponent <ThoughtScript>();
        if (other_thought != null)
        {
            other_sc     = other_thought.GetComponent <SizeControl>();
            other_cc     = other_thought.GetComponent <ColorControl>();
            othersize    = other_sc.GetSize();
            colorbalance = cc.ColorBalance();

            sc.AddSize(-othersize * HitCost); // thought that hits Aura reduces its size

            newcolor   = other_cc.GetColor() * othersize;
            newcolor.a = colorbalance; // alpha of Aura would be small (i.e. more transparent) if aura is not balanced
            cc.AddColor(newcolor);

            SetSizeGrowth();

            Destroy(other_thought.gameObject);
        }
    }