main.cs 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. using System.Collections;using System.Collections.Generic;using UnityEngine;using UnityEngine.UI;
  2. public class main : MonoBehaviour{
  3. public float range,ihorizm,ivertm;
  4. public Text textOutput0,textOutput1,textOutput2,textOutput3;
  5. public Text textOutputB1,textOutputB2;
  6. public int hgarbage1,vgarbage1,ubaxis,counter,counter2;
  7. public int keybd,keybd0,keybd1,keybd2,keybd3;
  8. public int isjumpn0,isjumpn1,isjumpn2,isjumpn3;
  9. public float xyspeed;
  10. public float xpos0,ypos0,xyspeed0,zpos0,zgra0;
  11. public float xpos1,ypos1,xyspeed1,zpos1,zgra1;
  12. public float xpos2,ypos2,xyspeed2,zpos2,zgra2;
  13. public float xpos3,ypos3,xyspeed3,zpos3,zgra3;
  14. public float grainc;
  15. public GameObject sprite0,sprite1,sprite2,sprite3;
  16. void Start(){
  17. counter=0;xyspeed=.1f;grainc=.1f;
  18. xpos0=0f;ypos0=3f;zpos0=.5f;zgra0=0f;isjumpn0=0;
  19. xpos1=3f;ypos1=0f;zpos1=.5f;zgra1=0f;isjumpn1=0;
  20. xpos2=0f;ypos2=-3f;zpos2=.5f;zgra2=0f;isjumpn2=0;
  21. xpos3=-3f;ypos3=0f;zpos3=.5f;zgra3=0f;isjumpn3=0;
  22. }
  23. void FixedUpdate (){
  24. grainc=.1f;
  25. keybd0=0;
  26. if (Input.GetKey(KeyCode.UpArrow)){keybd0+=4;ypos0-=xyspeed;}
  27. if (Input.GetKey(KeyCode.DownArrow)){keybd0+=8;ypos0+=xyspeed;}
  28. if (Input.GetKey(KeyCode.LeftArrow)){keybd0+=1;xpos0-=xyspeed;}
  29. if (Input.GetKey(KeyCode.RightArrow)){keybd0+=2;xpos0+=xyspeed;}
  30. //if (Input.GetKey(KeyCode.Keypad0) && isjumpn0==0){keybd0+=16;zgra0=-.7f;isjumpn0=1;}
  31. if (Input.GetKey(KeyCode.RightControl) && isjumpn0==0){keybd0+=16;zgra0=-.7f;isjumpn0=1;}
  32. keybd1=0;
  33. if (Input.GetKey(KeyCode.W)){keybd1+=4;ypos1-=xyspeed;}
  34. if (Input.GetKey(KeyCode.S)){keybd1+=8;ypos1+=xyspeed;}
  35. if (Input.GetKey(KeyCode.A)){keybd1+=1;xpos1-=xyspeed;}
  36. if (Input.GetKey(KeyCode.D)){keybd1+=2;xpos1+=xyspeed;}
  37. if (Input.GetKey(KeyCode.Q) && isjumpn1==0){keybd1+=16;zgra1=-.7f;isjumpn1=1;}
  38. keybd2=0;
  39. if (Input.GetKey(KeyCode.T)){keybd2+=4;ypos2-=xyspeed;}
  40. if (Input.GetKey(KeyCode.G)){keybd2+=8;ypos2+=xyspeed;}
  41. if (Input.GetKey(KeyCode.F)){keybd2+=1;xpos2-=xyspeed;}
  42. if (Input.GetKey(KeyCode.H)){keybd2+=2;xpos2+=xyspeed;}
  43. if (Input.GetKey(KeyCode.R) && isjumpn2==0){keybd2+=16;zgra2=-.7f;isjumpn2=1;}
  44. keybd3=0;
  45. if (Input.GetKey(KeyCode.I)){keybd3+=4;ypos3-=xyspeed;}
  46. if (Input.GetKey(KeyCode.K)){keybd3+=8;ypos3+=xyspeed;}
  47. if (Input.GetKey(KeyCode.J)){keybd3+=1;xpos3-=xyspeed;}
  48. if (Input.GetKey(KeyCode.L)){keybd3+=2;xpos3+=xyspeed;}
  49. if (Input.GetKey(KeyCode.U) && isjumpn3==0){keybd3+=16;zgra3=-.7f;isjumpn3=1;}
  50. if (Input.GetKey(KeyCode.Escape)){Application.Quit();}
  51. if (xpos0>4.5f){xpos0=-4.5f;}
  52. if (xpos0<-4.5f){xpos0=4.5f;}
  53. if (ypos0>4.5f){ypos0=-4.5f;}
  54. if (ypos0<-4.5f){ypos0=4.5f;}
  55. if (xpos1>4.5f){xpos1=-4.5f;}
  56. if (xpos1<-4.5f){xpos1=4.5f;}
  57. if (ypos1>4.5f){ypos1=-4.5f;}
  58. if (ypos1<-4.5f){ypos1=4.5f;}
  59. if (xpos2>4.5f){xpos2=-4.5f;}
  60. if (xpos2<-4.5f){xpos2=4.5f;}
  61. if (ypos2>4.5f){ypos2=-4.5f;}
  62. if (ypos2<-4.5f){ypos2=4.5f;}
  63. if (xpos3>4.5f){xpos3=-4.5f;}
  64. if (xpos3<-4.5f){xpos3=4.5f;}
  65. if (ypos3>4.5f){ypos3=-4.5f;}
  66. if (ypos3<-4.5f){ypos3=4.5f;}
  67. if (isjumpn0!=0){zpos0+=zgra0;zgra0+=grainc;}
  68. if (zpos0>-.5f){zpos0=-.5f;zgra0=0f;grainc=0f;isjumpn0=0;}
  69. if (isjumpn1!=0){zpos1+=zgra1;zgra1+=grainc;}
  70. if (zpos1>-.5f){zpos1=-.5f;zgra1=0f;grainc=0f;isjumpn1=0;}
  71. if (isjumpn2!=0){zpos2+=zgra2;zgra2+=grainc;}
  72. if (zpos2>-.5f){zpos2=-.5f;zgra2=0f;grainc=0f;isjumpn2=0;}
  73. if (isjumpn3!=0){zpos3+=zgra3;zgra3+=grainc;}
  74. if (zpos3>-.5f){zpos3=-.5f;zgra3=0f;grainc=0f;isjumpn3=0;}
  75. counter2=(counter/50)%1000;
  76. textOutput0.text=xpos0.ToString("F1")+","+ypos0.ToString("F1")+","+zpos0.ToString("F1")+","+zgra0.ToString("F1")+","+keybd0.ToString("F0");
  77. textOutput1.text=xpos1.ToString("F1")+","+ypos1.ToString("F1")+","+zpos1.ToString("F1")+","+zgra1.ToString("F1")+","+keybd1.ToString("F0");
  78. textOutput2.text=xpos2.ToString("F1")+","+ypos2.ToString("F1")+","+zpos2.ToString("F1")+","+zgra2.ToString("F1")+","+keybd2.ToString("F0");
  79. textOutput3.text=xpos3.ToString("F1")+","+ypos3.ToString("F1")+","+zpos3.ToString("F1")+","+zgra3.ToString("F1")+","+keybd3.ToString("F0");
  80. textOutputB1.text=counter2.ToString("F0");
  81. textOutputB2.text="";
  82. sprite0.transform.position = new Vector3(xpos0,zpos0*-1,ypos0*-1);
  83. sprite1.transform.position = new Vector3(xpos1,zpos1*-1,ypos1*-1);
  84. sprite2.transform.position = new Vector3(xpos2,zpos2*-1,ypos2*-1);
  85. sprite3.transform.position = new Vector3(xpos3,zpos3*-1,ypos3*-1);
  86. counter+=1;
  87. }}