IEnumerator NumberGlowRedAndDie(NumberInfo ni) { float glowTime = Random.Range(1.5f, 2f); float t = 0; float redSpeed = 1; List <Renderer> rs = new List <Renderer>(); foreach (Renderer rr in ni.GetComponentsInChildren <Renderer>()) { if (rr.material.HasProperty("_Color")) { rs.Add(rr); } } while (t < glowTime) { t += Time.deltaTime; yield return(new WaitForSeconds(Time.deltaTime)); foreach (Renderer r in rs) { if (r) { r.material.color = Color.Lerp(r.material.color, Color.red, Time.deltaTime * redSpeed); } } } // if (ni) ni.gameObject.AddComponent<ShrinkAndDisappear>(); // Destroy (ni.gameObject); }
public void SetUpDigits(NumberInfo ni) { // Debug.Log("setting up digits;"+ni.fraction); if (digits) { Destroy(digits); } digits = NumberManager.inst.CreateNumberAmmo(ni.fraction, ni.myShape); // if (ni.GetComponent // Debug.Log("set dig"); SetUpNumberGraphics(ni); digits.transform.SetParent(transform); digits.transform.localPosition = Vector3.zero; NumberInfo nim = digits.GetComponent <NumberInfo>(); foreach (Renderer r in digits.GetComponentsInChildren <Renderer>()) { r.material = NumberManager.inst.inventoryDigitMaterial; } Destroy(nim.childMeshRenderer.gameObject); // we created a 3D ammo object (which isn't ideal but it gives us mostly what we want) but we dont want the 3d sphere/cube if (nim.digits.gameObject.GetComponent <SometimesFacePlayer>()) { Destroy(nim.digits.gameObject.GetComponent <SometimesFacePlayer>()); // don't want digits moving about } if (nim.GetComponentsInChildren <CubeNumberFacePlayer90>().Length > 0) { foreach (CubeNumberFacePlayer90 c90 in nim.GetComponentsInChildren <CubeNumberFacePlayer90>()) { Destroy(c90); // don't want digits moving about } } Quaternion rot = new Quaternion(); digits.transform.localScale = Vector3.one * 55f; // Need to increase digits size for UI. We really should be pulling from a UI number prefab instead of chopping up NumberAmmoPrefab which is not intended for UI use. if (nim.myShape == NumberShape.Sphere) { rot.eulerAngles = new Vector3(0, 180, 0); } else if (nim.myShape == NumberShape.Cube) { rot.eulerAngles = new Vector3(0, 225, 0); } else if (nim.myShape == NumberShape.Tetrahedron) { rot.eulerAngles = new Vector3(0, 270, 15); nim.digits.transform.localPosition = new Vector3(0.037f, 0.012f, 0.004f); nim.digits.transform.localScale = Vector3.one * 0.5f; } else if (nim.myShape == NumberShape.Schur) { rot.eulerAngles = new Vector3(0, 180, 0); // nim.digits.transform.localPosition = new Vector3(0.037f,0.012f,0.004f); // nim.digits.transform.localScale = Vector3.one * 0.5f; } nim.digits.transform.localRotation = rot; SMW_GF.inst.SetLayerRecursively(digits, LayerMask.NameToLayer("UI")); Destroy(nim); return; // bool frac = false; // if (ni.fraction.denominator > 1) frac = true; // // digits = (GameObject)Instantiate(Inventory.inst.digitsPrefab); // digits.transform.SetParent(transform,false);// = transform; //// digits.transform.localPosition = Vector3.zero; // digits.GetComponent<InventoryDigits>().numerator.text = ni.texts[0].numerator.Text; // digits.GetComponent<InventoryDigits>().denominator.text = ni.texts[0].denominator.Text; // digits.GetComponent<InventoryDigits>().line.text = ni.texts[0].line.Text; // digits.GetComponent<InventoryDigits>().integer.text = ni.texts[0].integer.Text; // // List different cases for number sizes/combos and assign absolute positions and scales for digits based on these cases /* * 1 * 12 * 123 * 1234 * 12345 * 123456 * -123456 * 1/2 * 9/10 * 11/9 * 123/3 * 12/25 * 1/123 * 123/32 * 32/123 * 123/123 * 123/1234 * 1234/123 * 1234/1234 * * 1 1/2 * 2 1/2 * * * */ }
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); }