public override void UseHoop(GameObject obj, RecordPosition record, bool direction) { if (LevelBuilder.inst.levelBuilderIsShowing) { return; } base.UseHoop(obj, record, direction); NumberInfo ni = obj.GetComponent <NumberInfo>(); Player p = obj.GetComponent <Player>(); // Set number only if player is holding it. if (p) { if (PlayerGadgetController.inst.ThrowGadgetEquipped()) { if (GadgetThrow.inst.numberHeld) { ni = GadgetThrow.inst.numberHeld.GetComponent <NumberInfo>(); } } } if (ni) { if (ni.IsSoapable()) { if (direction) { ni.SoapNumber(); } else { ni.UnSoapNumber(); } } } if (p) { GadgetThrow.inst.UpdateAmmoGraphics(); } }
override public void UpdateAmmoGraphics(bool redraw = false) { // // commented Debug.Log("update:"+numberHeld); // if (PlayerGadgetController.inst.currentWeapon != this) return; // don't mess with graphics if this weapon isn't selected. base.UpdateAmmoGraphics(); if (ammoGraphics) { UnityEngine.Object.Destroy(ammoGraphics); } // if (ammoGraphics) UnityEngine.Object.Destroy(ammoGraphics); // // commented Debug.Log("modifying throw gfx"); if (numberHeld) { // // commented Debug.Log ("number held:"+numberHeld); // // commented Debug.Log ("number held:"+numberHeld.GetComponent<NumberInfo>().fraction); // // commented Debug.Log ("throw static"); NumberInfo ni = numberHeld.GetComponent <NumberInfo>(); if (ni) { // for numbers we do want to keep certain scripts on them as ammo, such as alwaysfaceplayer ammoGraphics = NumberManager.inst.CreateNumberAmmo(ni.fraction, ni.myShape); // Did the oriignal number info have soap bubbles? (bad place for this to be? lol) if (ni.IsSoapable() && ni.soapFx.activeSelf) { GameObject soapCopy = (GameObject)GameObject.Instantiate(ni.soapFx, ammoGraphics.transform.position, ammoGraphics.transform.rotation); soapCopy.transform.parent = ammoGraphics.transform; ParticleSystem ps = soapCopy.GetComponentInChildren <ParticleSystem>(); ParticleSystem.ShapeModule pss = ps.shape; pss.radius *= 0.5f; // ps.sh } } else { // otherwise, do not duplicate/strip the ammo, intead reconstruct it from scratch. ammoGraphics = Utils.ConstructFakeCopyOfAmmo(numberHeld); ammoGraphics.transform.rotation = Quaternion.identity; } // (GameObject)UnityEngine.Object.Instantiate(numberHeld); // if (ueo) ueo.isSerializeableForSceneInstance = false; // ammoGraphics.name = "ammo graphics"; CleanComponentsForAmmo(ammoGraphics); PickUppableObject pip = numberHeld.GetComponent <PickUppableObject>(); ammoGraphics.transform.parent = PlayerGadgetController.inst.GetPlayerLocationForGadget(gadgetLocationOnPlayer); if (pip) { ammoGraphics.transform.localScale *= pip.heldScale; } else { ammoGraphics.transform.localScale = Vector3.one * 0.5f; // * 0.5f; // * Player.inst.transform.localScale.x } Transform m1 = ammoGraphics.transform.Find("mesh"); if (m1) { m1.localScale = Vector3.one * 0.5f; // // commented Debug.Log ("set to 0.5"); } Transform m2 = ammoGraphics.transform.Find("mesh2"); if (m2) { m2.localScale = playerHoldingScale * Vector3.one; } ammoGraphics.transform.localPosition = playerHoldingPos; // Vector3.zero;// new Vector3(.3f,.078f,-.1f); if (pip.alwaysFacePlayerAsAmmo) { ammoGraphics.AddComponent <AlwaysFacePlayer>(); } // ammoGraphics.transform.LookAt(Player.inst.transform); // ammoGraphics.transform.rotation = Utils.FlattenRotation(ammoGraphics.transform.rotation); ammoGraphics.SetActive(true); ni = ammoGraphics.GetComponent <NumberInfo>(); if (ni) { ni.InitSinGrowAttributes(.100f); ni.SinGrowOnce(); } // // commented Debug.Log("ammogrpahics:"+ammoGraphics.transform.localPosition+", playerhod:"+playerHoldingPos); // // commented Debug.Log ("setting ammograph localpos to:"+ammoGraphics.transform.localPosition+", but player hollding pos was;"+playerHoldingPos); // // commented Debug.Log ("moved to:"+ammoGraphics.transform.localPosition); // ammoGraphics.transform.localRotation = Quaternion.identity; // ammoGraphics.SendMessage("OnPlayerEquip",SendMessageOptions.DontRequireReceiver); } else { numberHeld = null; MascotAnimatorController.inst.HoldRightArm(false); } }