Add 1.3-beta1

This commit is contained in:
Lncvrt committed 2025-08-28 15:17:56 -07:00
1 parent 211b3eabcc
commit 0333ca7355
10 files changed
+1401

No files matched your search

+509
View File
@@ -0,0 +1,509 @@
using System;
using System.Collections.Generic;
using System.Net.Http;
using System.Text.RegularExpressions;
using TMPro;
using UnityEngine;
using UnityEngine.SceneManagement;
using UnityEngine.UI;
public class Account : MonoBehaviour
{
public GameObject registerPanel;
public Button registerPanelLoginBtn;
public GameObject loginPanel;
public Button loginPanelRegisterBtn;
public GameObject accountPanel;
public Button backButton;
public Button accountPanelSyncButton;
public Button accountPanelLogoutButton;
public TMP_InputField registerPanelUsernameForm;
public TMP_InputField registerPanelEmailForm;
public TMP_InputField registerPanelEmailConfirmForm;
public TMP_InputField registerPanelPasswordForm;
public TMP_InputField registerPanelPasswordConfirmForm;
public TMP_InputField loginPanelUsernameForm;
public TMP_InputField loginPanelPasswordForm;
public TMP_Text registerPanelStatusText;
public TMP_Text loginPanelStatusText;
public TMP_Text accountPanelStatusText;
private static readonly HttpClient client = new HttpClient();
public string clientVersion;
public GameObject changeUsernamePanel;
public TMP_Text changeUsernamePanelStatusText;
public Button submitButton;
public Button changeUsernameButton;
public Button changePasswordButton;
public GameObject changePasswordPanel;
public TMP_Text changePasswordStatusText;
public TMP_Text changeUsernameStatusText;
public TMP_InputField changeUsernameNewForm;
public TMP_InputField changeUsernamePasswordForm;
public TMP_InputField changePasswordCurrentForm;
public TMP_InputField changePasswordNewForm;
private void Awake()
{
if (!client.DefaultRequestHeaders.Contains("Requester"))
{
client.DefaultRequestHeaders.Add("Requester", "BerryDashClientLegacy");
}
if (!client.DefaultRequestHeaders.Contains("ClientVersion"))
{
client.DefaultRequestHeaders.Add("ClientVersion", "1.3-beta1");
}
if (!client.DefaultRequestHeaders.Contains("ClientPlatform"))
{
client.DefaultRequestHeaders.Add("ClientPlatform", Application.platform.ToString());
}
if (PlayerPrefs.HasKey("gameSession") && PlayerPrefs.HasKey("userID"))
{
SwitchScene(0);
}
else
{
SwitchScene(1);
}
backButton.onClick.AddListener(BackToMenu);
registerPanelLoginBtn.onClick.AddListener(delegate
{
SwitchScene(2);
});
submitButton.onClick.AddListener(ButtonSubmit);
loginPanelRegisterBtn.onClick.AddListener(delegate
{
SwitchScene(1);
});
accountPanelSyncButton.onClick.AddListener(SyncStats);
accountPanelLogoutButton.onClick.AddListener(LogoutAccount);
changeUsernameButton.onClick.AddListener(delegate
{
SwitchScene(3);
});
changePasswordButton.onClick.AddListener(delegate
{
SwitchScene(4);
});
}
private void BackToMenu()
{
if (GetCurrentScene() == 3 || GetCurrentScene() == 4)
{
SwitchScene(0);
}
else
{
SceneManager.LoadScene("Menu");
}
}
private int GetCurrentScene()
{
if (accountPanel.activeSelf)
{
return 0;
}
if (registerPanel.activeSelf)
{
return 1;
}
if (loginPanel.activeSelf)
{
return 2;
}
if (changeUsernamePanel.activeSelf)
{
return 3;
}
if (changePasswordPanel.activeSelf)
{
return 3;
}
return -1;
}
private void ButtonSubmit()
{
if (GetCurrentScene() == 1)
{
SubmitRegister();
}
else if (GetCurrentScene() == 2)
{
SubmitLogin();
}
else if (GetCurrentScene() == 3)
{
ChangeUsername();
}
else if (GetCurrentScene() == 4)
{
ChangePassword();
}
}
private void SwitchScene(int scene)
{
ClearForms();
registerPanelStatusText.text = "";
loginPanelStatusText.text = "";
accountPanelStatusText.text = "";
changeUsernamePanelStatusText.text = "";
registerPanelStatusText.color = Color.white;
loginPanelStatusText.color = Color.white;
accountPanelStatusText.color = Color.white;
changeUsernamePanelStatusText.color = Color.white;
backButton.transform.localPosition = new Vector3(0f, -165f, 0f);
submitButton.transform.localPosition = new Vector3(110f, -165f, 0f);
submitButton.gameObject.SetActive(value: true);
accountPanel.SetActive(value: false);
registerPanel.SetActive(value: false);
loginPanel.SetActive(value: false);
changeUsernamePanel.SetActive(value: false);
changePasswordPanel.SetActive(value: false);
switch (scene)
{
case 0:
accountPanel.SetActive(value: true);
submitButton.gameObject.SetActive(value: false);
backButton.transform.localPosition = new Vector3(-55f, -165f, 0f);
break;
case 1:
registerPanel.SetActive(value: true);
break;
case 2:
loginPanel.SetActive(value: true);
break;
case 3:
changeUsernamePanel.SetActive(value: true);
backButton.transform.localPosition = new Vector3(-55f, -165f, 0f);
submitButton.transform.localPosition = new Vector3(55f, -165f, 0f);
break;
case 4:
changePasswordPanel.SetActive(value: true);
backButton.transform.localPosition = new Vector3(-55f, -165f, 0f);
submitButton.transform.localPosition = new Vector3(55f, -165f, 0f);
break;
}
}
private async void SubmitRegister()
{
if (!registerPanelEmailForm.text.Trim().Equals(registerPanelEmailConfirmForm.text.Trim(), StringComparison.OrdinalIgnoreCase))
{
UpdateStatusText(registerPanelStatusText, "Email doesn't match", Color.red);
return;
}
if (!registerPanelPasswordForm.text.Trim().Equals(registerPanelPasswordConfirmForm.text.Trim(), StringComparison.OrdinalIgnoreCase))
{
UpdateStatusText(registerPanelStatusText, "Password doesn't match", Color.red);
return;
}
if (!Regex.IsMatch(registerPanelUsernameForm.text, "^[a-zA-Z0-9]{3,16}$"))
{
UpdateStatusText(registerPanelStatusText, "Username must be 3-16 characters, letters and numbers only", Color.red);
return;
}
try
{
HttpResponseMessage obj = await client.PostAsync("https://berrydash.lncvrt.xyz/api/registerAccount.php", new FormUrlEncodedContent(new KeyValuePair<string, string>[3]
{
new KeyValuePair<string, string>("username", registerPanelUsernameForm.text),
new KeyValuePair<string, string>("email", registerPanelEmailForm.text),
new KeyValuePair<string, string>("password", registerPanelPasswordForm.text)
}));
obj.EnsureSuccessStatusCode();
string text = await obj.Content.ReadAsStringAsync();
Debug.Log(text);
switch (text)
{
case "1":
SwitchScene(2);
break;
case "-1":
UpdateStatusText(registerPanelStatusText, "Internal login server error", Color.red);
break;
case "-2":
UpdateStatusText(registerPanelStatusText, "Incomplete form data", Color.red);
break;
case "-3":
UpdateStatusText(registerPanelStatusText, "Username not valid", Color.red);
break;
case "-4":
UpdateStatusText(registerPanelStatusText, "Email not valid", Color.red);
break;
case "-5":
UpdateStatusText(registerPanelStatusText, "Password must have 8 characters, one number and one letter", Color.red);
break;
case "-6":
UpdateStatusText(registerPanelStatusText, "Username too long or short", Color.red);
break;
case "-7":
UpdateStatusText(registerPanelStatusText, "Username must be 3-16 characters, letters and numbers only", Color.red);
break;
case "-8":
UpdateStatusText(registerPanelStatusText, "Username or email already exists", Color.red);
break;
default:
UpdateStatusText(registerPanelStatusText, "Unknown server response \"" + text + "\"", Color.red);
break;
}
}
catch (HttpRequestException arg)
{
Debug.LogError($"HTTP Error: {arg}");
UpdateStatusText(registerPanelStatusText, "Failed to make HTTP request", Color.red);
}
}
private async void SubmitLogin()
{
_ = 1;
try
{
HttpResponseMessage obj = await client.PostAsync("https://berrydash.lncvrt.xyz/api/loginAccount.php", new FormUrlEncodedContent(new KeyValuePair<string, string>[2]
{
new KeyValuePair<string, string>("username", loginPanelUsernameForm.text),
new KeyValuePair<string, string>("password", loginPanelPasswordForm.text)
}));
obj.EnsureSuccessStatusCode();
string text = await obj.Content.ReadAsStringAsync();
Debug.Log(text);
if (!(text == "-1"))
{
if (text == "-2")
{
UpdateStatusText(loginPanelStatusText, "Incorrect username or password", Color.red);
}
else if (Regex.IsMatch(text, "^[a-zA-Z0-9]+:\\d+:\\d+$"))
{
string[] array = text.Split(':');
string value = array[0];
int value2 = int.Parse(array[1]);
int value3 = int.Parse(array[2]);
PlayerPrefs.SetString("gameSession", value);
PlayerPrefs.SetInt("userID", value2);
PlayerPrefs.SetInt("HighScore", value3);
SwitchScene(0);
}
else
{
UpdateStatusText(loginPanelStatusText, "Unknown server response", Color.red);
}
}
else
{
UpdateStatusText(loginPanelStatusText, "Internal login server error", Color.red);
}
}
catch (HttpRequestException arg)
{
Debug.LogError($"HTTP Error: {arg}");
UpdateStatusText(loginPanelStatusText, "Failed to make HTTP request", Color.red);
}
}
private async void ChangeUsername()
{
_ = 1;
try
{
HttpResponseMessage obj = await client.PostAsync("https://berrydash.lncvrt.xyz/api/changeAccountUsername.php", new FormUrlEncodedContent(new KeyValuePair<string, string>[3]
{
new KeyValuePair<string, string>("userID", PlayerPrefs.GetInt("userID", 0).ToString()),
new KeyValuePair<string, string>("currentPassword", changeUsernamePasswordForm.text),
new KeyValuePair<string, string>("newUsername", changeUsernameNewForm.text)
}));
obj.EnsureSuccessStatusCode();
string text = await obj.Content.ReadAsStringAsync();
Debug.Log(text);
switch (text)
{
case "1":
SwitchScene(0);
UpdateStatusText(accountPanelStatusText, "Username changed successfully", Color.green);
break;
case "-1":
UpdateStatusText(changeUsernameStatusText, "Internal login server error", Color.red);
break;
case "-2":
UpdateStatusText(changeUsernameStatusText, "New Username, Password, or old username is empty", Color.red);
break;
case "-3":
UpdateStatusText(changeUsernameStatusText, "New Username contains invalid characters", Color.red);
break;
case "-4":
UpdateStatusText(changeUsernameStatusText, "New Username is too short or too long", Color.red);
break;
case "-5":
UpdateStatusText(changeUsernameStatusText, "New Username does not match the required format", Color.red);
break;
case "-6":
UpdateStatusText(changeUsernameStatusText, "Incorrect current password", Color.red);
break;
case "-7":
UpdateStatusText(changeUsernameStatusText, "Current username does not exist", Color.red);
break;
default:
UpdateStatusText(changeUsernameStatusText, "Unknown server response", Color.red);
break;
}
}
catch (HttpRequestException arg)
{
Debug.LogError($"HTTP Error: {arg}");
UpdateStatusText(changeUsernameStatusText, "Failed to make HTTP request", Color.red);
}
}
private async void ChangePassword()
{
_ = 1;
try
{
HttpResponseMessage obj = await client.PostAsync("https://berrydash.lncvrt.xyz/api/changeAccountPassword.php", new FormUrlEncodedContent(new KeyValuePair<string, string>[3]
{
new KeyValuePair<string, string>("userID", PlayerPrefs.GetInt("userID", 0).ToString()),
new KeyValuePair<string, string>("currentPassword", changePasswordCurrentForm.text),
new KeyValuePair<string, string>("newPassword", changePasswordNewForm.text)
}));
obj.EnsureSuccessStatusCode();
string text = await obj.Content.ReadAsStringAsync();
Debug.Log(text);
switch (text)
{
case "1":
SwitchScene(0);
UpdateStatusText(accountPanelStatusText, "Password changed successfully", Color.green);
break;
case "-1":
UpdateStatusText(changePasswordStatusText, "Internal login server error", Color.red);
break;
case "-2":
UpdateStatusText(changePasswordStatusText, "New Password, Password, or username is empty", Color.red);
break;
case "-3":
UpdateStatusText(changePasswordStatusText, "New Password is too short or too long", Color.red);
break;
case "-4":
UpdateStatusText(changePasswordStatusText, "Username must be 3-16 characters, letters and numbers only", Color.red);
break;
case "-5":
UpdateStatusText(changePasswordStatusText, "Incorrect current password", Color.red);
break;
case "-6":
UpdateStatusText(changePasswordStatusText, "Username does not exist", Color.red);
break;
default:
UpdateStatusText(changePasswordStatusText, "Unknown server response", Color.red);
break;
}
}
catch (HttpRequestException arg)
{
Debug.LogError($"HTTP Error: {arg}");
UpdateStatusText(changePasswordStatusText, "Failed to make HTTP request", Color.red);
}
}
private void ClearForms()
{
registerPanelUsernameForm.text = "";
registerPanelEmailForm.text = "";
registerPanelEmailConfirmForm.text = "";
registerPanelPasswordForm.text = "";
registerPanelPasswordConfirmForm.text = "";
loginPanelUsernameForm.text = "";
loginPanelPasswordForm.text = "";
changeUsernameNewForm.text = "";
changeUsernamePasswordForm.text = "";
changePasswordCurrentForm.text = "";
changePasswordNewForm.text = "";
}
private async void SyncStats()
{
_ = 1;
try
{
HttpResponseMessage obj = await client.PostAsync("https://berrydash.lncvrt.xyz/api/syncAccount.php", new FormUrlEncodedContent(new KeyValuePair<string, string>[3]
{
new KeyValuePair<string, string>("userID", PlayerPrefs.GetInt("userID", 0).ToString()),
new KeyValuePair<string, string>("gameSession", PlayerPrefs.GetString("gameSession", "")),
new KeyValuePair<string, string>("highScore", PlayerPrefs.GetInt("HighScore", 0).ToString())
}));
obj.EnsureSuccessStatusCode();
string text = await obj.Content.ReadAsStringAsync();
Debug.Log(text);
switch (text)
{
case "1":
UpdateStatusText(accountPanelStatusText, "Updated leaderboard stats", Color.green);
break;
case "-1":
UpdateStatusText(accountPanelStatusText, "Internal login server error", Color.red);
break;
case "-2":
UpdateStatusText(accountPanelStatusText, "Stats already synced", Color.red);
break;
case "-3":
UpdateStatusText(accountPanelStatusText, "Invalid game session (re-login)", Color.red);
break;
default:
UpdateStatusText(accountPanelStatusText, "Unknown server response \"" + text + "\"", Color.red);
break;
}
}
catch (HttpRequestException arg)
{
Debug.LogError($"HTTP Error: {arg}");
UpdateStatusText(accountPanelStatusText, "Failed to make HTTP request", Color.red);
}
}
private void LogoutAccount()
{
PlayerPrefs.DeleteKey("userID");
PlayerPrefs.DeleteKey("gameSession");
PlayerPrefs.DeleteKey("HighScore");
SwitchScene(1);
}
private void UpdateStatusText(TMP_Text text, string message, Color color)
{
text.text = message;
text.color = color;
}
}
+582
View File
@@ -0,0 +1,582 @@
using TMPro;
using UnityEngine;
public class Game : MonoBehaviour
{
public float spawnRate = 1f;
private float nextSpawnTime;
private int score;
private int highscore;
private float boostLeft;
private float slownessLeft;
private float screenWidth;
private bool isGrounded;
private float groundYPosition = -4.3f;
public TMP_Text scoreText;
public TMP_Text highScoreText;
public TMP_Text boostText;
public GameObject bird;
public GameObject pausePanel;
public Rigidbody2D rb;
public AudioSource backgroundMusic;
public TMP_Text fpsCounter;
private float nextUpdate;
private float fps;
private void Awake()
{
highscore = PlayerPrefs.GetInt("HighScore", 0);
}
private void Start()
{
SpriteRenderer component = bird.GetComponent<SpriteRenderer>();
switch (PlayerPrefs.GetInt("iconSelected", 1))
{
case 1:
if (PlayerPrefs.GetInt("userID", 0) == 1)
{
component.sprite = Resources.Load<Sprite>("icons/icons/bird_-1");
}
else if (PlayerPrefs.GetInt("userID", 0) == 2)
{
component.sprite = Resources.Load<Sprite>("icons/icons/bird_-2");
}
else if (PlayerPrefs.GetInt("userID", 0) == 4)
{
component.sprite = Resources.Load<Sprite>("icons/icons/bird_-3");
}
else
{
component.sprite = Resources.Load<Sprite>("icons/icons/bird_1");
}
break;
case 2:
component.sprite = Resources.Load<Sprite>("icons/icons/bird_2");
break;
case 3:
component.sprite = Resources.Load<Sprite>("icons/icons/bird_3");
break;
case 4:
component.sprite = Resources.Load<Sprite>("icons/icons/bird_4");
break;
default:
component.sprite = Resources.Load<Sprite>("icons/icons/bird_1");
PlayerPrefs.SetInt("iconSelected", 1);
PlayerPrefs.Save();
break;
}
backgroundMusic.volume = PlayerPrefs.GetFloat("musicVolume", 1f);
screenWidth = Camera.main.orthographicSize * 2f * Camera.main.aspect;
GameObject.Find("HighScoreText").GetComponent<TMP_Text>().text = $"High Score: {highscore}";
if (PlayerPrefs.GetInt("Setting2", 0) == 1)
{
GameObject gameObject = new GameObject("LeftArrow");
GameObject gameObject2 = new GameObject("RightArrow");
GameObject gameObject3 = new GameObject("JumpArrow");
GameObject gameObject4 = new GameObject("RestartButton");
GameObject gameObject5 = new GameObject("BackButton");
gameObject.AddComponent<SpriteRenderer>();
gameObject2.AddComponent<SpriteRenderer>();
gameObject3.AddComponent<SpriteRenderer>();
gameObject4.AddComponent<SpriteRenderer>();
gameObject5.AddComponent<SpriteRenderer>();
gameObject.GetComponent<SpriteRenderer>().sprite = Resources.Load<Sprite>("textures/Arrow");
gameObject2.GetComponent<SpriteRenderer>().sprite = Resources.Load<Sprite>("textures/Arrow");
gameObject3.GetComponent<SpriteRenderer>().sprite = Resources.Load<Sprite>("textures/Arrow");
gameObject4.GetComponent<SpriteRenderer>().sprite = Resources.Load<Sprite>("textures/Restart");
gameObject5.GetComponent<SpriteRenderer>().sprite = Resources.Load<Sprite>("textures/Arrow");
gameObject.transform.rotation = Quaternion.Euler(0f, 0f, 90f);
gameObject2.transform.rotation = Quaternion.Euler(0f, 0f, -90f);
gameObject5.transform.rotation = Quaternion.Euler(0f, 0f, 90f);
gameObject.transform.position = new Vector3((0f - screenWidth) / 2.5f, -4f, 0f);
gameObject2.transform.position = new Vector3(screenWidth / 2.5f, -4f, 0f);
gameObject4.transform.position = new Vector3(screenWidth / 2.3f, Camera.main.orthographicSize - 1.2f, 0f);
gameObject5.transform.position = new Vector3((0f - screenWidth) / 2.3f, Camera.main.orthographicSize - 1.2f, 0f);
if (PlayerPrefs.GetInt("Setting3", 0) == 1)
{
gameObject.transform.localScale = new Vector3(screenWidth / 14f, screenWidth / 14f, 1f);
gameObject2.transform.localScale = new Vector3(screenWidth / 14f, screenWidth / 14f, 1f);
gameObject3.transform.localScale = new Vector3(screenWidth / 14f, screenWidth / 14f, 1f);
gameObject4.transform.localScale = new Vector3(screenWidth / 14f, screenWidth / 14f, 1f);
gameObject5.transform.localScale = new Vector3(screenWidth / 14f, screenWidth / 14f, 1f);
gameObject3.transform.position = new Vector3(screenWidth / 2.5f, -1f, 0f);
}
else
{
gameObject.transform.localScale = new Vector3(screenWidth / 20f, screenWidth / 20f, 1f);
gameObject2.transform.localScale = new Vector3(screenWidth / 20f, screenWidth / 20f, 1f);
gameObject3.transform.localScale = new Vector3(screenWidth / 20f, screenWidth / 20f, 1f);
gameObject4.transform.localScale = new Vector3(screenWidth / 20f, screenWidth / 20f, 1f);
gameObject5.transform.localScale = new Vector3(screenWidth / 20f, screenWidth / 20f, 1f);
gameObject3.transform.position = new Vector3(screenWidth / 2.5f, -2f, 0f);
}
}
}
private void MoveBird()
{
float num = Camera.main.orthographicSize * 2f * Camera.main.aspect;
float num2 = 0.18f * (num / 20.19257f);
bool flag = false;
bool flag2 = false;
bool flag3 = false;
bool flag4 = false;
bool flag5 = false;
float num3 = num2;
if (boostLeft > 0f)
{
num3 = num2 * 1.39f;
}
else if (slownessLeft > 0f)
{
num3 = num2 * 0.56f;
}
CheckIfGrounded();
float axisRaw = Input.GetAxisRaw("Horizontal");
if (axisRaw < 0f || Input.GetKey(KeyCode.LeftArrow) || Input.GetKey(KeyCode.A))
{
flag2 = true;
}
if (axisRaw > 0f || Input.GetKey(KeyCode.RightArrow) || Input.GetKey(KeyCode.D))
{
flag = true;
}
if (Input.GetKey(KeyCode.Space) || Input.GetKey(KeyCode.UpArrow) || Input.GetKey(KeyCode.W) || (Input.GetMouseButton(0) && PlayerPrefs.GetInt("Setting2", 0) == 0) || Input.GetKey(KeyCode.JoystickButton0))
{
flag3 = true;
}
if (Input.GetKey(KeyCode.R))
{
flag5 = true;
}
if (PlayerPrefs.GetInt("Setting2", 0) == 1)
{
GameObject gameObject = GameObject.Find("LeftArrow");
GameObject gameObject2 = GameObject.Find("RightArrow");
GameObject gameObject3 = GameObject.Find("JumpArrow");
GameObject gameObject4 = GameObject.Find("RestartButton");
GameObject gameObject5 = GameObject.Find("BackButton");
if (Input.GetMouseButton(0))
{
Vector3 point = Camera.main.ScreenToWorldPoint(Input.mousePosition);
point.z = 0f;
if (gameObject.GetComponent<SpriteRenderer>().bounds.Contains(point))
{
flag2 = true;
}
if (gameObject2.GetComponent<SpriteRenderer>().bounds.Contains(point))
{
flag = true;
}
if (gameObject3.GetComponent<SpriteRenderer>().bounds.Contains(point))
{
flag3 = true;
}
}
if (Input.GetMouseButtonDown(0))
{
Vector3 point2 = Camera.main.ScreenToWorldPoint(Input.mousePosition);
point2.z = 0f;
if (gameObject4.GetComponent<SpriteRenderer>().bounds.Contains(point2))
{
flag5 = true;
}
if (gameObject5.GetComponent<SpriteRenderer>().bounds.Contains(point2))
{
flag4 = true;
}
}
}
if (flag2 && !flag)
{
bird.transform.position += new Vector3(0f - num3, 0f, 0f);
ClampPosition(num, bird);
bird.transform.localScale = new Vector3(1.35f, 1.35f, 1.35f);
}
if (flag && !flag2)
{
bird.transform.position += new Vector3(num3, 0f, 0f);
ClampPosition(num, bird);
bird.transform.localScale = new Vector3(-1.35f, 1.35f, 1.35f);
}
if (flag3 && isGrounded)
{
AudioSource.PlayClipAtPoint(Resources.Load<AudioClip>("sounds/Jump"), Camera.main.transform.position, 0.75f * PlayerPrefs.GetFloat("sfxVolume", 1f));
if (boostLeft > 0f)
{
rb.velocity = Vector2.up * 12f;
}
else if (slownessLeft > 0f)
{
rb.velocity = Vector2.up * 6f;
}
else
{
rb.velocity = Vector2.up * 9f;
}
}
if (flag4)
{
TogglePause();
}
if (flag5)
{
Respawn();
}
}
private void ClampPosition(float screenWidth, GameObject bird)
{
float num = screenWidth / 2.17f;
float x = Mathf.Clamp(bird.transform.position.x, 0f - num, num);
bird.transform.position = new Vector3(x, bird.transform.position.y, bird.transform.position.z);
}
private void FixedUpdate()
{
SpawnBerries();
if (!pausePanel.activeSelf)
{
MoveBird();
if (boostLeft > 0f)
{
boostLeft -= Time.deltaTime;
boostText.GetComponent<TMP_Text>().text = "Boost expires in " + $"{boostLeft:0.0}" + "s";
}
else if (slownessLeft > 0f)
{
slownessLeft -= Time.deltaTime;
boostText.GetComponent<TMP_Text>().text = "Slowness expires in " + $"{slownessLeft:0.0}" + "s";
}
else
{
boostText.GetComponent<TMP_Text>().text = "";
}
}
}
private void SpawnBerries()
{
if (!(Time.time >= nextSpawnTime))
{
return;
}
nextSpawnTime = Time.time + 1f / spawnRate;
float value = Random.value;
if (!pausePanel.activeSelf)
{
GameObject gameObject;
SpriteRenderer spriteRenderer;
if (value <= 0.6f)
{
gameObject = new GameObject("Berry");
spriteRenderer = gameObject.AddComponent<SpriteRenderer>();
spriteRenderer.sprite = Resources.Load<Sprite>("textures/Berry");
gameObject.tag = "Berry";
}
else if (value <= 0.8f)
{
gameObject = new GameObject("PoisonBerry");
spriteRenderer = gameObject.AddComponent<SpriteRenderer>();
spriteRenderer.sprite = Resources.Load<Sprite>("textures/PoisonBerry");
gameObject.tag = "PoisonBerry";
}
else if (value <= 0.9f)
{
gameObject = new GameObject("SlowBerry");
spriteRenderer = gameObject.AddComponent<SpriteRenderer>();
spriteRenderer.sprite = Resources.Load<Sprite>("textures/SlowBerry");
gameObject.tag = "SlowBerry";
}
else
{
gameObject = new GameObject("UltraBerry");
spriteRenderer = gameObject.AddComponent<SpriteRenderer>();
spriteRenderer.sprite = Resources.Load<Sprite>("textures/UltraBerry");
gameObject.tag = "UltraBerry";
}
spriteRenderer.sortingOrder = -5;
float num = Camera.main.orthographicSize * 2f * Camera.main.aspect;
float x = Random.Range((0f - num) / 2.17f, num / 2.17f);
gameObject.transform.position = new Vector3(x, Camera.main.orthographicSize + 1f, 0f);
Rigidbody2D rigidbody2D = gameObject.AddComponent<Rigidbody2D>();
rigidbody2D.gravityScale = 0f;
rigidbody2D.velocity = new Vector2(0f, -3f);
}
}
private void Update()
{
if (PlayerPrefs.GetInt("Setting4", 0) == 1 && Time.time > nextUpdate)
{
fps = 1f / Time.deltaTime;
fpsCounter.text = "FPS: " + Mathf.Round(fps);
nextUpdate = Time.time + 0.25f;
}
if (screenWidth != Camera.main.orthographicSize * 2f * Camera.main.aspect)
{
screenWidth = Camera.main.orthographicSize * 2f * Camera.main.aspect;
ClampPosition(screenWidth, bird);
if (PlayerPrefs.GetInt("Setting2", 0) == 1)
{
GameObject gameObject = GameObject.Find("LeftArrow");
GameObject gameObject2 = GameObject.Find("RightArrow");
GameObject gameObject3 = GameObject.Find("JumpArrow");
GameObject gameObject4 = GameObject.Find("RestartButton");
GameObject gameObject5 = GameObject.Find("BackButton");
gameObject.transform.position = new Vector3((0f - screenWidth) / 2.5f, -4f, 0f);
gameObject2.transform.position = new Vector3(screenWidth / 2.5f, -4f, 0f);
gameObject4.transform.position = new Vector3(screenWidth / 2.3f, Camera.main.orthographicSize - 1.2f, 0f);
gameObject5.transform.position = new Vector3((0f - screenWidth) / 2.3f, Camera.main.orthographicSize - 1.2f, 0f);
if (PlayerPrefs.GetInt("Setting3", 0) == 1)
{
gameObject.transform.localScale = new Vector3(screenWidth / 14f, screenWidth / 14f, 1f);
gameObject2.transform.localScale = new Vector3(screenWidth / 14f, screenWidth / 14f, 1f);
gameObject3.transform.localScale = new Vector3(screenWidth / 14f, screenWidth / 14f, 1f);
gameObject4.transform.localScale = new Vector3(screenWidth / 14f, screenWidth / 14f, 1f);
gameObject5.transform.localScale = new Vector3(screenWidth / 14f, screenWidth / 14f, 1f);
gameObject3.transform.position = new Vector3(screenWidth / 2.5f, -1f, 0f);
}
else
{
gameObject.transform.localScale = new Vector3(screenWidth / 20f, screenWidth / 20f, 1f);
gameObject2.transform.localScale = new Vector3(screenWidth / 20f, screenWidth / 20f, 1f);
gameObject3.transform.localScale = new Vector3(screenWidth / 20f, screenWidth / 20f, 1f);
gameObject4.transform.localScale = new Vector3(screenWidth / 20f, screenWidth / 20f, 1f);
gameObject5.transform.localScale = new Vector3(screenWidth / 20f, screenWidth / 20f, 1f);
gameObject3.transform.position = new Vector3(screenWidth / 2.5f, -2f, 0f);
}
}
}
GameObject[] array = GameObject.FindGameObjectsWithTag("Berry");
GameObject[] array2 = GameObject.FindGameObjectsWithTag("PoisonBerry");
GameObject[] array3 = GameObject.FindGameObjectsWithTag("UltraBerry");
GameObject[] array4 = GameObject.FindGameObjectsWithTag("SlowBerry");
if (!pausePanel.activeSelf)
{
CheckIfGrounded();
GameObject[] array5 = array;
foreach (GameObject gameObject6 in array5)
{
if (gameObject6.transform.position.y < 0f - Camera.main.orthographicSize - 1f)
{
Object.Destroy(gameObject6);
}
else if (Vector3.Distance(bird.transform.position, gameObject6.transform.position) < 1.5f)
{
AudioSource.PlayClipAtPoint(Resources.Load<AudioClip>("sounds/Eat"), Camera.main.transform.position, PlayerPrefs.GetFloat("sfxVolume", 1f));
Object.Destroy(gameObject6);
score++;
UpdateScore(score);
}
gameObject6.GetComponent<Rigidbody2D>().velocity = new Vector2(0f, -3f);
}
array5 = array2;
foreach (GameObject gameObject7 in array5)
{
if (gameObject7.transform.position.y < 0f - Camera.main.orthographicSize - 1f)
{
Object.Destroy(gameObject7);
}
else if (Vector3.Distance(bird.transform.position, gameObject7.transform.position) < 1.5f)
{
AudioSource.PlayClipAtPoint(Resources.Load<AudioClip>("sounds/Death"), Camera.main.transform.position, PlayerPrefs.GetFloat("sfxVolume", 1f));
Respawn();
}
gameObject7.GetComponent<Rigidbody2D>().velocity = new Vector2(0f, -3f);
}
array5 = array3;
foreach (GameObject gameObject8 in array5)
{
if (gameObject8.transform.position.y < 0f - Camera.main.orthographicSize - 1f)
{
Object.Destroy(gameObject8);
}
else if (Vector3.Distance(bird.transform.position, gameObject8.transform.position) < 1.5f)
{
AudioSource.PlayClipAtPoint(Resources.Load<AudioClip>("sounds/Powerup"), Camera.main.transform.position, 0.5f * PlayerPrefs.GetFloat("sfxVolume", 1f));
Object.Destroy(gameObject8);
if (slownessLeft > 0f)
{
slownessLeft = 0f;
score++;
UpdateScore(score);
}
else
{
boostLeft += 10f;
score += 5;
UpdateScore(score);
}
}
gameObject8.GetComponent<Rigidbody2D>().velocity = new Vector2(0f, -3f);
}
array5 = array4;
foreach (GameObject gameObject9 in array5)
{
if (gameObject9.transform.position.y < 0f - Camera.main.orthographicSize - 1f)
{
Object.Destroy(gameObject9);
}
else if (Vector3.Distance(bird.transform.position, gameObject9.transform.position) < 1.5f)
{
AudioSource.PlayClipAtPoint(Resources.Load<AudioClip>("sounds/Slowness"), Camera.main.transform.position, 0.5f * PlayerPrefs.GetFloat("sfxVolume", 1f));
Object.Destroy(gameObject9);
boostLeft = 0f;
slownessLeft = 10f;
if (score > 0)
{
score--;
UpdateScore(score);
}
}
gameObject9.GetComponent<Rigidbody2D>().velocity = new Vector2(0f, -3f);
}
}
else
{
rb.gravityScale = 0f;
rb.velocity = Vector2.zero;
GameObject[] array5 = array;
for (int i = 0; i < array5.Length; i++)
{
array5[i].GetComponent<Rigidbody2D>().velocity = Vector2.zero;
}
array5 = array2;
for (int i = 0; i < array5.Length; i++)
{
array5[i].GetComponent<Rigidbody2D>().velocity = Vector2.zero;
}
array5 = array3;
for (int i = 0; i < array5.Length; i++)
{
array5[i].GetComponent<Rigidbody2D>().velocity = Vector2.zero;
}
array5 = array4;
for (int i = 0; i < array5.Length; i++)
{
array5[i].GetComponent<Rigidbody2D>().velocity = Vector2.zero;
}
}
if (Input.GetKeyDown(KeyCode.Escape) || Input.GetKeyDown(KeyCode.JoystickButton7) || Input.GetKeyDown(KeyCode.Joystick2Button7))
{
TogglePause();
}
}
private void Respawn()
{
bird.transform.position = new Vector3(0f, -4.3f, 0f);
bird.transform.localScale = new Vector3(1.35f, 1.35f, 1.35f);
rb.gravityScale = 0f;
rb.velocity = Vector2.zero;
score = 0;
boostLeft = 0f;
slownessLeft = 0f;
UpdateScore(score);
GameObject[] array = GameObject.FindGameObjectsWithTag("Berry");
GameObject[] array2 = GameObject.FindGameObjectsWithTag("PoisonBerry");
GameObject[] array3 = GameObject.FindGameObjectsWithTag("UltraBerry");
GameObject[] array4 = GameObject.FindGameObjectsWithTag("SlowBerry");
GameObject[] array5 = array;
for (int i = 0; i < array5.Length; i++)
{
Object.Destroy(array5[i]);
}
array5 = array2;
for (int i = 0; i < array5.Length; i++)
{
Object.Destroy(array5[i]);
}
array5 = array3;
for (int i = 0; i < array5.Length; i++)
{
Object.Destroy(array5[i]);
}
array5 = array4;
for (int i = 0; i < array5.Length; i++)
{
Object.Destroy(array5[i]);
}
}
private void UpdateScore(int score)
{
if (score > highscore)
{
highscore = score;
}
PlayerPrefs.SetInt("HighScore", highscore);
PlayerPrefs.Save();
scoreText.GetComponent<TMP_Text>().text = "Score: " + score;
highScoreText.GetComponent<TMP_Text>().text = "High Score: " + highscore;
}
private void CheckIfGrounded()
{
GameObject gameObject = GameObject.Find("JumpArrow");
isGrounded = bird.transform.position.y <= groundYPosition + 0.05f;
rb.gravityScale = (isGrounded ? 0f : 1.5f);
if (bird.transform.position.y < groundYPosition)
{
bird.transform.position = new Vector2(bird.transform.position.x, groundYPosition);
rb.velocity = new Vector2(rb.velocity.x, 0f);
}
if (gameObject != null)
{
Renderer component = gameObject.GetComponent<Renderer>();
if (component != null)
{
component.material.color = (isGrounded ? Color.white : Color.red);
}
}
}
private void TogglePause()
{
if (pausePanel.activeSelf)
{
DisablePause();
}
else
{
EnablePause();
}
}
private void EnablePause()
{
backgroundMusic.Pause();
pausePanel.SetActive(value: true);
}
private void DisablePause()
{
backgroundMusic.Play();
pausePanel.SetActive(value: false);
}
private void OnApplicationPause()
{
EnablePause();
}
}
+26
View File
@@ -0,0 +1,26 @@
using UnityEngine;
using UnityEngine.SceneManagement;
using UnityEngine.UI;
public class Iconkit : MonoBehaviour
{
public GameObject panel;
public GameObject iconSelectionPanel;
public GameObject overlaySelectionPanel;
public Button backButton;
private void Start()
{
backButton.onClick.AddListener(GoToMenu);
iconSelectionPanel.SetActive(value: true);
overlaySelectionPanel.SetActive(value: false);
}
public void GoToMenu()
{
SceneManager.LoadScene("Menu");
}
}
+26
View File
@@ -0,0 +1,26 @@
using UnityEngine;
using UnityEngine.SceneManagement;
using UnityEngine.UI;
public class Leaderboard : MonoBehaviour
{
public Button backButton;
public Button leaderboardsButton;
private void Awake()
{
leaderboardsButton.onClick.AddListener(LeaderboardsButton);
backButton.onClick.AddListener(BackButton);
}
private void LeaderboardsButton()
{
Application.OpenURL("https://berrydash.lncvrt.xyz/leaderboards");
}
private void BackButton()
{
SceneManager.LoadScene("Menu");
}
}
+19
View File
@@ -0,0 +1,19 @@
using UnityEngine;
using UnityEngine.SceneManagement;
public class Loading : MonoBehaviour
{
public string clientVersion;
private void Awake()
{
QualitySettings.vSyncCount = PlayerPrefs.GetInt("Setting5", 1);
Screen.fullScreen = PlayerPrefs.GetInt("Setting1", 1) == 1;
PlayerPrefs.SetString("latestVersion", clientVersion);
if (!PlayerPrefs.HasKey("iconSelected"))
{
PlayerPrefs.SetInt("iconSelected", 1);
}
SceneManager.LoadScene("Menu");
}
}
+58
View File
@@ -0,0 +1,58 @@
using UnityEngine;
using UnityEngine.SceneManagement;
using UnityEngine.UI;
public class Menu : MonoBehaviour
{
public Button exitBtn;
public Button playBtn;
public Button settingsBtn;
public Button accountBtn;
public Button leaderboardBtn;
public Button iconkitButton;
private void Awake()
{
exitBtn.onClick.AddListener(ExitClick);
playBtn.onClick.AddListener(PlayClick);
settingsBtn.onClick.AddListener(SettingsClick);
accountBtn.onClick.AddListener(AccountClick);
leaderboardBtn.onClick.AddListener(LeaderboardClick);
iconkitButton.onClick.AddListener(IconkitClick);
}
private void PlayClick()
{
SceneManager.LoadScene("Game");
}
private void SettingsClick()
{
SceneManager.LoadScene("Settings");
}
private void AccountClick()
{
SceneManager.LoadScene("Account");
}
private void LeaderboardClick()
{
SceneManager.LoadScene("Leaderboard");
}
private void IconkitClick()
{
SceneManager.LoadScene("Iconkit");
}
private void ExitClick()
{
Application.Quit();
}
}
+12
View File
@@ -0,0 +1,12 @@
using UnityEngine;
using UnityEngine.EventSystems;
public class MenuSocials : MonoBehaviour, IPointerClickHandler, IEventSystemHandler
{
public string URL;
public void OnPointerClick(PointerEventData eventData)
{
Application.OpenURL(URL);
}
}
+52
View File
@@ -0,0 +1,52 @@
using UnityEngine;
using UnityEngine.SceneManagement;
using UnityEngine.UI;
public class PauseMenu : MonoBehaviour
{
public GameObject pausePanel;
public Button menuButton;
public Button playButton;
public AudioSource backgroundMusic;
public Slider musicSlider;
public Slider sfxSlider;
private void Start()
{
menuButton.onClick.AddListener(MenuClick);
playButton.onClick.AddListener(TogglePause);
musicSlider.onValueChanged.AddListener(UpdateMusicVolume);
sfxSlider.onValueChanged.AddListener(UpdateSFXVolume);
musicSlider.value = PlayerPrefs.GetFloat("musicVolume", 1f);
sfxSlider.value = PlayerPrefs.GetFloat("sfxVolume", 1f);
}
private void TogglePause()
{
backgroundMusic.Play();
pausePanel.SetActive(value: false);
}
private void MenuClick()
{
SceneManager.LoadScene("Menu");
}
private void UpdateMusicVolume(float volume)
{
PlayerPrefs.SetFloat("musicVolume", volume);
PlayerPrefs.Save();
backgroundMusic.volume = volume;
}
private void UpdateSFXVolume(float volume)
{
PlayerPrefs.SetFloat("sfxVolume", volume);
PlayerPrefs.Save();
}
}
+100
View File
@@ -0,0 +1,100 @@
using UnityEngine;
using UnityEngine.SceneManagement;
using UnityEngine.UI;
public class Settings : MonoBehaviour
{
public Toggle setting1toggle;
public Toggle setting2toggle;
public Toggle setting3toggle;
public Toggle setting4toggle;
public Toggle setting5toggle;
public Button backbutton;
public Slider musicSlider;
public Slider sfxSlider;
private void Awake()
{
musicSlider.value = PlayerPrefs.GetFloat("musicVolume", 1f);
sfxSlider.value = PlayerPrefs.GetFloat("sfxVolume", 1f);
setting1toggle.isOn = PlayerPrefs.GetInt("Setting1", 1) == 1;
setting2toggle.isOn = PlayerPrefs.GetInt("Setting2", 0) == 1;
setting3toggle.isOn = PlayerPrefs.GetInt("Setting3", 0) == 1;
setting4toggle.isOn = PlayerPrefs.GetInt("Setting4", 0) == 1;
setting5toggle.isOn = PlayerPrefs.GetInt("Setting5", 1) == 1;
backbutton.onClick.AddListener(BackButton);
setting1toggle.onValueChanged.AddListener(delegate
{
Setting1ToggleValueChanged(setting1toggle);
});
setting2toggle.onValueChanged.AddListener(delegate
{
Setting2ToggleValueChanged(setting2toggle);
});
setting3toggle.onValueChanged.AddListener(delegate
{
Setting3ToggleValueChanged(setting3toggle);
});
setting4toggle.onValueChanged.AddListener(delegate
{
Setting4ToggleValueChanged(setting4toggle);
});
setting5toggle.onValueChanged.AddListener(delegate
{
Setting5ToggleValueChanged(setting5toggle);
});
musicSlider.onValueChanged.AddListener(UpdateMusicVolume);
sfxSlider.onValueChanged.AddListener(UpdateSFXVolume);
}
private void Setting1ToggleValueChanged(Toggle change)
{
Screen.fullScreen = change.isOn;
PlayerPrefs.SetInt("Setting1", change.isOn ? 1 : 0);
}
private void Setting2ToggleValueChanged(Toggle change)
{
PlayerPrefs.SetInt("Setting2", change.isOn ? 1 : 0);
}
private void Setting3ToggleValueChanged(Toggle change)
{
PlayerPrefs.SetInt("Setting3", change.isOn ? 1 : 0);
}
private void Setting4ToggleValueChanged(Toggle change)
{
PlayerPrefs.SetInt("Setting4", change.isOn ? 1 : 0);
}
private void Setting5ToggleValueChanged(Toggle change)
{
PlayerPrefs.SetInt("Setting5", change.isOn ? 1 : 0);
QualitySettings.vSyncCount = (change.isOn ? 1 : 0);
}
private void BackButton()
{
SceneManager.LoadScene("Menu");
}
private void UpdateMusicVolume(float volume)
{
PlayerPrefs.SetFloat("musicVolume", volume);
PlayerPrefs.Save();
}
private void UpdateSFXVolume(float volume)
{
PlayerPrefs.SetFloat("sfxVolume", volume);
PlayerPrefs.Save();
}
}
+17
View File
@@ -0,0 +1,17 @@
using UnityEngine;
using UnityEngine.UI;
public class UpdateRequired : MonoBehaviour
{
public Button btn;
private void Awake()
{
btn.onClick.AddListener(TaskOnClick);
}
private void TaskOnClick()
{
Application.OpenURL("https://berrydash.lncvrt.xyz/download");
}
}