IEnumerator Solve(Fraction fr) { // Dictionary<Transform,float> fuses = new Dictionary<Transform,float>(); // burst cubes apart float dt = .4f; foreach (DanMeyerCube dmc in cubes) { if (dmc) { // fuses.Add(dmc.transform,Random.Range(.5f,2.2f)); Rigidbody rb = dmc.gameObject.AddComponent <Rigidbody>(); Vector3 awayVector = dmc.transform.localPosition - CenterOfCube(); float awayForce = 155; rb.AddForce(awayVector * awayForce); } } yield return(StartCoroutine(DestroyCubesRandomly())); resourceDrop.DropResource(); // pop them one by one // int cubesToSkip = NumberCubesActive() / 5; // float percentChanceToSkipTime = 1/(float)cubesToSkip; // do 1 / n cubes every frame yield return(0); Destroy(this.gameObject); Debug.Log("<color=#f55>DESTROYED</color>"); PlayerNowMessage.inst.Display("Correct! This structure had " + fr.ToString() + " cubes."); }
public void DestroyedByPlayer() { ResourceDrop rd = GetComponentInChildren <ResourceDrop>(); if (rd) { rd.DropResource(); } }