Exemplo n.º 1
0
    private void Grasp(FrameInfoKey key)
    {
        if (Catched)
        {
            float t = (PicTranPos.z - picTran.position.z) / argus.Depth;

            picTran.position   = new Vector3(PicTranPos.x, PicTranPos.y, transform.position.z + Mathf.Clamp01(1 - 0.25f * t) * offset);
            picTran.localScale = new Vector3(1 + Mathf.Clamp01(2 * t), 1 + Mathf.Clamp01(2 * t), 1);
        }
    }
Exemplo n.º 2
0
 private IEnumerator CatchAct(FrameInfoKey key)
 {
     if (!Catched)
     {
         Catched = true;
         Vector3 pos    = picTran.position;
         float   z      = argus.maxZ + (pos.z - argus.maxZ) * 0.60f;
         Vector3 target = new Vector3(pos.x, pos.y, z);
         for (float time = 0; time <= 1.0f; time += 2 * Time.deltaTime)
         {
             picTran.position = Vector3.Lerp(pos, target, time);
             yield return(new WaitForEndOfFrame());
         }
     }
 }
Exemplo n.º 3
0
    private IEnumerator Recover(FrameInfoKey key)
    {
        if (Catched)
        {
            Catched = false;
            float time = 0;

            float   offset = (PicTranPos - picTran.position).z;
            float   speed  = 100 / offset;
            Vector3 pos    = picTran.position;
            while (time <= 1)
            {
                time            += speed * Time.deltaTime;
                picTran.position = Vector3.Lerp(pos, PicTranPos, time);
                yield return(null);
            }

            picTran.localScale = Vector3.one;
        }
    }
Exemplo n.º 4
0
 private void Media(FrameInfoKey key)
 {
     if (argus.MeidaHit(viewer.ResultCode))
     {
         frameNum += 60;
         if (!Catched)
         {
             playboxFlag = !playboxFlag;
             if (playboxFlag)
             {
                 moviePlayer.Play(true);
                 moviePlayer.PlayAudio(true);
             }
             else
             {
                 moviePlayer.Stop();
             }
         }
     }
 }
Exemplo n.º 5
0
    void Update()
    {
        FrameInfoKey key = viewer.OnUpdate(argus.meidaDecimals);

        if (key != null)
        {
            if (!hand.activeSelf)
            {
                hand.SetActive(true);
            }


            Vector3 center = key.center;
            if (center != Vector3.zero)
            {
                Debug.Log(center + "   " + key.fingerNum);
            }

            bool  flag = key.fingerNum > 0;
            Color c    = argus.GetColor(key.center.z);
            mat.SetColor("_Color", c);

            bool isInPic      = false;
            bool isCameraMove = true;


            if (center == Vector3.zero)
            {
                mat.SetColor("_OutlineColor", Color.gray);
                return;
            }

            mat.SetColor("_OutlineColor", new Color32(255, 100, 0, 255));
            float z = argus.GetZ(center.z);

            bool prevEnterSlide = enterSlide;
            enterSlide = argus.isInSlide(center.z);


            if (enterSlide)
            {
                float x = argus.GetX(center.x) - argus.GetX(enterSlideXPos);
                if (enterSlide != prevEnterSlide)
                {
                    enterSlideXPos = center.x;
                    enterSlideZPos = z;
                }



                if (Catched)
                {
                    transform.position = new Vector3(argus.BackPos.x, argus.BackPos.y, z);
                }
                else
                {
                    transform.position = new Vector3(argus.FrontPos.x + x, argus.BackPos.y, argus.SlidePos);
                    SlideTran.transform.localPosition = slideOriginPos + x * argus.slideSpeed * Vector3.right;
                    isCameraMove = false;
                }


                if (debugMode)
                {
                    slidePointer.gameObject.SetActive(true);
                    slidePointer.material.SetColor("_LineColor", Color.red);
                }
            }
            else
            {
                if (argus.isInMedia(center.z))
                {
                    if (frameNum > 0)
                    {
                        transform.position = new Vector3(argus.FrontPos.x, argus.FrontPos.y, argus.MediaMiddle);
                    }
                    else
                    {
                        transform.position = new Vector3(argus.FrontPos.x, argus.FrontPos.y, z);
                    }

                    if (debugMode)
                    {
                        btnPointer.gameObject.SetActive(true);
                        btnPointer.material.SetColor("_LineColor", Color.red);
                    }

                    Media(key);
                }
                //else if (argus.isInBack(center.z))
                //{
                //    //transform.position = new Vector3(argus.FrontPos.x, argus.FrontPos.y, argus.maxZ);


                //}
                //else if (argus.isInSlideBack(center.z))
                //{

                //    (false);
                //    transform.position = new Vector3(argus.FrontPos.x, argus.FrontPos.y, z);

                //}

                else if (argus.isInBottom(center.z))
                {
                    transform.position = new Vector3(argus.FrontPos.x, argus.FrontPos.y, z);
                    isInPic            = true;
                    if (argus.BackHit(viewer.ResultCode))
                    {
                        StartCoroutine(CatchAct(key));
                    }

                    if (debugMode)
                    {
                        graspPointer.gameObject.SetActive(true);
                        graspPointer.material.SetColor("_LineColor", Color.red);
                    }
                }
                else
                {
                    transform.position = new Vector3(argus.FrontPos.x, argus.FrontPos.y, z);

                    if (debugMode)
                    {
                        btnPointer.material.SetColor("_LineColor", Color.gray);
                        slidePointer.material.SetColor("_LineColor", Color.gray);
                        graspPointer.material.SetColor("_LineColor", Color.gray);
                    }
                }
            }

            if (!debugMode)
            {
                btnPointer.gameObject.SetActive(false);
                slidePointer.gameObject.SetActive(false);
                graspPointer.gameObject.SetActive(false);
            }

            Grasp(key);

            if (argus.BackHit(viewer.ResultCode) && !isInPic)
            {
                StartCoroutine(Recover(key));
            }


            cameraPos = Camera.main.transform.position;
            SetCamera(isCameraMove);
            prevFingerNum = key.fingerNum;

            frameNum--;
            frameNum = Mathf.Clamp(frameNum, 0, 120);
        }
    }