123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270 |
- using UnityEngine;
- public class MouseDrag3 : MonoBehaviour
- {
- public Transform head;
- public int ido;
- public bool isClick;
- public bool isClick2;
- public bool isHead;
- public bool isIdo;
- public bool isPlay;
- public bool isSelect;
- public bool isStop;
- public Maid maid;
- public int no;
- public GameObject obj;
- public Transform Pelvis;
- public bool reset;
- public bool shodaiFlg = false;
- public Transform Spine;
- public Transform Spine0a;
- public Transform Spine1;
- public Transform Spine1a;
- private float doubleTapTime;
- private int idoOld;
- private Vector3 mouseIti;
- private Vector3 mouseIti2;
- private Vector3 off;
- private Vector3 off2;
- private Vector3 pos3;
- private Quaternion quaL;
- private Quaternion quaR;
- private Vector3 rotate;
- private Vector3 rotate1;
- private Vector3 rotate2;
- private Vector3 rotate3;
- private Vector3 rotate4;
- private Vector3 rotate5;
- private Vector3 rotateL;
- private Vector3 rotateR;
- private Vector3 worldPoint;
- public void Update()
- {
- doubleTapTime += Time.deltaTime;
- }
- public void OnMouseDown()
- {
- if (!(maid != null))
- return;
- worldPoint = Camera.main.WorldToScreenPoint(transform.position);
- mouseIti = Input.mousePosition;
- if (ido == 1 || ido == 4 || ido == 8)
- rotate = head.localEulerAngles;
- if (ido == 2 || ido == 5)
- {
- rotate1 = Spine1a.localEulerAngles;
- rotate2 = Spine1.localEulerAngles;
- rotate3 = Spine0a.localEulerAngles;
- rotate4 = Spine.localEulerAngles;
- }
- if (ido == 3 || ido == 6)
- rotate5 = Pelvis.localEulerAngles;
- if (ido == 7)
- {
- rotateR = maid.body0.quaDefEyeR.eulerAngles;
- rotateL = maid.body0.quaDefEyeL.eulerAngles;
- quaL = maid.body0.quaDefEyeL;
- quaR = maid.body0.quaDefEyeR;
- }
- if (ido == 9)
- {
- worldPoint = Camera.main.WorldToScreenPoint(transform.position);
- off = transform.position
- - Camera.main.ScreenToWorldPoint(new Vector3(Input.mousePosition.x, Input.mousePosition.y, worldPoint.z));
- off2 = new Vector3(obj.transform.position.x - head.position.x,
- obj.transform.position.y - head.position.y,
- obj.transform.position.z - head.position.z);
- mouseIti = Input.mousePosition;
- }
- isSelect = true;
- isPlay = maid.body0.m_Bones.GetComponent<Animation>().isPlaying;
- if (!isPlay)
- isStop = true;
- if (doubleTapTime < 0.300000011920929 && isClick2 && ido == idoOld)
- isHead = true;
- if (doubleTapTime >= 0.300000011920929 && isClick)
- isClick = false;
- if (doubleTapTime >= 0.300000011920929 && isClick2)
- isClick2 = false;
- doubleTapTime = 0.0f;
- pos3 = Input.mousePosition - mouseIti;
- }
- public void OnMouseUp()
- {
- if (!(maid != null) || doubleTapTime >= 0.300000011920929)
- return;
- if (ido == 7)
- isClick = true;
- isClick2 = true;
- doubleTapTime = 0.0f;
- idoOld = ido;
- }
- public void OnMouseDrag()
- {
- if (!(maid != null))
- return;
- if (isPlay && mouseIti != Input.mousePosition)
- {
- maid.body0.m_Bones.GetComponent<Animation>().Stop();
- isStop = true;
- isPlay = false;
- }
- if (reset)
- {
- reset = false;
- worldPoint = Camera.main.WorldToScreenPoint(transform.position);
- if (ido == 1 || ido == 4 || ido == 8)
- rotate = head.localEulerAngles;
- if (ido == 2 || ido == 5)
- {
- rotate1 = Spine1a.localEulerAngles;
- rotate2 = Spine1.localEulerAngles;
- rotate3 = Spine0a.localEulerAngles;
- rotate4 = Spine.localEulerAngles;
- }
- if (ido == 3 || ido == 6)
- rotate5 = Pelvis.localEulerAngles;
- if (ido == 7)
- {
- rotateR = maid.body0.quaDefEyeR.eulerAngles;
- rotateL = maid.body0.quaDefEyeL.eulerAngles;
- quaL = maid.body0.quaDefEyeL;
- quaR = maid.body0.quaDefEyeR;
- }
- mouseIti = Input.mousePosition;
- if (ido == 9)
- {
- worldPoint = Camera.main.WorldToScreenPoint(transform.position);
- off = transform.position
- - Camera.main.ScreenToWorldPoint(new Vector3(Input.mousePosition.x, Input.mousePosition.y, worldPoint.z));
- off2 = new Vector3(obj.transform.position.x - head.position.x,
- obj.transform.position.y - head.position.y,
- obj.transform.position.z - head.position.z);
- mouseIti = Input.mousePosition;
- }
- }
- if (mouseIti != Input.mousePosition)
- {
- var position = new Vector3(Input.mousePosition.x, Input.mousePosition.y, worldPoint.z);
- Vector3 vector3_1 = Input.mousePosition - mouseIti;
- Transform transform = GameMain.Instance.MainCamera.gameObject.transform;
- Vector3 vector3_2 = transform.TransformDirection(Vector3.right);
- Vector3 vector3_3 = transform.TransformDirection(Vector3.forward);
- if (mouseIti2 != Input.mousePosition)
- {
- if (ido == 1)
- {
- isIdo = true;
- head.localEulerAngles = rotate;
- head.RotateAround(head.position, new Vector3(vector3_2.x, 0.0f, vector3_2.z), vector3_1.y / 3f);
- head.RotateAround(head.position, new Vector3(vector3_3.x, 0.0f, vector3_3.z), (float)(-(double)vector3_1.x / 4.5));
- }
- if (ido == 4)
- {
- isIdo = true;
- head.localEulerAngles = rotate;
- head.localRotation = Quaternion.Euler(head.localEulerAngles) * Quaternion.AngleAxis(vector3_1.x / 3f, Vector3.right);
- }
- if (ido == 8)
- {
- isIdo = true;
- head.localEulerAngles = rotate;
- head.localRotation = Quaternion.Euler(head.localEulerAngles)
- * Quaternion.AngleAxis((float)(-(double)vector3_1.x / 3.0), Vector3.forward);
- }
- if (ido == 9)
- head.transform.position = new Vector3(head.transform.position.x,
- (Camera.main.ScreenToWorldPoint(position) + off - off2).y,
- head.transform.position.z);
- if (ido == 2)
- {
- Spine1a.localEulerAngles = rotate1;
- Spine1.localEulerAngles = rotate2;
- Spine0a.localEulerAngles = rotate3;
- Spine.localEulerAngles = rotate4;
- float num1 = 1.5f;
- float num2 = 1f;
- float num3 = 0.03f;
- float num4 = 0.1f;
- float num5 = 0.09f;
- float num6 = 0.07f;
- Spine1a.RotateAround(Spine1a.position, new Vector3(vector3_2.x, 0.0f, vector3_2.z), vector3_1.y / num2 * num3);
- Spine1a.RotateAround(Spine1a.position, new Vector3(vector3_3.x, 0.0f, vector3_3.z), -vector3_1.x / num1 * num3);
- Spine1.RotateAround(Spine1.position, new Vector3(vector3_2.x, 0.0f, vector3_2.z), vector3_1.y / num2 * num4);
- Spine1.RotateAround(Spine1.position, new Vector3(vector3_3.x, 0.0f, vector3_3.z), -vector3_1.x / num1 * num4);
- Spine0a.RotateAround(Spine0a.position, new Vector3(vector3_2.x, 0.0f, vector3_2.z), vector3_1.y / num2 * num5);
- Spine0a.RotateAround(Spine0a.position, new Vector3(vector3_3.x, 0.0f, vector3_3.z), -vector3_1.x / num1 * num5);
- Spine.RotateAround(Spine.position, new Vector3(vector3_2.x, 0.0f, vector3_2.z), vector3_1.y / num2 * num6);
- Spine.RotateAround(Spine.position, new Vector3(vector3_3.x, 0.0f, vector3_3.z), -vector3_1.x / num1 * num6);
- }
- if (ido == 5)
- {
- Spine1a.localEulerAngles = rotate1;
- Spine1.localEulerAngles = rotate2;
- Spine0a.localEulerAngles = rotate3;
- Spine.localEulerAngles = rotate4;
- Spine1a.localRotation = Quaternion.Euler(Spine1a.localEulerAngles)
- * Quaternion.AngleAxis((float)(vector3_1.x / 1.5 * 0.0839999988675117), Vector3.right);
- Spine0a.localRotation = Quaternion.Euler(Spine0a.localEulerAngles)
- * Quaternion.AngleAxis((float)(vector3_1.x / 1.5 * 0.156000003218651), Vector3.right);
- Spine.localRotation = Quaternion.Euler(Spine.localEulerAngles)
- * Quaternion.AngleAxis((float)(vector3_1.x / 1.5 * 0.156000003218651), Vector3.right);
- }
- if (ido == 3)
- {
- Pelvis.localEulerAngles = rotate5;
- Pelvis.RotateAround(Pelvis.position, new Vector3(vector3_2.x, 0.0f, vector3_2.z), vector3_1.y / 4f);
- Pelvis.RotateAround(Pelvis.position, new Vector3(vector3_3.x, 0.0f, vector3_3.z), vector3_1.x / 6f);
- }
- if (ido == 6)
- {
- Pelvis.localEulerAngles = rotate5;
- Pelvis.localRotation =
- Quaternion.Euler(Pelvis.localEulerAngles) * Quaternion.AngleAxis(vector3_1.x / 3f, Vector3.right);
- }
- if (ido == 7)
- {
- var vector3_4 = new Vector3(rotateR.x, rotateR.y + vector3_1.x / 10f, rotateR.z + vector3_1.y / 10f);
- if (shodaiFlg)
- {
- if (vector3_4.z < 345.700012207031 && vector3_4.z > 335.700012207031)
- pos3.y = vector3_1.y;
- if (vector3_4.y < 347.600006103516 && vector3_4.y > 335.600006103516)
- pos3.x = vector3_1.x;
- }
- else
- {
- if (vector3_4.z < 354.799987792969 && vector3_4.z > 344.799987792969)
- pos3.y = vector3_1.y;
- if (vector3_4.y < 354.0 && vector3_4.y > 342.0)
- pos3.x = vector3_1.x;
- }
- maid.body0.quaDefEyeR.eulerAngles = new Vector3(rotateR.x, rotateR.y + pos3.x / 10f, rotateR.z + pos3.y / 10f);
- maid.body0.quaDefEyeL.eulerAngles = new Vector3(rotateL.x, rotateL.y - pos3.x / 10f, rotateL.z - pos3.y / 10f);
- }
- }
- mouseIti2 = Input.mousePosition;
- }
- }
- }
|