Esempio n. 1
0
 public virtual void NewTap(TapParams @params)
 {
     if ((@params.tap == this.tapType) || (this.tapType == 3))
     {
         if (!this.turning)
         {
             if (!this.turned || !this.toggleTurn)
             {
                 this.goalRotation = this.endRotation;
                 this.StartCoroutine(this.rotate(this.transform.rotation, this.endRotation));
                 if (this.pivotSound)
                 {
                     this.GetComponent <AudioSource>().PlayOneShot(this.pivotSound);
                 }
                 this.turned = true;
             }
             else
             {
                 this.goalRotation = this.startRotation;
                 this.StartCoroutine(this.rotate(this.transform.rotation, this.startRotation));
                 if (this.pivotSound)
                 {
                     this.GetComponent <AudioSource>().PlayOneShot(this.pivotSound);
                 }
                 this.turned = false;
             }
         }
     }
 }
Esempio n. 2
0
 public virtual void NewTap(TapParams @params)
 {
     if ((@params.tap == this.tapType) || (this.tapType == 3))
     {
         if (this.ready)
         {
             this.floating = !this.floating;
             this.ready    = false;
             this.StartCoroutine(this.takeBreather());
         }
         if (this.floating)
         {
             if (this.GetComponent <Rigidbody>())
             {
                 this.GetComponent <Rigidbody>().isKinematic = true;
             }
             this.originalParent = this.transform.parent;
             this.tempParent     = new GameObject("tempParent");
             this.tempParent.transform.position = this.transform.localPosition;
             this.tempParent.transform.rotation = this.transform.localRotation;
             this.transform.parent                = this.tempParent.transform;
             this.tempParent.transform.parent     = this.originalParent;
             this.cursorScript.followActiveObject = this.followWhenActive; // tell cursorScript whether it should follow this object
             this.cursorScript.activeObj          = this.gameObject;       // tell cursorScript that we have an active object
         }
         else
         {
             this.cursorScript.activeObj = null;
             this.transform.parent       = this.originalParent;
             UnityEngine.Object.Destroy(this.tempParent);
         }
     }
 }
Esempio n. 3
0
 public virtual void NewTap(TapParams @params)
 {
     if ((@params.tap == this.tapType) || (this.tapType == 3))
     {
         this.textOn = !this.textOn;
         this.textScript.toggleVisible(this.textOn);
     }
 }
Esempio n. 4
0
 public virtual void NewTap(TapParams @params)
 {
     if ((@params.tap == this.tapType) || (this.tapType == 3))
     {
         Vector3 pushForce = new Vector3(Random.Range(-this.randomForce, this.randomForce), this.upForce, Random.Range(-this.randomForce, this.randomForce));
         this.GetComponent <Rigidbody>().AddForce(pushForce);
         Vector3 spinForce = new Vector3(Random.Range(-this.torqueForce, this.torqueForce), Random.Range(-this.torqueForce, this.torqueForce), Random.Range(-this.torqueForce, this.torqueForce));
         this.GetComponent <Rigidbody>().AddRelativeTorque(spinForce);
     }
 }
Esempio n. 5
0
 public virtual void NewTap(TapParams @params)
 {
     if ((@params.tap == tapType) || (tapType == 3))
     {
         Vector3 vec = transform.position - @params.hit.point; // the direction from clickPoint to the rigidbody
         vec = vec.normalized;
         GetComponent <Rigidbody>().AddForce((vec * pushForce) * 100);
         Vector3 vec2 = new Vector3(Random.Range(-spinForce, spinForce), Random.Range(-spinForce, spinForce), Random.Range(-spinForce, spinForce));
         GetComponent <Rigidbody>().AddRelativeTorque(vec2 * 100);
     }
 }
Esempio n. 6
0
 public virtual void NewTap(TapParams @params)
 {
     if ((@params.tap == this.tapType) || (this.tapType == 3))
     {
         if (this.clickSound)
         {
             this.GetComponent <AudioSource>().PlayOneShot(this.clickSound);
         }
         this.thisScript.switchLighting();
     }
 }
Esempio n. 7
0
 public virtual void NewTap(TapParams @params)
 {
     if (readyForStateChange)
     {
         if (!activated)
         {
             if ((@params.tap == tapType) || (tapType == 3))
             {
                 activated = true;
             }
         }
         else
         {
             activated = false;
         }
         //activated = !activated;
         hitDistance         = @params.hit.distance;
         readyForStateChange = false;
         StartCoroutine(pauseAfterStateChange());
     }
     if (activated)
     {
         clickPosition          = @params.hit.point;
         cursorScript.activeObj = gameObject; // tell cursorScript that we have an active object
         if (!springJoint)
         {
             GameObject go   = new GameObject("Rigidbody dragger");
             Rigidbody  body = ((Rigidbody)go.AddComponent(typeof(Rigidbody))) as Rigidbody;
             springJoint      = (SpringJoint)go.AddComponent(typeof(SpringJoint));
             body.isKinematic = true;
         }
         springJoint.transform.position = @params.hit.point;
         if (attachToCenterOfMass)
         {
             Vector3 anchor = transform.TransformDirection(GetComponent <Rigidbody>().centerOfMass) + GetComponent <Rigidbody>().transform.position;
             anchor             = springJoint.transform.InverseTransformPoint(anchor);
             springJoint.anchor = anchor;
         }
         else
         {
             springJoint.anchor = Vector3.zero;
         }
         springJoint.spring        = spring;
         springJoint.damper        = damper;
         springJoint.maxDistance   = distance;
         springJoint.connectedBody = GetComponent <Rigidbody>();
         StartCoroutine(increaseSpringAfterPickup());
         StartCoroutine("DragObject");
     }
     else
     {
         cursorScript.activeObj = null;
     }
 }
Esempio n. 8
0
 public virtual void NewTap(TapParams @params)
 {
     if ((@params.tap == this.tapType) || (this.tapType == 3))
     {
         if (!this.spinning)
         {
             this.spinTapTime  = Time.time;
             this.spinAmount   = new Vector3(Random.Range(-30, 30), Random.Range(-30, 30), Random.Range(-30, 30));
             this.goalRotation = this.transform.rotation * Quaternion.Euler(this.spinAmount);
             this.spinning     = true;
             this.StartCoroutine(this.rotate(this.transform.rotation, this.goalRotation));
         }
     }
 }
Esempio n. 9
0
 public virtual void NewTap(TapParams @params)
 {
     if ((@params.tap == this.tapType) || (this.tapType == 3))
     {
         if (!this.GetComponent <AudioSource>().isPlaying)
         {
             this.GetComponent <AudioSource>().Play();
         }
         else
         {
             if (this.toggleOnOff)
             {
                 if (this.rewindOnStop)
                 {
                     this.GetComponent <AudioSource>().Stop();
                 }
                 else
                 {
                     this.GetComponent <AudioSource>().Pause();
                 }
             }
         }
     }
 }