Exemplo n.º 1
0
 private void Update()
 {
     if (Input.anyKey || JoyConInputManager.GetJoyConAnykeyDown())
     {
         Utility.MoveNextScene();
     }
 }
Exemplo n.º 2
0
 // Update is called once per frame
 void Update()
 {
     if (Input.GetKeyDown(KeyCode.Space))
     {
         JoyConInputManager.Recenter(false);
         Debug.Log("Rr");
     }
 }
Exemplo n.º 3
0
    private void Awake()
    {
        if (instance != null && instance != this)
        {
            Destroy(instance.gameObject);
        }
        instance = this;

        DontDestroyOnLoad(gameObject);
    }
Exemplo n.º 4
0
    private void OnGUI()
    {
        var style = GUI.skin.GetStyle("label");

        style.fontSize = 24;

        GUILayout.BeginArea(new Rect(450, 0, 480, 900));
        GUILayout.Label("inflatedAirVolume = " + inflatedAirVolume);
        GUILayout.Label("Joy-con accel Z   = " + JoyConInputManager.GetJoyConAccel(false).z);
        GUILayout.EndArea();
    }
Exemplo n.º 5
0
    private void Update()
    {
        // If left joycon, inverse the up down direction
        var gryo = JoyConInputManager.GetJoyConGyro(false);

        acc = JoyConInputManager.GetJoyConAccel(false);
        transform.localRotation = JoyConInputManager.GetJoyConOrientation(false);
        //var rotZ = TransformUtils.GetInspectorRotation(transform).z;
        //if (rotZ < 0 && Mathf.Abs(rotZ + 90.0f) > 22) return;
        //if (rotZ > 0 && Mathf.Abs(rotZ - 90.0f) > 22) return;
        //roundAccX = Mathf.Round(acc.x * 10.0f) / 10.0f;
        //transform.position = new Vector3(transform.position.x, transform.position.y + roundAccX * 12.0f * Time.deltaTime, transform.position.z);
        //Debug.Log(gryo);
        //Vector3 presentAcc = JoyConInputManager.GetJoyConAccel(false);
        //transform.Translate((prevAcc - presentAcc) * Time.deltaTime * speed);
        //prevAcc = presentAcc;
    }
Exemplo n.º 6
0
    private void OnCollisionEnter(Collision collision)
    {
        collision.gameObject.GetComponent <IReactionable>()?.OnEnter(this);

        // Save floor info
        if (collision.gameObject.tag == "Floor")
        {
            if (passedFloorQueue.Count == 3)
            {
                passedFloorQueue.Dequeue();
            }
            passedFloorQueue.Enqueue(collision.gameObject);
        }
        else
        {
            JoyConInputManager.TriggerRumble(true, 320, 160, 0.6f, 200);
        }
    }
Exemplo n.º 7
0
    private void RotatePlayer()
    {
        #region KeyboardInput
        var horizontalInput = Input.GetAxis("Keyboard_Horizontal");
        if (horizontalInput != 0.0f)
        {
            var newQuat = Quaternion.Euler(0.0f,
                                           horizontalInput * keyboardRotSpeed * Time.deltaTime,
                                           0.0f);
            rd.MoveRotation(newQuat * rd.rotation);
            return;
        }
        #endregion

        #region JoyConInput
        // Recenter
        if (JoyConInputManager.GetJoyConButtonDown(Joycon.Button.SHOULDER_1))
        {
            RecenterPlayerJoyCon();
        }

        // Clamp
        ++frameCount;
        Quaternion joyConFixQuat = Quaternion.Euler(0.0f, JoyConRotFixAngle * Mathf.Pow(frameCount, JoyConRotFixPower) * Time.deltaTime, 0.0f);
        targetJoyConRot = joyConFixQuat * JoyConInputManager.GetJoyConOrientation(isUsingLeftJoyCon);
        if (targetJoyConRot != Quaternion.identity)
        {
            deferredJoyConRot = Quaternion.RotateTowards(deferredJoyConRot,
                                                         targetJoyConRot, joyConRotSpeed * Time.deltaTime);

            var joyConDir = deferredJoyConRot * Vector3.up;
            if (Vector3.Angle(joyConDir, Vector3.forward) > angleLimit)
            {
                return;
            }

            // Add gyro data to player model rotation
            var initiRot = transform.rotation.eulerAngles;
            var tempQuat = deferredJoyConRot * Quaternion.Euler(90.0f, 0.0f, 0.0f);
            transform.rotation  = Quaternion.Euler(initiRot.x, tempQuat.eulerAngles.y, initiRot.z);
            transform.rotation *= Quaternion.AngleAxis(180.0f, Vector3.up);
        }
        #endregion
    }
Exemplo n.º 8
0
    private void Update()
    {
        #region Debug
        if (Input.GetKeyDown(KeyCode.F1))
        {
            Utility.ReloadCurrentScene();
        }
        #endregion

        if (playerScore == playerScoreMax && rivalScore == rivalScoreMax)
        {
            resultText.gameObject.SetActive(true);

            // Go next scene
            if (JoyConInputManager.GetJoyConAnykeyDown() || Input.anyKeyDown)
            {
                async.allowSceneActivation = true;
                Resources.UnloadUnusedAssets();
                System.GC.Collect();
            }
            return;
        }

        if (timer >= calcTimeInterval)
        {
            timer = 0.0f;

            // Main process
            float playerScoreAdd = calcStep + UnityEngine.Random.Range(0, calcStepVariety);
            float rivalScoreAdd  = calcStep + UnityEngine.Random.Range(0, calcStepVariety);
            UpdateScore(ref playerScore, ref playerScoreAdd, playerScoreMax);
            UpdateScore(ref rivalScore, ref rivalScoreAdd, rivalScoreMax);
            ProcessScoreBar(playerScoreAdd, rivalScoreAdd);
            ProcessScoreText();
        }
        else
        {
            timer += Time.deltaTime;
        }
    }
Exemplo n.º 9
0
 private void Update()
 {
     if (isTutorial)
     {
         if (!isBridgeTut)
         {
             if (JoyConInputManager.GetJoyConButtonDown(readyJoyConButton) ||
                 Input.GetButtonDown(readyKeyboardButton))
             {
                 AudioManager.Instance.Play("ZRTouch");
                 isBridgeTut = true;
                 MarathonTutUIController.Instace.ChangeToBridgeUI();
             }
         }
         else
         {
             if (JoyConInputManager.GetJoyConButtonDown(readyJoyConButton) ||
                 Input.GetButtonDown(readyKeyboardButton))
             {
                 AudioManager.Instance.Play("ZRTouch");
                 async.allowSceneActivation = true;
                 Resources.UnloadUnusedAssets();
                 System.GC.Collect();
             }
         }
     }
     else
     {
         if (MarathonScoreController.Instance.IsFinishedResultTimeline)
         {
             if (Input.anyKeyDown || JoyConInputManager.GetJoyConAnykeyDown())
             {
                 AudioManager.Instance.Play("ZRTouch");
                 async.allowSceneActivation = true;
                 Resources.UnloadUnusedAssets();
                 System.GC.Collect();
             }
         }
     }
 }
Exemplo n.º 10
0
    private void HandleJoyConInput()
    {
        // Recenter process
        if (JoyConInputManager.GetJoyConButtonDown(Joycon.Button.SHOULDER_1))
        {
            JoyConInputManager.Recenter(isUsingLeftJoyCon);
        }

        // Select icon process
        if (results.Count > 0 &&
            JoyConInputManager.GetJoyConButtonDown(Joycon.Button.SHOULDER_2))
        {
            foreach (var i in results)
            {
                var interfaceComp = i.gameObject.GetComponent <IJoyConSelectable>();
                if (interfaceComp != null)
                {
                    interfaceComp.OnJoyConClicked();
                }
            }
        }
    }
Exemplo n.º 11
0
 private void Playing()
 {
     if (IsPlaying)
     {
         titleManager.GetComponent <CutSceneManager>().SetInputState(false);
         Timer = 0.0f;
         if (JoyConInputManager.GetJoyConAnykeyDown() || Input.anyKeyDown)
         {
             IsPlaying = false;
             titleManager.GetComponent <CutSceneManager>().SetInputState(true);
         }
         if (PlayTime != 0.0f)
         {
             if (Demovideo.time > PlayTime)
             {
                 IsPlaying = false;
                 titleManager.GetComponent <CutSceneManager>().SetInputState(true);
             }
         }
         else
         {
             if (Demovideo.time >= Demovideo.length)
             {
                 IsPlaying = false;
                 titleManager.GetComponent <CutSceneManager>().SetInputState(true);
             }
         }
     }
     else
     {
         Timer += Time.deltaTime;
         if (Timer >= WaitTime)
         {
             ShouldPlay = true;
         }
         Stop();
     }
 }
Exemplo n.º 12
0
    private void getGyro()
    {
        var getGyroy = JoyConInputManager.GetJoyConGyro(isUsingLeftJoyCon).y;

        if (Outputcount > 0)
        {
            if (getGyroy < -2 || getGyroy > 2)
            {
                count       += Mathf.Abs(getGyroy);
                Outputcount  = countdown - (int)(count / 100.0f);
                Counter.text = "" + Outputcount;
                Debug.Log(count);
            }
        }
        else
        {
            Counter.enabled = false;
            //MarathonPlayer.isDown = false;
            ShouldRotate = false;
            player.transform.localRotation = Quaternion.identity;
            JoyConInputManager.Recenter(isUsingLeftJoyCon);
            Destroy(this.gameObject);
        }
    }
Exemplo n.º 13
0
 private void HandleInput()
 {
     #region TimelineProcess
     if (JoyConInputManager.GetJoyConAnykeyDown() || Input.anyKeyDown)
     {
         zrSoundEffect.Play();
         canInput = false;
         if (!IsPlaying)
         {
             IsPlaying = true;
             director.Play();
         }
         else
         {
             if (director.time == director.playableAsset.duration)
             {
                 async.allowSceneActivation = true;
                 Resources.UnloadUnusedAssets();
                 System.GC.Collect();
             }
             else
             {
                 var nextTime = director.time + director.playableAsset.duration / jumpTime;
                 if (nextTime > director.playableAsset.duration)
                 {
                     director.time = director.playableAsset.duration;
                 }
                 else
                 {
                     director.time += director.playableAsset.duration / jumpTime;
                 }
             }
         }
     }
     #endregion
 }
Exemplo n.º 14
0
    private void Update()
    {
        #region Debug
        if (Input.GetKeyDown(KeyCode.F1))
        {
            Utility.ReloadCurrentScene();
        }
        else if (Input.GetKeyDown(KeyCode.F2))
        {
            Utility.MoveNextScene();
        }
        else if (Input.GetKeyDown(KeyCode.F3))
        {
            for (int i = 0; i < dashEnergyList.Count; i++)
            {
                dashEnergyList[i] = dashPointCapacity;
            }
        }
        #endregion

        // If fell out main ground
        if (transform.position.y < landBaseline)
        {
            if (!AudioManager.Instance.CheckIsPlaying("Fall"))
            {
                AudioManager.Instance.Play("Fall");
            }
            SetPlayerState(MarathonPlayerStatus.Falling);
        }

        switch (State)
        {
        case MarathonPlayerStatus.WarmingUp:
            break;

        case MarathonPlayerStatus.Running:
            bool isTriggered = JoyConInputManager.GetJoyConButtonDown(Joycon.Button.SHOULDER_2) ||
                               Input.GetButtonDown("Fire1");
            if (dashEnergyList[0] == 1.0f && isTriggered)
            {
                dashEnergyList.RemoveAt(0);
                dashEnergyList.Add(0.0f);
                honeyMarkHolder.RefreshHoneyMarks(dashEnergyList);
                SetPlayerState(MarathonPlayerStatus.Dashing);
            }
            MovePlayer(runSpeed);
            RotatePlayer();
            break;

        case MarathonPlayerStatus.Dashing:
            Dash();
            break;

        case MarathonPlayerStatus.Falling:
            Fall();
            RotatePlayer();
            break;

        case MarathonPlayerStatus.BeKnockedBack:
            BeKnockedBack();
            break;

        case MarathonPlayerStatus.Dizzying:
            if (timer >= dizzyingTimeLength)
            {
                SetPlayerState(MarathonPlayerStatus.Running);
            }
            else
            {
                timer += Time.deltaTime;
            }
            break;

        case MarathonPlayerStatus.Dancing:
            if (timer >= dancingTimeLength)
            {
                SetPlayerState(MarathonPlayerStatus.Running);
            }
            else
            {
                timer += Time.deltaTime;
            }
            break;

        case MarathonPlayerStatus.PassingBridge:
            PassBridge();
            break;

        case MarathonPlayerStatus.HoldUp:
            if (timer >= afterResetHoldUpTimeLength)
            {
                SetPlayerState(MarathonPlayerStatus.Running);
            }
            else
            {
                timer += Time.deltaTime;
            }
            RotatePlayer();
            break;

        case MarathonPlayerStatus.ReachGoal:
            Vector3    relativePos = Camera.main.transform.position - transform.position;
            Quaternion rot         = Quaternion.LookRotation(relativePos);
            rot = Quaternion.Euler(0.0f, rot.eulerAngles.y, 0.0f);
            transform.rotation = Quaternion.Slerp(transform.rotation,
                                                  rot,
                                                  rotToCameraSpeed * Time.deltaTime);
            break;
        }

        // Set animation
        GetComponent <Animator>().SetInteger("playerState", (int)State);
    }
Exemplo n.º 15
0
 private void Start()
 {
     targetJoyConRot = JoyConInputManager.GetJoyConOrientation(isUsingLeftJoyCon);
     RecenterPlayerJoyCon();
 }
Exemplo n.º 16
0
    private void Update()
    {
        if (!isDirtyInitilized)
        {
            JoyConInputManager.Recenter(isUsingLeftJoyCon);
            isDirtyInitilized = true;
        }

        // Calc the point of intersection between joyConDirection and UIScreen
        var joyConQuat = JoyConInputManager.GetJoyConOrientation(isUsingLeftJoyCon);

        joyConPointDir = joyConQuat * Camera.main.transform.up;
        if (joyConPointDir.z < 0)
        {
            return;
        }
        if (shouldReverseJoyConY)
        {
            joyConPointDir = new Vector3(joyConPointDir.x, -joyConPointDir.y, joyConPointDir.z).normalized;
        }
        else
        {
            joyConPointDir = joyConPointDir.normalized;
        }

        joyConPointDir = Camera.main.WorldToScreenPoint(joyConPointDir * pointerMoveSpeed
                                                        + Camera.main.transform.position) + new Vector3(pointerAdjuster.x, pointerAdjuster.y, 0);

        // Detect hit
        eventDataCurrentPosition.position = joyConPointDir;
        EventSystem.current.RaycastAll(eventDataCurrentPosition, results);
        if (results.Count > 0)
        {
            bool hasIcon = false;
            foreach (var i in results)
            {
                var interfaceComp = i.gameObject.GetComponent <IJoyConSelectable>();
                // If not seletable icon
                if (interfaceComp == null)
                {
                    if (i.gameObject.name == "BG")
                    {
                        pointerMark.transform.position = i.screenPosition;
                    }
                }
                else
                {
                    i.gameObject.GetComponent <Image>().color = Color.red;
                    hasIcon = true;
                }
            }

            if (!hasIcon)
            {
                foreach (var i in iconObjs)
                {
                    i.GetComponent <Image>().color = Color.white;
                }
            }
        }

        HandleJoyConInput();
    }
Exemplo n.º 17
0
    /// <summary>
    ///
    /// </summary>
    /// <returns>Is used joyCon for input?</returns>
    private bool HandlePlayerJoyConInput()
    {
        if (!PlayerBalloon)
        {
            return(false);
        }
        if (!isUseLeftJoycon && !JoyConInputManager.IsUsingRightJoyCon())
        {
            return(false);
        }
        else if (isUseLeftJoycon && !JoyConInputManager.IsUsingLeftJoyCon())
        {
            return(false);
        }

        /// Handle release balloon
        var gyroInfo = JoyConInputManager.GetJoyConGyro(isUseLeftJoycon);

        if (gyroInfo.y < joyConReleaseSensitivity ||
            JoyConInputManager.GetJoyConButtonDown(Joycon.Button.SHOULDER_2))
        {
            if (PlayerBalloon.State != Balloon.BalloonStatus.Normal)
            {
                JoyConInputManager.TriggerRumble(false, 180.0f, 360.0f, 0.3f, 200);
                ReleaseBalloon(true);
            }
            return(true);
        }

        /// Handle inflate balloon and animation
        if (Mathf.Abs(gyroInfo.y) > Mathf.Abs(joyConReleaseSensitivity))
        {
            return(false);
        }
        Vector3 joyAccel   = JoyConInputManager.GetJoyConAccel(isUseLeftJoycon);
        float   accelDelta = joyAccel.sqrMagnitude - joyConInputSensitivity;

        if (accelDelta < 0.0f)
        {
            player.ResetInflateAnimationSpeed();
            return(false);
        }

        float newAir = accelDelta * joyConInflateSpeed * Time.deltaTime;

        if (newAir == 0.0f)
        {
            return(false);
        }
        playerJoyConInputSpeed = newAir * joyConInflateAniSpeedMultiplier;
        player.SetInflateAnimationSpeed(playerJoyConInputSpeed);
        inflatedAirVolume += newAir;
        if (PlayerBalloon.Inflate(newAir, newAir * joyConInputPitchMultiplier))
        {
            // Process after balloon boomed
            JoyConInputManager.TriggerRumble(false, 360.0f, 180.0f, 0.7f, 400);
            PlayerBalloon = null;
            Invoke("SpawnPlayerBalloon", failFreezeTime);
            IsPlayerFreezing = true;
            player.StartDizzy();
            player.ResetInflateAnimationSpeed();
        }
        return(true);
    }
Exemplo n.º 18
0
    private void Update()
    {
        #region Development
        if (Input.GetKeyDown(KeyCode.F1))
        {
            Utility.ReloadCurrentScene();
        }

        if (Input.GetKeyDown(KeyCode.F2))
        {
            Utility.MoveNextScene();
        }
        #endregion

        if (isTutorial)
        {
            var isUsedJoyCon = HandlePlayerJoyConInput();
            if (!isUsedJoyCon)
            {
                HandlePlayerKeyboardInput();
            }
            if (JoyConInputManager.GetJoyConButtonDown(readyJoyConButton) ||
                Input.GetButtonDown(readyKeyboardButton))
            {
                AudioManager.Instance.Play("ZRTouch");
                async.allowSceneActivation = true;
            }

            return;
        }

        switch (PresentGameState)
        {
        case GameStatus.Standby:
            break;

        case GameStatus.Playing:
            if (GameTime > gameTimeLimit)
            {
                GameTime = 0.0f;
                PrepareData();
                OnGameFinished?.Invoke();
                playableDirector.Play(gameEndTimelineAssert);
                AudioManager.Instance.Stop("TimeHint");
                AudioManager.Instance.Stop("BalloonReady");
                AudioManager.Instance.Play("SceneEnd");
                playerJoyConInputSpeed   = 0.0f;
                playerKeyboardInputSpeed = 0.0f;
                PresentGameState         = GameStatus.End;
            }
            else
            {
                GameTime += Time.deltaTime;
                var timeLeft = gameTimeLimit - GameTime;

                gameInfoText.text = "Time left: " + Mathf.RoundToInt(timeLeft) + "s";
            }

            var isUsedJoyCon = HandlePlayerJoyConInput();
            if (!isUsedJoyCon)
            {
                HandlePlayerKeyboardInput();
            }
            HandleRivalBehaviour();
            ProcessAI();
            break;

        case GameStatus.End:
            if (BalloonGameResultUIController.Instance.IsScoreCalcFinished)
            {
                if (JoyConInputManager.GetJoyConAnykeyDown() || Input.anyKeyDown)
                {
                    AudioManager.Instance.Play("ZRTouch");
                    async.allowSceneActivation = true;
                    Resources.UnloadUnusedAssets();
                    System.GC.Collect();
                }
            }
            break;

        default:
            break;
        }
    }
Exemplo n.º 19
0
    private void PassBridge()
    {
        if (!shouldCountUnstableTimer)
        {
            Debug.Assert(passingBridge != null);
            MovePlayer(passBridgeSpeed);
            transform.position = new Vector3(passingBridge.transform.position.x,
                                             transform.position.y, transform.position.z);
            transform.localRotation = Quaternion.identity;
        }

        #region UnstableProcess
        if (!shouldCheckUnstable)
        {
            return;
        }
        var  joyConAccel     = JoyConInputManager.GetJoyConAccel(isUsingLeftJoyCon);
        bool isAccelUnstable = joyConAccel.magnitude - 1.0f > accelTolerance ||
                               Input.GetAxis("Keyboard_Horizontal") != 0.0f;
        var  joyConYRot      = JoyConInputManager.GetJoyConOrientation(isUsingLeftJoyCon).eulerAngles.y;
        bool isAngleUnstable = Quaternion.Dot(passBridgeBenchmarkQuat,
                                              JoyConInputManager.GetJoyConOrientation(isUsingLeftJoyCon))
                               < angleTolerance;

        if (isAccelUnstable || isAngleUnstable)
        {
            shouldCountUnstableTimer = true;
            ani.SetBool("isBridgeUnstable", true);
        }

        if (shouldCountUnstableTimer)
        {
            timer += Time.deltaTime;
        }

        if (timer >= unstableHoldTime)
        {
            timer = 0.0f;
            shouldCountUnstableTimer = false;
            ani.SetBool("isBridgeUnstable", false);
        }
        else
        {
            if (timer < unstableRemedyTime)
            {
                return;
            }
            if (isAccelUnstable || isAngleUnstable)
            {
                timer = 0.0f;
                shouldCountUnstableTimer = false;
                ani.SetBool("isBridgeUnstable", false);
                SetPlayerState(MarathonPlayerStatus.Falling);
                passingBridge.BeforePlayerFelledOut(this);
                Vector3 dropDir = UnityEngine.Random.value > 0.5f ?
                                  transform.right : -transform.right;
                rd.AddForce(dropDir * fellOutForce, ForceMode.Impulse);
            }
        }
        #endregion
    }
Exemplo n.º 20
0
 public Quaternion RecenterPlayerJoyCon()
 {
     frameCount = 0;
     return(JoyConInputManager.Recenter(isUsingLeftJoyCon));
 }
Exemplo n.º 21
0
    private void GetInitialVelocity()
    {
        var getstick = JoyConInputManager.Getstick(false);

        initialVelocity = getstick[0] * rotspeed;
    }