コード例 #1
0
 public void TransitionToRunSummaryState()
 {
     gameState = GameState.RunSummary;
     scoreManager.StopCounting();
     if (scoreManager.GetScore() > highScore)
     {
         highScore = scoreManager.GetScore();
     }
     runSummaryLevelKey.text = ChunkSpawner.GetInstance().GetLevelKey();
     Invoke("PostRunSummary", runSummaryScreenTime);
 }
コード例 #2
0
    private string GetBestSavedScoreLookUp()
    {
        string levelKey = ChunkSpawner.GetInstance().GetLevelKey();
        string lookUp   = levelKey;

        return(lookUp);
    }
コード例 #3
0
ファイル: Player.cs プロジェクト: gamkedo-la/Late-For-School
    private void HandleWallClimb()
    {
        // wall climb
        if (isGrabbingWall)
        {
            Vector2 climbVector = new Vector2(0, inputVerticalAxis * speed);
            if (isStuck)
            {
                climbVector /= stuckSlowdownFactor;
            }
            rigidbody2d.velocity = climbVector;

            if (inputVerticalAxis != 0 && !ObstructionAboveOverlapCircle(0.1f, 0.1f))
            {
                StartWallClimbSound();
                anim.SetBool("isClimbing", true);
            }
            else
            {
                StopWallClimbSound();
                anim.SetBool("isClimbing", false);
            }
            anim.SetBool("isWallGrabbing", true);


            // Set off climb tooltip if player hasn't climbed in level yet
            if (GameManager.GetInstance().GetState() == GameManager.GameState.Play &&
                GameManager.GetInstance().levelInputConfig.includeTutorialChunks&&
                IsOnRightWall() &&
                !ChunkSpawner.GetInstance().IsKnownSkill(Skill.WallClimb) &&
                !wallClimbTooltipShown)
            {
                wallClimbTooltip.parent = ChunkSpawner.GetInstance().LastChunk().transform;
                wallClimbTooltip.Activate(transform.position + wallClimbTooltip.position);
                wallClimbTooltipShown = true;
            }

            // Set off detach tooltip if player hasn't attached to left side yet
            if (GameManager.GetInstance().GetState() == GameManager.GameState.Play &&
                GameManager.GetInstance().levelInputConfig.includeTutorialChunks&&
                IsOnLeftWall() &&
                !ChunkSpawner.GetInstance().IsKnownSkill(Skill.WallJump) &&
                !wallDetachTooltipShown)
            {
                wallDetachTooltip.parent = ChunkSpawner.GetInstance().LastChunk().transform;
                wallDetachTooltip.Activate(transform.position + wallDetachTooltip.position);
                wallDetachTooltipShown = true;
            }
        }
        else
        {
            anim.SetBool("isWallGrabbing", false);
            anim.SetBool("isClimbing", false);
            StopWallClimbSound();
        }
    }
コード例 #4
0
ファイル: Player.cs プロジェクト: gamkedo-la/Late-For-School
    private void HandleSlide()
    {
        bool canSlide = CanSlideRight(boxCollider2d.bounds.size.y / 2); // TODO: replace this parameter with the slide collider height when it is known

        if (GameManager.GetInstance().GetState() != GameManager.GameState.Play)
        {
            canSlide = canSlide && CanSlideLeft(boxCollider2d.bounds.size.y / 2);
        }

        if (inputVerticalAxisDown < 0 && IsGrounded() && !isSliding && canSlide)
        {
            StartSlide();
        }
        if (isSliding && slideTimeLeft > 0)
        {
            if (slideFxPrefab)
            {
                var     slideParticles    = Instantiate(slideFxPrefab);
                Vector3 particlesPosition = slideParticles.transform.position;
                particlesPosition.x = transform.position.x;
                particlesPosition.y = transform.position.y - 0.5f;
                slideParticles.transform.position = particlesPosition;
                if ((GameManager.GetInstance().GetState() == GameManager.GameState.Play ||
                     GameManager.GetInstance().GetState() == GameManager.GameState.RunSummary) &&
                    ChunkSpawner.GetInstance().LastChunk() != null)
                {
                    // attach particles to a chunk so that they move left if the game is being played
                    slideParticles.transform.parent = ChunkSpawner.GetInstance().LastChunk().transform;
                }
            }
            ;
            // If we're not playing the game, then the game is not moving - get player slide to move
            if (GameManager.GetInstance().GetState() != GameManager.GameState.Play)
            {
                float speed;
                if (slideDirection == HorizontalDirection.Left)
                {
                    speed = -slideSpeed;
                }
                else
                {
                    speed = slideSpeed;
                }
                Vector2 velocity = rigidbody2d.velocity;
                velocity.x          += speed;
                rigidbody2d.velocity = velocity;
            }
            slideTimeLeft -= Time.deltaTime;
        }
        else if (isSliding && slideTimeLeft <= 0 && !ObstructionAbove(0.5f))
        {
            StopSlide();
        }


        // Stop sliding if we hit a wall or for some reason we're no longer on the ground
        if (isSliding && !canSlide)
        {
            StopSlide();
        }
        if (isSliding && !IsGrounded())
        {
            StopSlide();
        }
    }
コード例 #5
0
ファイル: Player.cs プロジェクト: gamkedo-la/Late-For-School
    private void HandleHorizontalMovement()
    {
        if (!isDashing)
        {
            bool justStartedWallJumping = wallJumpTimeLeft > wallJumpResetTime - 0.1;
            // move sidewards
            if (!isGrabbingWall && !justStartedWallJumping)
            {
                // sliding while background not moving - slow down amount that horizontal movement has one speed
                if (GameManager.GetInstance().GetState() != GameManager.GameState.Play && isSliding)
                {
                    rigidbody2d.velocity = new Vector2(inputHorizontalAxis * speed / 2, rigidbody2d.velocity.y);
                }
                else if (GameManager.GetInstance().GetState() == GameManager.GameState.Play && isStuck)
                {
                    float velX = -1 * stuckSlowdownFactor;
                    velX += (inputHorizontalAxis * speed) / stuckSlowdownFactor;
                    rigidbody2d.velocity = new Vector2(velX, rigidbody2d.velocity.y);
                }
                // ground movement
                else if (!isWallJumpingLeft && !isWallJumpingRight && IsGrounded())
                {
                    if (isSliding && inputHorizontalAxis < 0)
                    {
                        inputHorizontalAxis /= 2;
                    }
                    rigidbody2d.velocity = new Vector2(inputHorizontalAxis * speed, rigidbody2d.velocity.y);
                } // normal air movement
                else if (!isWallJumpingLeft && !isWallJumpingRight && !IsGrounded())
                {
                    rigidbody2d.velocity = Vector2.Lerp(rigidbody2d.velocity, new Vector2(inputHorizontalAxis * speed, rigidbody2d.velocity.y), airAcceleration * Time.deltaTime);
                }
                // prevent moving back to the wall if jumping away from it
                else
                {
                    rigidbody2d.velocity = Vector2.Lerp(rigidbody2d.velocity, new Vector2(inputHorizontalAxis * speed, rigidbody2d.velocity.y), wallJumpStopMultiplier * Time.deltaTime);
                }
            }


            bool isOnWall = IsOnLeftWall() || IsOnRightWall();
            // Running sound
            bool isRunning = (GameManager.GetInstance().GetState() == GameManager.GameState.Play && IsGrounded() && !isSliding && !isOnWall) ||
                             (GameManager.GetInstance().GetState() != GameManager.GameState.Play && IsGrounded() && inputHorizontalAxis != 0 && !isSliding && !isOnWall);

            runParticles.gameObject.SetActive(isRunning);

            // Stop at ledge
            if (GameManager.GetInstance().GetState() == GameManager.GameState.Play && AtRightLedge() && inputHorizontalAxis == 0 && ledgeAutoStop)
            {
                Vector2 pos = transform.position;
                pos.x -= ChunkSpawner.GetInstance().levelConfig.speed *Time.deltaTime;
                transform.position = pos;
                isRunning          = false;
            }

            if (isRunning)
            {
                StartRunSound();
                anim.SetBool("isRunning", true);
            }
            else
            {
                StopRunSound();
                anim.SetBool("isRunning", false);
            }
        }
    }