예제 #1
0
        private void CheckJump()
        {
            groundRayLeft = gameObject.GetComponent <Collider2D>().bounds.min;
            //HACK May need to adjust offset if to far back, shouldn't ever matter though since left will trigger can jump.
            groundRayRight = new Vector2(groundRayLeft.x + gameObject.GetComponent <Collider2D>().bounds.size.x - 0.19f, groundRayLeft.y);

            jumpRayHitLeft  = Physics2D.Raycast(groundRayLeft, new Vector2(-0.6f, -1f), groundRayLength, groundRayMask);
            jumpRayHitRight = Physics2D.Raycast(groundRayRight, Vector2.down, groundRayLength, groundRayMask);

            if (jumpRayHitLeft.collider != null)
            {
                //Waits till lands on next platform before player takes over.
                if (GameManager_Master.playPressed && GameManager_Master.gameState == GameState.Menu && lastObjectTouched != null)
                {
                    if (lastObjectTouched != jumpRayHitRight.transform.gameObject)
                    {
                        _runAudioSource.Stop();
                        startDelayActive = true;

                        _animator.SetFloat("RunMultiplier", 0);
                        //Used to subtract start position from score.
                        playerStartX = gameObject.transform.position.x;
                        _velocity.x  = 0f;
                        runSpeed     = 0f;
                        StartCoroutine(StartDelay());
                        StartCoroutine(gameManagerMaster.GetComponent <GameManager_PlayPressed>().MoveLogoOffScreen());

                        GameManager_Master.gameState = GameState.Playing;
                        gameManagerMaster.CallEventInputToggle();


                        //For time played achievement.
                        startTime = Time.unscaledTime;
                    }
                }

                if (jumpRayHitLeft.transform.gameObject.tag != "MovingPlatform")
                {
                    lastObjectTouched = jumpRayHitLeft.transform.gameObject;
                }

                canJump = true;
            }
            else if (jumpRayHitRight.collider != null)
            {
                canJump = true;
            }
            else
            {
                canJump = false;
            }

#if UNITY_EDITOR
            //Debug.DrawRay(groundRayLeft, new Vector2(-0.6f, -1f) * groundRayLength, Color.magenta);
            //Debug.DrawRay(groundRayRight, Vector2.down * groundRayLength, Color.magenta);
            //Debug.DrawRay(groundRayRight, Vector2.right *0.06f, Color.magenta, 600f);
#endif
        }
예제 #2
0
 private void Start()
 {
     if (Restart.restartPressed)
     {
         gameManagerMaster.GetComponent <GameManager_PlayPressed>().PlayPressed();
         UIPlayerPreview.SetActive(false);
         Restart.restartPressed = false;
     }
 }