이상윤

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

......@@ -40,6 +40,11 @@ public class Move : MonoBehaviour
public int[] trainer_state;
public int speed = 0;
public int trainer_count = 0;
public bool trainer_check = true;
public bool trainer_check_outside = true;
public float trainer_timer = 0;
public bool trainer_other_side = false;
public int trainer_speed = 5;
//lsy end
public Text AngleLeftKnee;
......@@ -53,7 +58,7 @@ public class Move : MonoBehaviour
public Text HipBalance;
public Text PullHipBack;
public Text Great;
string hipbal, leftkneewarning, rightkneewarning, leftsidehighkick, rightsidehighkick;
string spinestraight, pullhipback, great;
......@@ -71,79 +76,141 @@ public class Move : MonoBehaviour
//lsy
void Trainer_Run()
{
if (!trainer_check)//운동 끝났을 때
{
trainer_timer += Time.deltaTime;
if (trainer_timer > 3)
{
Debug.Log("3초 됨 운동 끝!!!!!"); //결과씬이나 다른씬으로
trainer_check_outside = false;
}
return;
}
//Thread.Sleep(50);
if (trainer_j >= lines.Length - 3)
{
trainer_count++;
Debug.Log("카운트 : " + trainer_count);
if (trainer_count < 20 && exercise == "Squat")
{
trainer_count++;
Debug.Log("카운트 : " + trainer_count);
}
if (trainer_count < 10 && exercise == "SideHiKick")
{
trainer_count++;
Debug.Log("카운트 : " + trainer_count);
}
if (trainer_count < 10 && exercise == "Lunge")
{
trainer_count++;
Debug.Log("카운트 : " + trainer_count);
}
if (trainer_count >= 20 && exercise == "Squat")
{
trainer_check = false;//스쿼트일때 운동 끝나는 시점!!!!!
}
if (trainer_count >= 10 && exercise == "SideHiKick")
{
if (!trainer_other_side)
{
if (trainer_timer > 3)
{
trainer_count = 0;
lines = lines_right;
trainer_other_side = true;
trainer_timer = 0;
}
else
{
trainer_timer += Time.deltaTime;
return;
}
}
else
{
trainer_check = false;//사이드하이킥일때 운동 끝나는 시점!!!!!
}
}
if (trainer_count >= 10 && exercise == "Lunge")
{
if (!trainer_other_side)
{
if (trainer_timer > 3)
{
trainer_speed = 8;
trainer_count = 0;
lines = lines_right;
trainer_other_side = true;
trainer_timer = 0;
}
else
{
trainer_timer += Time.deltaTime;
return;
}
}
else
{
trainer_check = false;//사이드하이킥일때 운동 끝나는 시점!!!!!
}
}
trainer_j = 0;
return;
}
trainer_i = -1;
trainer_data1 = new float[bodyCount * jointCount * 3];
trainer_state = new int[bodyCount * jointCount];
//Debug.Log("초기화");
//Thread.Sleep(5000);
for (int k = 0; k < 25; k++)
{
//Debug.Log("trainer_j: " + trainer_j);
//Debug.Log("test1");
//Debug.Log(lines[trainer_j]);
trainer_i++;
trainer_data1[trainer_i] = float.Parse(lines[trainer_j]);
//Debug.Log("test2" + trainer_i);
trainer_i++;
trainer_data1[trainer_i] = float.Parse(lines[trainer_j + 1]);
//Debug.Log("test3" + trainer_i);
trainer_i++;
trainer_data1[trainer_i] = float.Parse(lines[trainer_j + 2]);
//Debug.Log("test4" + trainer_i);
if ((float.Parse(lines[trainer_j]) + float.Parse(lines[trainer_j + 1]) + float.Parse(lines[trainer_j + 2])) != 0)
{
trainer_state[trainer_i - 2] = 1;
}
//Debug.Log("test4-1");
skeleton_Trainnner.dasomset_trainer(trainer_data1, trainer_state, 0, true, true);
//Debug.Log("test5");
//Debug.Log(trainer_i);
//Debug.Log("메모라인 : " + trainer_j);
trainer_j = trainer_j + 3;
}
if (speed < 5)
if (speed < trainer_speed)
{
trainer_j -= 75;
speed++;
}
else
{
// Debug.Log("다음");
// Debug.Log(trainer_j);
// Debug.Log("다음");
// Debug.Log(trainer_j);
speed = 0;
}
//Debug.Log("탈출!======================================================");
}
//lsy end
void Trainee_Count() {
void Trainee_Count()
{
if (exercise == "Squat") {
if (exercise == "Squat")
{
workout_flag = 0;
workout_flag2 = 0;
}
else if (exercise == "SideHiKick") {
else if (exercise == "SideHiKick")
{
workout_flag = 0;
}
else if (exercise == "Lunge") {
else if (exercise == "Lunge")
{
workout_flag = 0;
}
workout_count++;
workout = false;
}
void Start()
......@@ -157,8 +224,9 @@ public class Move : MonoBehaviour
trainer_state = new int[bodyCount * jointCount];
trainer_data1 = new float[bodyCount * jointCount * 3];
//lsy end
exercise = ClickExercise.selected_exercise; //ClickExercise에서 선택한 운동이 무엇인지 String으로 넘어옴.
exercise = "SideHiKick";
Debug.Log(exercise); //Squat, SideHiKick, Lunge 에 따라서 Trainer움직이고, 사용자에게 instruction주기
if (exercise == "Squat")
......@@ -168,19 +236,20 @@ public class Move : MonoBehaviour
}
else if (exercise == "SideHiKick")
{
lines = File.ReadAllLines(@"Trainer_txt/leg_left.txt");
lines_right = File.ReadAllLines(@"Trainer_txt/leg_right.txt");
lines = File.ReadAllLines(@"Trainer_txt/leg_right.txt");
lines_right = File.ReadAllLines(@"Trainer_txt/leg_left.txt");
Debug.Log("읽음");
}
else if (exercise == "Lunge")
{
lines = File.ReadAllLines(@"Trainer_txt/runzi_left.txt");
lines_right = File.ReadAllLines(@"Trainer_txt/runzi_right.txt");
trainer_speed = 5;
lines = File.ReadAllLines(@"Trainer_txt/runzi_right.txt");
lines_right = File.ReadAllLines(@"Trainer_txt/runzi_left.txt");
Debug.Log("읽음");
}
else {
lines = File.ReadAllLines(@"Trainer_txt/leg_left.txt");
else
{
lines = File.ReadAllLines(@"Trainer_txt/squart.txt");
Debug.Log("읽음");
}
......@@ -249,7 +318,8 @@ public class Move : MonoBehaviour
KneeDown6.SetActive(false);
}
else if (timer >= 1 && timer < 2) {
else if (timer >= 1 && timer < 2)
{
count3.SetActive(false);
count2.SetActive(true);
count1.SetActive(false);
......@@ -286,10 +356,15 @@ public class Move : MonoBehaviour
ex_start.SetActive(false);
//lsy
Trainer_Run();
if (trainer_check_outside)
{
Trainer_Run();
}
//lsy end
IfSpineIsStraight.text = "허리를 곧게: Tracking";
HipBalance.text = "양쪽 힙 균형: Calculating";
AngleLeftKnee.text = "";
......@@ -372,7 +447,7 @@ public class Move : MonoBehaviour
}
}
}
}
private GameObject CreateBodyObject(ulong id)
......@@ -558,7 +633,7 @@ public class Move : MonoBehaviour
SpineStraight4.SetActive(false);
}
///////////////////////////
if (_BoneMap.ContainsKey(jt))
......@@ -665,7 +740,7 @@ public class Move : MonoBehaviour
double AngleLeftKnee = AngleBetweenTwoVectors(HipLeft - KneeLeft, AnkleLeft - KneeLeft); //스쿼트, 런지, 사이드하이킥 - Joint 3개로도 가능
//double AngleRightKnee = AngleBetweenTwoVectors(KneeRight - HipRight, KneeRight - AnkleRight); //스쿼트, 런지, 사이드하이킥 - Joint 3개로도 가능
double AngleRightKnee = AngleBetweenTwoVectors(HipRight - KneeRight, AnkleRight - KneeRight); //스쿼트, 런지, 사이드하이킥 - Joint 3개로도 가능
double KneeToeLeft = AngleBetweenTwoVectors(AnkleLeft - FootLeft, KneeLeft - FootLeft); //스쿼트 - Joint 3개로도 가능
double KneeToeRight = AngleBetweenTwoVectors(AnkleRight - FootRight, KneeRight - FootRight); //스쿼트 - Joint 3개로도 가능
//double LeftLegUp = AngleBetweenTwoVectors(SpineMid - SpineShoulder, KneeLeft - HipLeft); //사이드 하이킥
......