private void Update() { if (GameManager.Instance.StoppedPlaying) { return; } DrawHud(); var(playerX, playerY) = new Vector2(player.x, player.y).ToGrid().ToInt().Unpack(); var movementDirection = new Vector2Int((int)Input.GetAxisDown("Horizontal"), (int)Input.GetAxisDown("Vertical")); var drillDirection = new Vector2Int((int)Input.GetAxis("Horizontal"), (int)Input.GetAxis("Vertical")); // Constrain movement to only one axis, with priority for vertical movement if (movementDirection.x != 0 && movementDirection.y != 0) { movementDirection.x = 0; } if (drillDirection.x != 0 && drillDirection.y != 0) { drillDirection.x = 0; } var desiredPosition = movementDirection.Add(playerX, playerY); var desiredDrillDirection = drillDirection.Add(playerX, playerY); var rangeCheck = desiredPosition.x >= 0 && desiredPosition.x < TilesHorizontal && desiredPosition.y >= 0 && desiredPosition.y < TilesVertical; var movedThisFrame = false; UpdateDrilling(ref playerX, ref playerY, ref rangeCheck, ref movedThisFrame, ref movementDirection, ref desiredPosition, ref drillDirection, ref desiredDrillDirection); UpdateMovement(ref playerX, ref playerY, ref rangeCheck, ref movedThisFrame, ref movementDirection, ref desiredPosition); UpdateGravity(ref playerX, ref playerY, ref rangeCheck, ref movementDirection, ref desiredPosition); UpdateFuel(ref playerX, ref playerY); UpdateTimers(); UpdateCamera(); PostUpdateChecks(ref playerY); }
private void Update() { canvas.graphics.Clear(Color.Transparent); canvas.graphics.DrawString($"Score", FontLoader.Instance[64f], Brushes.White, Globals.WIDTH / 2f, 320f, FontLoader.CenterAlignment); canvas.graphics.DrawString($"{score}", FontLoader.Instance[64f], Brushes.White, Globals.WIDTH / 2f, 320f + 48f, FontLoader.CenterAlignment); canvas.graphics.DrawString($"press any button", FontLoader.Instance[48f], Brushes.White, Globals.WIDTH / 2f, Globals.HEIGHT - 48f, FontLoader.CenterAlignment); if (Input.GetAxisDown("Horizontal") != 0 || Input.GetAxisDown("Vertical") != 0 || Input.GetButtonDown("Drill") || Input.GetButtonDown("Refuel")) { GameManager.Instance.ShouldShowLeaderboard = true; } }
private void Update() { canvas.graphics.Clear(Color.Transparent); canvas.graphics.DrawString($"LEADERBOARD", FontLoader.Instance[42f], Brushes.White, Globals.WIDTH / 2f, 320f, FontLoader.CenterAlignment); foreach (var(score, index) in scores.Select((score, index) => (score, index))) { canvas.graphics.DrawString($"{index+1}. {score}", FontLoader.Instance[28f], Brushes.White, Globals.WIDTH / 2f, 320 + 62 + index * (413 - 362), FontLoader.CenterAlignment); } canvas.graphics.DrawString($"press any button", FontLoader.Instance[48f], Brushes.White, Globals.WIDTH / 2f, Globals.HEIGHT - 48f, FontLoader.CenterAlignment); if (Input.GetAxisDown("Horizontal") != 0 || Input.GetAxisDown("Vertical") != 0 || Input.GetButtonDown("Drill") || Input.GetButtonDown("Refuel")) { GameManager.Instance.ShouldShowMenu = true; } }
private void Update() { if (Input.GetButtonDown("Refuel")) { GameManager.Instance.ShouldStartPlaying = true; } if (Input.GetAxisDown("Horizontal") != 0 || Input.GetAxisDown("Vertical") != 0) { tutorialIndex++; if (tutorialIndex >= tutorialTextures.Length) { GameManager.Instance.ShouldStartPlaying = true; } } }