IEnumerator GameUpdateL() { for (;;) { if (pause) { break; } Kinect.Body[] data = _BodyManager.GetData(); if (data == null) { yield return(null); continue; } List <Kinect.Body> bodies = new List <Kinect.Body>(); foreach (Kinect.Body body in data) { if (body != null && body.IsTracked) { bodies.Add(body); } } if (bodies.Count != 2) { //Debug.LogError("Body count not 1 or 2! Got " + bodies.Count.ToString()); //Debug.LogError("Body count Got " + bodies.Count.ToString()); StartCoroutine(WaitForBodies()); break; //if (bodies.Count == 0) //{ // yield return null; // continue; //} } if (charL.transform.position.z > levelL[nextWallL].transform.position.z - wallAnimDistance) { levelL[nextWallL].GetComponent <Animator>().SetBool("isPlay", true); } if (charL.transform.position.z > levelL[nextWallL + 1].transform.position.z - wallAnimDistance) { levelL[nextWallL + 1].GetComponent <Animator>().SetBool("isPlay", true); } if (charL.transform.position.z > endPrefabZ) { // We win! Script motion, land in truck... playerLNoCam = true; Vector3 angleDir = Quaternion.Euler(0.0f, 17.7f, 0.0f) * Vector3.forward; while (charL.transform.position.z < endPrefabZ + 57.0f) { camL.transform.Translate(3 * camMoveTickL * beat * Time.deltaTime * angleDir, Space.World); charL.transform.Translate(3 * camMoveTickL * beat * Time.deltaTime * angleDir, Space.World); yield return(null); } while (charL.transform.position.z < endPrefabZ + 117.0f) { camL.transform.Translate(3 * camMoveTickL * beat * Time.deltaTime * Vector3.forward, Space.World); charL.transform.Translate(3 * camMoveTickL * beat * Time.deltaTime * Vector3.forward, Space.World); yield return(null); } charL.transform.position = new Vector3(charL.transform.position.x, charL.transform.position.y, endPrefabZ + 117.0f); yield return(null); goL = avatarL.gameObject; Destroy(avatarL); GameObject dancer = Instantiate(dancerPrefab); dancer.transform.localScale = goL.transform.localScale; dancer.transform.rotation = goL.transform.rotation; dancer.transform.position = goL.transform.position; Destroy(goL); goL = dancer; // jump in box float jumpVel = 3.5f; float startSizeFactor = 4.0f; float endSizeFactor = 3.5f; float sizeVel = 0.0f; float startLot = 0.0f; float endLot = -180.0f; float rotVel = 0.0f; float rot = startLot; while (rot > -175f) { jumpVel -= 0.1f; goL.transform.Translate(new Vector3(1.0f * Time.deltaTime, Time.deltaTime * jumpVel, 0.87f * camMoveTickL * beat * Time.deltaTime), Space.World); if (goL.transform.position.z > endPrefabZ + 122.0f) { Vector3 pos = goL.transform.position; pos.z = endPrefabZ + 122.0f; goL.transform.position = pos; } if (goL.transform.position.y < 1.0f && rot < -80.0f) { Vector3 pos = goL.transform.position; pos.y = 1.0f; goL.transform.position = pos; } float scale = Mathf.SmoothDamp(goL.transform.localScale.x, endSizeFactor, ref sizeVel, 0.5f); goL.transform.localScale = scale * Vector3.one; rot = Mathf.SmoothDamp(rot, endLot, ref rotVel, 0.8f); goL.transform.eulerAngles = new Vector3(0.0f, rot, 0.0f); yield return(null); } playerLdone = true; break; } if (charL.transform.position.z > levelL[nextWallL].transform.position.z - collisionCheckDistance) { Vector3 failVecL = Vector3.zero; uint newFailStateL = 0; if (levelL[nextWallL].Permits(BodyL, ref failVecL, failStateL, out newFailStateL)) { permitL = true; } if (charL.transform.position.z >= levelL[nextWallL].transform.position.z) { if (permitL) { Debug.Log("Player L made it past wall " + nextWallL.ToString() + "!"); passWallAudio.PlayOneShot(passWallAudio.clip); } else { failStateL |= newFailStateL; materialL.mainTexture = tex[failStateL]; GameObject limb = null; Vector3 limbVelocity = Vector3.zero; switch ((Wall.FailStates)newFailStateL) { case Wall.FailStates.LeftArm: { limb = Instantiate(arm); limb.transform.position = LshoulderL.transform.position; limbVelocity = armVelocity; //Debug.Log("Left arm is gone!"); } break; case Wall.FailStates.RightArm: { limb = Instantiate(arm); limb.transform.position = LshoulderL.transform.position; limbVelocity = armVelocity; //Debug.Log("Light arm is gone!"); } break; case Wall.FailStates.LeftLeg: { limb = Instantiate(leg); limb.transform.position = LhipL.transform.position; limbVelocity = legVelocity; //Debug.Log("Left leg is gone!"); } break; case Wall.FailStates.RightLeg: { limb = Instantiate(leg); limb.transform.position = LhipL.transform.position; limbVelocity = legVelocity; //Debug.Log("Light leg is gone!"); } break; } limb.transform.forward = failVecL; Rigidbody rb = limb.AddComponent <Rigidbody>(); rb.velocity = limbVelocity + new Vector3(Random.Range(-0.3f, 0.3f), Random.Range(-0.3f, 0.3f), Random.Range(-0.3f, 0.3f)); rb.angularVelocity = Random.Range(4.0f, 7.0f) * Random.onUnitSphere; GenerateParticle(failVecL, charL.transform.position); splatAudio.PlayOneShot(splatAudio.clip); Vector3 camPos = camL.transform.position; Vector3 shakeVel = Vector3.zero; Quaternion rot = camL.transform.rotation; { float moveVel = 0.0f; while (camMoveTickL > 0.03f) { camMoveTickL = Mathf.SmoothDamp(camMoveTickL, 0.0f, ref moveVel, 0.1f); Vector3 pos = Vector3.SmoothDamp(camL.transform.position, camPos + Random.Range(0.0f, 0.4f * (camMoveSpeed - camMoveTickL) / camMoveSpeed) * Random.onUnitSphere, ref shakeVel, 0.2f); pos.z = camL.transform.position.z; camL.transform.position = pos; camL.transform.rotation = Quaternion.Euler(Random.Range(-3.0f * (camMoveSpeed - camMoveTickL) / camMoveSpeed, 3.0f * (camMoveSpeed - camMoveTickL) / camMoveSpeed), Random.Range(-3.0f * (camMoveSpeed - camMoveTickL) / camMoveSpeed, 3.0f * (camMoveSpeed - camMoveTickL) / camMoveSpeed), Random.Range(-3.0f * (camMoveSpeed - camMoveTickL) / camMoveSpeed, 3.0f * (camMoveSpeed - camMoveTickL) / camMoveSpeed)) * rot; yield return(null); } camL.transform.rotation = rot; camMoveTickL = 0.03f; } yield return(new WaitForSeconds(1.0f)); if ((failStateL & (uint)Wall.FailStates.LeftLeg) != 0 && (failStateL & (uint)Wall.FailStates.RightLeg) != 0) { failStateL = 0; materialL.mainTexture = tex[failStateL]; yield return(new WaitForSeconds(0.5f)); meshL.GetComponent <SkinnedMeshRenderer>().enabled = false; yield return(new WaitForSeconds(0.5f)); meshL.GetComponent <SkinnedMeshRenderer>().enabled = true; yield return(new WaitForSeconds(0.5f)); meshL.GetComponent <SkinnedMeshRenderer>().enabled = false; yield return(new WaitForSeconds(0.5f)); meshL.GetComponent <SkinnedMeshRenderer>().enabled = true; } { float vel = 0.0f; while (camMoveTickL < camMoveSpeed - 0.1f) { camMoveTickL = Mathf.SmoothDamp(camMoveTickL, camMoveSpeed, ref vel, 0.6f); Vector3 pos = Vector3.SmoothDamp(camL.transform.position, camPos, ref shakeVel, 0.3f); pos.z = camL.transform.position.z; camL.transform.position = pos; yield return(null); } camMoveTickL = camMoveSpeed; } } ++nextWallL; permitL = false; } } progress.SetLeftValue(charL.transform.position.z / endZ); yield return(null); } }