// Update is called once per frame void Update() { mainHand = controller.Frame().Hands[0]; objInLastFrame = objInCurrFrame; objInCurrFrame = null; //testing purposes if (Input.GetKeyDown(KeyCode.I)) { objInCurrFrame = CreateObject(MagicType.IceWall); } if (Input.GetKeyDown(KeyCode.F)) { objInCurrFrame = CreateObject(MagicType.Fireball); } if (Input.GetKeyDown(KeyCode.T)) { Application.LoadLevel(MagicConstant.TUTORIAL_LEVEL); } if (Input.GetKeyDown(KeyCode.G)) { Application.LoadLevel(MagicConstant.GAME_LEVEL); } if (Input.GetKey(KeyCode.J) || Input.GetKey(KeyCode.Q)) { player.transform.Rotate(new Vector3(0, -TURN_DIST, 0)); //pivot left } if (Input.GetKey(KeyCode.K) || Input.GetKey(KeyCode.E)) { //pivot right player.transform.Rotate(new Vector3(0, TURN_DIST, 0)); } //Debug.Log (HandHelper.isFaceForward(mainHand, controller.Frame()) + " " + mainHand.Direction + ":" + mainHand.PalmNormal); //cooling down, don't do anything else if (cd.coolingDown(nc)) { neutralize(); //hand stuff } else if (HandHelper.isValidHand(mainHand)) { if (HandHelper.isClosedFist(mainHand)) { //nc.resetBottomServo(); canCharge = true; } else if (HandHelper.isFaceUp(mainHand, controller.Frame()) && canCharge) { Debug.Log(chargeCounter); if (chargeCounter <= LONG_THRESHOLD) { if (chargeCounter > SHORT_THRESHOLD && chargeCounter <= MEDIUM_THRESHOLD) { objInCurrFrame = CreateObject(MagicType.FireCharge, Size.Medium); } else if (chargeCounter > MEDIUM_THRESHOLD) { objInCurrFrame = CreateObject(MagicType.FireCharge, Size.Large); } else { objInCurrFrame = CreateObject(MagicType.FireCharge, Size.Small); } //Debug.Log ("Charging: " + chargeCounter); nc.heatPeltier(lastSize); chargeCounter++; //overloaded, go into cooldown } else { Debug.Log("Charged too long, in cooldown mode"); neutralize(); cd.startCooldown(); } //shoot charged object } else if (HandHelper.isFaceForward(mainHand, controller.Frame()) && chargeCounter > MIN_THRESHOLD) { objInCurrFrame = CreateObject(MagicType.Fireball); neutralize(); //charge ice wall } else if (HandHelper.isFaceForward(mainHand, controller.Frame())) { Vector3 palmPos = mainHand.PalmPosition.ToUnityScaled(); Collider[] hitColliders = Physics.OverlapSphere(transform.TransformPoint(palmPos), CLOSEST_ICEWALL_DIST); bool collided = false; for (int i = 0; i < hitColliders.Length; i++) { if (hitColliders[i].tag == MagicConstant.ICEWALL_TAG) { hitColliders[i].SendMessage(MagicConstant.ICEWALL_CHARGE_SPELLNAME); collided = true; } } //create an ice wall if there isn't a nearby one and a circle gesture was performed if (!collided && GameObject.FindWithTag(MagicConstant.FIREBALL_TAG) == null) { iceCounter++; if (iceCounter > ICE_THRESHOLD) { objInCurrFrame = CreateObject(MagicType.IceWall); canIce = false; iceCounter = 0; } } } else { idling(); } } else { idling(); } }