public override void ModifyAmmo(NumberModifier.ModifyOperation fn) { if (numberHeld) { NumberInfo ni = numberHeld.GetComponent <NumberInfo>(); if (!ni) { return; } Fraction fracc = fn(ni.fraction); // commented Debug.Log("set ni:"+fracc); ni.SetNumber(fracc); MonsterAIRevertNumber mairn = ni.GetComponent <MonsterAIRevertNumber>(); if (mairn) { mairn.SetNumber(ni.fraction); } if (fracc.numerator == 0) { DropAmmo(true); NullifyAmmo(); } UpdateAmmoGraphics(true); // commented Debug.Log("modified! "); } // RecalcInfoText(); }
public override void ModifyAmmo(NumberModifier.ModifyOperation fn) { compounderAmmo.ammoValue = fn(compounderAmmo.ammoValue); if (compounderAmmo.ammoValue.numerator == 0) { ClearAmmo(); } else { UpdateAmmoGraphics(); } }
public override void ModifyAmmo(NumberModifier.ModifyOperation fn) { foreach (Ammo a in bulletAmmo) { a.ammoValue = fn(a.ammoValue); if (a.ammoValue.numerator == 0) { DropAmmo(true); return; } // // commented Debug.Log(a.ammoValue); } UpdateAmmoGraphics(true); }
public override void UseHoop(GameObject obj, RecordPosition record, bool direction) { if (!ObjectIsCloseToSurface(obj)) { // Prevents objects from getting flipped when being taken out of inventory, or created, INSIDE the sphere. return; } if (LevelBuilder.inst.levelBuilderIsShowing) { return; } base.UseHoop(obj, record, direction); NumberModifier.ModifyOperation nmf = (x => x); if (frac.numerator == -1 && frac.denominator == 1) { nmf = (x => Fraction.Multiply(x, frac)); currentEquation = " * " + frac; } else { if (direction) { nmf = (x => Fraction.Multiply(x, frac)); currentEquation = " * " + frac; } else { nmf = (x => Fraction.Multiply(x, Fraction.Inverse(frac))); currentEquation = " / " + frac; } } // // commented Debug.Log("2"); if (obj.tag == "Player") { // PlayerInventory.inst.ModifyInventoryItemnmf); Inventory.inst.ModifyInventoryItems(nmf); } else if (obj.GetComponent <NumberInfo>() != null && obj.GetComponent <ResourceNumber>() == null) { NumberInfo ni = obj.GetComponent <NumberInfo>(); modifyOp = nmf; // // commented Debug.Log("3"); ModifyNumber(ni); } // obj.SendMessage("OnNumberChanged",SendMessageOptions.DontRequireReceiver); }
void OnTriggerEnter(Collider col) { if (LevelBuilder.inst.levelBuilderIsShowing) { return; } // // commented Debug.Log ("trigger entered:"+col.name); NumberInfo ni = col.GetComponent <NumberInfo>(); if (ni) { ActivateEffects(); if (lightAreaType == LightAreaType.Negative) { ni.SetNumber(Fraction.Multiply(new Fraction(-1, 1), Fraction.GetAbsoluteValue(ni.fraction)), false); } if (lightAreaType == LightAreaType.Positive) { ni.SetNumber(Fraction.Multiply(new Fraction(1, 1), Fraction.GetAbsoluteValue(ni.fraction)), false); } // NumberModifier.ModifyOperation nmf = (x => x); // if (lightAreaType == LightAreaType.Negative && ni.fraction.numerator > 0) nmf = (x => Fraction.Multiply(x, new Fraction(-1, 1))); // else if (lightAreaType == LightAreaType.Negative && ni.fraction.numerator < 0) nmf = (x => Fraction.Multiply(x, new Fraction(1, 1))); // else if (lightAreaType == LightAreaType.Positive && ni.fraction.numerator > 0) nmf = (x => Fraction.Multiply(x, new Fraction(1, 1))); // else if (lightAreaType == LightAreaType.Positive && ni.fraction.numerator < 0) nmf = (x => Fraction.Multiply(x, new Fraction(-1, 1))); // modifyOp = nmf; // ModifyNumber(ni); } else if (col.tag == "Player") { ActivateEffects(); // // commented Debug.Log("Player triggered positive area"); NumberModifier.ModifyOperation nmf = (x => x); if (lightAreaType == LightAreaType.Positive) { nmf = (x => Fraction.GetAbsoluteValue(x)); } else if (lightAreaType == LightAreaType.Negative) { nmf = (x => Fraction.Multiply(new Fraction(-1, 1), Fraction.GetAbsoluteValue(x))); } Inventory.inst.ModifyInventoryItems(nmf); } }
public override void ModifyAmmo(NumberModifier.ModifyOperation fn) { List <Ammo> toremove = new List <Ammo>(); foreach (Ammo a in rocketAmmo) { a.ammoValue = fn(a.ammoValue); if (a.ammoValue.numerator == 0) { toremove.Add(a); } // // commented Debug.Log(a.ammoValue); } foreach (Ammo a in toremove) { rocketAmmo.Remove(a); } UpdateAmmoGraphics(); }
void OnExplode() { float radius = 20; Collider[] cols = Physics.OverlapSphere(transform.position, radius); foreach (Collider c in cols) { if (c.tag == "Player") { // GlobalVars.inst.pnc.DropAmmo(); NumberInfo ni = GetComponent <NumberInfo>(); NumberModifier.ModifyOperation nmf = (x => x); nmf = (x => Fraction.Add(x, ni.fraction)); // GlobalVars.inst.inv.ClearInventory(); Inventory.inst.ModifyInventoryItems(nmf); // GlobalVars.inst.pnc.ModifyAmmoNumbers(nmf); } } }
virtual public void ModifyAmmo(NumberModifier.ModifyOperation nmf) { }