void HandlePacket(GuitarPacket packet) { UpdateTopFrets?.Invoke(packet.TopFrets); UpdateBottomFrets?.Invoke(packet.BottomFrets); UpdateStrum?.Invoke(packet.Strum); UpdateButtons?.Invoke(packet.Buttons); UpdateMotion?.Invoke(packet.Motion); UpdateSlider?.Invoke(packet.Slider); }
void Awake() { //Get Root Transform. objectSlot = GameObject.Find("UISlot").transform; UICamera = GameObject.Find("UICamera").GetComponent <Camera>(); UISlot = GameObject.Find("UISlot").GetComponent <ImageUISlot> (); objectRoot = GameObject.Find("ObjectRoot").transform; objectWrapper = this.transform.parent; scale = this.transform.localScale; // objectRigidbody.Sleep (); updateMotion = updateUIMotion; }
//change parent private void attachToUI() { objectWrapper = UISlot.GetCurrentCenterWrapper(); this.transform.parent = Camera.main.transform; position = this.transform.localPosition; this.transform.parent = UICamera.transform; this.transform.localPosition = position; this.transform.parent = objectWrapper; updateMotion = updateUIMotion; disableRigidBody(); }
//update Function for Grabed MODE void updateGrabMotion(float dt) { const float limit = 0.2f; //calculating to get depth. touch = UICamera.WorldToScreenPoint(this.transform.position); //calculating to get position x, y. touch.x = ImageUITouch.PixelPosition.x; touch.y = ImageUITouch.PixelPosition.y; position = UICamera.ScreenToWorldPoint(touch); calcSlotRotateSpeed(); if (ImageUITouch.Status == ImageUITouch.TouchStatus.idle) { //need one more condition. (speed or area) if (ImageUITouch.ElaspedNormalPosition.y > limit) { attachToWorld(); updateMotion = updateReleaseMotion; } else { updateMotion = updateUIMotion; } UISlot.PickInit(); } else { if (ImageUITouch.ElaspedNormalPosition.y > limit) { this.transform.parent = objectSlot; UISlot.PickUp(); } else { this.transform.parent = objectWrapper; UISlot.PickDown(); } //set position this.transform.position += (position - this.transform.position) * dt * 20.0f; } }
// update Function for UI MODE void updateUIMotion(float dt) { if (ImageUITouch.Status == ImageUITouch.TouchStatus.pick && ImageUITouch.HitObject == this.gameObject) { updateMotion = updateGrabMotion; } position.Set(0.0f, 2.0f, 0.0f); rotation.Set(0.0f, 0.0f, 0.0f); rotation.z = rotation.z > 180.0f ? rotation.z - 360.0f : rotation.z; rotation.z += (0.0f - rotation.z) * dt * 10.0f; this.transform.localPosition += (position - this.transform.localPosition) * dt * 10.0f; this.transform.localEulerAngles = rotation; this.transform.localScale += (scale - this.transform.localScale) * dt * 10.0f; objectWrapper = this.transform.parent; }