private void FistInWaist(List <OutPutData> lstVet, int i)
        {
            bool RightFistInWaist = false;
            bool LeftFistInWaist  = false;

            //叉腰动作

            if (lstVet[i].score < 0.5 || lstVet[i - 1].score < 0.5 || lstVet[i - 2].score < 0.5 ||
                lstVet[i + 3].score < 0.5 || lstVet[i + 2].score < 0.5 || lstVet[i + 1].score < 0.5)
            {
                StopSoundEffect(0);
                FistInWaistFrameCount = 0;
                return;
            }
            RightFistInWaist = ARHumanBodyDataParse.fistInWaistRight(lstVet[i].VectorScreenPos, lstVet[i - 1].VectorScreenPos, lstVet[i - 2].VectorScreenPos, lstVet[i + 4].VectorScreenPos);
            LeftFistInWaist  = ARHumanBodyDataParse.fistInWaistLeft(lstVet[i + 3].VectorScreenPos, lstVet[i + 2].VectorScreenPos, lstVet[i + 1].VectorScreenPos, lstVet[i + 7].VectorScreenPos);

            if (RightFistInWaist && LeftFistInWaist)
            {
                Static_pose[0].transform.position = ARHumanBodyDataParse.GetGroundVet(lstVet[0].VectorScreenPos, 0, (int)(300 * ARHumanBodyDataParse.lengthShoulder / 600), 1000 / ARHumanBodyDataParse.lengthShoulder);
                wistTogether = false;
                FistInWaistFrameCount++;
                if (FistInWaistFrameCount < DomainNumber) //5帧才认
                {
                    return;
                }
                //表示叉腰动作
                if (!Static_pose[0].activeSelf)
                {
                    Static_pose[0].SetActive(true);
                    //特效消失
                    if (Static_pose[1].activeSelf)
                    {
                        Static_pose[1].SetActive(false);
                    }
                }

                if (!audios[0].activeSelf)
                {
                    audios[0].SetActive(true);
                    if (audios[1].activeSelf)
                    {
                        audios[1].SetActive(false);
                    }
                }

                return;
            }
            else
            {
                //动作消失
                StopSoundEffect(0);
                FistInWaistFrameCount = 0;
            }
        }
Example #2
0
        private void StartEffect(Vector3 vet, int index)
        {
            if (Time.time - deltime < 1)
            {
                return;
            }
            deltime = Time.time;
            //  ARDebug.Log("vet.x = "+vet.x + " vet.y ="+vet.y +" vet.z = "+vet.z);
            Vector3 vetRet = ARHumanBodyDataParse.GetGroundVet(vet, 0, -60, 5000 / ARHumanBodyDataParse.lengthShoulder);

            //  if (goEffect[index] == null){
            goEffect[index] = Instantiate(FootLiftEffect[index]) as GameObject;
            goEffect[index].SetActive(true);
            goEffect[index].transform.position = vetRet;
            //}
        }
        private void StaticPose(List <OutPutData> lstVet)
        {
            for (int i = 0; i < lstVet.Count; i++)
            {
                if (i == 4)
                {
                    if (ARHumanBodyDataParse.StaticPose(lstVet[i].VectorScreenPos, lstVet[i - 1].VectorScreenPos, lstVet[i - 2].VectorScreenPos, lstVet[i + 4].VectorScreenPos) ||
                        ARHumanBodyDataParse.StaticPose(lstVet[i + 3].VectorScreenPos, lstVet[i + 2].VectorScreenPos, lstVet[i + 1].VectorScreenPos, lstVet[i + 7].VectorScreenPos)
                        )
                    {
                        IsWistFrontChest      = false;
                        wistTogether          = false;
                        FistInWaistFrameCount = 0;
                    }

                    FistInWaist(lstVet, i);
                    FistFrontChest(lstVet, i);
                    FistFrontIn(lstVet, i);
                }
            }
        }
Example #4
0
        public bool CheckEffect(int index, Vector3 firstVet, Vector3 secondVet, Vector3 endVet, Vector3 dstVet)
        {
            if (!IsFootUp[index])
            {
                // IsFootUp[index] = ARBodyDataParse.FootLift(firstVet, secondVet,endVet,dstVet);
                IsFootUp[index] = ARHumanBodyDataParse.FootLift(firstVet, index);
                if (IsFootUp[index])
                {
                    ARDebug.Log("index = " + index);
                    if (index == 0)
                    {
                        StopCoroutine("ActionDisable_One");
                        StartCoroutine("ActionDisable_One", index);
                    }
                    else
                    {
                        StopCoroutine("ActionDisable_Two");
                        StartCoroutine("ActionDisable_Two", index);
                    }
                }

                //StartEffect(firstVet, index);
            }
            else
            {
                IsFootDown[index] = ARHumanBodyDataParse.FootDown(firstVet, index, endVet);
                if (IsFootDown[index])
                {
                    //ARDebug.Log("index11 = " + index);
                    IsFootUp[index]   = false;
                    IsFootDown[index] = false;
                    //开启特效
                    StartEffect(firstVet, index);
                    return(true);
                }
            }

            return(false);
        }
        private void FistFrontIn(List <OutPutData> lstVet, int i)
        {
            bool RightFistFrontChest = false;
            bool LeftFistFrontChest  = false;

            bool RightFistFrontTo = false;
            bool LeftFistFrontTo  = false;

            if (lstVet[i].score < 0.5 || lstVet[i - 1].score < 0.5 || lstVet[i - 2].score < 0.5 ||
                lstVet[i + 3].score < 0.5 || lstVet[i + 2].score < 0.5 || lstVet[i + 1].score < 0.5)
            {
                return;
            }

            RightFistFrontChest = ARHumanBodyDataParse.fistFrontChestRight(lstVet[i].VectorScreenPos, lstVet[i - 1].VectorScreenPos, lstVet[i - 2].VectorScreenPos, lstVet[i + 4].VectorScreenPos);
            LeftFistFrontChest  = ARHumanBodyDataParse.fistFrontChestLeft(lstVet[i + 3].VectorScreenPos, lstVet[i + 2].VectorScreenPos, lstVet[i + 1].VectorScreenPos, lstVet[i + 7].VectorScreenPos);

            if (RightFistFrontChest && LeftFistFrontChest)
            {
                IsWistFrontChest = true;
            }

            if (IsWistFrontChest)
            {
                //双掌向前推动作
                RightFistFrontTo = ARHumanBodyDataParse.fistFrontToRight(lstVet[i].VectorScreenPos, lstVet[i - 1].VectorScreenPos, lstVet[i - 2].VectorScreenPos, lstVet[i + 4].VectorScreenPos);
                LeftFistFrontTo  = ARHumanBodyDataParse.fistFrontToLeft(lstVet[i + 3].VectorScreenPos, lstVet[i + 2].VectorScreenPos, lstVet[i + 1].VectorScreenPos, lstVet[i + 7].VectorScreenPos);


                if (RightFistFrontTo && LeftFistFrontTo)
                {
                    if (ARHumanBodyDataParse.FistIntenal(lstVet[i - 1].VectorScreenPos, lstVet[i].VectorScreenPos) &&
                        ARHumanBodyDataParse.FistIntenal(lstVet[i + 3].VectorScreenPos, lstVet[i + 2].VectorScreenPos))
                    {
                        return;
                    }
                    IsWistFrontChest         = false;
                    wistTogether             = false;
                    FistFrontChestFrameCount = DomainNumber + 5;
                    StopCoroutine("WaitFrontChestEnable");
                    //时间到了消失
                    if (!Static_pose[2].activeSelf)
                    {
                        Static_pose[2].SetActive(true);
                    }
                    Static_pose[2].GetComponent <ParticleSystem>().Play();
                    Vector3 centerChest = (lstVet[i].VectorScreenPos + lstVet[i + 3].VectorScreenPos) / 2;
                    //  Vector2 centerChest = new Vector2((lstVet[i].VectorScreenPos.x + lstVet[i +3].VectorScreenPos.x)/2,(lstVet[i].VectorScreenPos.y + lstVet[i + 3].VectorScreenPos.y)/2);
                    ARDebug.Log("my = " + centerChest.x + "  " + centerChest.y);

                    float distance = Vector2.Distance(lstVet[i].VectorScreenPos, lstVet[i + 3].VectorScreenPos);
                    ARDebug.Log("distance = " + distance);
                    float z = 20;
                    z = z * 500 / distance;
                    Static_pose[2].transform.position = ARHumanBodyDataParse.GetGroundVet(centerChest, 0, 0, 1000 / ARHumanBodyDataParse.lengthShoulder);
                    //Static_pose[2].transform.position = ARBodyDataParse.GetGroundVet(centerChest, 0, 0, 2);
                    //双掌向前推动作
                    ARDebug.Log("chayao wistFront");

                    if (!audios[2].activeSelf)
                    {
                        audios[2].SetActive(true);
                    }
                    audios[2].GetComponent <AudioSource>().Play();
                    return;
                }
            }
        }
        private void FistFrontChest(List <OutPutData> lstVet, int i)
        {
            bool RightFistFrontChest = false;
            bool LeftFistFrontChest  = false;

            if (lstVet[i].score < 0.5 || lstVet[i - 1].score < 0.5 || lstVet[i - 2].score < 0.5 ||
                lstVet[i + 3].score < 0.5 || lstVet[i + 2].score < 0.5 || lstVet[i + 1].score < 0.5)
            {
                StopSoundEffect(1);
                return;
            }

            if (!wistTogether)
            {
                RightFistFrontChest = ARHumanBodyDataParse.fistFrontChestRight(lstVet[i].VectorScreenPos, lstVet[i - 1].VectorScreenPos, lstVet[i - 2].VectorScreenPos, lstVet[i + 4].VectorScreenPos);;
                LeftFistFrontChest  = ARHumanBodyDataParse.fistFrontChestLeft(lstVet[i + 3].VectorScreenPos, lstVet[i + 2].VectorScreenPos, lstVet[i + 1].VectorScreenPos, lstVet[i + 7].VectorScreenPos);
                if (RightFistFrontChest && LeftFistFrontChest)
                {
                    if (ARHumanBodyDataParse.fistTogether(lstVet[i].VectorScreenPos, lstVet[i + 3].VectorScreenPos))
                    {
                        wistTogether = true;
                    }
                }
            }

            if (wistTogether)
            {
                //双掌在胸前的动作
                RightFistFrontChest = ARHumanBodyDataParse.fistFrontChestRight(lstVet[i].VectorScreenPos, lstVet[i - 1].VectorScreenPos, lstVet[i - 2].VectorScreenPos, lstVet[i + 4].VectorScreenPos);;
                LeftFistFrontChest  = ARHumanBodyDataParse.fistFrontChestLeft(lstVet[i + 3].VectorScreenPos, lstVet[i + 2].VectorScreenPos, lstVet[i + 1].VectorScreenPos, lstVet[i + 7].VectorScreenPos);

                if (RightFistFrontChest && LeftFistFrontChest)
                {
                    FistFrontChestFrameCount = 0;
                    //双掌在胸前动作
                    StopCoroutine("WaitFrontChestEnable");
                    StartCoroutine("WaitFrontChestEnable");
                    ARDebug.Log("chayao chestFront");

                    Vector3 centerChest = (lstVet[i].VectorScreenPos + lstVet[i + 3].VectorScreenPos) / 2;
                    centerChest.y = centerChest.y + ARHumanBodyDataParse.lengthShoulder / 20;
                    //  Vector2 centerChest = new Vector2((lstVet[i].VectorScreenPos.x + lstVet[i +3].VectorScreenPos.x)/2,(lstVet[i].VectorScreenPos.y + lstVet[i + 3].VectorScreenPos.y)/2);
                    ARDebug.Log("my = " + centerChest.x + "  " + centerChest.y);

                    float distance = Vector2.Distance(lstVet[i].VectorScreenPos, lstVet[i + 3].VectorScreenPos);
                    float z        = 20;
                    z = z * 500 / distance;
                    Static_pose[1].transform.position = ARHumanBodyDataParse.GetGroundVet(centerChest, 0, 0, z);

                    if (!audios[1].activeSelf)
                    {
                        audios[1].SetActive(true);
                    }
                    ARDebug.Log("chayao chestFront Hinde");
                    if (!Static_pose[1].activeSelf)
                    {
                        Static_pose[1].SetActive(true);
                    }
                    audios[0].SetActive(false);

                    return;
                }
                else
                {
                    FistFrontChestFrameCount++;
                    if (FistFrontChestFrameCount > (DomainNumber - 3))
                    {
                        StopSoundEffect(1);
                    }
                }
            }
            else
            {
                //特效消失
                FistFrontChestFrameCount++;
                if (FistFrontChestFrameCount > (DomainNumber - 3))
                {
                    StopSoundEffect(1);
                }
            }
        }
        public void Electric(List <OutPutData> lstVet)
        {
            for (int i = 0; i < lstVet.Count; i++)
            {
                if (i == 1 || i == 4 || i == 7 || i == 10 || i == 13 ||
                    i == 3 || i == 6) //电流
                {
                    Vector3 vetRet = ARHumanBodyDataParse.GetElectricVet(lstVet[i].VectorScreenPos, lstVet[i - 1].VectorScreenPos);
                    float   angle  = ARHumanBodyDataParse.GetAngleBetweenPos(lstVet[i].VectorScreenPos, lstVet[i - 1].VectorScreenPos);
                    if (i == 1)
                    {
                        Vector3 centerVet = (lstVet[i + 7].VectorScreenPos + lstVet[i + 10].VectorScreenPos) / 2;

                        // Vector3 centerVet = lstVet[i + 7].VectorScreenPos;
                        vetRet = ARHumanBodyDataParse.GetElectricVet(lstVet[i].VectorScreenPos, centerVet);
                        angle  = ARHumanBodyDataParse.GetAngleBetweenPos(lstVet[i].VectorScreenPos, centerVet);

                        if (lstVet[i].score < 0.5 || lstVet[i + 7].score < 0.5 || lstVet[i + 10].score < 0.5)
                        {
                            Electrics[4].SetActive(false);
                            sound_Electric.SetActive(false);
                            continue;
                        }
                        ShowElectric(4, vetRet, angle);


                        if (!sound_Electric.activeSelf)
                        {
                            sound_Electric.SetActive(true);
                        }
                    }

                    //continue;
                    if (i == 4)
                    {
                        if (lstVet[i].score < 0.5 || lstVet[i - 1].score < 0.5)
                        {
                            Electrics[0].SetActive(false);
                            continue;
                        }
                        ShowElectric(0, vetRet, angle);
                    }
                    if (i == 7)
                    {
                        if (lstVet[i].score < 0.5 || lstVet[i - 1].score < 0.5)
                        {
                            Electrics[1].SetActive(false);
                            continue;
                        }
                        ShowElectric(1, vetRet, angle);
                    }
                    if (i == 10)
                    {
                        if (lstVet[i].score < 0.5 || lstVet[i - 1].score < 0.5)
                        {
                            Electrics[2].SetActive(false);
                            continue;
                        }
                        ShowElectric(2, vetRet, angle);
                    }
                    if (i == 13)
                    {
                        if (lstVet[i].score < 0.5 || lstVet[i - 1].score < 0.5)
                        {
                            Electrics[3].SetActive(false);
                            continue;
                        }
                        ShowElectric(3, vetRet, angle);
                    }

                    if (i == 3)
                    {
                        if (lstVet[i].score < 0.5 || lstVet[i - 1].score < 0.5)
                        {
                            Electrics[5].SetActive(false);
                            continue;
                        }
                        ShowElectric(5, vetRet, angle);
                    }
                    if (i == 6)
                    {
                        if (lstVet[i].score < 0.5 || lstVet[i - 1].score < 0.5)
                        {
                            Electrics[6].SetActive(false);
                            continue;
                        }
                        ShowElectric(6, vetRet, angle);
                    }
                }
            }
        }