Add Auto/AI mode
This commit is contained in:
10 files changed
+10803
-4
No files matched your search
@@ -0,0 +1,672 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Numerics;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.InputSystem;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class AutoGamePlayer : MonoBehaviour {
|
||||
public static AutoGamePlayer Instance;
|
||||
private readonly float spawnRate = 1f;
|
||||
private float nextSpawnTime;
|
||||
internal BigInteger score;
|
||||
private BigInteger attempts;
|
||||
internal BigInteger highscore;
|
||||
internal BigInteger totalNormalBerries;
|
||||
internal BigInteger totalPoisonBerries;
|
||||
internal BigInteger totalSlowBerries;
|
||||
internal BigInteger totalUltraBerries;
|
||||
internal BigInteger totalSpeedyBerries;
|
||||
internal BigInteger totalRandomBerries;
|
||||
internal BigInteger totalAntiBerries;
|
||||
internal BigInteger totalGoldenBerries;
|
||||
internal BigInteger totalAttempts;
|
||||
private float boostLeft;
|
||||
private float slownessLeft;
|
||||
private float speedyLeft;
|
||||
private float antiLeft;
|
||||
private float goldenLeft;
|
||||
private float screenWidth;
|
||||
internal bool isGrounded;
|
||||
[SerializeField] private TMP_Text scoreText;
|
||||
[SerializeField] private TMP_Text highScoreText;
|
||||
[SerializeField] private TMP_Text boostText;
|
||||
[SerializeField] private GameObject bird;
|
||||
[SerializeField] private GameObject pausePanel;
|
||||
[SerializeField] private Rigidbody2D rb;
|
||||
public AudioSource backgroundMusic;
|
||||
[SerializeField] private SpriteRenderer overlayRender;
|
||||
private float lastMoveTime;
|
||||
[SerializeField] private GameObject berryParent;
|
||||
[SerializeField] private TMP_Text levelText;
|
||||
|
||||
[SerializeField] private Button pauseButton;
|
||||
|
||||
void Awake() {
|
||||
Instance = this;
|
||||
}
|
||||
|
||||
void Start() {
|
||||
lastMoveTime = Time.time;
|
||||
UnityEngine.InputSystem.EnhancedTouch.EnhancedTouchSupport.Enable();
|
||||
|
||||
Cursor.visible = false;
|
||||
Cursor.lockState = CursorLockMode.Locked;
|
||||
backgroundMusic.volume = BazookaManager.Instance.GetSettingMusicVolume();
|
||||
screenWidth = Camera.main.orthographicSize * 2f * Camera.main.aspect;
|
||||
if (Application.isMobilePlatform) pauseButton.gameObject.SetActive(true);
|
||||
UpdateStats(0, 1);
|
||||
}
|
||||
|
||||
void MoveBird() {
|
||||
float screenWidth = Camera.main.orthographicSize * 2f * Camera.main.aspect;
|
||||
float baseSpeed = 0.18f * (screenWidth / 20.19257f);
|
||||
bool doMoveRight = false;
|
||||
bool doMoveLeft = false;
|
||||
bool doJump = false;
|
||||
bool doBack = false;
|
||||
float movespeed = baseSpeed;
|
||||
if (boostLeft > 0f || speedyLeft > 0f) {
|
||||
movespeed = baseSpeed * 1.39f;
|
||||
} else if (slownessLeft > 0f) {
|
||||
movespeed = baseSpeed * 0.56f;
|
||||
}
|
||||
CheckIfGrounded();
|
||||
|
||||
float birdX = bird.transform.position.x;
|
||||
float birdY = bird.transform.position.y;
|
||||
|
||||
var berryScores = new System.Collections.Generic.Dictionary<string, float> {
|
||||
{ "NormalBerry", 1f },
|
||||
{ "UltraBerry", 5f },
|
||||
{ "SpeedyBerry", 10f },
|
||||
{ "RandomBerry", 0f },
|
||||
{ "GoldenBerry", 4f },
|
||||
{ "PoisonBerry", -100f },
|
||||
{ "SlowBerry", -1f },
|
||||
{ "AntiBerry", -10f },
|
||||
};
|
||||
|
||||
var allBerries = new System.Collections.Generic.List<(float x, float y, float score)>();
|
||||
foreach (var kvp in berryScores) {
|
||||
foreach (var b in GameObject.FindGameObjectsWithTag(kvp.Key)) {
|
||||
allBerries.Add((b.transform.position.x, b.transform.position.y, kvp.Value));
|
||||
}
|
||||
}
|
||||
|
||||
float collectRadius = 1.5f;
|
||||
|
||||
bool WouldCollideAtX(float testX, float berryX, float berryY, float radius) {
|
||||
float dx = Mathf.Abs(testX - berryX);
|
||||
float dy = Mathf.Abs(birdY - berryY);
|
||||
return dx < radius && dy < radius;
|
||||
}
|
||||
|
||||
bool PathHasDanger(float targetX) {
|
||||
foreach (var (bx, by, score) in allBerries) {
|
||||
if (score >= 0f) continue;
|
||||
float dy = Mathf.Abs(by - birdY);
|
||||
if (dy >= collectRadius) continue;
|
||||
float pathMin = Mathf.Min(birdX, targetX);
|
||||
float pathMax = Mathf.Max(birdX, targetX);
|
||||
if (bx + collectRadius > pathMin && bx - collectRadius < pathMax) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
float closestBadX = float.MaxValue;
|
||||
float closestBadDist = float.MaxValue;
|
||||
float dodgeLookahead = collectRadius + movespeed * 8f;
|
||||
|
||||
foreach (var (bx, by, score) in allBerries) {
|
||||
if (score >= 0f) continue;
|
||||
float dy = Mathf.Abs(by - birdY);
|
||||
if (dy >= collectRadius) continue;
|
||||
float dx = Mathf.Abs(bx - birdX);
|
||||
if (dx < dodgeLookahead && dx < closestBadDist) {
|
||||
closestBadDist = dx;
|
||||
closestBadX = bx;
|
||||
}
|
||||
}
|
||||
|
||||
bool inDanger = closestBadDist < float.MaxValue;
|
||||
|
||||
if (inDanger) {
|
||||
doMoveLeft = closestBadX >= birdX;
|
||||
doMoveRight = closestBadX < birdX;
|
||||
} else {
|
||||
var clusters = new System.Collections.Generic.List<(float x, float y, float score)>();
|
||||
var used = new bool[allBerries.Count];
|
||||
float clusterRadius = 1.8f;
|
||||
|
||||
for (int i = 0; i < allBerries.Count; i++) {
|
||||
if (used[i]) continue;
|
||||
var (ax, ay, aScore, _) = (allBerries[i].x, allBerries[i].y, allBerries[i].score, 0);
|
||||
float wX = ax * Mathf.Abs(aScore), wY = ay, total = aScore, wTotal = Mathf.Abs(aScore);
|
||||
int count = 1;
|
||||
used[i] = true;
|
||||
for (int j = i + 1; j < allBerries.Count; j++) {
|
||||
if (used[j]) continue;
|
||||
var (bx, by, bScore, _) = (allBerries[j].x, allBerries[j].y, allBerries[j].score, 0);
|
||||
float d = Mathf.Sqrt((bx - ax) * (bx - ax) + (by - ay) * (by - ay));
|
||||
if (d < clusterRadius) {
|
||||
wX += bx * Mathf.Abs(bScore); wY += by;
|
||||
total += bScore; wTotal += Mathf.Abs(bScore);
|
||||
count++; used[j] = true;
|
||||
}
|
||||
}
|
||||
clusters.Add((wTotal > 0f ? wX / wTotal : ax, wY / count, total));
|
||||
}
|
||||
|
||||
float bestScore = 0f;
|
||||
float bestX = float.MaxValue;
|
||||
bool foundTarget = false;
|
||||
|
||||
foreach (var (cx, cy, cs) in clusters) {
|
||||
if (cs <= 0f) continue;
|
||||
if (PathHasDanger(cx)) continue;
|
||||
float dist = Mathf.Abs(cx - birdX);
|
||||
float adjusted = cs - dist * 0.05f;
|
||||
if (adjusted > bestScore) {
|
||||
bestScore = adjusted;
|
||||
bestX = cx;
|
||||
foundTarget = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (foundTarget) {
|
||||
float alignTolerance = collectRadius * 0.6f;
|
||||
if (birdX < bestX - alignTolerance) {
|
||||
doMoveRight = true;
|
||||
} else if (birdX > bestX + alignTolerance) {
|
||||
doMoveLeft = true;
|
||||
} else {
|
||||
bool goodBerryAbove = false;
|
||||
foreach (var (bx, by, score) in allBerries) {
|
||||
if (score > 0f && by > birdY && WouldCollideAtX(birdX, bx, by, collectRadius))
|
||||
goodBerryAbove = true;
|
||||
}
|
||||
if (goodBerryAbove) doJump = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (Application.isMobilePlatform) {
|
||||
var touches = UnityEngine.InputSystem.EnhancedTouch.Touch.activeTouches;
|
||||
for (int i = 0; i < touches.Count; i++) {
|
||||
var pos = touches[i].screenPosition;
|
||||
UnityEngine.Vector3 clickPosition = Camera.main.ScreenToWorldPoint(new UnityEngine.Vector3(pos.x, pos.y, 0f));
|
||||
clickPosition.z = 0f;
|
||||
if (pauseButton.GetComponent<HoldableButton>().isPressed) doBack = true;
|
||||
}
|
||||
}
|
||||
if (doMoveLeft && !doMoveRight) {
|
||||
lastMoveTime = Time.time;
|
||||
bird.transform.position += new UnityEngine.Vector3(-movespeed, 0f, 0f);
|
||||
ClampPosition(bird);
|
||||
bird.transform.localScale = new UnityEngine.Vector3(1.35f, 1.35f, 1.35f);
|
||||
}
|
||||
if (doMoveRight && !doMoveLeft) {
|
||||
lastMoveTime = Time.time;
|
||||
bird.transform.position += new UnityEngine.Vector3(movespeed, 0f, 0f);
|
||||
ClampPosition(bird);
|
||||
bird.transform.localScale = new UnityEngine.Vector3(-1.35f, 1.35f, 1.35f);
|
||||
}
|
||||
if (doJump && isGrounded) {
|
||||
lastMoveTime = Time.time;
|
||||
AudioSource.PlayClipAtPoint(Resources.Load<AudioClip>("Sounds/Jump"), Camera.main.transform.position, 0.75f * BazookaManager.Instance.GetSettingSFXVolume());
|
||||
if (boostLeft > 0f || speedyLeft > 0f) {
|
||||
rb.linearVelocity = UnityEngine.Vector2.up * 12f;
|
||||
} else if (slownessLeft > 0f) {
|
||||
rb.linearVelocity = UnityEngine.Vector2.up * 6f;
|
||||
} else {
|
||||
rb.linearVelocity = UnityEngine.Vector2.up * 9f;
|
||||
}
|
||||
}
|
||||
if (doBack) {
|
||||
TogglePause();
|
||||
}
|
||||
if (antiLeft > 0f || goldenLeft > 0f) {
|
||||
string[] berryTags = { "NormalBerry", "SlowBerry", "UltraBerry", "SpeedyBerry", "RandomBerry", "AntiBerry", "GoldenBerry" };
|
||||
if (antiLeft > 0f) berryTags.Append("PoisonBerry");
|
||||
foreach (string tag in berryTags) {
|
||||
foreach (var berry in GameObject.FindGameObjectsWithTag(tag)) {
|
||||
UnityEngine.Vector3 dir = berry.transform.position - bird.transform.position;
|
||||
if (dir.magnitude < (antiLeft > 0 ? 3f : 4.5f)) {
|
||||
berry.GetComponent<Rigidbody2D>().linearVelocity = dir.normalized * (antiLeft > 0 ? 5f : -5f);
|
||||
ClampPosition(berry, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ClampPosition(GameObject obj, bool modifyY = true) {
|
||||
var cam = Camera.main;
|
||||
var pos = obj.transform.position;
|
||||
var bounds = obj.GetComponent<Renderer>().bounds.extents;
|
||||
|
||||
float zDist = Mathf.Abs(cam.transform.position.z - pos.z);
|
||||
|
||||
UnityEngine.Vector3 min = cam.ViewportToWorldPoint(new UnityEngine.Vector3(0, 0, zDist));
|
||||
UnityEngine.Vector3 max = cam.ViewportToWorldPoint(new UnityEngine.Vector3(1, 1, zDist));
|
||||
|
||||
pos.x = Mathf.Clamp(pos.x, min.x + bounds.x, max.x - bounds.x);
|
||||
if (modifyY) pos.y = Mathf.Clamp(pos.y, min.y + bounds.y, max.y - bounds.y);
|
||||
|
||||
obj.transform.position = pos;
|
||||
}
|
||||
|
||||
void FixedUpdate() {
|
||||
SpawnBerries();
|
||||
if (!pausePanel.activeSelf) {
|
||||
MoveBird();
|
||||
if (boostLeft > 0f) {
|
||||
boostLeft -= Time.deltaTime;
|
||||
boostText.text = "Boost expires in " + string.Format("{0:0.0}", boostLeft) + "s";
|
||||
} else if (slownessLeft > 0f) {
|
||||
slownessLeft -= Time.deltaTime;
|
||||
boostText.text = "Slowness expires in " + string.Format("{0:0.0}", slownessLeft) + "s";
|
||||
} else if (speedyLeft > 0f) {
|
||||
speedyLeft -= Time.deltaTime;
|
||||
boostText.text = "Speed expires in " + string.Format("{0:0.0}", speedyLeft) + "s";
|
||||
} else if (antiLeft > 0f) {
|
||||
antiLeft -= Time.deltaTime;
|
||||
boostText.text = "Berry repellent expires in " + string.Format("{0:0.0}", antiLeft) + "s";
|
||||
} else if (goldenLeft > 0f) {
|
||||
goldenLeft -= Time.deltaTime;
|
||||
boostText.text = "Berry magnet expires in " + string.Format("{0:0.0}", goldenLeft) + "s";
|
||||
} else {
|
||||
boostText.text = "";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void SpawnBerries() {
|
||||
if (Time.time < nextSpawnTime) {
|
||||
return;
|
||||
}
|
||||
if (speedyLeft > 0) {
|
||||
nextSpawnTime = Time.time + 1f / (spawnRate * 1.875f);
|
||||
} else {
|
||||
nextSpawnTime = Time.time + 1f / spawnRate;
|
||||
}
|
||||
float spawnProbability = UnityEngine.Random.value;
|
||||
if (!pausePanel.activeSelf) {
|
||||
GameObject newBerry = new("Berry");
|
||||
newBerry.transform.SetParent(berryParent.transform);
|
||||
SpriteRenderer spriteRenderer = newBerry.AddComponent<SpriteRenderer>();
|
||||
if (spawnProbability <= 0.425f) {
|
||||
spriteRenderer.sprite = Resources.Load<Sprite>("Berries/Berry");
|
||||
newBerry.tag = "NormalBerry";
|
||||
} else if (spawnProbability <= 0.60) {
|
||||
spriteRenderer.sprite = Resources.Load<Sprite>("Berries/PoisonBerry");
|
||||
newBerry.tag = "PoisonBerry";
|
||||
} else if (spawnProbability <= 0.65f) {
|
||||
spriteRenderer.sprite = Resources.Load<Sprite>("Berries/SlowBerry");
|
||||
newBerry.tag = "SlowBerry";
|
||||
} else if (spawnProbability <= 0.75f) {
|
||||
spriteRenderer.sprite = Resources.Load<Sprite>("Berries/UltraBerry");
|
||||
newBerry.tag = "UltraBerry";
|
||||
} else if (spawnProbability <= 0.85f) {
|
||||
spriteRenderer.sprite = Resources.Load<Sprite>("Berries/SpeedyBerry");
|
||||
newBerry.tag = "SpeedyBerry";
|
||||
} else if (spawnProbability <= 0.90f) {
|
||||
spriteRenderer.sprite = Resources.Load<Sprite>("Berries/BerryNoColor");
|
||||
newBerry.tag = "RandomBerry";
|
||||
RainbowSpriteRender randomBerryRainbowImage = newBerry.AddComponent<RainbowSpriteRender>();
|
||||
randomBerryRainbowImage.frequency = 5f;
|
||||
} else if (spawnProbability <= 0.95f) {
|
||||
spriteRenderer.sprite = Resources.Load<Sprite>("Berries/AntiBerry");
|
||||
newBerry.tag = "AntiBerry";
|
||||
} else {
|
||||
spriteRenderer.sprite = Resources.Load<Sprite>("Berries/GoldenBerry");
|
||||
newBerry.tag = "GoldenBerry";
|
||||
}
|
||||
spriteRenderer.sortingOrder = -5;
|
||||
|
||||
float screenWidth = Camera.main.orthographicSize * 2 * Camera.main.aspect;
|
||||
float spawnPositionX = UnityEngine.Random.Range(-screenWidth / 2.17f, screenWidth / 2.17f);
|
||||
newBerry.transform.position = new UnityEngine.Vector3(spawnPositionX, Camera.main.orthographicSize + 1f, 0f);
|
||||
|
||||
Rigidbody2D rb = newBerry.AddComponent<Rigidbody2D>();
|
||||
rb.gravityScale = 0f;
|
||||
rb.linearVelocity = new UnityEngine.Vector2(0f, -4f);
|
||||
}
|
||||
}
|
||||
|
||||
void Update() {
|
||||
foreach (AudioSource audio in FindObjectsByType<AudioSource>(FindObjectsSortMode.None)) {
|
||||
audio.pitch = speedyLeft > 0f ? 1.3f : 1f;
|
||||
}
|
||||
if (screenWidth != Camera.main.orthographicSize * 2f * Camera.main.aspect) {
|
||||
screenWidth = Camera.main.orthographicSize * 2f * Camera.main.aspect;
|
||||
ClampPosition(bird);
|
||||
GameObject[] allberries = GameObject.FindGameObjectsWithTag("NormalBerry")
|
||||
.Concat(GameObject.FindGameObjectsWithTag("PoisonBerry"))
|
||||
.Concat(GameObject.FindGameObjectsWithTag("SlowBerry"))
|
||||
.Concat(GameObject.FindGameObjectsWithTag("UltraBerry"))
|
||||
.Concat(GameObject.FindGameObjectsWithTag("SpeedyBerry"))
|
||||
.Concat(GameObject.FindGameObjectsWithTag("RandomBerry"))
|
||||
.Concat(GameObject.FindGameObjectsWithTag("AntiBerry"))
|
||||
.Concat(GameObject.FindGameObjectsWithTag("GoldenBerry"))
|
||||
.ToArray();
|
||||
foreach (GameObject berry in allberries) {
|
||||
ClampPosition(berry, false);
|
||||
}
|
||||
}
|
||||
GameObject[] normalBerries = GameObject.FindGameObjectsWithTag("NormalBerry");
|
||||
GameObject[] poisonBerries = GameObject.FindGameObjectsWithTag("PoisonBerry");
|
||||
GameObject[] slowBerries = GameObject.FindGameObjectsWithTag("SlowBerry");
|
||||
GameObject[] ultraBerries = GameObject.FindGameObjectsWithTag("UltraBerry");
|
||||
GameObject[] speedyBerries = GameObject.FindGameObjectsWithTag("SpeedyBerry");
|
||||
GameObject[] randomBerries = GameObject.FindGameObjectsWithTag("RandomBerry");
|
||||
GameObject[] antiBerries = GameObject.FindGameObjectsWithTag("AntiBerry");
|
||||
GameObject[] goldenBerries = GameObject.FindGameObjectsWithTag("GoldenBerry");
|
||||
|
||||
if (!pausePanel.activeSelf) {
|
||||
if (Time.time - lastMoveTime > 20) {
|
||||
lastMoveTime = float.MaxValue;
|
||||
EnablePause();
|
||||
}
|
||||
CheckIfGrounded();
|
||||
foreach (GameObject normalBerry in normalBerries) {
|
||||
if (normalBerry.transform.position.y < 0f - Camera.main.orthographicSize - 1f) {
|
||||
Destroy(normalBerry);
|
||||
} else if (UnityEngine.Vector3.Distance(bird.transform.position, normalBerry.transform.position) < 1.5f) {
|
||||
totalNormalBerries++;
|
||||
DoNormalBerry(normalBerry);
|
||||
}
|
||||
if (speedyLeft > 0) {
|
||||
normalBerry.GetComponent<Rigidbody2D>().linearVelocity = new UnityEngine.Vector2(0f, -7.5f);
|
||||
} else {
|
||||
normalBerry.GetComponent<Rigidbody2D>().linearVelocity = new UnityEngine.Vector2(0f, -4f);
|
||||
}
|
||||
}
|
||||
foreach (GameObject poisonBerry in poisonBerries) {
|
||||
if (poisonBerry.transform.position.y < 0f - Camera.main.orthographicSize - 1f) {
|
||||
Destroy(poisonBerry);
|
||||
} else if (UnityEngine.Vector3.Distance(bird.transform.position, poisonBerry.transform.position) < 1.5f) {
|
||||
totalPoisonBerries++;
|
||||
DoPoisonBerry();
|
||||
}
|
||||
if (speedyLeft > 0) {
|
||||
poisonBerry.GetComponent<Rigidbody2D>().linearVelocity = new UnityEngine.Vector2(0f, -7.5f);
|
||||
} else {
|
||||
poisonBerry.GetComponent<Rigidbody2D>().linearVelocity = new UnityEngine.Vector2(0f, -4f);
|
||||
}
|
||||
}
|
||||
foreach (GameObject slowBerry in slowBerries) {
|
||||
if (slowBerry.transform.position.y < 0f - Camera.main.orthographicSize - 1f) {
|
||||
Destroy(slowBerry);
|
||||
} else if (UnityEngine.Vector3.Distance(bird.transform.position, slowBerry.transform.position) < 1.5f) {
|
||||
totalSlowBerries++;
|
||||
DoSlowBerry(slowBerry);
|
||||
}
|
||||
if (speedyLeft > 0) {
|
||||
slowBerry.GetComponent<Rigidbody2D>().linearVelocity = new UnityEngine.Vector2(0f, -7.5f);
|
||||
} else {
|
||||
slowBerry.GetComponent<Rigidbody2D>().linearVelocity = new UnityEngine.Vector2(0f, -4f);
|
||||
}
|
||||
}
|
||||
foreach (GameObject ultraBerry in ultraBerries) {
|
||||
if (ultraBerry.transform.position.y < 0f - Camera.main.orthographicSize - 1f) {
|
||||
Destroy(ultraBerry);
|
||||
} else if (UnityEngine.Vector3.Distance(bird.transform.position, ultraBerry.transform.position) < 1.5f) {
|
||||
totalUltraBerries++;
|
||||
DoUltraBerry(ultraBerry);
|
||||
}
|
||||
if (speedyLeft > 0) {
|
||||
ultraBerry.GetComponent<Rigidbody2D>().linearVelocity = new UnityEngine.Vector2(0f, -7.5f);
|
||||
} else {
|
||||
ultraBerry.GetComponent<Rigidbody2D>().linearVelocity = new UnityEngine.Vector2(0f, -4f);
|
||||
}
|
||||
}
|
||||
foreach (GameObject speedyBerry in speedyBerries) {
|
||||
if (speedyBerry.transform.position.y < 0f - Camera.main.orthographicSize - 1f) {
|
||||
Destroy(speedyBerry);
|
||||
} else if (UnityEngine.Vector3.Distance(bird.transform.position, speedyBerry.transform.position) < 1.5f) {
|
||||
totalSpeedyBerries++;
|
||||
DoSpeedyBerry(speedyBerry);
|
||||
}
|
||||
if (speedyLeft > 0) {
|
||||
speedyBerry.GetComponent<Rigidbody2D>().linearVelocity = new UnityEngine.Vector2(0f, -7.5f);
|
||||
} else {
|
||||
speedyBerry.GetComponent<Rigidbody2D>().linearVelocity = new UnityEngine.Vector2(0f, -4f);
|
||||
}
|
||||
}
|
||||
foreach (GameObject randomBerry in randomBerries) {
|
||||
if (randomBerry.transform.position.y < 0f - Camera.main.orthographicSize - 1f) {
|
||||
Destroy(randomBerry);
|
||||
} else if (UnityEngine.Vector3.Distance(bird.transform.position, randomBerry.transform.position) < 1.5f) {
|
||||
totalRandomBerries++;
|
||||
Action[] funcs = {
|
||||
() => DoNormalBerry(randomBerry),
|
||||
() => DoSlowBerry(randomBerry),
|
||||
() => DoUltraBerry(randomBerry),
|
||||
() => DoSpeedyBerry(randomBerry),
|
||||
() => DoAntiBerry(randomBerry),
|
||||
() => DoGoldenBerry(randomBerry)
|
||||
};
|
||||
funcs[UnityEngine.Random.Range(0, funcs.Length)]();
|
||||
}
|
||||
if (speedyLeft > 0) {
|
||||
randomBerry.GetComponent<Rigidbody2D>().linearVelocity = new UnityEngine.Vector2(0f, -7.5f);
|
||||
} else {
|
||||
randomBerry.GetComponent<Rigidbody2D>().linearVelocity = new UnityEngine.Vector2(0f, -4f);
|
||||
}
|
||||
}
|
||||
foreach (GameObject antiBerry in antiBerries) {
|
||||
if (antiBerry.transform.position.y < 0f - Camera.main.orthographicSize - 1f) {
|
||||
Destroy(antiBerry);
|
||||
} else if (UnityEngine.Vector3.Distance(bird.transform.position, antiBerry.transform.position) < 1.5f) {
|
||||
totalAntiBerries++;
|
||||
DoAntiBerry(antiBerry);
|
||||
}
|
||||
if (speedyLeft > 0) {
|
||||
antiBerry.GetComponent<Rigidbody2D>().linearVelocity = new UnityEngine.Vector2(0f, -7.5f);
|
||||
} else {
|
||||
antiBerry.GetComponent<Rigidbody2D>().linearVelocity = new UnityEngine.Vector2(0f, -4f);
|
||||
}
|
||||
}
|
||||
foreach (GameObject goldenBerry in goldenBerries) {
|
||||
if (goldenBerry.transform.position.y < 0f - Camera.main.orthographicSize - 1f) {
|
||||
Destroy(goldenBerry);
|
||||
} else if (UnityEngine.Vector3.Distance(bird.transform.position, goldenBerry.transform.position) < 1.5f) {
|
||||
totalGoldenBerries++;
|
||||
DoGoldenBerry(goldenBerry);
|
||||
}
|
||||
if (speedyLeft > 0) {
|
||||
goldenBerry.GetComponent<Rigidbody2D>().linearVelocity = new UnityEngine.Vector2(0f, -7.5f);
|
||||
} else {
|
||||
goldenBerry.GetComponent<Rigidbody2D>().linearVelocity = new UnityEngine.Vector2(0f, -4f);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
rb.gravityScale = 0f;
|
||||
rb.linearVelocity = UnityEngine.Vector2.zero;
|
||||
GameObject[] allberries = normalBerries
|
||||
.Concat(poisonBerries)
|
||||
.Concat(slowBerries)
|
||||
.Concat(ultraBerries)
|
||||
.Concat(speedyBerries)
|
||||
.Concat(randomBerries)
|
||||
.Concat(antiBerries)
|
||||
.Concat(goldenBerries)
|
||||
.ToArray();
|
||||
foreach (GameObject berry in allberries) {
|
||||
berry.GetComponent<Rigidbody2D>().linearVelocity = UnityEngine.Vector2.zero;
|
||||
}
|
||||
}
|
||||
if ((Application.platform == RuntimePlatform.Android && Keyboard.current.escapeKey.wasPressedThisFrame) || !Application.isMobilePlatform && (Keyboard.current.escapeKey.wasPressedThisFrame || (Gamepad.current != null && (Gamepad.current.startButton.wasPressedThisFrame || Gamepad.current.buttonEast.wasPressedThisFrame)))) TogglePause();
|
||||
}
|
||||
|
||||
void Respawn() {
|
||||
bird.transform.position = new UnityEngine.Vector3(0f, -4.3f, 0f);
|
||||
bird.transform.localScale = new UnityEngine.Vector3(1.35f, 1.35f, 1.35f);
|
||||
rb.gravityScale = 0f;
|
||||
rb.linearVelocity = UnityEngine.Vector2.zero;
|
||||
score = 0;
|
||||
boostLeft = 0f;
|
||||
slownessLeft = 0f;
|
||||
speedyLeft = 0f;
|
||||
antiLeft = 0f;
|
||||
UpdateStats(0, 1);
|
||||
|
||||
GameObject[] allberries = GameObject.FindGameObjectsWithTag("NormalBerry")
|
||||
.Concat(GameObject.FindGameObjectsWithTag("PoisonBerry"))
|
||||
.Concat(GameObject.FindGameObjectsWithTag("SlowBerry"))
|
||||
.Concat(GameObject.FindGameObjectsWithTag("UltraBerry"))
|
||||
.Concat(GameObject.FindGameObjectsWithTag("SpeedyBerry"))
|
||||
.Concat(GameObject.FindGameObjectsWithTag("RandomBerry"))
|
||||
.Concat(GameObject.FindGameObjectsWithTag("AntiBerry"))
|
||||
.Concat(GameObject.FindGameObjectsWithTag("GoldenBerry"))
|
||||
.ToArray();
|
||||
foreach (GameObject berry in allberries) {
|
||||
Destroy(berry);
|
||||
}
|
||||
}
|
||||
|
||||
void UpdateStats(BigInteger scoreAddAmount, BigInteger attemptAddAmount) {
|
||||
var levelBefore = Tools.GetLevelInfo().level;
|
||||
var prefix = "";
|
||||
var suffix = "";
|
||||
score += scoreAddAmount;
|
||||
totalAttempts += attemptAddAmount;
|
||||
attempts += attemptAddAmount;
|
||||
if (score >= highscore) {
|
||||
highscore = score;
|
||||
prefix = "<color=#7FFFD4>";
|
||||
suffix = "</color>";
|
||||
}
|
||||
scoreText.text = $"Score: {Tools.FormatWithCommas(score)} \\u2022 Attempts: {Tools.FormatWithCommas(attempts)}";
|
||||
highScoreText.text = prefix + $"High Score: {Tools.FormatWithCommas(highscore) + suffix} \\u2022 Total Attempts: {Tools.FormatWithCommas(totalAttempts)}";
|
||||
if (DiscordRPCHandler.Instance != null)
|
||||
DiscordRPCHandler.Instance.UpdateRPC("Playing in auto mode", $"AI Score: {Tools.FormatWithCommas(score)} | AI High Score: {Tools.FormatWithCommas(highscore)}");
|
||||
var (_, level, currentXpInLevel, totalXpForLevel, percentDone) = Tools.GetLevelInfo(Tools.CalculateXP(totalNormalBerries, totalPoisonBerries, totalSlowBerries, totalUltraBerries, totalSpeedyBerries, 0, totalRandomBerries, totalAntiBerries, totalGoldenBerries));
|
||||
levelText.text = $"Level: {Tools.FormatWithCommas(level.ToString())}" + (Application.isMobilePlatform ? " \\u2022 " : "\n") + $"XP: {Tools.FormatWithCommas(currentXpInLevel.ToString())}/{Tools.FormatWithCommas(totalXpForLevel.ToString())} ({Math.Floor(percentDone)}%)";
|
||||
if (level != levelBefore) AudioSource.PlayClipAtPoint(Resources.Load<AudioClip>("Sounds/Levelup"), Camera.main.transform.position, 1f * BazookaManager.Instance.GetSettingSFXVolume());
|
||||
}
|
||||
|
||||
void CheckIfGrounded() {
|
||||
isGrounded = bird.transform.position.y <= -4.1299996f;
|
||||
|
||||
rb.gravityScale = isGrounded ? 0f : 1.5f;
|
||||
|
||||
if (bird.transform.position.y < -4.1359f) {
|
||||
bird.transform.position = new UnityEngine.Vector2(bird.transform.position.x, -4.1359f);
|
||||
rb.linearVelocity = new UnityEngine.Vector2(rb.linearVelocity.x, 0f);
|
||||
}
|
||||
}
|
||||
|
||||
internal void TogglePause() {
|
||||
if (pausePanel.activeSelf) DisablePause();
|
||||
else EnablePause();
|
||||
}
|
||||
|
||||
internal void EnablePause() {
|
||||
Cursor.visible = true;
|
||||
Cursor.lockState = CursorLockMode.None;
|
||||
backgroundMusic.GetComponent<GameMusicHandler>().PauseMusic();
|
||||
pausePanel.SetActive(true);
|
||||
}
|
||||
|
||||
internal void DisablePause() {
|
||||
if (AutoGamePlayerPauseMenu.Instance.statsMenu.activeSelf) {
|
||||
AutoGamePlayerPauseMenu.Instance.statsMenuExitButton.onClick.Invoke();
|
||||
return;
|
||||
}
|
||||
if (AutoGamePlayerPauseMenu.Instance.editingUI == true) {
|
||||
AutoGamePlayerPauseMenu.Instance.ToggleEditingUI();
|
||||
return;
|
||||
}
|
||||
lastMoveTime = Time.time;
|
||||
Cursor.visible = false;
|
||||
Cursor.lockState = CursorLockMode.Locked;
|
||||
backgroundMusic.GetComponent<GameMusicHandler>().ResumeMusic();
|
||||
pausePanel.SetActive(false);
|
||||
}
|
||||
|
||||
void OnApplicationPause(bool pause) {
|
||||
if (pause) EnablePause();
|
||||
}
|
||||
|
||||
void OnApplicationQuit() {
|
||||
Cursor.visible = true;
|
||||
Cursor.lockState = CursorLockMode.None;
|
||||
}
|
||||
|
||||
void DoNormalBerry(GameObject berry) {
|
||||
AudioSource.PlayClipAtPoint(Resources.Load<AudioClip>("Sounds/Eat"), Camera.main.transform.position, 1.2f * BazookaManager.Instance.GetSettingSFXVolume());
|
||||
Destroy(berry);
|
||||
UpdateStats(1, 0);
|
||||
}
|
||||
|
||||
void DoPoisonBerry() {
|
||||
AudioSource.PlayClipAtPoint(Resources.Load<AudioClip>("Sounds/Death"), Camera.main.transform.position, 1.2f * BazookaManager.Instance.GetSettingSFXVolume());
|
||||
Respawn();
|
||||
UpdateStats(0, 0);
|
||||
}
|
||||
|
||||
void DoSlowBerry(GameObject berry) {
|
||||
AudioSource.PlayClipAtPoint(Resources.Load<AudioClip>("Sounds/Downgrade"), Camera.main.transform.position, 0.35f * BazookaManager.Instance.GetSettingSFXVolume());
|
||||
Destroy(berry);
|
||||
boostLeft = 0f;
|
||||
slownessLeft = 10f;
|
||||
speedyLeft = 0f;
|
||||
antiLeft = 0f;
|
||||
goldenLeft = 0f;
|
||||
if (score > 0) {
|
||||
UpdateStats(-1, 0);
|
||||
}
|
||||
}
|
||||
|
||||
void DoUltraBerry(GameObject berry) {
|
||||
AudioSource.PlayClipAtPoint(Resources.Load<AudioClip>("Sounds/Powerup"), Camera.main.transform.position, 0.35f * BazookaManager.Instance.GetSettingSFXVolume());
|
||||
Destroy(berry);
|
||||
speedyLeft = 0f;
|
||||
antiLeft = 0f;
|
||||
goldenLeft = 0f;
|
||||
if (slownessLeft > 0f) {
|
||||
slownessLeft = 0f;
|
||||
UpdateStats(1, 0);
|
||||
} else {
|
||||
boostLeft += 10f;
|
||||
UpdateStats(5, 0);
|
||||
}
|
||||
}
|
||||
|
||||
void DoSpeedyBerry(GameObject berry) {
|
||||
AudioSource.PlayClipAtPoint(Resources.Load<AudioClip>("Sounds/SpeedyPowerup"), Camera.main.transform.position, 0.35f * BazookaManager.Instance.GetSettingSFXVolume());
|
||||
Destroy(berry);
|
||||
boostLeft = 0f;
|
||||
slownessLeft = 0f;
|
||||
speedyLeft = 10f;
|
||||
antiLeft = 0f;
|
||||
goldenLeft = 0f;
|
||||
UpdateStats(10, 0);
|
||||
}
|
||||
|
||||
void DoAntiBerry(GameObject berry) {
|
||||
AudioSource.PlayClipAtPoint(Resources.Load<AudioClip>("Sounds/Downgrade"), Camera.main.transform.position, 0.35f * BazookaManager.Instance.GetSettingSFXVolume());
|
||||
Destroy(berry);
|
||||
boostLeft = 0f;
|
||||
slownessLeft = 0f;
|
||||
speedyLeft = 0f;
|
||||
antiLeft = 10f;
|
||||
goldenLeft = 0f;
|
||||
UpdateStats(0, 0);
|
||||
}
|
||||
|
||||
void DoGoldenBerry(GameObject berry) {
|
||||
AudioSource.PlayClipAtPoint(Resources.Load<AudioClip>("Sounds/Powerup"), Camera.main.transform.position, 0.35f * BazookaManager.Instance.GetSettingSFXVolume());
|
||||
Destroy(berry);
|
||||
boostLeft = 0f;
|
||||
slownessLeft = 0f;
|
||||
speedyLeft = 0f;
|
||||
antiLeft = 0f;
|
||||
goldenLeft = 10f;
|
||||
UpdateStats(4, 0);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4ff2abfbae5214f4b812df1e737a8393
|
||||
@@ -0,0 +1,165 @@
|
||||
using System.Text;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class AutoGamePlayerPauseMenu : MonoBehaviour {
|
||||
public static AutoGamePlayerPauseMenu Instance;
|
||||
[SerializeField] private Button backButton;
|
||||
[SerializeField] private Button continueButton;
|
||||
[SerializeField] private Button statsButton;
|
||||
[SerializeField] private Button editUiButton;
|
||||
[SerializeField] private Button resetUiButton;
|
||||
[SerializeField] private AudioSource songLoop;
|
||||
[SerializeField] private TMP_Text scoreText;
|
||||
[SerializeField] private TMP_Text highScoreText;
|
||||
[SerializeField] private TMP_Text boostText;
|
||||
[SerializeField] private TMP_Text coinsText;
|
||||
[SerializeField] private TMP_Text levelText;
|
||||
[SerializeField] private Button pauseButton;
|
||||
[SerializeField] private Button restartButton;
|
||||
[SerializeField] private Button jumpButton;
|
||||
[SerializeField] private Button rightButton;
|
||||
[SerializeField] private Button leftButton;
|
||||
internal bool editingUI = false;
|
||||
|
||||
public GameObject statsMenu;
|
||||
public Button statsMenuExitButton;
|
||||
[SerializeField] private TMP_Text statsText;
|
||||
|
||||
[SerializeField] private Toggle settingFullscreenToggle;
|
||||
[SerializeField] private Toggle settingVSyncToggle;
|
||||
[SerializeField] private Toggle settingRandomMusicToggle;
|
||||
[SerializeField] private Slider musicSlider;
|
||||
[SerializeField] private Slider sfxSlider;
|
||||
[SerializeField] private TMP_Text musicSliderText;
|
||||
[SerializeField] private TMP_Text sfxSliderText;
|
||||
|
||||
void Awake() {
|
||||
Instance = this;
|
||||
continueButton.onClick.AddListener(AutoGamePlayer.Instance.DisablePause);
|
||||
musicSlider.onValueChanged.AddListener(value => {
|
||||
BazookaManager.Instance.SetSettingMusicVolume(value);
|
||||
songLoop.volume = value;
|
||||
});
|
||||
sfxSlider.onValueChanged.AddListener(value => {
|
||||
BazookaManager.Instance.SetSettingSFXVolume(value);
|
||||
});
|
||||
editUiButton.onClick.AddListener(() => {
|
||||
ToggleEditingUI();
|
||||
});
|
||||
resetUiButton.onClick.AddListener(() => {
|
||||
((RectTransform)scoreText.transform).anchoredPosition = new Vector2(0f, -70f);
|
||||
((RectTransform)highScoreText.transform).anchoredPosition = new Vector2(0f, -140f);
|
||||
((RectTransform)boostText.transform).anchoredPosition = new Vector2(0f, -190f);
|
||||
((RectTransform)coinsText.transform).anchoredPosition = new Vector2(260f, 47.5f);
|
||||
((RectTransform)levelText.transform).anchoredPosition = new Vector2(-260f, 85f);
|
||||
PlayerPrefs.DeleteKey("DraggedUIScoreText");
|
||||
PlayerPrefs.DeleteKey("DraggedUIHighScoreText");
|
||||
PlayerPrefs.DeleteKey("DraggedUIBoostText");
|
||||
PlayerPrefs.DeleteKey("DraggedUICoinsText");
|
||||
PlayerPrefs.DeleteKey("DraggedUILevelText");
|
||||
if (Application.isMobilePlatform) {
|
||||
((RectTransform)pauseButton.transform).anchoredPosition = new Vector2(128f, -128f);
|
||||
((RectTransform)restartButton.transform).anchoredPosition = new Vector2(-128f, -128f);
|
||||
((RectTransform)jumpButton.transform).anchoredPosition = new Vector2(-128f, 288f);
|
||||
((RectTransform)rightButton.transform).anchoredPosition = new Vector2(-128f, 128f);
|
||||
((RectTransform)leftButton.transform).anchoredPosition = new Vector2(128f, 128f);
|
||||
PlayerPrefs.DeleteKey("DraggedUIPauseButton");
|
||||
PlayerPrefs.DeleteKey("DraggedUIRestartButton");
|
||||
PlayerPrefs.DeleteKey("DraggedUIJumpButton");
|
||||
PlayerPrefs.DeleteKey("DraggedUIRightButton");
|
||||
PlayerPrefs.DeleteKey("DraggedUILeftButton");
|
||||
}
|
||||
});
|
||||
statsButton.onClick.AddListener(() => {
|
||||
statsMenu.SetActive(true);
|
||||
var text = new StringBuilder();
|
||||
text.AppendLine("High Score: " + Tools.FormatWithCommas(AutoGamePlayer.Instance.highscore));
|
||||
text.AppendLine("Total Normal Berries: " + Tools.FormatWithCommas(AutoGamePlayer.Instance.totalNormalBerries));
|
||||
text.AppendLine("Total Poison Berries: " + Tools.FormatWithCommas(AutoGamePlayer.Instance.totalPoisonBerries));
|
||||
text.AppendLine("Total Slow Berries: " + Tools.FormatWithCommas(AutoGamePlayer.Instance.totalSlowBerries));
|
||||
text.AppendLine("Total Ultra Berries: " + Tools.FormatWithCommas(AutoGamePlayer.Instance.totalUltraBerries));
|
||||
text.AppendLine("Total Speedy Berries: " + Tools.FormatWithCommas(AutoGamePlayer.Instance.totalSpeedyBerries));
|
||||
text.AppendLine("Total Random Berries: " + Tools.FormatWithCommas(AutoGamePlayer.Instance.totalRandomBerries));
|
||||
text.AppendLine("Total Anti Berries: " + Tools.FormatWithCommas(AutoGamePlayer.Instance.totalAntiBerries));
|
||||
text.AppendLine("Total Golden Berries: " + Tools.FormatWithCommas(AutoGamePlayer.Instance.totalGoldenBerries));
|
||||
text.AppendLine("Total Attempts: " + Tools.FormatWithCommas(AutoGamePlayer.Instance.totalAttempts));
|
||||
text.AppendLine("Note: This is the AI stats");
|
||||
statsText.text = text.ToString();
|
||||
});
|
||||
statsMenuExitButton.onClick.AddListener(() => {
|
||||
statsMenu.SetActive(false);
|
||||
statsText.text = string.Empty;
|
||||
});
|
||||
|
||||
musicSlider.value = BazookaManager.Instance.GetSettingMusicVolume();
|
||||
sfxSlider.value = BazookaManager.Instance.GetSettingSFXVolume();
|
||||
if (!Application.isMobilePlatform) {
|
||||
settingFullscreenToggle.isOn = BazookaManager.Instance.GetSettingFullScreen() == true;
|
||||
settingVSyncToggle.isOn = BazookaManager.Instance.GetSettingVsync() == true;
|
||||
settingRandomMusicToggle.isOn = BazookaManager.Instance.GetSettingRandomMusic() == true;
|
||||
settingFullscreenToggle.onValueChanged.AddListener(value => {
|
||||
BazookaManager.Instance.SetSettingFullScreen(value);
|
||||
var width = Display.main.systemWidth;
|
||||
var height = Display.main.systemHeight;
|
||||
Screen.SetResolution(width, height, value);
|
||||
});
|
||||
settingVSyncToggle.onValueChanged.AddListener(value => {
|
||||
BazookaManager.Instance.SetSettingVsync(value);
|
||||
QualitySettings.vSyncCount = value ? 1 : -1;
|
||||
});
|
||||
} else {
|
||||
settingFullscreenToggle.interactable = false;
|
||||
settingVSyncToggle.interactable = false;
|
||||
settingRandomMusicToggle.isOn = BazookaManager.Instance.GetSettingRandomMusic() == true;
|
||||
}
|
||||
settingRandomMusicToggle.onValueChanged.AddListener(value => BazookaManager.Instance.SetSettingRandomMusic(value));
|
||||
musicSlider.onValueChanged.AddListener(value => {
|
||||
BazookaManager.Instance.SetSettingMusicVolume(value);
|
||||
AutoGamePlayer.Instance.backgroundMusic.volume = value;
|
||||
});
|
||||
sfxSlider.onValueChanged.AddListener(value => BazookaManager.Instance.SetSettingSFXVolume(value));
|
||||
}
|
||||
|
||||
public void ToggleEditingUI() {
|
||||
editingUI = !editingUI;
|
||||
musicSlider.gameObject.SetActive(!musicSlider.gameObject.activeSelf);
|
||||
sfxSlider.gameObject.SetActive(!sfxSlider.gameObject.activeSelf);
|
||||
musicSliderText.gameObject.SetActive(!musicSliderText.gameObject.activeSelf);
|
||||
sfxSliderText.gameObject.SetActive(!sfxSliderText.gameObject.activeSelf);
|
||||
settingFullscreenToggle.gameObject.SetActive(!settingFullscreenToggle.gameObject.activeSelf);
|
||||
settingVSyncToggle.gameObject.SetActive(!settingVSyncToggle.gameObject.activeSelf);
|
||||
settingRandomMusicToggle.gameObject.SetActive(!settingRandomMusicToggle.gameObject.activeSelf);
|
||||
backButton.gameObject.SetActive(!backButton.gameObject.activeSelf);
|
||||
continueButton.gameObject.SetActive(!continueButton.gameObject.activeSelf);
|
||||
statsButton.gameObject.SetActive(!statsButton.gameObject.activeSelf);
|
||||
editUiButton.transform.GetChild(0).GetComponent<TMP_Text>().text = editUiButton.transform.GetChild(0).GetComponent<TMP_Text>().text == "Edit UI" ? "Done" : "Edit UI";
|
||||
resetUiButton.gameObject.SetActive(!resetUiButton.gameObject.activeSelf);
|
||||
scoreText.GetComponent<DraggableUI>().canDrag = !scoreText.GetComponent<DraggableUI>().canDrag;
|
||||
highScoreText.GetComponent<DraggableUI>().canDrag = !highScoreText.GetComponent<DraggableUI>().canDrag;
|
||||
boostText.GetComponent<DraggableUI>().canDrag = !boostText.GetComponent<DraggableUI>().canDrag;
|
||||
coinsText.GetComponent<DraggableUI>().canDrag = !coinsText.GetComponent<DraggableUI>().canDrag;
|
||||
levelText.GetComponent<DraggableUI>().canDrag = !levelText.GetComponent<DraggableUI>().canDrag;
|
||||
if (Application.isMobilePlatform) {
|
||||
var pauseDraggableUI = pauseButton.GetComponent<DraggableUI>();
|
||||
var restartDraggableUI = restartButton.GetComponent<DraggableUI>();
|
||||
var jumpDraggableUI = jumpButton.GetComponent<DraggableUI>();
|
||||
var rightDraggableUI = rightButton.GetComponent<DraggableUI>();
|
||||
var leftDraggableUI = leftButton.GetComponent<DraggableUI>();
|
||||
pauseButton.transform.parent.SetSiblingIndex(pauseDraggableUI.canDrag ? 0 : 2);
|
||||
pauseDraggableUI.canDrag = !pauseDraggableUI.canDrag;
|
||||
restartDraggableUI.canDrag = !restartDraggableUI.canDrag;
|
||||
jumpDraggableUI.canDrag = !jumpDraggableUI.canDrag;
|
||||
rightDraggableUI.canDrag = !rightDraggableUI.canDrag;
|
||||
leftDraggableUI.canDrag = !leftDraggableUI.canDrag;
|
||||
pauseButton.interactable = !pauseDraggableUI.canDrag;
|
||||
restartButton.interactable = !restartDraggableUI.canDrag;
|
||||
jumpButton.interactable = !jumpDraggableUI.canDrag;
|
||||
rightButton.interactable = !rightDraggableUI.canDrag;
|
||||
leftButton.interactable = !leftDraggableUI.canDrag;
|
||||
jumpButton.transform.GetChild(0).GetComponent<TMP_Text>().color = !jumpDraggableUI.canDrag ? AutoGamePlayer.Instance.isGrounded ? Color.white : Color.red : Color.white;
|
||||
restartButton.interactable = AutoGamePlayer.Instance.score != 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9ac9e14a63a25400aa356479e5c7d5cb
|
||||
@@ -9,6 +9,7 @@ public class PlayMenu : MonoBehaviour {
|
||||
[SerializeField] private GameObject selectionMenu;
|
||||
[SerializeField] private GameObject customMenu;
|
||||
[SerializeField] private Button customButton;
|
||||
[SerializeField] private Button autoButton;
|
||||
[SerializeField] private Button customBackButton;
|
||||
[SerializeField] private Button customPlayButton;
|
||||
[SerializeField] private Button customNormalizeButton;
|
||||
@@ -202,6 +203,10 @@ public class PlayMenu : MonoBehaviour {
|
||||
customButton.interactable = false;
|
||||
customButton.transform.GetChild(0).GetComponent<TMP_Text>().text += "\n<size=12>You need level 5 or higher to access this</size>";
|
||||
}
|
||||
if (Tools.GetLevelInfo().level < 10) {
|
||||
autoButton.interactable = false;
|
||||
autoButton.transform.GetChild(0).GetComponent<TMP_Text>().text += "\n<size=12>You need level 10 or higher to access this</size>";
|
||||
}
|
||||
}
|
||||
|
||||
void ValidateTotal() {
|
||||
|
||||
Reference in new issue
Block a user