Ejemplo n.º 1
0
 public void RemoveMonster(MonsterAIBase m)
 {
     if (monsters.Contains(m))
     {
         monsters.Remove(m);
     }
     if (awakeMonsters.Contains(m))
     {
         awakeMonsters.Remove(m);
     }
 }
Ejemplo n.º 2
0
    void FinishStack(NumberStack ns)
    {
        NumberInfo    ni   = ns.stackingNumber;
        MonsterAIBase maib = ni.GetComponent <MonsterAIBase>();

        if (maib)
        {
            maib.enabled = true;
        }
        foreach (Renderer r in ns.hiddenRends)
        {
            r.enabled = true;
        }
        if (ni.GetComponent <Rigidbody>())
        {
            ni.GetComponent <Rigidbody>().isKinematic = ns.kinematic;
            ni.GetComponent <Rigidbody>().useGravity  = ns.useGravity;
        }
        PickUppableObject pip = ni.GetComponent <PickUppableObject>();

        if (pip)
        {
            pip.enabled = true;
        }
        ns.stackingNumber.SetNumber(Fraction.Multiply(ns.stackingNumber.fraction, new Fraction(ns.stackHeight, 1)), true);
        EffectsManager.inst.RevertSparks(ns.stackingNumber.transform.position, 2);
        AudioManager.inst.PlayCrystalThump1(ns.stackingNumber.transform.position);
//		if (ni.GetComponent<Rigidbody>()) ni.GetComponent<Rigidbody>().isKinematic = false;
//		ni.GetComponent<Collider>().enabled = true;
        ni.enabled = true;
        foreach (GameObject o in ns.stackedGhosts)
        {
            foreach (IMuteDestroySound mute in o.GetComponents(typeof(IMuteDestroySound)))
            {
                mute.MuteDestroy();
            }
            Destroy(o);
        }
        // note the stack is not destroyed here beacuse this method is called in an iterator blcok over the list
        // can't take one out int he middle of iteration, so it's taken care of after the loop finishes in update()
    }
Ejemplo n.º 3
0
    public void OnTriggerEnter(Collider other)
    {
//		if(Network.isClient) { return; }
        NumberInfo ni = other.GetComponent <NumberInfo>();

        if (ni && ni.enabled)
        {
            if (touched.Contains(ni))
            {
                return;
            }
            touched.Add(ni);
            AudioManager.inst.PlayCrystalThump1(other.transform.position);

            int stackHeight = waveFrac1.numerator;
//			Debug.Log ("a starts:" +a+ " and " +ni.fraction);

//			ni.fraction = Fraction.Multiply(a,ni.fraction);

//			Debug.Log ("ni.fraction at this stage :" + ni.fraction);

//			Debug.Log ("a at this stage 2:" + a);
            MonsterAIBase maib = ni.transform.root.GetComponentInChildren <MonsterAIBase>();
            if (stackHeight == 1)
            {
                // nothing happens to target num when you multiply by 1
            }
            else if (stackHeight == -1)
            {
                // we multiplied by -1
                // simply invert the number immediately (no stack)
                ni.SetNumber(Fraction.Multiply(new Fraction(stackHeight, 1), ni.fraction));
            }
            else if (ni.fraction.numerator == -1 && ni.fraction.denominator == 1)
            {
                // target num was -1
                ni.SetNumber(Fraction.Multiply(new Fraction(stackHeight, 1), ni.fraction));
            }
            else if (ni.fraction.numerator == 1 && ni.fraction.denominator == 1)
            {
                // target num was a 1, but the source num was not, so set the number immediate (no stack)
                // dry
                ni.SetNumber(Fraction.Multiply(new Fraction(stackHeight, 1), ni.fraction));
            }
            else if (maib)
            {
                if (!maibs.Contains(maib))
                {
                    maibs.Add(maib);
                    for (int i = 0; i < stackHeight; i++)
                    {
                        GameObject copy = (GameObject)Instantiate(maib.gameObject, maib.transform.right * i * 4f, maib.transform.rotation);
//						Debug.Log("copy");
                    }
//					Debug.Log("amib:"+maib);
                }
            }
            else
            {
                // the regular case
                // perform an x by y operation on the number hit by the wave
                // create stack fx
                NumberManager.inst.CreateNumberStack(ni, stackHeight);
            }

//			ni.SetNumber(ni.fraction);
            EffectsManager.inst.CreateSmallPurpleExplosion(ni.transform.position, 1, 1);
        }
    }
Ejemplo n.º 4
0
    float numberStackFXDuration     = 6f;   // the total length of time the stack lasts (regardless of how close the "ghost "numbers are together in the end)

    public void CreateNumberStack(NumberInfo ni, int stackHeight)
    {
        NumberStack newStack = new NumberStack();

        ni.enabled = false;
        PickUppableObject pip = ni.GetComponent <PickUppableObject>();

        if (pip)
        {
            pip.enabled = false;
        }
        MonsterAIBase maib = ni.GetComponent <MonsterAIBase>();

        if (maib)
        {
            maib.enabled = false;
        }
        // the stack of fx numbers will be positive or negative depending on the result.
        int      resultSign = ni.fraction.numerator * stackHeight > 0 ? 1 : -1;
        Fraction resultFrac = Fraction.Multiply(Fraction.GetAbsoluteValue(ni.fraction), new Fraction(resultSign, 1));

//		Debug.Log("stack:"+stackHeight+", restul;"+resultFrac+", ni frac;"+ni.fraction+", resultsign:"+resultSign);
        for (int i = 0; i < Mathf.Abs(stackHeight); i++)
        {
            GameObject numberAmmo = (GameObject)Instantiate(ni.gameObject);
            numberAmmo.GetComponentInChildren <NumberInfo>().SetNumber(resultFrac);            // destroys if zero.
            Rigidbody rb = numberAmmo.GetComponent <Rigidbody>();
            if (rb)
            {
                Destroy(rb);
            }
            Collider c = numberAmmo.GetComponent <Collider>();
            if (c)
            {
                Destroy(c);
            }
            Vector3 fixzfighting = UnityEngine.Random.insideUnitSphere * .01f;
            numberAmmo.transform.position = ni.transform.position + Vector3.up * i * Utils.RealHeight(ni.transform) * 1.14f + fixzfighting;            // ni.transform.localScale.x;
            newStack.stackedGhosts.Add(numberAmmo);
        }
        foreach (Renderer r in ni.GetComponentsInChildren <Renderer>())
        {
            if (r.enabled)
            {
                r.enabled = false;
                newStack.hiddenRends.Add(r);
            }
        }
        newStack.stackTime      = numberStackFXDuration;
        newStack.stackingNumber = ni;
        newStack.stackHeight    = stackHeight;
        newStack.sign           = stackHeight > 0 ? 1 : -1;
        if (ni.GetComponent <Rigidbody>())
        {
            newStack.kinematic  = ni.GetComponent <Rigidbody>().isKinematic;
            newStack.useGravity = ni.GetComponent <Rigidbody>().useGravity;
            ni.GetComponent <Rigidbody>().useGravity  = false;
            ni.GetComponent <Rigidbody>().isKinematic = true;
        }
//		if (ni.GetComponent<Rigidbody>()) ni.GetComponent<Rigidbody>().isKinematic = true;
//		ni.GetComponent<Collider>().enabled = false;

//		Debug.Log("added newstack. ghosts;"+newStack.stackedGhosts[0]);
        numberStacks.Add(newStack);
    }