이상윤

트레이너 속도와 끝나는 위치 지정 2020-06-18 11:17 commit

...@@ -40,6 +40,11 @@ public class Move : MonoBehaviour ...@@ -40,6 +40,11 @@ public class Move : MonoBehaviour
40 public int[] trainer_state; 40 public int[] trainer_state;
41 public int speed = 0; 41 public int speed = 0;
42 public int trainer_count = 0; 42 public int trainer_count = 0;
43 + public bool trainer_check = true;
44 + public bool trainer_check_outside = true;
45 + public float trainer_timer = 0;
46 + public bool trainer_other_side = false;
47 + public int trainer_speed = 5;
43 //lsy end 48 //lsy end
44 49
45 public Text AngleLeftKnee; 50 public Text AngleLeftKnee;
...@@ -71,46 +76,105 @@ public class Move : MonoBehaviour ...@@ -71,46 +76,105 @@ public class Move : MonoBehaviour
71 //lsy 76 //lsy
72 void Trainer_Run() 77 void Trainer_Run()
73 { 78 {
79 + if (!trainer_check)//운동 끝났을 때
80 + {
81 + trainer_timer += Time.deltaTime;
82 + if (trainer_timer > 3)
83 + {
84 + Debug.Log("3초 됨 운동 끝!!!!!"); //결과씬이나 다른씬으로
85 + trainer_check_outside = false;
86 + }
87 + return;
88 + }
74 //Thread.Sleep(50); 89 //Thread.Sleep(50);
75 if (trainer_j >= lines.Length - 3) 90 if (trainer_j >= lines.Length - 3)
76 { 91 {
92 + if (trainer_count < 20 && exercise == "Squat")
93 + {
77 trainer_count++; 94 trainer_count++;
78 Debug.Log("카운트 : " + trainer_count); 95 Debug.Log("카운트 : " + trainer_count);
96 + }
97 + if (trainer_count < 10 && exercise == "SideHiKick")
98 + {
99 + trainer_count++;
100 + Debug.Log("카운트 : " + trainer_count);
101 + }
102 + if (trainer_count < 10 && exercise == "Lunge")
103 + {
104 + trainer_count++;
105 + Debug.Log("카운트 : " + trainer_count);
106 + }
107 + if (trainer_count >= 20 && exercise == "Squat")
108 + {
109 + trainer_check = false;//스쿼트일때 운동 끝나는 시점!!!!!
110 + }
111 + if (trainer_count >= 10 && exercise == "SideHiKick")
112 + {
113 + if (!trainer_other_side)
114 + {
115 + if (trainer_timer > 3)
116 + {
117 + trainer_count = 0;
118 + lines = lines_right;
119 + trainer_other_side = true;
120 + trainer_timer = 0;
121 + }
122 + else
123 + {
124 + trainer_timer += Time.deltaTime;
125 + return;
126 + }
127 + }
128 + else
129 + {
130 + trainer_check = false;//사이드하이킥일때 운동 끝나는 시점!!!!!
131 + }
132 + }
133 + if (trainer_count >= 10 && exercise == "Lunge")
134 + {
135 + if (!trainer_other_side)
136 + {
137 + if (trainer_timer > 3)
138 + {
139 + trainer_speed = 8;
140 + trainer_count = 0;
141 + lines = lines_right;
142 + trainer_other_side = true;
143 + trainer_timer = 0;
144 + }
145 + else
146 + {
147 + trainer_timer += Time.deltaTime;
148 + return;
149 + }
150 + }
151 + else
152 + {
153 + trainer_check = false;//사이드하이킥일때 운동 끝나는 시점!!!!!
154 + }
155 + }
79 trainer_j = 0; 156 trainer_j = 0;
80 return; 157 return;
81 } 158 }
82 trainer_i = -1; 159 trainer_i = -1;
83 trainer_data1 = new float[bodyCount * jointCount * 3]; 160 trainer_data1 = new float[bodyCount * jointCount * 3];
84 trainer_state = new int[bodyCount * jointCount]; 161 trainer_state = new int[bodyCount * jointCount];
85 - //Debug.Log("초기화");
86 - //Thread.Sleep(5000);
87 for (int k = 0; k < 25; k++) 162 for (int k = 0; k < 25; k++)
88 { 163 {
89 - //Debug.Log("trainer_j: " + trainer_j);
90 - //Debug.Log("test1");
91 - //Debug.Log(lines[trainer_j]);
92 -
93 trainer_i++; 164 trainer_i++;
94 trainer_data1[trainer_i] = float.Parse(lines[trainer_j]); 165 trainer_data1[trainer_i] = float.Parse(lines[trainer_j]);
95 - //Debug.Log("test2" + trainer_i);
96 trainer_i++; 166 trainer_i++;
97 trainer_data1[trainer_i] = float.Parse(lines[trainer_j + 1]); 167 trainer_data1[trainer_i] = float.Parse(lines[trainer_j + 1]);
98 - //Debug.Log("test3" + trainer_i);
99 trainer_i++; 168 trainer_i++;
100 trainer_data1[trainer_i] = float.Parse(lines[trainer_j + 2]); 169 trainer_data1[trainer_i] = float.Parse(lines[trainer_j + 2]);
101 - //Debug.Log("test4" + trainer_i);
102 if ((float.Parse(lines[trainer_j]) + float.Parse(lines[trainer_j + 1]) + float.Parse(lines[trainer_j + 2])) != 0) 170 if ((float.Parse(lines[trainer_j]) + float.Parse(lines[trainer_j + 1]) + float.Parse(lines[trainer_j + 2])) != 0)
103 { 171 {
104 trainer_state[trainer_i - 2] = 1; 172 trainer_state[trainer_i - 2] = 1;
105 } 173 }
106 - //Debug.Log("test4-1");
107 skeleton_Trainnner.dasomset_trainer(trainer_data1, trainer_state, 0, true, true); 174 skeleton_Trainnner.dasomset_trainer(trainer_data1, trainer_state, 0, true, true);
108 - //Debug.Log("test5");
109 - //Debug.Log(trainer_i);
110 - //Debug.Log("메모라인 : " + trainer_j);
111 trainer_j = trainer_j + 3; 175 trainer_j = trainer_j + 3;
112 } 176 }
113 - if (speed < 5) 177 + if (speed < trainer_speed)
114 { 178 {
115 trainer_j -= 75; 179 trainer_j -= 75;
116 speed++; 180 speed++;
...@@ -122,22 +186,25 @@ public class Move : MonoBehaviour ...@@ -122,22 +186,25 @@ public class Move : MonoBehaviour
122 speed = 0; 186 speed = 0;
123 187
124 } 188 }
125 - //Debug.Log("탈출!======================================================");
126 } 189 }
127 //lsy end 190 //lsy end
128 191
129 - void Trainee_Count() { 192 + void Trainee_Count()
193 + {
130 194
131 - if (exercise == "Squat") { 195 + if (exercise == "Squat")
196 + {
132 197
133 workout_flag = 0; 198 workout_flag = 0;
134 workout_flag2 = 0; 199 workout_flag2 = 0;
135 } 200 }
136 - else if (exercise == "SideHiKick") { 201 + else if (exercise == "SideHiKick")
202 + {
137 workout_flag = 0; 203 workout_flag = 0;
138 204
139 } 205 }
140 - else if (exercise == "Lunge") { 206 + else if (exercise == "Lunge")
207 + {
141 workout_flag = 0; 208 workout_flag = 0;
142 } 209 }
143 210
...@@ -159,6 +226,7 @@ public class Move : MonoBehaviour ...@@ -159,6 +226,7 @@ public class Move : MonoBehaviour
159 //lsy end 226 //lsy end
160 227
161 exercise = ClickExercise.selected_exercise; //ClickExercise에서 선택한 운동이 무엇인지 String으로 넘어옴. 228 exercise = ClickExercise.selected_exercise; //ClickExercise에서 선택한 운동이 무엇인지 String으로 넘어옴.
229 + exercise = "SideHiKick";
162 Debug.Log(exercise); //Squat, SideHiKick, Lunge 에 따라서 Trainer움직이고, 사용자에게 instruction주기 230 Debug.Log(exercise); //Squat, SideHiKick, Lunge 에 따라서 Trainer움직이고, 사용자에게 instruction주기
163 231
164 if (exercise == "Squat") 232 if (exercise == "Squat")
...@@ -168,19 +236,20 @@ public class Move : MonoBehaviour ...@@ -168,19 +236,20 @@ public class Move : MonoBehaviour
168 } 236 }
169 else if (exercise == "SideHiKick") 237 else if (exercise == "SideHiKick")
170 { 238 {
171 - lines = File.ReadAllLines(@"Trainer_txt/leg_left.txt"); 239 + lines = File.ReadAllLines(@"Trainer_txt/leg_right.txt");
172 - lines_right = File.ReadAllLines(@"Trainer_txt/leg_right.txt"); 240 + lines_right = File.ReadAllLines(@"Trainer_txt/leg_left.txt");
173 Debug.Log("읽음"); 241 Debug.Log("읽음");
174 } 242 }
175 else if (exercise == "Lunge") 243 else if (exercise == "Lunge")
176 { 244 {
177 - lines = File.ReadAllLines(@"Trainer_txt/runzi_left.txt"); 245 + trainer_speed = 5;
178 - lines_right = File.ReadAllLines(@"Trainer_txt/runzi_right.txt"); 246 + lines = File.ReadAllLines(@"Trainer_txt/runzi_right.txt");
247 + lines_right = File.ReadAllLines(@"Trainer_txt/runzi_left.txt");
179 Debug.Log("읽음"); 248 Debug.Log("읽음");
180 } 249 }
181 - else { 250 + else
182 - 251 + {
183 - lines = File.ReadAllLines(@"Trainer_txt/leg_left.txt"); 252 + lines = File.ReadAllLines(@"Trainer_txt/squart.txt");
184 Debug.Log("읽음"); 253 Debug.Log("읽음");
185 } 254 }
186 255
...@@ -249,7 +318,8 @@ public class Move : MonoBehaviour ...@@ -249,7 +318,8 @@ public class Move : MonoBehaviour
249 KneeDown6.SetActive(false); 318 KneeDown6.SetActive(false);
250 319
251 } 320 }
252 - else if (timer >= 1 && timer < 2) { 321 + else if (timer >= 1 && timer < 2)
322 + {
253 count3.SetActive(false); 323 count3.SetActive(false);
254 count2.SetActive(true); 324 count2.SetActive(true);
255 count1.SetActive(false); 325 count1.SetActive(false);
...@@ -286,7 +356,12 @@ public class Move : MonoBehaviour ...@@ -286,7 +356,12 @@ public class Move : MonoBehaviour
286 ex_start.SetActive(false); 356 ex_start.SetActive(false);
287 357
288 //lsy 358 //lsy
359 + if (trainer_check_outside)
360 + {
361 +
289 Trainer_Run(); 362 Trainer_Run();
363 +
364 + }
290 //lsy end 365 //lsy end
291 366
292 367
......