示例#1
0
        private void OnRocketImpactedWithBorder()
        {
            GetComponent <CapsuleCollider>().enabled = false;
            myCollider.enabled = false;
            mazeLetter.GetComponent <BoxCollider>().enabled = false;

            ragdoll.transform.SetParent(rocket.transform, true);

            rocket.GetComponent <SphereCollider>().enabled = true;

            var rocketRigidBody = rocket.GetComponent <Rigidbody>();

            rocketRigidBody.isKinematic = false;
            rocketRigidBody.useGravity  = true;

            var rocketRotation = rocket.transform.rotation.eulerAngles.y;

            var velocity = new Vector3(Mathf.Sin(rocketRotation * Mathf.Deg2Rad), 0f, Mathf.Cos(rocketRotation * Mathf.Deg2Rad));

            velocity  *= 10f;
            velocity.y = 20f;

            rocketRigidBody.velocity        = Vector3.zero;
            rocketRigidBody.angularVelocity = Vector3.zero;

            rocketRigidBody.AddForce(velocity, ForceMode.VelocityChange);
            rocketRigidBody.AddRelativeTorque(new Vector3(Random.Range(-40f, 40f), Random.Range(-40f, 40f), Random.Range(-40f, 40f)) * 100f);

            State = LLState.Impacted;

            rocketMoveSFX.Stop();

            MazeConfiguration.Instance.Context.GetAudioManager().PlaySound(Sfx.CrateLandOnground);
        }
示例#2
0
        private void FixedUpdate()
        {
            switch (_state)
            {
            case LLState.Normal:
                break;

            case LLState.Braked:
                if (stateTime > DELAY_TO_PRONOUNCE_LETTER && !pronouncedLetter)
                {
                    letterPronounciation = MazeConfiguration.Instance.Context.GetAudioManager().PlayVocabularyData(
                        MazeGame.instance.currentLL,
                        soundType: MazeConfiguration.Instance.GetVocabularySoundType()
                        );
                    pronouncedLetter = true;
                }
                else if (pronouncedLetter && (letterPronounciation == null || !letterPronounciation.IsPlaying))
                {
                    if (!markedEndTimeOfLetterPronounciation)
                    {
                        endTimeOfLetterPronounciation       = Time.time;
                        markedEndTimeOfLetterPronounciation = true;
                    }

                    if (Time.time - endTimeOfLetterPronounciation > DELAY_BETWEEN_LETTER_SOUND_AND_CHECKMARK && !showedCheckmarkUponVictory)
                    {
                        var tickPosition = transform.position;
                        tickPosition.z -= 1.5f;
                        tickPosition.x -= 0.5f;

                        Tutorial.TutorialUI.MarkYes(tickPosition, Tutorial.TutorialUI.MarkSize.Big);
                        MazeConfiguration.Instance.Context.GetAudioManager().PlaySound(Sfx.StampOK);

                        showedCheckmarkUponVictory = true;
                        if (OnMarkStamp != null)
                        {
                            OnMarkStamp();
                        }
                    }

                    if (Time.time - endTimeOfLetterPronounciation > (DELAY_BETWEEN_LETTER_SOUND_AND_CHECKMARK + DELAY_BETWEEN_CHECKMARK_AND_EXIT))
                    {
                        State = LLState.Normal;

                        brakeYoyoTweener.Kill();
                        celebrationPathTweener.Play();
                    }
                }

                break;

            case LLState.Impacted:
                if (stateTime >= 0.33f)
                {
                    State = LLState.Ragdolling;
                }
                break;
            }

            stateTime += Time.fixedDeltaTime;
        }
示例#3
0
        public void Celebrate(System.Action OnCelebrationOver, System.Action OnMarkStamp)
        {
            this.OnMarkStamp = OnMarkStamp;
            List <Vector3> celebrationPathPoints = new List <Vector3>();

            var cameraPosition = Camera.main.transform.position;

            var frustumHeight = GetFrustumHeightAtDistance(CELEBRATION_PATH_ENDPOINT_DISTANCE_FROM_CAMERA);
            var frustumWidth  = GetFrustumWidth(frustumHeight);

            Vector3 endPoint = new Vector3(cameraPosition.x + (frustumWidth / 2) * CELEBRATION_PATH_ENDPOINT_X_ANCHOR,
                                           cameraPosition.y - CELEBRATION_PATH_ENDPOINT_DISTANCE_FROM_CAMERA,
                                           cameraPosition.z + (frustumHeight / 2) * CELEBRATION_PATH_ENDPOINT_Z_ANCHOR);

            Vector3 midPoint = transform.position + endPoint;

            midPoint *= 0.5f;

            frustumHeight = GetFrustumHeightAtDistance(cameraPosition.y - midPoint.y);
            frustumWidth  = GetFrustumWidth(frustumHeight);

            midPoint = new Vector3(cameraPosition.x + (frustumWidth / 2) * CELEBRATION_PATH_MIDPOINT_X_ANCHOR,
                                   midPoint.y,
                                   cameraPosition.z + (frustumHeight / 2) * CELEBRATION_PATH_MIDPOINT_Z_ANCHOR);

            celebrationPathPoints.Add(transform.position);
            celebrationPathPoints.Add(midPoint);
            celebrationPathPoints.Add(endPoint);

            var offscreenPoint = endPoint + (endPoint - midPoint).normalized * 6f;

            celebrationPathPoints.Add(offscreenPoint);

            LL.Init(MazeGame.instance.currentLL);
            LL.Horraying = true;

            bool braked = false;

            celebrationPathTweener = transform.DOPath(celebrationPathPoints.ToArray(), CELEBRATION_PATH_DURATION, PathType.CatmullRom, PathMode.Ignore).OnWaypointChange((int index) => {
                if (index == celebrationPathPoints.Count - 3)
                {
                    var rotationQuaterion = Quaternion.LookRotation(celebrationPathPoints[index + 1] - transform.position);
                    var eulerAngles       = rotationQuaterion.eulerAngles;
                    eulerAngles.z        -= 90f;
                    transform.DORotate(eulerAngles, 0.33f);
                }
                else if (index < celebrationPathPoints.Count - 2)
                {
                    transform.DOLookAt(celebrationPathPoints[index + 1], 0.33f, AxisConstraint.None, Vector3.forward);
                }
                else if (index == celebrationPathPoints.Count - 2 && !braked)
                {
                    braked = true;

                    celebrationPathTweener.Pause();
                    State = LLState.Braked;
                    winParticleVFX.SetActive(true);
                    brakeYoyoTweener = transform.DOMove(transform.position + new Vector3(-0.5f, 0.5f, -0.5f) * 0.33f, 0.75f).SetEase(Ease.InOutSine).SetLoops(-1, LoopType.Yoyo);
                }
            }).OnComplete(() => {
                toggleVisibility(false);
                gameObject.SetActive(false);
                OnCelebrationOver();
            });
        }
示例#4
0
        private IEnumerator Flee_Coroutine()
        {
            yield return(new WaitForSeconds(0.25f));

            finishedRound = true;
            isFleeing     = true;

            List <Vector3> fleePathPoints = new List <Vector3>();

            var cameraPosition = Camera.main.transform.position;

            var frustumHeight = GetFrustumHeightAtDistance(FLEE_PATH_ENDPOINT_DISTANCE_FROM_CAMERA);
            var frustumWidth  = GetFrustumWidth(frustumHeight);

            Vector3 endPoint = new Vector3(cameraPosition.x + (frustumWidth / 2) * FLEE_PATH_ENDPOINT_X_ANCHOR,
                                           cameraPosition.y - FLEE_PATH_ENDPOINT_DISTANCE_FROM_CAMERA,
                                           cameraPosition.z + (frustumHeight / 2) * FLEE_PATH_ENDPOINT_Z_ANCHOR);

            Vector3 midPoint = transform.position + endPoint;

            midPoint *= 0.5f;

            frustumHeight = GetFrustumHeightAtDistance(cameraPosition.y - midPoint.y);
            frustumWidth  = GetFrustumWidth(frustumHeight);

            midPoint = new Vector3(cameraPosition.x + (frustumWidth / 2) * FLEE_PATH_MIDPOINT_X_ANCHOR,
                                   midPoint.y,
                                   cameraPosition.z + (frustumHeight / 2) * FLEE_PATH_MIDPOINT_Z_ANCHOR);


            fleePathPoints.Add(transform.position);
            fleePathPoints.Add(midPoint);
            fleePathPoints.Add(endPoint);

            LL.Init(MazeGame.instance.currentLL);

            var fleePathPointsArray = fleePathPoints.ToArray();

            transform.DOKill();

            transform.DOLookAt(fleePathPointsArray[1], 0.33f, AxisConstraint.None, Vector3.forward);

            transform.DOPath(fleePathPointsArray, FLEE_PATH_DURATION, PathType.Linear).OnWaypointChange((int index) => {
                if (index < fleePathPoints.Count - 1)
                {
                    transform.DOLookAt(fleePathPointsArray[index + 1], 0.33f, AxisConstraint.None, Vector3.forward);
                }
            }).OnComplete(() => {
                //wait then show cracks:
                StartCoroutine(waitAndPerformCallback(3.5f, () => {
                    MazeGame.instance.showAllCracks();
                    donotHandleBorderCollision = true;
                    characterIsMoving          = false;
                    transform.DOKill(false);

                    rocket.GetComponent <SphereCollider>().enabled = true;

                    var rocketRigidBody         = rocket.GetComponent <Rigidbody>();
                    rocketRigidBody.isKinematic = true;

                    State = LLState.Ragdolling;

                    ragdoll.deleteOnRagdollHit = false;

                    MazeGame.instance.ColorCurrentLinesAsIncorrect();

                    var tickPosition = transform.position;
                    tickPosition.z  -= 1f;
                    tickPosition.x  -= 2f;
                    tickPosition.y  -= 3f;
                    Tutorial.TutorialUI.MarkNo(tickPosition, Tutorial.TutorialUI.MarkSize.Normal);
                    MazeConfiguration.Instance.Context.GetAudioManager().PlaySound(Sfx.KO);

                    if (!MazeGame.instance.isTutorialMode)
                    {
                        MazeConfiguration.Instance.Context.GetAudioManager().PlaySound(Sfx.Lose);
                    }
                },
                                                      () => {
                    MazeGame.instance.lostCurrentLetter();
                }));
            });
        }