Beispiel #1
0
    public void Eat(NumberInfo ni)
    {
        if (!ni)
        {
            return;
        }
        if (ni.faucetRels.Count > 0 && faucetRels.Count > 0)          // Two oneballs with both have a faucet rel. e.g. two oneballs were combined.
        {
            faucetRels.AddRange(ni.faucetRels);
            foreach (NumberFaucet nf in faucetRels)
            {
                nf.SetOneballRel(this);
            }
            ni.faucetRels.Clear(); // the number we're eating shouldn't have a faucet rel any more.
        }
        else                       // at most one of the two balls was a "oneball" so lose all oneball-ness and faucet rels.
        {
            if (faucetRels.Count > 0)
            {
                foreach (NumberFaucet nf in faucetRels)
                {
                    nf.SetOneballRel(null);
                }
            }
            else if (ni.faucetRels.Count > 0)
            {
                foreach (NumberFaucet nf in ni.faucetRels)
                {
                    nf.SetOneballRel(null);
                }
            }
        }

        if (GetComponent <Rigidbody>())
        {
            if (!GetComponent <Rigidbody>().isKinematic)
            {
                GetComponent <Rigidbody>().velocity /= 5f;
            }
        }

        NumberManager.inst.DestroyOrPool(ni);
//		if (ni.myShape == NumberShape.Cube){
//			NumberManager.inst.DestroyOrPool(ni);
//		} else {
//			NumberManager.inst.DestroyOrPool(ni);
//		}

        Fraction result = Fraction.Add(ni.fraction, fraction);

        if (result.numerator == 0)
        {
            ZeroFX(transform.position);
            GemFX();
        }
        else
        {
            ni.DestroyedFX();
            AudioManager.inst.PlayNumberEat(transform.position);
        }
        SetNumber(result, true);
//		GetComponent<SometimesFacePlayer>().FacePlayerOnce();
    }