Example #1
0
        void OnTriggerStay(Collider other)
        {
            if ((other.tag == ScannerGame.TAG_SCAN_START || other.tag == ScannerGame.TAG_SCAN_END) && isDragging)
            {
                if (!willPronounce)
                {
                    scanStartPos  = transform.position;
                    playTime      = 0;
                    willPronounce = true;

                    if (LL)
                    {
                        LL.setColor(Color.white);
                    }

                    LL        = other.transform.parent.GetComponent <ScannerLivingLetter>();
                    dataAudio = game.Context.GetAudioManager().PlayVocabularyData(LL.LLController.Data, true);

                    LL.setColor(Color.green);

                    if (game.tut.tutStep == 1)
                    {
                        game.tut.setupTutorial(2, LL);
                    }
                }

                /*if (timeDelta == 0 || lastTag == other.tag)
                 *              {
                 *                      timeDelta = Time.time;
                 *                      lastTag = other.tag;
                 *              }
                 *              else
                 *              {
                 *                      ScannerLivingLetter LL = other.transform.parent.GetComponent<ScannerLivingLetter>();
                 *                      timeDelta = Time.time - timeDelta;
                 *                      game.PlayWord(timeDelta, LL);
                 *                      timeDelta = 0;
                 *
                 *  if(game.tut.tutStep == 1)
                 *      game.tut.setupTutorial(2, LL);
                 * }*/
            }


            if (other.gameObject.name.Equals("Antura") && isDragging)
            {
                game.antura.GetComponent <ScannerAntura>().beScared();
            }
        }
Example #2
0
        void Update()
        {
            calculateSmoothedSpeed();

            if (game.scannerLL.Count != 0 && letterEventsNotSet)
            {
                letterEventsNotSet = false;
                foreach (ScannerLivingLetter LL in game.scannerLL)
                {
                    LL.onFlying += OnLetterFlying;
                }
            }

            if (moveBack && transform.position.z < backDepth)
            {
                transform.Translate(Vector3.forward * depthMovementSpeed * Time.deltaTime);
            }
            else if (!moveBack && transform.position.z > frontDepth)
            {
                transform.Translate(Vector3.back * depthMovementSpeed * Time.deltaTime);
            }


            if (dataAudio != null)
            {
                if (curPos != prevPose)
                {
                    playTime = Mathf.Clamp(playTime + Time.deltaTime, 0, dataAudio.Duration);
                    prevPose = scanPos;
                    scanPos  = Mathf.Lerp(0, dataAudio.Duration, Vector3.Distance(scanStartPos, transform.position) / 15f);

                    /*if (Mathf.Abs(scanPos) < Mathf.Abs(prevPose))
                     *  dataAudio.Pitch = -Mathf.Clamp(1 + (scanPos - playTime), 0, 100);
                     * else*/
                    dataAudio.Pitch = Mathf.Clamp(1 + (scanPos - playTime), 0, 100);

                    //Debug.LogError(dataAudio.Position + " / " + dataAudio.Duration);
                    //Debug.LogError(Mathf.Abs(scanPos) + " / " + Mathf.Abs(prevPose));
                }
                else
                {
                    dataAudio.Pitch = 0;

                    /*scanStartPos = transform.position;
                     * playTime = scanPos;*/
                }
                if (!isDragging || (willPronounce && (scanPos >= dataAudio.Duration - 0.1f /*|| dataAudio.Position >= dataAudio.Duration - 0.1f*/)))
                {
                    dataAudio     = null;
                    willPronounce = false;
                    LL.setColor(Color.white);
                }
            }

            if (willPronounce && LL && Vector3.Distance(LL.collForScan.position, transform.position) > 5.5f)
            {
                dataAudio     = null;
                willPronounce = false;
                LL.setColor(Color.white);
            }
        }