Add 1.2 source
This commit is contained in:
10 files changed
+1239
No files matched your search
+303
@@ -0,0 +1,303 @@
|
||||
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
|
||||
{
|
||||
private readonly string GameSession;
|
||||
|
||||
public GameObject registerPanel;
|
||||
|
||||
public Button registerPanelSubmitBtn;
|
||||
|
||||
public Button registerPanelLoginBtn;
|
||||
|
||||
public GameObject loginPanel;
|
||||
|
||||
public Button loginPanelSubmitBtn;
|
||||
|
||||
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;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
if (!client.DefaultRequestHeaders.Contains("Requester"))
|
||||
{
|
||||
client.DefaultRequestHeaders.Add("Requester", "BerryDashClientLegacy");
|
||||
}
|
||||
if (!client.DefaultRequestHeaders.Contains("ClientVersion"))
|
||||
{
|
||||
client.DefaultRequestHeaders.Add("ClientVersion", "1.2");
|
||||
}
|
||||
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);
|
||||
});
|
||||
registerPanelSubmitBtn.onClick.AddListener(SubmitRegister);
|
||||
loginPanelRegisterBtn.onClick.AddListener(delegate
|
||||
{
|
||||
SwitchScene(1);
|
||||
});
|
||||
loginPanelSubmitBtn.onClick.AddListener(SubmitLogin);
|
||||
accountPanelSyncButton.onClick.AddListener(SyncStats);
|
||||
accountPanelLogoutButton.onClick.AddListener(LogoutAccount);
|
||||
}
|
||||
|
||||
private void BackToMenu()
|
||||
{
|
||||
SceneManager.LoadScene("Menu");
|
||||
}
|
||||
|
||||
private void SwitchScene(int scene)
|
||||
{
|
||||
ClearForms();
|
||||
registerPanelStatusText.text = "";
|
||||
loginPanelStatusText.text = "";
|
||||
accountPanelStatusText.text = "";
|
||||
switch (scene)
|
||||
{
|
||||
case 0:
|
||||
accountPanel.SetActive(value: true);
|
||||
registerPanel.SetActive(value: false);
|
||||
loginPanel.SetActive(value: false);
|
||||
break;
|
||||
case 1:
|
||||
accountPanel.SetActive(value: false);
|
||||
registerPanel.SetActive(value: true);
|
||||
loginPanel.SetActive(value: false);
|
||||
break;
|
||||
case 2:
|
||||
accountPanel.SetActive(value: false);
|
||||
registerPanel.SetActive(value: false);
|
||||
loginPanel.SetActive(value: true);
|
||||
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;
|
||||
}
|
||||
try
|
||||
{
|
||||
HttpResponseMessage obj = await client.PostAsync("https://berrydash.lncvrt.xyz/database/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 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/database/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();
|
||||
if (!(text == "-1"))
|
||||
{
|
||||
if (!(text == "-2"))
|
||||
{
|
||||
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 \"" + text + "\"", Color.red);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
UpdateStatusText(loginPanelStatusText, "Incorrect username or password", 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 void ClearForms()
|
||||
{
|
||||
registerPanelUsernameForm.text = "";
|
||||
registerPanelEmailForm.text = "";
|
||||
registerPanelEmailConfirmForm.text = "";
|
||||
registerPanelPasswordForm.text = "";
|
||||
registerPanelPasswordConfirmForm.text = "";
|
||||
loginPanelUsernameForm.text = "";
|
||||
loginPanelPasswordForm.text = "";
|
||||
}
|
||||
|
||||
private async void SyncStats()
|
||||
{
|
||||
_ = 1;
|
||||
try
|
||||
{
|
||||
HttpResponseMessage obj = await client.PostAsync("https://berrydash.lncvrt.xyz/database/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;
|
||||
}
|
||||
|
||||
static Account()
|
||||
{
|
||||
client = new HttpClient();
|
||||
}
|
||||
}
|
||||
+579
@@ -0,0 +1,579 @@
|
||||
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()
|
||||
{
|
||||
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 || Application.isMobilePlatform)
|
||||
{
|
||||
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>("Arrow");
|
||||
gameObject2.GetComponent<SpriteRenderer>().sprite = Resources.Load<Sprite>("Arrow");
|
||||
gameObject3.GetComponent<SpriteRenderer>().sprite = Resources.Load<Sprite>("Arrow");
|
||||
gameObject4.GetComponent<SpriteRenderer>().sprite = Resources.Load<Sprite>("Restart");
|
||||
gameObject5.GetComponent<SpriteRenderer>().sprite = Resources.Load<Sprite>("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 (!Application.isMobilePlatform)
|
||||
{
|
||||
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.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) != 0 || Application.isMobilePlatform)
|
||||
{
|
||||
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 (Application.isMobilePlatform)
|
||||
{
|
||||
Touch[] touches = Input.touches;
|
||||
for (int i = 0; i < touches.Length; i++)
|
||||
{
|
||||
Touch touch = touches[i];
|
||||
Vector3 point = Camera.main.ScreenToWorldPoint(touch.position);
|
||||
point.z = 0f;
|
||||
if (touch.phase == TouchPhase.Stationary || touch.phase == TouchPhase.Moved)
|
||||
{
|
||||
if (gameObject.GetComponent<SpriteRenderer>().bounds.Contains(point))
|
||||
{
|
||||
flag2 = true;
|
||||
}
|
||||
else if (gameObject2.GetComponent<SpriteRenderer>().bounds.Contains(point))
|
||||
{
|
||||
flag = true;
|
||||
}
|
||||
else if (gameObject3.GetComponent<SpriteRenderer>().bounds.Contains(point))
|
||||
{
|
||||
flag3 = true;
|
||||
}
|
||||
}
|
||||
if (touch.phase == TouchPhase.Began)
|
||||
{
|
||||
if (gameObject4.GetComponent<SpriteRenderer>().bounds.Contains(point))
|
||||
{
|
||||
flag5 = true;
|
||||
}
|
||||
else if (gameObject5.GetComponent<SpriteRenderer>().bounds.Contains(point))
|
||||
{
|
||||
flag4 = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Input.GetMouseButton(0))
|
||||
{
|
||||
Vector3 point2 = Camera.main.ScreenToWorldPoint(Input.mousePosition);
|
||||
point2.z = 0f;
|
||||
if (gameObject.GetComponent<SpriteRenderer>().bounds.Contains(point2))
|
||||
{
|
||||
flag2 = true;
|
||||
}
|
||||
if (gameObject2.GetComponent<SpriteRenderer>().bounds.Contains(point2))
|
||||
{
|
||||
flag = true;
|
||||
}
|
||||
if (gameObject3.GetComponent<SpriteRenderer>().bounds.Contains(point2))
|
||||
{
|
||||
flag3 = true;
|
||||
}
|
||||
}
|
||||
if (Input.GetMouseButtonDown(0))
|
||||
{
|
||||
Vector3 point3 = Camera.main.ScreenToWorldPoint(Input.mousePosition);
|
||||
point3.z = 0f;
|
||||
if (gameObject4.GetComponent<SpriteRenderer>().bounds.Contains(point3))
|
||||
{
|
||||
flag5 = true;
|
||||
}
|
||||
if (gameObject5.GetComponent<SpriteRenderer>().bounds.Contains(point3))
|
||||
{
|
||||
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>("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.active)
|
||||
{
|
||||
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.active)
|
||||
{
|
||||
GameObject gameObject;
|
||||
SpriteRenderer spriteRenderer;
|
||||
if (value <= 0.6f)
|
||||
{
|
||||
gameObject = new GameObject("Berry");
|
||||
spriteRenderer = gameObject.AddComponent<SpriteRenderer>();
|
||||
spriteRenderer.sprite = Resources.Load<Sprite>("Berry");
|
||||
gameObject.tag = "Berry";
|
||||
}
|
||||
else if (value <= 0.8f)
|
||||
{
|
||||
gameObject = new GameObject("PoisonBerry");
|
||||
spriteRenderer = gameObject.AddComponent<SpriteRenderer>();
|
||||
spriteRenderer.sprite = Resources.Load<Sprite>("PoisonBerry");
|
||||
gameObject.tag = "PoisonBerry";
|
||||
}
|
||||
else if (value <= 0.9f)
|
||||
{
|
||||
gameObject = new GameObject("SlowBerry");
|
||||
spriteRenderer = gameObject.AddComponent<SpriteRenderer>();
|
||||
spriteRenderer.sprite = Resources.Load<Sprite>("SlowBerry");
|
||||
gameObject.tag = "SlowBerry";
|
||||
}
|
||||
else
|
||||
{
|
||||
gameObject = new GameObject("UltraBerry");
|
||||
spriteRenderer = gameObject.AddComponent<SpriteRenderer>();
|
||||
spriteRenderer.sprite = Resources.Load<Sprite>("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.active)
|
||||
{
|
||||
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>("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>("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>("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>("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 OnApplicationQuit()
|
||||
{
|
||||
PlayerPrefs.SetInt("HighScore", highscore);
|
||||
PlayerPrefs.Save();
|
||||
}
|
||||
|
||||
private void TogglePause()
|
||||
{
|
||||
if (pausePanel.active)
|
||||
{
|
||||
backgroundMusic.Play();
|
||||
pausePanel.SetActive(value: false);
|
||||
}
|
||||
else
|
||||
{
|
||||
backgroundMusic.Pause();
|
||||
pausePanel.SetActive(value: true);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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/leaderboard.php");
|
||||
}
|
||||
|
||||
private void BackButton()
|
||||
{
|
||||
SceneManager.LoadScene("Menu");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.SceneManagement;
|
||||
|
||||
public class Loading : MonoBehaviour
|
||||
{
|
||||
private void Start()
|
||||
{
|
||||
if (!Application.isMobilePlatform)
|
||||
{
|
||||
QualitySettings.vSyncCount = PlayerPrefs.GetInt("Setting5", 0);
|
||||
if (PlayerPrefs.GetInt("Setting1", 1) == 1)
|
||||
{
|
||||
Screen.fullScreen = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
Screen.fullScreen = false;
|
||||
}
|
||||
}
|
||||
if (Application.platform == RuntimePlatform.WebGLPlayer)
|
||||
{
|
||||
Screen.fullScreen = true;
|
||||
}
|
||||
SceneManager.LoadScene("Menu");
|
||||
}
|
||||
}
|
||||
+66
@@ -0,0 +1,66 @@
|
||||
using System.Linq;
|
||||
using UnityEngine;
|
||||
using UnityEngine.SceneManagement;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class Menu : MonoBehaviour
|
||||
{
|
||||
public RuntimePlatform[] desktopPlatforms = new RuntimePlatform[3]
|
||||
{
|
||||
RuntimePlatform.WindowsPlayer,
|
||||
RuntimePlatform.LinuxPlayer,
|
||||
RuntimePlatform.OSXPlayer
|
||||
};
|
||||
|
||||
public GameObject exitObj;
|
||||
|
||||
public Button playBtn;
|
||||
|
||||
public Button settingsBtn;
|
||||
|
||||
public Button accountBtn;
|
||||
|
||||
public Button leaderboardBtn;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
Button component = exitObj.GetComponent<Button>();
|
||||
if (desktopPlatforms.Contains(Application.platform))
|
||||
{
|
||||
component.onClick.AddListener(ExitClick);
|
||||
}
|
||||
else
|
||||
{
|
||||
Object.Destroy(exitObj);
|
||||
}
|
||||
playBtn.onClick.AddListener(PlayClick);
|
||||
settingsBtn.onClick.AddListener(SettingsClick);
|
||||
accountBtn.onClick.AddListener(AccountClick);
|
||||
leaderboardBtn.onClick.AddListener(LeaderboardClick);
|
||||
}
|
||||
|
||||
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 ExitClick()
|
||||
{
|
||||
Application.Quit();
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
using UnityEngine;
|
||||
|
||||
public class Player : MonoBehaviour
|
||||
{
|
||||
public float jumpForce;
|
||||
|
||||
private Rigidbody2D rb;
|
||||
|
||||
public float groundYPosition = -4.3f;
|
||||
|
||||
private bool isGrounded;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
rb = GetComponent<Rigidbody2D>();
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
CheckIfGrounded();
|
||||
if (isGrounded && Input.GetKey(KeyCode.Space))
|
||||
{
|
||||
rb.velocity = Vector2.up * jumpForce;
|
||||
}
|
||||
}
|
||||
|
||||
private void CheckIfGrounded()
|
||||
{
|
||||
isGrounded = base.transform.position.y <= groundYPosition + 0.05f;
|
||||
rb.gravityScale = (isGrounded ? 0f : 1.5f);
|
||||
if (base.transform.position.y < groundYPosition)
|
||||
{
|
||||
base.transform.position = new Vector2(base.transform.position.x, groundYPosition);
|
||||
rb.velocity = new Vector2(rb.velocity.x, 0f);
|
||||
}
|
||||
}
|
||||
}
|
||||
+122
@@ -0,0 +1,122 @@
|
||||
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);
|
||||
if (Application.platform == RuntimePlatform.WebGLPlayer)
|
||||
{
|
||||
setting1toggle.isOn = true;
|
||||
setting1toggle.interactable = false;
|
||||
setting2toggle.isOn = PlayerPrefs.GetInt("Setting2", 1) == 1;
|
||||
}
|
||||
else if (Application.isMobilePlatform)
|
||||
{
|
||||
setting1toggle.isOn = true;
|
||||
setting2toggle.isOn = true;
|
||||
setting5toggle.isOn = true;
|
||||
setting1toggle.interactable = false;
|
||||
setting2toggle.interactable = false;
|
||||
setting5toggle.interactable = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
setting1toggle.isOn = PlayerPrefs.GetInt("Setting1", 1) == 1;
|
||||
setting2toggle.isOn = PlayerPrefs.GetInt("Setting2", 1) == 1;
|
||||
}
|
||||
setting3toggle.isOn = PlayerPrefs.GetInt("Setting3", 1) == 1;
|
||||
setting4toggle.isOn = PlayerPrefs.GetInt("Setting4", 0) == 1;
|
||||
if (Application.platform == RuntimePlatform.WebGLPlayer || !Application.isMobilePlatform)
|
||||
{
|
||||
setting5toggle.interactable = false;
|
||||
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();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class UpdateRequired : MonoBehaviour
|
||||
{
|
||||
private void Awake()
|
||||
{
|
||||
GameObject.Find("Canvas/Button").GetComponent<Button>().onClick.AddListener(TaskOnClick);
|
||||
}
|
||||
|
||||
private void TaskOnClick()
|
||||
{
|
||||
string text = "/windows";
|
||||
Application.OpenURL("https://berrydash.lncvrt.xyz/download" + text);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user