Update to Berry Dash 1.8.2!
This commit is contained in:
140 files changed
+32883
-3840
No files matched your search
+158
-115
@@ -1,4 +1,3 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Numerics;
|
||||
using System.Text;
|
||||
@@ -13,7 +12,6 @@ public class BazookaManager : MonoBehaviour
|
||||
{
|
||||
["version"] = "0"
|
||||
};
|
||||
private JObject lastSaveFile = new();
|
||||
|
||||
void Awake()
|
||||
{
|
||||
@@ -33,81 +31,55 @@ public class BazookaManager : MonoBehaviour
|
||||
}
|
||||
}
|
||||
|
||||
void Update()
|
||||
void OnApplicationQuit()
|
||||
{
|
||||
if (Instance == null && !firstLoadDone) return;
|
||||
if (!JToken.DeepEquals(saveFile, lastSaveFile)) Save();
|
||||
lastSaveFile = saveFile;
|
||||
Save();
|
||||
}
|
||||
|
||||
void OnApplicationPause(bool pause)
|
||||
{
|
||||
if (pause)
|
||||
{
|
||||
Save();
|
||||
}
|
||||
}
|
||||
|
||||
public void Load()
|
||||
{
|
||||
if (Application.platform != RuntimePlatform.WebGLPlayer)
|
||||
string path = Path.Join(Application.persistentDataPath, "save.json");
|
||||
if (!File.Exists(path))
|
||||
{
|
||||
string path = Path.Join(Application.persistentDataPath, "save.json");
|
||||
if (!File.Exists(path))
|
||||
{
|
||||
File.Create(path).Dispose();
|
||||
}
|
||||
else
|
||||
{
|
||||
try
|
||||
{
|
||||
var tempSaveFile = JObject.Parse(File.ReadAllText(path));
|
||||
if (tempSaveFile != null)
|
||||
{
|
||||
saveFile = tempSaveFile;
|
||||
lastSaveFile = tempSaveFile;
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
Debug.LogWarning("Failed to load save file");
|
||||
}
|
||||
}
|
||||
if (saveFile["version"] == null || saveFile["version"].ToString() != "0")
|
||||
{
|
||||
saveFile["version"] = "0";
|
||||
}
|
||||
File.Create(path).Dispose();
|
||||
}
|
||||
else
|
||||
{
|
||||
try
|
||||
{
|
||||
var tempSaveFile = JObject.Parse(File.ReadAllText(Encoding.UTF8.GetString(Convert.FromBase64String(PlayerPrefs.GetString("saveFile", "e30=")))));
|
||||
if (tempSaveFile != null)
|
||||
{
|
||||
saveFile = tempSaveFile;
|
||||
lastSaveFile = tempSaveFile;
|
||||
}
|
||||
Debug.Log(tempSaveFile.ToString());
|
||||
saveFile = JObject.Parse(File.ReadAllText(path));
|
||||
}
|
||||
catch
|
||||
{
|
||||
Debug.LogWarning("Failed to load save file");
|
||||
}
|
||||
}
|
||||
if (saveFile["version"] == null || saveFile["version"].ToString() != "0")
|
||||
{
|
||||
saveFile["version"] = "0";
|
||||
}
|
||||
}
|
||||
|
||||
public void Save()
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
return;
|
||||
#else
|
||||
if (Application.platform != RuntimePlatform.WebGLPlayer)
|
||||
{
|
||||
string path = Path.Join(Application.persistentDataPath, "save.json");
|
||||
var encoded = Encoding.UTF8.GetBytes(saveFile.ToString());
|
||||
using var fileStream = new FileStream(path, FileMode.Create, FileAccess.Write, FileShare.None);
|
||||
fileStream.Write(encoded, 0, encoded.Length);
|
||||
fileStream.Flush(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
PlayerPrefs.SetString("saveFile", Convert.ToBase64String(Encoding.UTF8.GetBytes(saveFile.ToString(Newtonsoft.Json.Formatting.None))));
|
||||
}
|
||||
#endif
|
||||
}
|
||||
#if UNITY_EDITOR
|
||||
return;
|
||||
#else
|
||||
string path = Path.Join(Application.persistentDataPath, "save.json");
|
||||
var encoded = Encoding.UTF8.GetBytes(saveFile.ToString());
|
||||
using var fileStream = new FileStream(path, FileMode.Create, FileAccess.Write, FileShare.None);
|
||||
fileStream.Write(encoded, 0, encoded.Length);
|
||||
fileStream.Flush(true);
|
||||
#endif
|
||||
}
|
||||
|
||||
public void ResetSave()
|
||||
{
|
||||
@@ -201,6 +173,19 @@ public class BazookaManager : MonoBehaviour
|
||||
return bool.Parse(saveFile["settings"]["vsync"].ToString());
|
||||
}
|
||||
|
||||
public void SetSettingRandomMusic(bool value)
|
||||
{
|
||||
if (saveFile["settings"] == null) saveFile["settings"] = new JObject();
|
||||
saveFile["settings"]["randomMusic"] = value;
|
||||
}
|
||||
|
||||
public bool GetSettingRandomMusic()
|
||||
{
|
||||
if (saveFile["settings"] == null) return true;
|
||||
if (saveFile["settings"]["randomMusic"] == null) return true;
|
||||
return bool.Parse(saveFile["settings"]["randomMusic"].ToString());
|
||||
}
|
||||
|
||||
public void SetSettingMusicVolume(float value)
|
||||
{
|
||||
if (saveFile["settings"] == null) saveFile["settings"] = new JObject();
|
||||
@@ -242,6 +227,66 @@ public class BazookaManager : MonoBehaviour
|
||||
return JArray.Parse(saveFile["settings"]["colors"]["background"].ToString());
|
||||
}
|
||||
|
||||
public void SetColorSettingMenuBackground(JArray value)
|
||||
{
|
||||
if (saveFile["settings"] == null) saveFile["settings"] = new JObject();
|
||||
if (saveFile["settings"]["colors"] == null) saveFile["settings"]["colors"] = new JObject();
|
||||
saveFile["settings"]["colors"]["menuBackground"] = value;
|
||||
}
|
||||
|
||||
public JArray GetColorSettingMenuBackground()
|
||||
{
|
||||
if (saveFile["settings"] == null) return new JArray(24, 24, 24);
|
||||
if (saveFile["settings"]["colors"] == null) return new JArray(24, 24, 24);
|
||||
if (saveFile["settings"]["colors"]["menuBackground"] == null) return new JArray(24, 24, 24);
|
||||
return JArray.Parse(saveFile["settings"]["colors"]["menuBackground"].ToString());
|
||||
}
|
||||
|
||||
public void SetColorSettingButton(JArray value)
|
||||
{
|
||||
if (saveFile["settings"] == null) saveFile["settings"] = new JObject();
|
||||
if (saveFile["settings"]["colors"] == null) saveFile["settings"]["colors"] = new JObject();
|
||||
saveFile["settings"]["colors"]["button"] = value;
|
||||
}
|
||||
|
||||
public JArray GetColorSettingButton()
|
||||
{
|
||||
if (saveFile["settings"] == null) return new JArray(255, 255, 255);
|
||||
if (saveFile["settings"]["colors"] == null) return new JArray(255, 255, 255);
|
||||
if (saveFile["settings"]["colors"]["button"] == null) return new JArray(255, 255, 255);
|
||||
return JArray.Parse(saveFile["settings"]["colors"]["button"].ToString());
|
||||
}
|
||||
|
||||
public void SetColorSettingText(JArray value)
|
||||
{
|
||||
if (saveFile["settings"] == null) saveFile["settings"] = new JObject();
|
||||
if (saveFile["settings"]["colors"] == null) saveFile["settings"]["colors"] = new JObject();
|
||||
saveFile["settings"]["colors"]["text"] = value;
|
||||
}
|
||||
|
||||
public JArray GetColorSettingText()
|
||||
{
|
||||
if (saveFile["settings"] == null) return new JArray(255, 255, 255);
|
||||
if (saveFile["settings"]["colors"] == null) return new JArray(255, 255, 255);
|
||||
if (saveFile["settings"]["colors"]["text"] == null) return new JArray(255, 255, 255);
|
||||
return JArray.Parse(saveFile["settings"]["colors"]["text"].ToString());
|
||||
}
|
||||
|
||||
public void SetColorSettingButtonContent(JArray value)
|
||||
{
|
||||
if (saveFile["settings"] == null) saveFile["settings"] = new JObject();
|
||||
if (saveFile["settings"]["colors"] == null) saveFile["settings"]["colors"] = new JObject();
|
||||
saveFile["settings"]["colors"]["buttonColor"] = value;
|
||||
}
|
||||
|
||||
public JArray GetColorSettingButtonContent()
|
||||
{
|
||||
if (saveFile["settings"] == null) return new JArray(0, 0, 0);
|
||||
if (saveFile["settings"]["colors"] == null) return new JArray(0, 0, 0);
|
||||
if (saveFile["settings"]["colors"]["buttonColor"] == null) return new JArray(0, 0, 0);
|
||||
return JArray.Parse(saveFile["settings"]["colors"]["buttonColor"].ToString());
|
||||
}
|
||||
|
||||
public void SetColorSettingIcon(JArray value)
|
||||
{
|
||||
if (saveFile["settings"] == null) saveFile["settings"] = new JObject();
|
||||
@@ -288,65 +333,6 @@ public class BazookaManager : MonoBehaviour
|
||||
(saveFile["settings"]["colors"] as JObject)?.Remove("overlay");
|
||||
}
|
||||
|
||||
//Account stuff
|
||||
|
||||
public void SetAccountSession(string value)
|
||||
{
|
||||
if (saveFile["account"] == null) saveFile["account"] = new JObject();
|
||||
saveFile["account"]["session"] = value;
|
||||
}
|
||||
|
||||
public string GetAccountSession()
|
||||
{
|
||||
if (saveFile["account"] == null) return null;
|
||||
if (saveFile["account"]["session"] == null) return null;
|
||||
return saveFile["account"]["session"].ToString();
|
||||
}
|
||||
|
||||
public void UnsetAccountSession()
|
||||
{
|
||||
if (saveFile["account"] == null) return;
|
||||
(saveFile["account"] as JObject)?.Remove("session");
|
||||
}
|
||||
|
||||
public void SetAccountName(string value)
|
||||
{
|
||||
if (saveFile["account"] == null) saveFile["account"] = new JObject();
|
||||
saveFile["account"]["name"] = value;
|
||||
}
|
||||
|
||||
public string GetAccountName()
|
||||
{
|
||||
if (saveFile["account"] == null) return null;
|
||||
if (saveFile["account"]["name"] == null) return null;
|
||||
return saveFile["account"]["name"].ToString();
|
||||
}
|
||||
|
||||
public void UnsetAccountName()
|
||||
{
|
||||
if (saveFile["account"] == null) return;
|
||||
(saveFile["account"] as JObject)?.Remove("name");
|
||||
}
|
||||
|
||||
public void SetAccountID(BigInteger value)
|
||||
{
|
||||
if (saveFile["account"] == null) saveFile["account"] = new JObject();
|
||||
saveFile["account"]["id"] = value.ToString();
|
||||
}
|
||||
|
||||
public BigInteger? GetAccountID()
|
||||
{
|
||||
if (saveFile["account"] == null) return null;
|
||||
if (saveFile["account"]["id"] == null) return null;
|
||||
return BigInteger.Parse(saveFile["account"]["id"].ToString());
|
||||
}
|
||||
|
||||
public void UnsetAccountID()
|
||||
{
|
||||
if (saveFile["account"] == null) return;
|
||||
(saveFile["account"] as JObject)?.Remove("id");
|
||||
}
|
||||
|
||||
//Game store stuff
|
||||
|
||||
public void SetGameStoreHighScore(BigInteger value)
|
||||
@@ -482,6 +468,63 @@ public class BazookaManager : MonoBehaviour
|
||||
(saveFile["gameStore"] as JObject)?.Remove("totalSpeedyBerries");
|
||||
}
|
||||
|
||||
public void SetGameStoreTotalCoinBerries(BigInteger value)
|
||||
{
|
||||
if (saveFile["gameStore"] == null) saveFile["gameStore"] = new JObject();
|
||||
saveFile["gameStore"]["totalCoinBerries"] = value.ToString();
|
||||
}
|
||||
|
||||
public BigInteger GetGameStoreTotalCoinBerries()
|
||||
{
|
||||
if (saveFile["gameStore"] == null) return 0;
|
||||
if (saveFile["gameStore"]["totalCoinBerries"] == null) return 0;
|
||||
return BigInteger.Parse(saveFile["gameStore"]["totalCoinBerries"].ToString());
|
||||
}
|
||||
|
||||
public void UnsetGameStoreTotalCoinBerries()
|
||||
{
|
||||
if (saveFile["gameStore"] == null) return;
|
||||
(saveFile["gameStore"] as JObject)?.Remove("totalCoinBerries");
|
||||
}
|
||||
|
||||
public void SetGameStoreTotalRandomBerries(BigInteger value)
|
||||
{
|
||||
if (saveFile["gameStore"] == null) saveFile["gameStore"] = new JObject();
|
||||
saveFile["gameStore"]["totalRandomBerries"] = value.ToString();
|
||||
}
|
||||
|
||||
public BigInteger GetGameStoreTotalRandomBerries()
|
||||
{
|
||||
if (saveFile["gameStore"] == null) return 0;
|
||||
if (saveFile["gameStore"]["totalRandomBerries"] == null) return 0;
|
||||
return BigInteger.Parse(saveFile["gameStore"]["totalRandomBerries"].ToString());
|
||||
}
|
||||
|
||||
public void UnsetGameStoreTotalRandomBerries()
|
||||
{
|
||||
if (saveFile["gameStore"] == null) return;
|
||||
(saveFile["gameStore"] as JObject)?.Remove("totalRandomBerries");
|
||||
}
|
||||
|
||||
public void SetGameStoreTotalAntiBerries(BigInteger value)
|
||||
{
|
||||
if (saveFile["gameStore"] == null) saveFile["gameStore"] = new JObject();
|
||||
saveFile["gameStore"]["totalAntiBerries"] = value.ToString();
|
||||
}
|
||||
|
||||
public BigInteger GetGameStoreTotalAntiBerries()
|
||||
{
|
||||
if (saveFile["gameStore"] == null) return 0;
|
||||
if (saveFile["gameStore"]["totalAntiBerries"] == null) return 0;
|
||||
return BigInteger.Parse(saveFile["gameStore"]["totalAntiBerries"].ToString());
|
||||
}
|
||||
|
||||
public void UnsetGameStoreTotalAntiBerries()
|
||||
{
|
||||
if (saveFile["gameStore"] == null) return;
|
||||
(saveFile["gameStore"] as JObject)?.Remove("totalAntiBerries");
|
||||
}
|
||||
|
||||
public void SetGameStoreTotalTimeSlowBerries(BigInteger value)
|
||||
{
|
||||
if (saveFile["gameStore"] == null) saveFile["gameStore"] = new JObject();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
using UnityEngine;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
|
||||
public class BouncyText : MonoBehaviour
|
||||
{
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
using UnityEngine;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
|
||||
public class ImageColorSync : MonoBehaviour
|
||||
{
|
||||
|
||||
@@ -16,12 +16,14 @@ public class ColorPanel : MonoBehaviour
|
||||
public Button resetButton;
|
||||
public Button switchModeButton;
|
||||
public event Action<JArray> OnColorChanged;
|
||||
public Color defaultColor;
|
||||
|
||||
public void Init(JArray color, Color defaultColor)
|
||||
public void Init(Color color, Color defaultColorArg)
|
||||
{
|
||||
rSlider.value = (int)color[0];
|
||||
gSlider.value = (int)color[1];
|
||||
bSlider.value = (int)color[2];
|
||||
defaultColor = defaultColorArg;
|
||||
rSlider.value = color.r * 255f;
|
||||
gSlider.value = color.g * 255f;
|
||||
bSlider.value = color.b * 255f;
|
||||
|
||||
SyncAll();
|
||||
|
||||
@@ -64,6 +66,12 @@ public class ColorPanel : MonoBehaviour
|
||||
};
|
||||
}
|
||||
|
||||
public void Init(JArray color, Color defaultColorArg)
|
||||
{
|
||||
|
||||
Init(new Color((int)color[0] / 255f, (int)color[1] / 255f, (int)color[2] / 255f), defaultColorArg);
|
||||
}
|
||||
|
||||
void SyncAll(bool fromPicker = false)
|
||||
{
|
||||
var col = new Color(rSlider.value / 255f, gSlider.value / 255f, bSlider.value / 255f);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using UnityEngine.InputSystem;
|
||||
using System;
|
||||
using UnityEngine;
|
||||
using UnityEngine.InputSystem;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class ColorPickerUI : MonoBehaviour
|
||||
{
|
||||
|
||||
@@ -0,0 +1,158 @@
|
||||
using Newtonsoft.Json.Linq;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class CustomColorObject : MonoBehaviour
|
||||
{
|
||||
public ColorObjectType type;
|
||||
public bool invert;
|
||||
public Color addMore;
|
||||
public bool reverseAdd;
|
||||
|
||||
Color ApplyModifiers(Color baseColor)
|
||||
{
|
||||
if (invert) baseColor = new(1f - baseColor.r, 1f - baseColor.g, 1f - baseColor.b);
|
||||
|
||||
if (reverseAdd)
|
||||
{
|
||||
baseColor.r = Mathf.Clamp01(baseColor.r - addMore.r);
|
||||
baseColor.g = Mathf.Clamp01(baseColor.g - addMore.g);
|
||||
baseColor.b = Mathf.Clamp01(baseColor.b - addMore.b);
|
||||
}
|
||||
else
|
||||
{
|
||||
baseColor.r = Mathf.Clamp01(baseColor.r + addMore.r);
|
||||
baseColor.g = Mathf.Clamp01(baseColor.g + addMore.g);
|
||||
baseColor.b = Mathf.Clamp01(baseColor.b + addMore.b);
|
||||
}
|
||||
|
||||
return baseColor;
|
||||
}
|
||||
|
||||
public void SetColor()
|
||||
{
|
||||
JArray color = null;
|
||||
Color colorType = Color.white;
|
||||
Color currentColor = Color.white;
|
||||
|
||||
switch (type)
|
||||
{
|
||||
case ColorObjectType.InGameBackgroundColor:
|
||||
color = BazookaManager.Instance.GetColorSettingBackground();
|
||||
colorType = new((int)color[0] / 255f, (int)color[1] / 255f, (int)color[2] / 255f);
|
||||
colorType = ApplyModifiers(colorType);
|
||||
var obj = gameObject.GetComponent<Camera>();
|
||||
currentColor = obj.backgroundColor;
|
||||
currentColor.r = colorType.r;
|
||||
currentColor.g = colorType.g;
|
||||
currentColor.b = colorType.b;
|
||||
obj.backgroundColor = currentColor;
|
||||
break;
|
||||
case ColorObjectType.MenuBackgroundColor:
|
||||
color = BazookaManager.Instance.GetColorSettingMenuBackground();
|
||||
colorType = new((int)color[0] / 255f, (int)color[1] / 255f, (int)color[2] / 255f);
|
||||
colorType = ApplyModifiers(colorType);
|
||||
obj = gameObject.GetComponent<Camera>();
|
||||
currentColor = obj.backgroundColor;
|
||||
currentColor.r = colorType.r;
|
||||
currentColor.g = colorType.g;
|
||||
currentColor.b = colorType.b;
|
||||
obj.backgroundColor = currentColor;
|
||||
break;
|
||||
case ColorObjectType.MenuBackgroundColorImage:
|
||||
color = BazookaManager.Instance.GetColorSettingMenuBackground();
|
||||
colorType = new((int)color[0] / 255f, (int)color[1] / 255f, (int)color[2] / 255f);
|
||||
colorType = ApplyModifiers(colorType);
|
||||
var obj2 = gameObject.GetComponent<Image>();
|
||||
currentColor = obj2.color;
|
||||
currentColor.r = colorType.r;
|
||||
currentColor.g = colorType.g;
|
||||
currentColor.b = colorType.b;
|
||||
obj2.color = currentColor;
|
||||
break;
|
||||
case ColorObjectType.MenuBackgroundColorText:
|
||||
color = BazookaManager.Instance.GetColorSettingMenuBackground();
|
||||
colorType = new((int)color[0] / 255f, (int)color[1] / 255f, (int)color[2] / 255f);
|
||||
colorType = ApplyModifiers(colorType);
|
||||
var obj3 = gameObject.GetComponent<TMP_Text>();
|
||||
currentColor = obj3.color;
|
||||
currentColor.r = colorType.r;
|
||||
currentColor.g = colorType.g;
|
||||
currentColor.b = colorType.b;
|
||||
obj3.color = currentColor;
|
||||
break;
|
||||
case ColorObjectType.ButtonColor:
|
||||
color = BazookaManager.Instance.GetColorSettingButton();
|
||||
colorType = new((int)color[0] / 255f, (int)color[1] / 255f, (int)color[2] / 255f);
|
||||
colorType = ApplyModifiers(colorType);
|
||||
obj2 = gameObject.GetComponent<Image>();
|
||||
currentColor = obj2.color;
|
||||
currentColor.r = colorType.r;
|
||||
currentColor.g = colorType.g;
|
||||
currentColor.b = colorType.b;
|
||||
obj2.color = currentColor;
|
||||
break;
|
||||
case ColorObjectType.ButtonColorText:
|
||||
color = BazookaManager.Instance.GetColorSettingButton();
|
||||
colorType = new((int)color[0] / 255f, (int)color[1] / 255f, (int)color[2] / 255f);
|
||||
colorType = ApplyModifiers(colorType);
|
||||
obj3 = gameObject.GetComponent<TMP_Text>();
|
||||
currentColor = obj3.color;
|
||||
currentColor.r = colorType.r;
|
||||
currentColor.g = colorType.g;
|
||||
currentColor.b = colorType.b;
|
||||
obj3.color = currentColor;
|
||||
break;
|
||||
case ColorObjectType.TextColor:
|
||||
color = BazookaManager.Instance.GetColorSettingText();
|
||||
colorType = new((int)color[0] / 255f, (int)color[1] / 255f, (int)color[2] / 255f);
|
||||
colorType = ApplyModifiers(colorType);
|
||||
obj3 = gameObject.GetComponent<TMP_Text>();
|
||||
currentColor = obj3.color;
|
||||
currentColor.r = colorType.r;
|
||||
currentColor.g = colorType.g;
|
||||
currentColor.b = colorType.b;
|
||||
obj3.color = currentColor;
|
||||
break;
|
||||
case ColorObjectType.TextColorImage:
|
||||
color = BazookaManager.Instance.GetColorSettingText();
|
||||
colorType = new((int)color[0] / 255f, (int)color[1] / 255f, (int)color[2] / 255f);
|
||||
colorType = ApplyModifiers(colorType);
|
||||
obj2 = gameObject.GetComponent<Image>();
|
||||
currentColor = obj2.color;
|
||||
currentColor.r = colorType.r;
|
||||
currentColor.g = colorType.g;
|
||||
currentColor.b = colorType.b;
|
||||
obj2.color = currentColor;
|
||||
break;
|
||||
case ColorObjectType.ButtonContentColorImage:
|
||||
color = BazookaManager.Instance.GetColorSettingButtonContent();
|
||||
colorType = new((int)color[0] / 255f, (int)color[1] / 255f, (int)color[2] / 255f);
|
||||
colorType = ApplyModifiers(colorType);
|
||||
obj2 = gameObject.GetComponent<Image>();
|
||||
currentColor = obj2.color;
|
||||
currentColor.r = colorType.r;
|
||||
currentColor.g = colorType.g;
|
||||
currentColor.b = colorType.b;
|
||||
obj2.color = currentColor;
|
||||
break;
|
||||
case ColorObjectType.ButtonContentColorText:
|
||||
color = BazookaManager.Instance.GetColorSettingButtonContent();
|
||||
colorType = new((int)color[0] / 255f, (int)color[1] / 255f, (int)color[2] / 255f);
|
||||
colorType = ApplyModifiers(colorType);
|
||||
obj3 = gameObject.GetComponent<TMP_Text>();
|
||||
currentColor = obj3.color;
|
||||
currentColor.r = colorType.r;
|
||||
currentColor.g = colorType.g;
|
||||
currentColor.b = colorType.b;
|
||||
obj3.color = currentColor;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void Start()
|
||||
{
|
||||
SetColor();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 73b30df2b3a7144b99b75ce70168fd50
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7e945865486fb4598b189eca994d3973
|
||||
@@ -0,0 +1,172 @@
|
||||
using System.Text;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class CustomGamePlayerPauseMenu : MonoBehaviour
|
||||
{
|
||||
public static CustomGamePlayerPauseMenu Instance;
|
||||
public Button backButton;
|
||||
public Button continueButton;
|
||||
public Button statsButton;
|
||||
public Button editUiButton;
|
||||
public Button resetUiButton;
|
||||
public AudioSource songLoop;
|
||||
public TMP_Text scoreText;
|
||||
public TMP_Text boostText;
|
||||
public Button pauseButton;
|
||||
public Button restartButton;
|
||||
public Button jumpButton;
|
||||
public Button rightButton;
|
||||
public Button leftButton;
|
||||
internal bool editingUI = false;
|
||||
|
||||
public GameObject statsMenu;
|
||||
public Button statsMenuExitButton;
|
||||
public TMP_Text statsText;
|
||||
|
||||
public Toggle settingFullscreenToggle;
|
||||
public Toggle settingVSyncToggle;
|
||||
public Toggle settingRandomMusicToggle;
|
||||
public Slider musicSlider;
|
||||
public Slider sfxSlider;
|
||||
public TMP_Text musicSliderText;
|
||||
public TMP_Text sfxSliderText;
|
||||
|
||||
void Awake()
|
||||
{
|
||||
Instance = this;
|
||||
continueButton.onClick.AddListener(CustomGamePlayer.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)boostText.transform).anchoredPosition = new Vector2(0f, -190f);
|
||||
PlayerPrefs.DeleteKey("DraggedUIScoreText");
|
||||
PlayerPrefs.DeleteKey("DraggedUIBoostTextCustom");
|
||||
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(BazookaManager.Instance.GetGameStoreHighScore()));
|
||||
text.AppendLine("Total Normal Berries: " + Tools.FormatWithCommas(BazookaManager.Instance.GetGameStoreTotalNormalBerries()));
|
||||
text.AppendLine("Total Poison Berries: " + Tools.FormatWithCommas(BazookaManager.Instance.GetGameStoreTotalPoisonBerries()));
|
||||
text.AppendLine("Total Slow Berries: " + Tools.FormatWithCommas(BazookaManager.Instance.GetGameStoreTotalSlowBerries()));
|
||||
text.AppendLine("Total Ultra Berries: " + Tools.FormatWithCommas(BazookaManager.Instance.GetGameStoreTotalUltraBerries()));
|
||||
text.AppendLine("Total Speedy Berries: " + Tools.FormatWithCommas(BazookaManager.Instance.GetGameStoreTotalSpeedyBerries()));
|
||||
text.AppendLine("Total Random Berries: " + Tools.FormatWithCommas(BazookaManager.Instance.GetGameStoreTotalRandomBerries()));
|
||||
text.AppendLine("Total Anti Berries: " + Tools.FormatWithCommas(BazookaManager.Instance.GetGameStoreTotalAntiBerries()));
|
||||
text.AppendLine("Total Time Slow Berries: " + Tools.FormatWithCommas(BazookaManager.Instance.GetGameStoreTotalTimeSlowBerries()));
|
||||
text.AppendLine("Total Purple Berries: " + Tools.FormatWithCommas(BazookaManager.Instance.GetGameStoreTotalPurpleBerries()));
|
||||
text.AppendLine("Total Time Freeze Berries: " + Tools.FormatWithCommas(BazookaManager.Instance.GetGameStoreTotalTimeFreezeBerries()));
|
||||
text.AppendLine("Total Evil Berries: " + Tools.FormatWithCommas(BazookaManager.Instance.GetGameStoreTotalEvilBerries()));
|
||||
text.AppendLine("Total Attempts: " + Tools.FormatWithCommas(BazookaManager.Instance.GetGameStoreTotalAttepts()));
|
||||
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);
|
||||
CustomGamePlayer.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;
|
||||
boostText.GetComponent<DraggableUI>().canDrag = !boostText.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 ? CustomGamePlayer.instance.isGrounded ? Color.white : Color.red : Color.white;
|
||||
restartButton.interactable = CustomGamePlayer.instance.score != 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: cb3cceafdff314c81bfc7b7b68db9014
|
||||
@@ -0,0 +1,22 @@
|
||||
using UnityEngine;
|
||||
|
||||
public class CustomGameTempData : MonoBehaviour
|
||||
{
|
||||
public float normalBerryChance;
|
||||
public float poisonBerryChance;
|
||||
public float slowBerryChance;
|
||||
public float ultraBerryChance;
|
||||
public float speedyBerryChance;
|
||||
public float randomBerryChance;
|
||||
public float antiBerryChance;
|
||||
public float nothingBerryChance;
|
||||
public float timeSlowBerryChance;
|
||||
public float purpleBerryChance;
|
||||
public float timeFreezeBerryChance;
|
||||
public float evilBerryChance;
|
||||
|
||||
void Awake()
|
||||
{
|
||||
DontDestroyOnLoad(gameObject);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 75c0e3b54a62242329b74751967b9cf9
|
||||
@@ -1,7 +1,7 @@
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
using UnityEngine.UI;
|
||||
using System.Collections.Generic;
|
||||
|
||||
public class DraggableUI : MonoBehaviour, IDragHandler, IBeginDragHandler
|
||||
{
|
||||
|
||||
@@ -0,0 +1,67 @@
|
||||
using UnityEngine;
|
||||
|
||||
[RequireComponent(typeof(AudioSource))]
|
||||
public class GameMusicHandler : MonoBehaviour
|
||||
{
|
||||
public AudioClip[] audioClips;
|
||||
private AudioSource audioSource;
|
||||
private int lastIndex = -1;
|
||||
private int currentIndex = 0;
|
||||
private bool isPaused = false;
|
||||
|
||||
void Start()
|
||||
{
|
||||
audioSource = GetComponent<AudioSource>();
|
||||
PlayNextClip();
|
||||
}
|
||||
|
||||
void Update()
|
||||
{
|
||||
if (!audioSource.isPlaying && !isPaused) PlayNextClip();
|
||||
}
|
||||
|
||||
void PlayNextClip()
|
||||
{
|
||||
if (audioClips.Length == 0) return;
|
||||
|
||||
int index;
|
||||
if (BazookaManager.Instance.GetSettingRandomMusic())
|
||||
{
|
||||
do index = Random.Range(0, audioClips.Length);
|
||||
while (audioClips.Length > 1 && index == lastIndex);
|
||||
}
|
||||
else
|
||||
{
|
||||
index = currentIndex;
|
||||
currentIndex = (currentIndex + 1) % audioClips.Length;
|
||||
}
|
||||
|
||||
lastIndex = index;
|
||||
audioSource.clip = audioClips[index];
|
||||
audioSource.Play();
|
||||
}
|
||||
|
||||
public void PauseMusic()
|
||||
{
|
||||
if (audioSource.isPlaying)
|
||||
{
|
||||
audioSource.Pause();
|
||||
isPaused = true;
|
||||
}
|
||||
}
|
||||
|
||||
public void ResumeMusic()
|
||||
{
|
||||
if (isPaused)
|
||||
{
|
||||
audioSource.Play();
|
||||
isPaused = false;
|
||||
}
|
||||
}
|
||||
|
||||
public void RestartMusic()
|
||||
{
|
||||
audioSource.Stop();
|
||||
audioSource.Play();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 81a98a63df08841c4b3fdc71ceecda4c
|
||||
+363
-195
@@ -10,7 +10,7 @@ public class GamePlayer : MonoBehaviour
|
||||
public static GamePlayer instance;
|
||||
private readonly float spawnRate = 1f;
|
||||
private float nextSpawnTime;
|
||||
private BigInteger score;
|
||||
internal BigInteger score;
|
||||
private BigInteger attempts;
|
||||
private BigInteger highscore;
|
||||
private BigInteger totalNormalBerries;
|
||||
@@ -18,18 +18,21 @@ public class GamePlayer : MonoBehaviour
|
||||
private BigInteger totalSlowBerries;
|
||||
private BigInteger totalUltraBerries;
|
||||
private BigInteger totalSpeedyBerries;
|
||||
private BigInteger totalRandomBerries;
|
||||
private BigInteger totalAntiBerries;
|
||||
private BigInteger totalTimeSlowBerries;
|
||||
private BigInteger totalPurpleBerries;
|
||||
private BigInteger totalTimeFreezeBerries;
|
||||
private BigInteger totalEvilBerries;
|
||||
private BigInteger totalAttempts;
|
||||
private float boostLeft;
|
||||
private float timeslowLeft;
|
||||
private float timefreezeLeft;
|
||||
private float slownessLeft;
|
||||
private float speedyLeft;
|
||||
private float antiLeft;
|
||||
private float timeSlowLeft;
|
||||
private float timeFreezeLeft;
|
||||
private float screenWidth;
|
||||
private bool isGrounded;
|
||||
internal bool isGrounded;
|
||||
public TMP_Text scoreText;
|
||||
public TMP_Text highScoreText;
|
||||
public TMP_Text boostText;
|
||||
@@ -37,9 +40,6 @@ public class GamePlayer : MonoBehaviour
|
||||
public GameObject pausePanel;
|
||||
public Rigidbody2D rb;
|
||||
public AudioSource backgroundMusic;
|
||||
public TMP_Text fpsCounter;
|
||||
private float nextUpdate;
|
||||
private float fps;
|
||||
public SpriteRenderer overlayRender;
|
||||
private float lastMoveTime;
|
||||
public GameObject berryParent;
|
||||
@@ -76,14 +76,7 @@ public class GamePlayer : MonoBehaviour
|
||||
|
||||
int num = BazookaManager.Instance.GetBirdIcon();
|
||||
int num2 = BazookaManager.Instance.GetBirdOverlay();
|
||||
if (num == 1)
|
||||
{
|
||||
component.sprite = Tools.GetIconForUser(BazookaManager.Instance.GetAccountID() ?? 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
component.sprite = Resources.Load<Sprite>("Icons/Icons/bird_" + num);
|
||||
}
|
||||
component.sprite = Resources.Load<Sprite>("Icons/Icons/bird_" + num);
|
||||
if (num2 == 8)
|
||||
{
|
||||
overlayRender.sprite = Resources.Load<Sprite>("Icons/Overlays/overlay_" + num2);
|
||||
@@ -124,7 +117,12 @@ public class GamePlayer : MonoBehaviour
|
||||
totalSlowBerries = BazookaManager.Instance.GetGameStoreTotalSlowBerries();
|
||||
totalUltraBerries = BazookaManager.Instance.GetGameStoreTotalUltraBerries();
|
||||
totalSpeedyBerries = BazookaManager.Instance.GetGameStoreTotalSpeedyBerries();
|
||||
totalRandomBerries = BazookaManager.Instance.GetGameStoreTotalRandomBerries();
|
||||
totalAntiBerries = BazookaManager.Instance.GetGameStoreTotalAntiBerries();
|
||||
totalTimeSlowBerries = BazookaManager.Instance.GetGameStoreTotalTimeSlowBerries();
|
||||
totalPurpleBerries = BazookaManager.Instance.GetGameStoreTotalPurpleBerries();
|
||||
totalTimeFreezeBerries = BazookaManager.Instance.GetGameStoreTotalTimeFreezeBerries();
|
||||
totalEvilBerries = BazookaManager.Instance.GetGameStoreTotalEvilBerries();
|
||||
totalAttempts = BazookaManager.Instance.GetGameStoreTotalAttepts();
|
||||
|
||||
Cursor.visible = false;
|
||||
@@ -230,9 +228,25 @@ public class GamePlayer : MonoBehaviour
|
||||
{
|
||||
if (score != 0) Respawn();
|
||||
}
|
||||
if (antiLeft > 0f)
|
||||
{
|
||||
string[] berryTags = { "NormalBerry", "PoisonBerry", "SlowBerry", "UltraBerry", "SpeedyBerry", "RandomBerry", "AntiBerry", "TimeSlowBerry", "PurpleBerry", "TimeFreezeBerry", "EvilBerry" };
|
||||
foreach (string tag in berryTags)
|
||||
{
|
||||
foreach (var berry in GameObject.FindGameObjectsWithTag(tag))
|
||||
{
|
||||
UnityEngine.Vector3 dir = berry.transform.position - bird.transform.position;
|
||||
if (dir.magnitude < 3f)
|
||||
{
|
||||
berry.GetComponent<Rigidbody2D>().linearVelocity = dir.normalized * 5f;
|
||||
ClampPosition(berry, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ClampPosition(GameObject obj)
|
||||
void ClampPosition(GameObject obj, bool modifyY = true)
|
||||
{
|
||||
var cam = Camera.main;
|
||||
var pos = obj.transform.position;
|
||||
@@ -244,7 +258,7 @@ public class GamePlayer : MonoBehaviour
|
||||
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);
|
||||
pos.y = Mathf.Clamp(pos.y, min.y + bounds.y, max.y - bounds.y);
|
||||
if (modifyY) pos.y = Mathf.Clamp(pos.y, min.y + bounds.y, max.y - bounds.y);
|
||||
|
||||
obj.transform.position = pos;
|
||||
}
|
||||
@@ -270,15 +284,20 @@ public class GamePlayer : MonoBehaviour
|
||||
speedyLeft -= Time.deltaTime;
|
||||
boostText.text = "Speed expires in " + string.Format("{0:0.0}", speedyLeft) + "s";
|
||||
}
|
||||
else if (timeslowLeft > 0f)
|
||||
else if (antiLeft > 0f)
|
||||
{
|
||||
timeslowLeft -= Time.deltaTime;
|
||||
boostText.text = "Time Slow expires in " + string.Format("{0:0.0}", timeslowLeft) + "s";
|
||||
antiLeft -= Time.deltaTime;
|
||||
boostText.text = "Berry repellent expires in " + string.Format("{0:0.0}", antiLeft) + "s";
|
||||
}
|
||||
else if (timefreezeLeft > 0f)
|
||||
else if (timeSlowLeft > 0f)
|
||||
{
|
||||
timefreezeLeft -= Time.deltaTime;
|
||||
boostText.text = "Time Freeze expires in " + string.Format("{0:0.0}", timefreezeLeft) + "s";
|
||||
timeSlowLeft -= Time.deltaTime;
|
||||
boostText.text = "Time Slow expires in " + string.Format("{0:0.0}", timeSlowLeft) + "s";
|
||||
}
|
||||
else if (timeFreezeLeft > 0f)
|
||||
{
|
||||
timeFreezeLeft -= Time.deltaTime;
|
||||
boostText.text = "Time Freeze expires in " + string.Format("{0:0.0}", timeFreezeLeft) + "s";
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -302,60 +321,69 @@ public class GamePlayer : MonoBehaviour
|
||||
nextSpawnTime = Time.time + 1f / spawnRate;
|
||||
}
|
||||
float spawnProbability = Random.value;
|
||||
if ((int)timefreezeLeft != 0) return;
|
||||
if ((int)timeFreezeLeft != 0) return;
|
||||
if (!pausePanel.activeSelf)
|
||||
{
|
||||
GameObject newBerry = new("Berry");
|
||||
newBerry.transform.SetParent(berryParent.transform);
|
||||
SpriteRenderer spriteRenderer = newBerry.AddComponent<SpriteRenderer>();
|
||||
|
||||
if (spawnProbability <= 0.35f)
|
||||
if (spawnProbability <= 0.275f)
|
||||
{
|
||||
spriteRenderer.sprite = Resources.Load<Sprite>("Berries/Berry");
|
||||
newBerry.tag = "NormalBerry";
|
||||
}
|
||||
else if (spawnProbability <= 0.50f)
|
||||
else if (spawnProbability <= 0.40f)
|
||||
{
|
||||
spriteRenderer.sprite = Resources.Load<Sprite>("Berries/PoisonBerry");
|
||||
newBerry.tag = "PoisonBerry";
|
||||
}
|
||||
else if (spawnProbability <= 0.60f)
|
||||
else if (spawnProbability <= 0.50f)
|
||||
{
|
||||
spriteRenderer.sprite = Resources.Load<Sprite>("Berries/SlowBerry");
|
||||
newBerry.tag = "SlowBerry";
|
||||
}
|
||||
else if (spawnProbability <= 0.70f)
|
||||
else if (spawnProbability <= 0.60f)
|
||||
{
|
||||
spriteRenderer.sprite = Resources.Load<Sprite>("Berries/UltraBerry");
|
||||
newBerry.tag = "UltraBerry";
|
||||
}
|
||||
else if (spawnProbability <= 0.80f)
|
||||
else if (spawnProbability <= 0.70f)
|
||||
{
|
||||
spriteRenderer.sprite = Resources.Load<Sprite>("Berries/SpeedyBerry");
|
||||
newBerry.tag = "SpeedyBerry";
|
||||
}
|
||||
else if (spawnProbability <= 0.85f)
|
||||
else if (spawnProbability <= 0.75f)
|
||||
{
|
||||
spriteRenderer.sprite = Resources.Load<Sprite>("Berries/PurpleBerry");
|
||||
newBerry.tag = "PurpleBerry";
|
||||
spriteRenderer.sprite = Resources.Load<Sprite>("Berries/BerryNoColor");
|
||||
newBerry.tag = "RandomBerry";
|
||||
RainbowSpriteRender randomBerryRainbowImage = newBerry.AddComponent<RainbowSpriteRender>();
|
||||
randomBerryRainbowImage.frequency = 5f;
|
||||
}
|
||||
else if (spawnProbability <= 0.90f)
|
||||
else if (spawnProbability <= 0.8f)
|
||||
{
|
||||
spriteRenderer.sprite = Resources.Load<Sprite>("Berries/AntiBerry");
|
||||
newBerry.tag = "AntiBerry";
|
||||
}
|
||||
else if (spawnProbability <= 0.85f)
|
||||
{
|
||||
spriteRenderer.sprite = Resources.Load<Sprite>("Berries/TimeSlowBerry");
|
||||
newBerry.tag = "TimeSlowBerry";
|
||||
}
|
||||
else if (spawnProbability <= 0.95f)
|
||||
else if (spawnProbability <= 0.9f)
|
||||
{
|
||||
spriteRenderer.sprite = Resources.Load<Sprite>("Berries/EvilBerry");
|
||||
newBerry.tag = "EvilBerry";
|
||||
spriteRenderer.sprite = Resources.Load<Sprite>("Berries/PurpleBerry");
|
||||
newBerry.tag = "PurpleBerry";
|
||||
}
|
||||
else
|
||||
else if (spawnProbability <= 0.95f)
|
||||
{
|
||||
spriteRenderer.sprite = Resources.Load<Sprite>("Berries/TimeFreezeBerry");
|
||||
newBerry.tag = "TimeFreezeBerry";
|
||||
}
|
||||
|
||||
|
||||
else
|
||||
{
|
||||
spriteRenderer.sprite = Resources.Load<Sprite>("Berries/EvilBerry");
|
||||
newBerry.tag = "EvilBerry";
|
||||
}
|
||||
spriteRenderer.sortingOrder = -5;
|
||||
|
||||
float screenWidth = Camera.main.orthographicSize * 2 * Camera.main.aspect;
|
||||
@@ -370,25 +398,41 @@ public class GamePlayer : MonoBehaviour
|
||||
|
||||
void Update()
|
||||
{
|
||||
if (BazookaManager.Instance.GetSettingShowFPS() && Time.time > nextUpdate)
|
||||
foreach (AudioSource audio in FindObjectsByType<AudioSource>(FindObjectsSortMode.None))
|
||||
{
|
||||
fps = 1f / Time.deltaTime;
|
||||
fpsCounter.text = "FPS: " + Mathf.Round(fps);
|
||||
nextUpdate = Time.time + 0.25f;
|
||||
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("TimeSlowBerry"))
|
||||
.Concat(GameObject.FindGameObjectsWithTag("PurpleBerry"))
|
||||
.Concat(GameObject.FindGameObjectsWithTag("TimeFreezeBerry"))
|
||||
.Concat(GameObject.FindGameObjectsWithTag("EvilBerry"))
|
||||
.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[] timeslowBerries = GameObject.FindGameObjectsWithTag("TimeSlowBerry");
|
||||
GameObject[] randomBerries = GameObject.FindGameObjectsWithTag("RandomBerry");
|
||||
GameObject[] antiBerries = GameObject.FindGameObjectsWithTag("AntiBerry");
|
||||
GameObject[] timeSlowBerries = GameObject.FindGameObjectsWithTag("TimeSlowBerry");
|
||||
GameObject[] purpleBerries = GameObject.FindGameObjectsWithTag("PurpleBerry");
|
||||
GameObject[] timefreezeBerries = GameObject.FindGameObjectsWithTag("TimeFreezeBerry");
|
||||
GameObject[] timeFreezeBerries = GameObject.FindGameObjectsWithTag("TimeFreezeBerry");
|
||||
GameObject[] evilBerries = GameObject.FindGameObjectsWithTag("EvilBerry");
|
||||
|
||||
if (!pausePanel.activeSelf)
|
||||
@@ -407,30 +451,26 @@ public class GamePlayer : MonoBehaviour
|
||||
}
|
||||
else if (UnityEngine.Vector3.Distance(bird.transform.position, normalBerry.transform.position) < 1.5f)
|
||||
{
|
||||
AudioSource.PlayClipAtPoint(Resources.Load<AudioClip>("Sounds/Eat"), Camera.main.transform.position, 1.2f * BazookaManager.Instance.GetSettingSFXVolume());
|
||||
Destroy(normalBerry);
|
||||
totalNormalBerries++;
|
||||
UpdateStats(1, 0);
|
||||
DoNormalBerry(normalBerry);
|
||||
}
|
||||
|
||||
if (timefreezeLeft > 0)
|
||||
if (timeFreezeLeft > 0)
|
||||
{
|
||||
normalBerry.GetComponent<Rigidbody2D>().linearVelocity = new UnityEngine.Vector2(0f, 0f);
|
||||
}
|
||||
else if (timeSlowLeft > 0)
|
||||
{
|
||||
normalBerry.GetComponent<Rigidbody2D>().linearVelocity = new UnityEngine.Vector2(0f, -2f);
|
||||
}
|
||||
else if (speedyLeft > 0)
|
||||
{
|
||||
normalBerry.GetComponent<Rigidbody2D>().linearVelocity = new UnityEngine.Vector2(0f, -7.5f);
|
||||
}
|
||||
else if (timeslowLeft > 0)
|
||||
{
|
||||
normalBerry.GetComponent<Rigidbody2D>().linearVelocity = new UnityEngine.Vector2(0f, -2f);
|
||||
}
|
||||
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)
|
||||
@@ -439,30 +479,26 @@ public class GamePlayer : MonoBehaviour
|
||||
}
|
||||
else if (UnityEngine.Vector3.Distance(bird.transform.position, poisonBerry.transform.position) < 1.5f)
|
||||
{
|
||||
AudioSource.PlayClipAtPoint(Resources.Load<AudioClip>("Sounds/Death"), Camera.main.transform.position, 1.2f * BazookaManager.Instance.GetSettingSFXVolume());
|
||||
Respawn();
|
||||
totalPoisonBerries++;
|
||||
UpdateStats(0, 0);
|
||||
DoPoisonBerry();
|
||||
}
|
||||
|
||||
if (timefreezeLeft > 0)
|
||||
if (timeFreezeLeft > 0)
|
||||
{
|
||||
poisonBerry.GetComponent<Rigidbody2D>().linearVelocity = new UnityEngine.Vector2(0f, 0f);
|
||||
}
|
||||
else if (timeSlowLeft > 0)
|
||||
{
|
||||
poisonBerry.GetComponent<Rigidbody2D>().linearVelocity = new UnityEngine.Vector2(0f, -2f);
|
||||
}
|
||||
else if (speedyLeft > 0)
|
||||
{
|
||||
poisonBerry.GetComponent<Rigidbody2D>().linearVelocity = new UnityEngine.Vector2(0f, -7.5f);
|
||||
}
|
||||
else if (timeslowLeft > 0)
|
||||
{
|
||||
poisonBerry.GetComponent<Rigidbody2D>().linearVelocity = new UnityEngine.Vector2(0f, -2f);
|
||||
}
|
||||
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)
|
||||
@@ -471,36 +507,26 @@ public class GamePlayer : MonoBehaviour
|
||||
}
|
||||
else if (UnityEngine.Vector3.Distance(bird.transform.position, slowBerry.transform.position) < 1.5f)
|
||||
{
|
||||
AudioSource.PlayClipAtPoint(Resources.Load<AudioClip>("Sounds/Downgrade"), Camera.main.transform.position, 0.35f * BazookaManager.Instance.GetSettingSFXVolume());
|
||||
Destroy(slowBerry);
|
||||
boostLeft = 0f;
|
||||
slownessLeft = 10f;
|
||||
speedyLeft = 0f;
|
||||
totalSlowBerries++;
|
||||
if (score > 0)
|
||||
{
|
||||
UpdateStats(-1, 0);
|
||||
}
|
||||
DoSlowBerry(slowBerry);
|
||||
}
|
||||
|
||||
if (timefreezeLeft > 0)
|
||||
if (timeFreezeLeft > 0)
|
||||
{
|
||||
slowBerry.GetComponent<Rigidbody2D>().linearVelocity = new UnityEngine.Vector2(0f, 0f);
|
||||
}
|
||||
else if (timeSlowLeft > 0)
|
||||
{
|
||||
slowBerry.GetComponent<Rigidbody2D>().linearVelocity = new UnityEngine.Vector2(0f, -2f);
|
||||
}
|
||||
else if (speedyLeft > 0)
|
||||
{
|
||||
slowBerry.GetComponent<Rigidbody2D>().linearVelocity = new UnityEngine.Vector2(0f, -7.5f);
|
||||
}
|
||||
else if (timeslowLeft > 0)
|
||||
{
|
||||
slowBerry.GetComponent<Rigidbody2D>().linearVelocity = new UnityEngine.Vector2(0f, -2f);
|
||||
}
|
||||
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)
|
||||
@@ -509,42 +535,26 @@ public class GamePlayer : MonoBehaviour
|
||||
}
|
||||
else if (UnityEngine.Vector3.Distance(bird.transform.position, ultraBerry.transform.position) < 1.5f)
|
||||
{
|
||||
AudioSource.PlayClipAtPoint(Resources.Load<AudioClip>("Sounds/Powerup"), Camera.main.transform.position, 0.35f * BazookaManager.Instance.GetSettingSFXVolume());
|
||||
Destroy(ultraBerry);
|
||||
totalUltraBerries++;
|
||||
timeslowLeft = 0f;
|
||||
timefreezeLeft = 0f;
|
||||
speedyLeft = 0f;
|
||||
if (slownessLeft > 0f)
|
||||
{
|
||||
slownessLeft = 0f;
|
||||
UpdateStats(1, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
boostLeft += 10f;
|
||||
UpdateStats(5, 0);
|
||||
}
|
||||
DoUltraBerry(ultraBerry);
|
||||
}
|
||||
|
||||
if (timefreezeLeft > 0)
|
||||
if (timeFreezeLeft > 0)
|
||||
{
|
||||
ultraBerry.GetComponent<Rigidbody2D>().linearVelocity = new UnityEngine.Vector2(0f, 0f);
|
||||
}
|
||||
else if (timeSlowLeft > 0)
|
||||
{
|
||||
ultraBerry.GetComponent<Rigidbody2D>().linearVelocity = new UnityEngine.Vector2(0f, -2f);
|
||||
}
|
||||
else if (speedyLeft > 0)
|
||||
{
|
||||
ultraBerry.GetComponent<Rigidbody2D>().linearVelocity = new UnityEngine.Vector2(0f, -7.5f);
|
||||
}
|
||||
else if (timeslowLeft > 0)
|
||||
{
|
||||
ultraBerry.GetComponent<Rigidbody2D>().linearVelocity = new UnityEngine.Vector2(0f, -2f);
|
||||
}
|
||||
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)
|
||||
@@ -553,72 +563,117 @@ public class GamePlayer : MonoBehaviour
|
||||
}
|
||||
else if (UnityEngine.Vector3.Distance(bird.transform.position, speedyBerry.transform.position) < 1.5f)
|
||||
{
|
||||
AudioSource.PlayClipAtPoint(Resources.Load<AudioClip>("Sounds/SpeedyPowerup"), Camera.main.transform.position, 0.35f * BazookaManager.Instance.GetSettingSFXVolume());
|
||||
Destroy(speedyBerry);
|
||||
boostLeft = 0f;
|
||||
slownessLeft = 0f;
|
||||
timeslowLeft = 0f;
|
||||
timefreezeLeft = 0f;
|
||||
speedyLeft = 10f;
|
||||
totalSpeedyBerries++;
|
||||
UpdateStats(10, 0);
|
||||
DoSpeedyBerry(speedyBerry);
|
||||
}
|
||||
|
||||
if (timefreezeLeft > 0)
|
||||
if (timeFreezeLeft > 0)
|
||||
{
|
||||
speedyBerry.GetComponent<Rigidbody2D>().linearVelocity = new UnityEngine.Vector2(0f, 0f);
|
||||
}
|
||||
else if (timeSlowLeft > 0)
|
||||
{
|
||||
speedyBerry.GetComponent<Rigidbody2D>().linearVelocity = new UnityEngine.Vector2(0f, -2f);
|
||||
}
|
||||
else if (speedyLeft > 0)
|
||||
{
|
||||
speedyBerry.GetComponent<Rigidbody2D>().linearVelocity = new UnityEngine.Vector2(0f, -7.5f);
|
||||
}
|
||||
else if (timeslowLeft > 0)
|
||||
{
|
||||
speedyBerry.GetComponent<Rigidbody2D>().linearVelocity = new UnityEngine.Vector2(0f, -2f);
|
||||
}
|
||||
else
|
||||
{
|
||||
speedyBerry.GetComponent<Rigidbody2D>().linearVelocity = new UnityEngine.Vector2(0f, -4f);
|
||||
}
|
||||
}
|
||||
|
||||
foreach (GameObject timeslowBerry in timeslowBerries)
|
||||
foreach (GameObject randomBerry in randomBerries)
|
||||
{
|
||||
if (timeslowBerry.transform.position.y < 0f - Camera.main.orthographicSize - 1f)
|
||||
if (randomBerry.transform.position.y < 0f - Camera.main.orthographicSize - 1f)
|
||||
{
|
||||
Destroy(timeslowBerry);
|
||||
Destroy(randomBerry);
|
||||
}
|
||||
else if (UnityEngine.Vector3.Distance(bird.transform.position, timeslowBerry.transform.position) < 1.5f)
|
||||
else if (UnityEngine.Vector3.Distance(bird.transform.position, randomBerry.transform.position) < 1.5f)
|
||||
{
|
||||
AudioSource.PlayClipAtPoint(Resources.Load<AudioClip>("Sounds/SlowMotion"), Camera.main.transform.position, 1.2f * BazookaManager.Instance.GetSettingSFXVolume());
|
||||
Destroy(timeslowBerry);
|
||||
boostLeft = 0f;
|
||||
timeslowLeft = 0f;
|
||||
timefreezeLeft = 0f;
|
||||
speedyLeft = 0f;
|
||||
timeslowLeft = 10f;
|
||||
totalTimeSlowBerries++;
|
||||
UpdateStats(1, 0);
|
||||
totalRandomBerries++;
|
||||
System.Action[] funcs = {
|
||||
() => DoNormalBerry(randomBerry),
|
||||
() => DoSlowBerry(randomBerry),
|
||||
() => DoUltraBerry(randomBerry),
|
||||
() => DoSpeedyBerry(randomBerry),
|
||||
() => DoAntiBerry(randomBerry)
|
||||
};
|
||||
funcs[Random.Range(0, funcs.Length)]();
|
||||
}
|
||||
|
||||
if (timefreezeLeft > 0)
|
||||
if (timeFreezeLeft > 0)
|
||||
{
|
||||
timeslowBerry.GetComponent<Rigidbody2D>().linearVelocity = new UnityEngine.Vector2(0f, 0f);
|
||||
randomBerry.GetComponent<Rigidbody2D>().linearVelocity = new UnityEngine.Vector2(0f, 0f);
|
||||
}
|
||||
else if (timeSlowLeft > 0)
|
||||
{
|
||||
randomBerry.GetComponent<Rigidbody2D>().linearVelocity = new UnityEngine.Vector2(0f, -2f);
|
||||
}
|
||||
else if (speedyLeft > 0)
|
||||
{
|
||||
timeslowBerry.GetComponent<Rigidbody2D>().linearVelocity = new UnityEngine.Vector2(0f, -7.5f);
|
||||
}
|
||||
else if (timeslowLeft > 0)
|
||||
{
|
||||
timeslowBerry.GetComponent<Rigidbody2D>().linearVelocity = new UnityEngine.Vector2(0f, -2f);
|
||||
randomBerry.GetComponent<Rigidbody2D>().linearVelocity = new UnityEngine.Vector2(0f, -7.5f);
|
||||
}
|
||||
else
|
||||
{
|
||||
timeslowBerry.GetComponent<Rigidbody2D>().linearVelocity = new UnityEngine.Vector2(0f, -4f);
|
||||
{
|
||||
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 (timeFreezeLeft > 0)
|
||||
{
|
||||
antiBerry.GetComponent<Rigidbody2D>().linearVelocity = new UnityEngine.Vector2(0f, 0f);
|
||||
}
|
||||
else if (timeSlowLeft > 0)
|
||||
{
|
||||
antiBerry.GetComponent<Rigidbody2D>().linearVelocity = new UnityEngine.Vector2(0f, -2f);
|
||||
}
|
||||
else 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 timeSlowBerry in timeSlowBerries)
|
||||
{
|
||||
if (timeSlowBerry.transform.position.y < 0f - Camera.main.orthographicSize - 1f)
|
||||
{
|
||||
Destroy(timeSlowBerry);
|
||||
}
|
||||
else if (UnityEngine.Vector3.Distance(bird.transform.position, timeSlowBerry.transform.position) < 1.5f)
|
||||
{
|
||||
totalTimeSlowBerries++;
|
||||
DoTimeSlowBerry(timeSlowBerry);
|
||||
}
|
||||
if (timeFreezeLeft > 0)
|
||||
{
|
||||
timeSlowBerry.GetComponent<Rigidbody2D>().linearVelocity = new UnityEngine.Vector2(0f, 0f);
|
||||
}
|
||||
else if (timeSlowLeft > 0)
|
||||
{
|
||||
timeSlowBerry.GetComponent<Rigidbody2D>().linearVelocity = new UnityEngine.Vector2(0f, -2f);
|
||||
}
|
||||
else if (speedyLeft > 0)
|
||||
{
|
||||
timeSlowBerry.GetComponent<Rigidbody2D>().linearVelocity = new UnityEngine.Vector2(0f, -7.5f);
|
||||
}
|
||||
else
|
||||
{
|
||||
timeSlowBerry.GetComponent<Rigidbody2D>().linearVelocity = new UnityEngine.Vector2(0f, -4f);
|
||||
}
|
||||
}
|
||||
|
||||
foreach (GameObject purpleBerry in purpleBerries)
|
||||
{
|
||||
if (purpleBerry.transform.position.y < 0f - Camera.main.orthographicSize - 1f)
|
||||
@@ -627,63 +682,52 @@ public class GamePlayer : MonoBehaviour
|
||||
}
|
||||
else if (UnityEngine.Vector3.Distance(bird.transform.position, purpleBerry.transform.position) < 1.5f)
|
||||
{
|
||||
AudioSource.PlayClipAtPoint(Resources.Load<AudioClip>("Sounds/Eat"), Camera.main.transform.position, 1.2f * BazookaManager.Instance.GetSettingSFXVolume());
|
||||
Destroy(purpleBerry);
|
||||
totalPurpleBerries++;
|
||||
UpdateStats(15, 0);
|
||||
DoPurpleBerry(purpleBerry);
|
||||
}
|
||||
|
||||
if (timefreezeLeft > 0)
|
||||
if (timeFreezeLeft > 0)
|
||||
{
|
||||
purpleBerry.GetComponent<Rigidbody2D>().linearVelocity = new UnityEngine.Vector2(0f, 0f);
|
||||
}
|
||||
else if (timeSlowLeft > 0)
|
||||
{
|
||||
purpleBerry.GetComponent<Rigidbody2D>().linearVelocity = new UnityEngine.Vector2(0f, -2f);
|
||||
}
|
||||
else if (speedyLeft > 0)
|
||||
{
|
||||
purpleBerry.GetComponent<Rigidbody2D>().linearVelocity = new UnityEngine.Vector2(0f, -7.5f);
|
||||
}
|
||||
else if (timeslowLeft > 0)
|
||||
{
|
||||
purpleBerry.GetComponent<Rigidbody2D>().linearVelocity = new UnityEngine.Vector2(0f, -2f);
|
||||
}
|
||||
else
|
||||
{
|
||||
purpleBerry.GetComponent<Rigidbody2D>().linearVelocity = new UnityEngine.Vector2(0f, -4f);
|
||||
}
|
||||
}
|
||||
|
||||
foreach (GameObject timefreezeBerry in timefreezeBerries)
|
||||
foreach (GameObject timeFreezeBerry in timeFreezeBerries)
|
||||
{
|
||||
if (timefreezeBerry.transform.position.y < 0f - Camera.main.orthographicSize - 1f)
|
||||
if (timeFreezeBerry.transform.position.y < 0f - Camera.main.orthographicSize - 1f)
|
||||
{
|
||||
Destroy(timefreezeBerry);
|
||||
Destroy(timeFreezeBerry);
|
||||
}
|
||||
else if (UnityEngine.Vector3.Distance(bird.transform.position, timefreezeBerry.transform.position) < 1.5f)
|
||||
else if (UnityEngine.Vector3.Distance(bird.transform.position, timeFreezeBerry.transform.position) < 1.5f)
|
||||
{
|
||||
AudioSource.PlayClipAtPoint(Resources.Load<AudioClip>("Sounds/TimeStop"), Camera.main.transform.position, 1.2f * BazookaManager.Instance.GetSettingSFXVolume());
|
||||
Destroy(timefreezeBerry);
|
||||
boostLeft = 0f;
|
||||
speedyLeft = 0f;
|
||||
slownessLeft = 0f;
|
||||
timeslowLeft = 0f;
|
||||
timefreezeLeft = 5f;
|
||||
totalTimeFreezeBerries++;
|
||||
DoTimeFreezeBerry(timeFreezeBerry);
|
||||
}
|
||||
|
||||
if (timefreezeLeft > 0)
|
||||
if (timeFreezeLeft > 0)
|
||||
{
|
||||
timefreezeBerry.GetComponent<Rigidbody2D>().linearVelocity = new UnityEngine.Vector2(0f, 0f);
|
||||
timeFreezeBerry.GetComponent<Rigidbody2D>().linearVelocity = new UnityEngine.Vector2(0f, 0f);
|
||||
}
|
||||
else if (timeSlowLeft > 0)
|
||||
{
|
||||
timeFreezeBerry.GetComponent<Rigidbody2D>().linearVelocity = new UnityEngine.Vector2(0f, -2f);
|
||||
}
|
||||
else if (speedyLeft > 0)
|
||||
{
|
||||
timefreezeBerry.GetComponent<Rigidbody2D>().linearVelocity = new UnityEngine.Vector2(0f, -7.5f);
|
||||
}
|
||||
else if (timeslowLeft > 0)
|
||||
{
|
||||
timefreezeBerry.GetComponent<Rigidbody2D>().linearVelocity = new UnityEngine.Vector2(0f, -2f);
|
||||
timeFreezeBerry.GetComponent<Rigidbody2D>().linearVelocity = new UnityEngine.Vector2(0f, -7.5f);
|
||||
}
|
||||
else
|
||||
{
|
||||
timefreezeBerry.GetComponent<Rigidbody2D>().linearVelocity = new UnityEngine.Vector2(0f, -4f);
|
||||
timeFreezeBerry.GetComponent<Rigidbody2D>().linearVelocity = new UnityEngine.Vector2(0f, -4f);
|
||||
}
|
||||
}
|
||||
foreach (GameObject evilBerry in evilBerries)
|
||||
@@ -694,35 +738,27 @@ public class GamePlayer : MonoBehaviour
|
||||
}
|
||||
else if (UnityEngine.Vector3.Distance(bird.transform.position, evilBerry.transform.position) < 1.5f)
|
||||
{
|
||||
AudioSource.PlayClipAtPoint(Resources.Load<AudioClip>("Sounds/EvilLaugh"), Camera.main.transform.position, 1.2f * BazookaManager.Instance.GetSettingSFXVolume());
|
||||
Destroy(evilBerry);
|
||||
totalEvilBerries++;
|
||||
if (score > 9)
|
||||
{
|
||||
UpdateStats(-10, 0);
|
||||
}
|
||||
DoEvilBerry(evilBerry);
|
||||
}
|
||||
|
||||
if (timefreezeLeft > 0)
|
||||
if (timeFreezeLeft > 0)
|
||||
{
|
||||
evilBerry.GetComponent<Rigidbody2D>().linearVelocity = new UnityEngine.Vector2(0f, 0f);
|
||||
}
|
||||
else if (timeSlowLeft > 0)
|
||||
{
|
||||
evilBerry.GetComponent<Rigidbody2D>().linearVelocity = new UnityEngine.Vector2(0f, -2f);
|
||||
}
|
||||
else if (speedyLeft > 0)
|
||||
{
|
||||
evilBerry.GetComponent<Rigidbody2D>().linearVelocity = new UnityEngine.Vector2(0f, -7.5f);
|
||||
}
|
||||
else if (timeslowLeft > 0)
|
||||
{
|
||||
evilBerry.GetComponent<Rigidbody2D>().linearVelocity = new UnityEngine.Vector2(0f, -2f);
|
||||
}
|
||||
else
|
||||
{
|
||||
evilBerry.GetComponent<Rigidbody2D>().linearVelocity = new UnityEngine.Vector2(0f, -4f);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
rb.gravityScale = 0f;
|
||||
@@ -732,9 +768,11 @@ public class GamePlayer : MonoBehaviour
|
||||
.Concat(slowBerries)
|
||||
.Concat(ultraBerries)
|
||||
.Concat(speedyBerries)
|
||||
.Concat(timeslowBerries)
|
||||
.Concat(randomBerries)
|
||||
.Concat(antiBerries)
|
||||
.Concat(timeSlowBerries)
|
||||
.Concat(purpleBerries)
|
||||
.Concat(timefreezeBerries)
|
||||
.Concat(timeFreezeBerries)
|
||||
.Concat(evilBerries)
|
||||
.ToArray();
|
||||
foreach (GameObject berry in allberries)
|
||||
@@ -753,10 +791,11 @@ public class GamePlayer : MonoBehaviour
|
||||
rb.linearVelocity = UnityEngine.Vector2.zero;
|
||||
score = 0;
|
||||
boostLeft = 0f;
|
||||
timeslowLeft = 0f;
|
||||
timefreezeLeft = 0f;
|
||||
slownessLeft = 0f;
|
||||
speedyLeft = 0f;
|
||||
antiLeft = 0f;
|
||||
timeSlowLeft = 0f;
|
||||
timeFreezeLeft = 0f;
|
||||
UpdateStats(0, 1);
|
||||
|
||||
GameObject[] allberries = GameObject.FindGameObjectsWithTag("NormalBerry")
|
||||
@@ -764,6 +803,8 @@ public class GamePlayer : MonoBehaviour
|
||||
.Concat(GameObject.FindGameObjectsWithTag("SlowBerry"))
|
||||
.Concat(GameObject.FindGameObjectsWithTag("UltraBerry"))
|
||||
.Concat(GameObject.FindGameObjectsWithTag("SpeedyBerry"))
|
||||
.Concat(GameObject.FindGameObjectsWithTag("RandomBerry"))
|
||||
.Concat(GameObject.FindGameObjectsWithTag("AntiBerry"))
|
||||
.Concat(GameObject.FindGameObjectsWithTag("TimeSlowBerry"))
|
||||
.Concat(GameObject.FindGameObjectsWithTag("PurpleBerry"))
|
||||
.Concat(GameObject.FindGameObjectsWithTag("TimeFreezeBerry"))
|
||||
@@ -777,12 +818,16 @@ public class GamePlayer : MonoBehaviour
|
||||
|
||||
void UpdateStats(BigInteger scoreAddAmount, BigInteger attemptAddAmount)
|
||||
{
|
||||
var prefix = "";
|
||||
var suffix = "";
|
||||
score += scoreAddAmount;
|
||||
totalAttempts += attemptAddAmount;
|
||||
attempts += attemptAddAmount;
|
||||
if (score > highscore)
|
||||
if (score >= highscore)
|
||||
{
|
||||
highscore = score;
|
||||
prefix = "<color=#7FFFD4>";
|
||||
suffix = "</color>";
|
||||
}
|
||||
BazookaManager.Instance.SetGameStoreHighScore(highscore);
|
||||
BazookaManager.Instance.SetGameStoreTotalNormalBerries(totalNormalBerries);
|
||||
@@ -790,13 +835,15 @@ public class GamePlayer : MonoBehaviour
|
||||
BazookaManager.Instance.SetGameStoreTotalSlowBerries(totalSlowBerries);
|
||||
BazookaManager.Instance.SetGameStoreTotalUltraBerries(totalUltraBerries);
|
||||
BazookaManager.Instance.SetGameStoreTotalSpeedyBerries(totalSpeedyBerries);
|
||||
BazookaManager.Instance.SetGameStoreTotalRandomBerries(totalRandomBerries);
|
||||
BazookaManager.Instance.SetGameStoreTotalAntiBerries(totalAntiBerries);
|
||||
BazookaManager.Instance.SetGameStoreTotalTimeSlowBerries(totalTimeSlowBerries);
|
||||
BazookaManager.Instance.SetGameStoreTotalPurpleBerries(totalPurpleBerries);
|
||||
BazookaManager.Instance.SetGameStoreTotalTimeFreezeBerries(totalTimeFreezeBerries);
|
||||
BazookaManager.Instance.SetGameStoreTotalEvilBerries(totalEvilBerries);
|
||||
BazookaManager.Instance.SetGameStoreTotalAttepts(totalAttempts);
|
||||
scoreText.text = $"Score: {Tools.FormatWithCommas(score)} \\u2022 Attempts: {Tools.FormatWithCommas(attempts)}";
|
||||
highScoreText.text = $"High Score: {Tools.FormatWithCommas(highscore)} \\u2022 Total Attempts: {Tools.FormatWithCommas(totalAttempts)}";
|
||||
highScoreText.text = prefix + $"High Score: {Tools.FormatWithCommas(highscore) + suffix} \\u2022 Total Attempts: {Tools.FormatWithCommas(totalAttempts)}";
|
||||
if (Application.isMobilePlatform) restartButton.interactable = score != 0;
|
||||
}
|
||||
|
||||
@@ -830,7 +877,7 @@ public class GamePlayer : MonoBehaviour
|
||||
{
|
||||
Cursor.visible = true;
|
||||
Cursor.lockState = CursorLockMode.None;
|
||||
backgroundMusic.Pause();
|
||||
backgroundMusic.GetComponent<GameMusicHandler>().PauseMusic();
|
||||
pausePanel.SetActive(true);
|
||||
}
|
||||
|
||||
@@ -839,7 +886,7 @@ public class GamePlayer : MonoBehaviour
|
||||
lastMoveTime = Time.time;
|
||||
Cursor.visible = false;
|
||||
Cursor.lockState = CursorLockMode.Locked;
|
||||
backgroundMusic.Play();
|
||||
backgroundMusic.GetComponent<GameMusicHandler>().ResumeMusic();
|
||||
pausePanel.SetActive(false);
|
||||
if (GamePlayerPauseMenu.Instance.editingUI == true) GamePlayerPauseMenu.Instance.ToggleEditingUI();
|
||||
}
|
||||
@@ -854,4 +901,125 @@ public class GamePlayer : MonoBehaviour
|
||||
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;
|
||||
timeSlowLeft = 0f;
|
||||
timeFreezeLeft = 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;
|
||||
if (slownessLeft > 0f)
|
||||
{
|
||||
slownessLeft = 0f;
|
||||
UpdateStats(1, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
boostLeft += 10f;
|
||||
UpdateStats(5, 0);
|
||||
}
|
||||
timeSlowLeft = 0f;
|
||||
timeFreezeLeft = 0f;
|
||||
}
|
||||
|
||||
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;
|
||||
timeSlowLeft = 0f;
|
||||
timeFreezeLeft = 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;
|
||||
timeSlowLeft = 0f;
|
||||
timeFreezeLeft = 0f;
|
||||
UpdateStats(0, 0);
|
||||
}
|
||||
|
||||
void DoTimeSlowBerry(GameObject berry)
|
||||
{
|
||||
AudioSource.PlayClipAtPoint(Resources.Load<AudioClip>("Sounds/SlowMotion"), Camera.main.transform.position, 1.2f * BazookaManager.Instance.GetSettingSFXVolume());
|
||||
Destroy(berry);
|
||||
boostLeft = 0f;
|
||||
slownessLeft = 0f;
|
||||
speedyLeft = 0f;
|
||||
antiLeft = 0f;
|
||||
timeSlowLeft = 10f;
|
||||
timeFreezeLeft = 0f;
|
||||
UpdateStats(1, 0);
|
||||
}
|
||||
|
||||
void DoPurpleBerry(GameObject berry)
|
||||
{
|
||||
AudioSource.PlayClipAtPoint(Resources.Load<AudioClip>("Sounds/Eat"), Camera.main.transform.position, 1.2f * BazookaManager.Instance.GetSettingSFXVolume());
|
||||
Destroy(berry);
|
||||
UpdateStats(15, 0);
|
||||
}
|
||||
|
||||
void DoTimeFreezeBerry(GameObject berry)
|
||||
{
|
||||
AudioSource.PlayClipAtPoint(Resources.Load<AudioClip>("Sounds/TimeStop"), Camera.main.transform.position, 1.2f * BazookaManager.Instance.GetSettingSFXVolume());
|
||||
Destroy(berry);
|
||||
boostLeft = 0f;
|
||||
slownessLeft = 0f;
|
||||
speedyLeft = 0f;
|
||||
antiLeft = 0f;
|
||||
timeSlowLeft = 0f;
|
||||
timeFreezeLeft = 5f;
|
||||
}
|
||||
|
||||
void DoEvilBerry(GameObject berry)
|
||||
{
|
||||
AudioSource.PlayClipAtPoint(Resources.Load<AudioClip>("Sounds/EvilLaugh"), Camera.main.transform.position, 1.2f * BazookaManager.Instance.GetSettingSFXVolume());
|
||||
Destroy(berry);
|
||||
if (score >= 10)
|
||||
{
|
||||
UpdateStats(-10, 0);
|
||||
} else
|
||||
{
|
||||
score = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,4 @@
|
||||
using System.Text;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
@@ -7,14 +8,10 @@ public class GamePlayerPauseMenu : MonoBehaviour
|
||||
public static GamePlayerPauseMenu Instance;
|
||||
public Button backButton;
|
||||
public Button continueButton;
|
||||
public Button statsButton;
|
||||
public Button editUiButton;
|
||||
public Button resetUiButton;
|
||||
public AudioSource songLoop;
|
||||
public Slider musicSlider;
|
||||
public Slider sfxSlider;
|
||||
public TMP_Text musicSliderText;
|
||||
public TMP_Text sfxSliderText;
|
||||
public TMP_Text fpsText;
|
||||
public TMP_Text scoreText;
|
||||
public TMP_Text highScoreText;
|
||||
public TMP_Text boostText;
|
||||
@@ -25,15 +22,21 @@ public class GamePlayerPauseMenu : MonoBehaviour
|
||||
public Button leftButton;
|
||||
internal bool editingUI = false;
|
||||
|
||||
public GameObject statsMenu;
|
||||
public Button statsMenuExitButton;
|
||||
public TMP_Text statsText;
|
||||
|
||||
public Toggle settingFullscreenToggle;
|
||||
public Toggle settingVSyncToggle;
|
||||
public Toggle settingRandomMusicToggle;
|
||||
public Slider musicSlider;
|
||||
public Slider sfxSlider;
|
||||
public TMP_Text musicSliderText;
|
||||
public TMP_Text sfxSliderText;
|
||||
|
||||
void Awake()
|
||||
{
|
||||
Instance = this;
|
||||
musicSlider.value = BazookaManager.Instance.GetSettingMusicVolume();
|
||||
sfxSlider.value = BazookaManager.Instance.GetSettingSFXVolume();
|
||||
backButton.onClick.AddListener(async () =>
|
||||
{
|
||||
await UnityEngine.SceneManagement.SceneManager.LoadSceneAsync("MainMenu");
|
||||
});
|
||||
continueButton.onClick.AddListener(GamePlayer.instance.DisablePause);
|
||||
musicSlider.onValueChanged.AddListener(value =>
|
||||
{
|
||||
@@ -50,11 +53,9 @@ public class GamePlayerPauseMenu : MonoBehaviour
|
||||
});
|
||||
resetUiButton.onClick.AddListener(() =>
|
||||
{
|
||||
((RectTransform)fpsText.transform).anchoredPosition = new Vector2(210f, -35f);
|
||||
((RectTransform)scoreText.transform).anchoredPosition = new Vector2(0f, -70f);
|
||||
((RectTransform)highScoreText.transform).anchoredPosition = new Vector2(0f, -140f);
|
||||
((RectTransform)boostText.transform).anchoredPosition = new Vector2(0f, -190f);
|
||||
PlayerPrefs.DeleteKey("DraggedUIFPSText");
|
||||
PlayerPrefs.DeleteKey("DraggedUIScoreText");
|
||||
PlayerPrefs.DeleteKey("DraggedUIHighScoreText");
|
||||
PlayerPrefs.DeleteKey("DraggedUIBoostText");
|
||||
@@ -72,6 +73,64 @@ public class GamePlayerPauseMenu : MonoBehaviour
|
||||
PlayerPrefs.DeleteKey("DraggedUILeftButton");
|
||||
}
|
||||
});
|
||||
statsButton.onClick.AddListener(() =>
|
||||
{
|
||||
statsMenu.SetActive(true);
|
||||
var text = new StringBuilder();
|
||||
text.AppendLine("High Score: " + Tools.FormatWithCommas(BazookaManager.Instance.GetGameStoreHighScore()));
|
||||
text.AppendLine("Total Normal Berries: " + Tools.FormatWithCommas(BazookaManager.Instance.GetGameStoreTotalNormalBerries()));
|
||||
text.AppendLine("Total Poison Berries: " + Tools.FormatWithCommas(BazookaManager.Instance.GetGameStoreTotalPoisonBerries()));
|
||||
text.AppendLine("Total Slow Berries: " + Tools.FormatWithCommas(BazookaManager.Instance.GetGameStoreTotalSlowBerries()));
|
||||
text.AppendLine("Total Ultra Berries: " + Tools.FormatWithCommas(BazookaManager.Instance.GetGameStoreTotalUltraBerries()));
|
||||
text.AppendLine("Total Speedy Berries: " + Tools.FormatWithCommas(BazookaManager.Instance.GetGameStoreTotalSpeedyBerries()));
|
||||
text.AppendLine("Total Random Berries: " + Tools.FormatWithCommas(BazookaManager.Instance.GetGameStoreTotalRandomBerries()));
|
||||
text.AppendLine("Total Anti Berries: " + Tools.FormatWithCommas(BazookaManager.Instance.GetGameStoreTotalAntiBerries()));
|
||||
text.AppendLine("Total Time Slow Berries: " + Tools.FormatWithCommas(BazookaManager.Instance.GetGameStoreTotalTimeSlowBerries()));
|
||||
text.AppendLine("Total Purple Berries: " + Tools.FormatWithCommas(BazookaManager.Instance.GetGameStoreTotalPurpleBerries()));
|
||||
text.AppendLine("Total Time Freeze Berries: " + Tools.FormatWithCommas(BazookaManager.Instance.GetGameStoreTotalTimeFreezeBerries()));
|
||||
text.AppendLine("Total Evil Berries: " + Tools.FormatWithCommas(BazookaManager.Instance.GetGameStoreTotalEvilBerries()));
|
||||
text.AppendLine("Total Attempts: " + Tools.FormatWithCommas(BazookaManager.Instance.GetGameStoreTotalAttepts()));
|
||||
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);
|
||||
GamePlayer.instance.backgroundMusic.volume = value;
|
||||
});
|
||||
sfxSlider.onValueChanged.AddListener(value => BazookaManager.Instance.SetSettingSFXVolume(value));
|
||||
}
|
||||
|
||||
public void ToggleEditingUI()
|
||||
@@ -79,13 +138,16 @@ public class GamePlayerPauseMenu : MonoBehaviour
|
||||
editingUI = !editingUI;
|
||||
musicSlider.gameObject.SetActive(!musicSlider.gameObject.activeSelf);
|
||||
sfxSlider.gameObject.SetActive(!sfxSlider.gameObject.activeSelf);
|
||||
musicSliderText.gameObject.SetActive(musicSlider.gameObject.activeSelf);
|
||||
sfxSliderText.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);
|
||||
fpsText.GetComponent<DraggableUI>().canDrag = !fpsText.GetComponent<DraggableUI>().canDrag;
|
||||
scoreText.GetComponent<DraggableUI>().canDrag = !scoreText.GetComponent<DraggableUI>().canDrag;
|
||||
highScoreText.GetComponent<DraggableUI>().canDrag = !highScoreText.GetComponent<DraggableUI>().canDrag;
|
||||
boostText.GetComponent<DraggableUI>().canDrag = !boostText.GetComponent<DraggableUI>().canDrag;
|
||||
@@ -107,6 +169,8 @@ public class GamePlayerPauseMenu : MonoBehaviour
|
||||
jumpButton.interactable = !jumpDraggableUI.canDrag;
|
||||
rightButton.interactable = !rightDraggableUI.canDrag;
|
||||
leftButton.interactable = !leftDraggableUI.canDrag;
|
||||
jumpButton.transform.GetChild(0).GetComponent<TMP_Text>().color = !jumpDraggableUI.canDrag ? GamePlayer.instance.isGrounded ? Color.white : Color.red : Color.white;
|
||||
restartButton.interactable = GamePlayer.instance.score != 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
|
||||
[RequireComponent(typeof(TMP_Text))]
|
||||
public class GlobalFPSText : MonoBehaviour
|
||||
{
|
||||
private TMP_Text text;
|
||||
private float timer;
|
||||
private int frames;
|
||||
private float fps;
|
||||
|
||||
void Awake()
|
||||
{
|
||||
if (FindObjectsByType<GlobalFPSText>(FindObjectsSortMode.None).Length > 1)
|
||||
{
|
||||
Destroy(gameObject.transform.parent.gameObject);
|
||||
return;
|
||||
}
|
||||
DontDestroyOnLoad(transform.parent.gameObject);
|
||||
text = GetComponent<TMP_Text>();
|
||||
}
|
||||
|
||||
void Update()
|
||||
{
|
||||
var enabled = BazookaManager.Instance.GetSettingShowFPS();
|
||||
if (!enabled && text.text != "")
|
||||
{
|
||||
text.text = "";
|
||||
return;
|
||||
}
|
||||
else if (!enabled) return;
|
||||
frames++;
|
||||
timer += Time.unscaledDeltaTime;
|
||||
if (timer >= 0.25f)
|
||||
{
|
||||
fps = frames / timer;
|
||||
text.text = "FPS: " + Mathf.RoundToInt(fps);
|
||||
frames = 0;
|
||||
timer = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 703a7c60af3394e688f2e2bdec342176
|
||||
@@ -1,17 +1,21 @@
|
||||
using UnityEngine;
|
||||
|
||||
public class HideIfSettingFalse : MonoBehaviour {
|
||||
public class HideIfSettingFalse : MonoBehaviour
|
||||
{
|
||||
public SettingTypes setting;
|
||||
public bool reverse;
|
||||
|
||||
void Start() {
|
||||
void Start()
|
||||
{
|
||||
bool value = GetSettingValue(setting);
|
||||
gameObject.SetActive(value == !reverse);
|
||||
}
|
||||
|
||||
bool GetSettingValue(SettingTypes s) {
|
||||
bool GetSettingValue(SettingTypes s)
|
||||
{
|
||||
var b = BazookaManager.Instance;
|
||||
return s switch {
|
||||
return s switch
|
||||
{
|
||||
SettingTypes.FullScreen => b.GetSettingFullScreen(),
|
||||
SettingTypes.ShowFPS => b.GetSettingShowFPS(),
|
||||
SettingTypes.Vsync => b.GetSettingVsync(),
|
||||
|
||||
@@ -1,15 +1,11 @@
|
||||
using System.Collections.Generic;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.SceneManagement;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class Iconsmenu : MonoBehaviour
|
||||
{
|
||||
public GameObject iconsPanel;
|
||||
public GameObject overlaysPanel;
|
||||
public Button backButton;
|
||||
public Sprite defaultIcon;
|
||||
public Button placeholderButton;
|
||||
public TMP_Text selectionText;
|
||||
@@ -52,7 +48,6 @@ public class Iconsmenu : MonoBehaviour
|
||||
}
|
||||
};
|
||||
|
||||
defaultIcon = Tools.GetIconForUser(BazookaManager.Instance.GetAccountID() ?? 0);
|
||||
icons[0].transform.GetChild(0).GetComponent<Image>().sprite = defaultIcon;
|
||||
|
||||
SwitchToIcon();
|
||||
@@ -65,10 +60,6 @@ public class Iconsmenu : MonoBehaviour
|
||||
placeholderButton.interactable = false;
|
||||
}
|
||||
placeholderButton.onClick.AddListener(ToggleKit);
|
||||
backButton.onClick.AddListener(async () =>
|
||||
{
|
||||
await SceneManager.LoadSceneAsync("MainMenu");
|
||||
});
|
||||
previewBird.GetComponentInParent<Button>().onClick.AddListener(() =>
|
||||
{
|
||||
var scale = previewBird.transform.localScale;
|
||||
@@ -149,7 +140,7 @@ public class Iconsmenu : MonoBehaviour
|
||||
{
|
||||
previewBird.sprite = defaultIcon;
|
||||
}
|
||||
if (iconID == 7)
|
||||
if (iconID == 7 || iconID == 10 || iconID == 12 || iconID == 13)
|
||||
{
|
||||
SelectOverlay(0);
|
||||
placeholderButton.interactable = false;
|
||||
|
||||
@@ -5,10 +5,12 @@ public class LoadingMenu : MonoBehaviour
|
||||
{
|
||||
async void Start()
|
||||
{
|
||||
QualitySettings.vSyncCount = BazookaManager.Instance.GetSettingVsync() ? 1 : -1;
|
||||
if (!Application.isMobilePlatform)
|
||||
{
|
||||
Screen.fullScreen = BazookaManager.Instance.GetSettingFullScreen();
|
||||
var width = Display.main.systemWidth;
|
||||
var height = Display.main.systemHeight;
|
||||
Screen.SetResolution(width, height, BazookaManager.Instance.GetSettingFullScreen());
|
||||
QualitySettings.vSyncCount = BazookaManager.Instance.GetSettingVsync() ? 1 : -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -26,7 +26,7 @@ public class MenuMusic : MonoBehaviour
|
||||
|
||||
void OnSceneLoaded(Scene scene, LoadSceneMode mode)
|
||||
{
|
||||
if (scene.name == "GamePlayer")
|
||||
if (scene.name == "GamePlayer" || scene.name == "CustomGamePlayer")
|
||||
{
|
||||
SceneManager.sceneLoaded -= OnSceneLoaded;
|
||||
Destroy(gameObject);
|
||||
|
||||
@@ -0,0 +1,348 @@
|
||||
using System;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.SceneManagement;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class PlayMenu : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private GameObject selectionMenu;
|
||||
[SerializeField] private GameObject customMenu;
|
||||
[SerializeField] private Button customButton;
|
||||
[SerializeField] private Button customBackButton;
|
||||
[SerializeField] private Button customPlayButton;
|
||||
[SerializeField] private Button customNormalizeButton;
|
||||
|
||||
[SerializeField] private TMP_InputField normalBerryChance;
|
||||
[SerializeField] private TMP_InputField poisonBerryChance;
|
||||
[SerializeField] private TMP_InputField slowBerryChance;
|
||||
[SerializeField] private TMP_InputField ultraBerryChance;
|
||||
[SerializeField] private TMP_InputField speedyBerryChance;
|
||||
[SerializeField] private TMP_InputField randomBerryChance;
|
||||
[SerializeField] private TMP_InputField antiBerryChance;
|
||||
[SerializeField] private TMP_InputField nothingBerryChance;
|
||||
[SerializeField] private TMP_InputField timeSlowBerryChance;
|
||||
[SerializeField] private TMP_InputField purpleBerryChance;
|
||||
[SerializeField] private TMP_InputField timeFreezeBerryChance;
|
||||
[SerializeField] private TMP_InputField evilBerryChance;
|
||||
|
||||
[SerializeField] private TMP_Text validateTotalText;
|
||||
|
||||
private readonly float defaultNormalBerryChance = 27.5f;
|
||||
private readonly float defaultPoisonBerryChance = 12.5f;
|
||||
private readonly float defaultSlowBerryChance = 10f;
|
||||
private readonly float defaultUltraBerryChance = 10f;
|
||||
private readonly float defaultSpeedyBerryChance = 10f;
|
||||
private readonly float defaultRandomBerryChance = 5f;
|
||||
private readonly float defaultAntiBerryChance = 5f;
|
||||
private readonly float defaultNothingBerryChance = 0f;
|
||||
private readonly float defaultTimeSlowBerryChance = 5f;
|
||||
private readonly float defaultPurpleBerryChance = 5f;
|
||||
private readonly float defaultTimeFreezeBerryChance = 5f;
|
||||
private readonly float defaultEvilBerryChance = 5f;
|
||||
|
||||
void Awake()
|
||||
{
|
||||
customButton.onClick.AddListener(() =>
|
||||
{
|
||||
selectionMenu.SetActive(false);
|
||||
customMenu.SetActive(true);
|
||||
});
|
||||
customBackButton.onClick.AddListener(() =>
|
||||
{
|
||||
customMenu.SetActive(false);
|
||||
selectionMenu.SetActive(true);
|
||||
|
||||
normalBerryChance.text = defaultNormalBerryChance.ToString();
|
||||
poisonBerryChance.text = defaultPoisonBerryChance.ToString();
|
||||
slowBerryChance.text = defaultSlowBerryChance.ToString();
|
||||
ultraBerryChance.text = defaultUltraBerryChance.ToString();
|
||||
speedyBerryChance.text = defaultSpeedyBerryChance.ToString();
|
||||
randomBerryChance.text = defaultRandomBerryChance.ToString();
|
||||
antiBerryChance.text = defaultAntiBerryChance.ToString();
|
||||
nothingBerryChance.text = defaultNothingBerryChance.ToString();
|
||||
timeSlowBerryChance.text = defaultTimeSlowBerryChance.ToString();
|
||||
purpleBerryChance.text = defaultPurpleBerryChance.ToString();
|
||||
timeFreezeBerryChance.text = defaultTimeFreezeBerryChance.ToString();
|
||||
evilBerryChance.text = defaultEvilBerryChance.ToString();
|
||||
ValidateTotal();
|
||||
});
|
||||
customNormalizeButton.onClick.AddListener(() =>
|
||||
{
|
||||
float normalBerry = GetValueFrom(normalBerryChance);
|
||||
float poisonBerry = GetValueFrom(poisonBerryChance);
|
||||
float slowBerry = GetValueFrom(slowBerryChance);
|
||||
float ultraBerry = GetValueFrom(ultraBerryChance);
|
||||
float speedyBerry = GetValueFrom(speedyBerryChance);
|
||||
float randomBerry = GetValueFrom(randomBerryChance);
|
||||
float antiBerry = GetValueFrom(antiBerryChance);
|
||||
float nothingBerry = GetValueFrom(nothingBerryChance);
|
||||
float timeSlowBerry = GetValueFrom(timeSlowBerryChance);
|
||||
float purpleBerry = GetValueFrom(purpleBerryChance);
|
||||
float timeFreezeBerry = GetValueFrom(timeFreezeBerryChance);
|
||||
float evilBerry = GetValueFrom(evilBerryChance);
|
||||
|
||||
int divideBy = 0;
|
||||
|
||||
divideBy += normalBerry > 0 ? 1 : 0;
|
||||
divideBy += poisonBerry > 0 ? 1 : 0;
|
||||
divideBy += slowBerry > 0 ? 1 : 0;
|
||||
divideBy += ultraBerry > 0 ? 1 : 0;
|
||||
divideBy += speedyBerry > 0 ? 1 : 0;
|
||||
divideBy += randomBerry > 0 ? 1 : 0;
|
||||
divideBy += antiBerry > 0 ? 1 : 0;
|
||||
divideBy += nothingBerry > 0 ? 1 : 0;
|
||||
divideBy += timeSlowBerry > 0 ? 1 : 0;
|
||||
divideBy += purpleBerry > 0 ? 1 : 0;
|
||||
divideBy += timeFreezeBerry > 0 ? 1 : 0;
|
||||
divideBy += evilBerry > 0 ? 1 : 0;
|
||||
|
||||
float addedChances = normalBerry + poisonBerry + slowBerry + ultraBerry + speedyBerry + randomBerry + antiBerry + nothingBerry + timeSlowBerry + purpleBerry + timeFreezeBerry + evilBerry;
|
||||
float difference = addedChances - 100f;
|
||||
|
||||
if (normalBerry > 0) NormalizeOne(normalBerryChance, normalBerry, divideBy, difference);
|
||||
if (poisonBerry > 0) NormalizeOne(poisonBerryChance, poisonBerry, divideBy, difference);
|
||||
if (slowBerry > 0) NormalizeOne(slowBerryChance, slowBerry, divideBy, difference);
|
||||
if (ultraBerry > 0) NormalizeOne(ultraBerryChance, ultraBerry, divideBy, difference);
|
||||
if (speedyBerry > 0) NormalizeOne(speedyBerryChance, speedyBerry, divideBy, difference);
|
||||
if (randomBerry > 0) NormalizeOne(randomBerryChance, randomBerry, divideBy, difference);
|
||||
if (antiBerry > 0) NormalizeOne(antiBerryChance, antiBerry, divideBy, difference);
|
||||
if (nothingBerry > 0) NormalizeOne(nothingBerryChance, nothingBerry, divideBy, difference);
|
||||
if (timeSlowBerry > 0) NormalizeOne(timeSlowBerryChance, timeSlowBerry, divideBy, difference);
|
||||
if (purpleBerry > 0) NormalizeOne(purpleBerryChance, purpleBerry, divideBy, difference);
|
||||
if (timeFreezeBerry > 0) NormalizeOne(timeFreezeBerryChance, timeFreezeBerry, divideBy, difference);
|
||||
if (purpleBerry > 0) NormalizeOne(evilBerryChance, evilBerry, divideBy, difference);
|
||||
|
||||
normalBerry = GetValueFrom(normalBerryChance);
|
||||
poisonBerry = GetValueFrom(poisonBerryChance);
|
||||
slowBerry = GetValueFrom(slowBerryChance);
|
||||
ultraBerry = GetValueFrom(ultraBerryChance);
|
||||
speedyBerry = GetValueFrom(speedyBerryChance);
|
||||
randomBerry = GetValueFrom(randomBerryChance);
|
||||
antiBerry = GetValueFrom(antiBerryChance);
|
||||
nothingBerry = GetValueFrom(nothingBerryChance);
|
||||
timeSlowBerry = GetValueFrom(timeSlowBerryChance);
|
||||
purpleBerry = GetValueFrom(purpleBerryChance);
|
||||
timeFreezeBerry = GetValueFrom(timeFreezeBerryChance);
|
||||
evilBerry = GetValueFrom(evilBerryChance);
|
||||
|
||||
if (normalBerry > 0) normalBerry = (float)Math.Floor(normalBerry);
|
||||
if (poisonBerry > 0) poisonBerry = (float)Math.Floor(poisonBerry);
|
||||
if (slowBerry > 0) slowBerry = (float)Math.Floor(slowBerry);
|
||||
if (ultraBerry > 0) ultraBerry = (float)Math.Floor(ultraBerry);
|
||||
if (speedyBerry > 0) speedyBerry = (float)Math.Floor(speedyBerry);
|
||||
if (randomBerry > 0) randomBerry = (float)Math.Floor(randomBerry);
|
||||
if (antiBerry > 0) antiBerry = (float)Math.Floor(antiBerry);
|
||||
if (nothingBerry > 0) nothingBerry = (float)Math.Floor(nothingBerry);
|
||||
if (timeSlowBerry > 0) timeSlowBerry = (float)Math.Floor(timeSlowBerry);
|
||||
if (purpleBerry > 0) purpleBerry = (float)Math.Floor(purpleBerry);
|
||||
if (timeFreezeBerry > 0) timeFreezeBerry = (float)Math.Floor(timeFreezeBerry);
|
||||
if (evilBerry > 0) evilBerry = (float)Math.Floor(evilBerry);
|
||||
|
||||
float addedChances2 = normalBerry + poisonBerry + slowBerry + ultraBerry + speedyBerry + randomBerry + antiBerry + nothingBerry + timeSlowBerry + purpleBerry + timeFreezeBerry + evilBerry;
|
||||
float difference2 = addedChances2 - 100f;
|
||||
bool fixedValues = false;
|
||||
|
||||
if (normalBerry > 0)
|
||||
{
|
||||
NormalizeTwo(normalBerryChance, fixedValues, normalBerry, difference2);
|
||||
fixedValues = true;
|
||||
}
|
||||
if (poisonBerry > 0)
|
||||
{
|
||||
NormalizeTwo(poisonBerryChance, fixedValues, poisonBerry, difference2);
|
||||
fixedValues = true;
|
||||
}
|
||||
if (slowBerry > 0)
|
||||
{
|
||||
NormalizeTwo(slowBerryChance, fixedValues, slowBerry, difference2);
|
||||
fixedValues = true;
|
||||
}
|
||||
if (ultraBerry > 0)
|
||||
{
|
||||
NormalizeTwo(ultraBerryChance, fixedValues, ultraBerry, difference2);
|
||||
fixedValues = true;
|
||||
}
|
||||
if (speedyBerry > 0)
|
||||
{
|
||||
NormalizeTwo(speedyBerryChance, fixedValues, speedyBerry, difference2);
|
||||
fixedValues = true;
|
||||
}
|
||||
if (randomBerry > 0)
|
||||
{
|
||||
NormalizeTwo(randomBerryChance, fixedValues, randomBerry, difference2);
|
||||
fixedValues = true;
|
||||
}
|
||||
if (antiBerry > 0)
|
||||
{
|
||||
NormalizeTwo(antiBerryChance, fixedValues, antiBerry, difference2);
|
||||
fixedValues = true;
|
||||
}
|
||||
if (nothingBerry > 0)
|
||||
{
|
||||
NormalizeTwo(nothingBerryChance, fixedValues, nothingBerry, difference2);
|
||||
fixedValues = true;
|
||||
}
|
||||
if (nothingBerry > 0)
|
||||
{
|
||||
NormalizeTwo(nothingBerryChance, fixedValues, nothingBerry, difference2);
|
||||
fixedValues = true;
|
||||
}
|
||||
if (timeSlowBerry > 0)
|
||||
{
|
||||
NormalizeTwo(timeSlowBerryChance, fixedValues, timeSlowBerry, difference2);
|
||||
fixedValues = true;
|
||||
}
|
||||
if (purpleBerry > 0)
|
||||
{
|
||||
NormalizeTwo(purpleBerryChance, fixedValues, purpleBerry, difference2);
|
||||
fixedValues = true;
|
||||
}
|
||||
if (timeFreezeBerry > 0)
|
||||
{
|
||||
NormalizeTwo(timeFreezeBerryChance, fixedValues, timeFreezeBerry, difference2);
|
||||
fixedValues = true;
|
||||
}
|
||||
if (evilBerry > 0)
|
||||
{
|
||||
NormalizeTwo(evilBerryChance, fixedValues, evilBerry, difference2);
|
||||
fixedValues = true;
|
||||
}
|
||||
|
||||
ValidateTotal();
|
||||
});
|
||||
customPlayButton.onClick.AddListener(async () =>
|
||||
{
|
||||
GameObject obj = new("CustomGameTempData");
|
||||
obj.AddComponent<CustomGameTempData>();
|
||||
CustomGameTempData customGameTempData = obj.GetComponent<CustomGameTempData>();
|
||||
customGameTempData.normalBerryChance = GetValueFrom(normalBerryChance);
|
||||
customGameTempData.poisonBerryChance = GetValueFrom(poisonBerryChance);
|
||||
customGameTempData.slowBerryChance = GetValueFrom(slowBerryChance);
|
||||
customGameTempData.ultraBerryChance = GetValueFrom(ultraBerryChance);
|
||||
customGameTempData.speedyBerryChance = GetValueFrom(speedyBerryChance);
|
||||
customGameTempData.randomBerryChance = GetValueFrom(randomBerryChance);
|
||||
customGameTempData.antiBerryChance = GetValueFrom(antiBerryChance);
|
||||
customGameTempData.nothingBerryChance = GetValueFrom(nothingBerryChance);
|
||||
customGameTempData.timeSlowBerryChance = GetValueFrom(timeSlowBerryChance);
|
||||
customGameTempData.purpleBerryChance = GetValueFrom(purpleBerryChance);
|
||||
customGameTempData.timeFreezeBerryChance = GetValueFrom(timeFreezeBerryChance);
|
||||
customGameTempData.evilBerryChance = GetValueFrom(evilBerryChance);
|
||||
await SceneManager.LoadSceneAsync("CustomGamePlayer");
|
||||
});
|
||||
|
||||
normalBerryChance.onSelect.AddListener((value) => OnSelect(value, normalBerryChance));
|
||||
normalBerryChance.onDeselect.AddListener((value) => OnDeselect(value, normalBerryChance));
|
||||
poisonBerryChance.onSelect.AddListener((value) => OnSelect(value, poisonBerryChance));
|
||||
poisonBerryChance.onDeselect.AddListener((value) => OnDeselect(value, poisonBerryChance));
|
||||
slowBerryChance.onSelect.AddListener((value) => OnSelect(value, slowBerryChance));
|
||||
slowBerryChance.onDeselect.AddListener((value) => OnDeselect(value, slowBerryChance));
|
||||
ultraBerryChance.onSelect.AddListener((value) => OnSelect(value, ultraBerryChance));
|
||||
ultraBerryChance.onDeselect.AddListener((value) => OnDeselect(value, ultraBerryChance));
|
||||
speedyBerryChance.onSelect.AddListener((value) => OnSelect(value, speedyBerryChance));
|
||||
speedyBerryChance.onDeselect.AddListener((value) => OnDeselect(value, speedyBerryChance));
|
||||
randomBerryChance.onSelect.AddListener((value) => OnSelect(value, randomBerryChance));
|
||||
randomBerryChance.onDeselect.AddListener((value) => OnDeselect(value, randomBerryChance));
|
||||
antiBerryChance.onSelect.AddListener((value) => OnSelect(value, antiBerryChance));
|
||||
antiBerryChance.onDeselect.AddListener((value) => OnDeselect(value, antiBerryChance));
|
||||
nothingBerryChance.onSelect.AddListener((value) => OnSelect(value, nothingBerryChance));
|
||||
nothingBerryChance.onDeselect.AddListener((value) => OnDeselect(value, nothingBerryChance));
|
||||
timeSlowBerryChance.onSelect.AddListener((value) => OnSelect(value, timeSlowBerryChance));
|
||||
timeSlowBerryChance.onDeselect.AddListener((value) => OnDeselect(value, timeSlowBerryChance));
|
||||
purpleBerryChance.onSelect.AddListener((value) => OnSelect(value, purpleBerryChance));
|
||||
purpleBerryChance.onDeselect.AddListener((value) => OnDeselect(value, purpleBerryChance));
|
||||
timeFreezeBerryChance.onSelect.AddListener((value) => OnSelect(value, timeFreezeBerryChance));
|
||||
timeFreezeBerryChance.onDeselect.AddListener((value) => OnDeselect(value, timeFreezeBerryChance));
|
||||
evilBerryChance.onSelect.AddListener((value) => OnSelect(value, evilBerryChance));
|
||||
evilBerryChance.onDeselect.AddListener((value) => OnDeselect(value, evilBerryChance));
|
||||
}
|
||||
|
||||
void ValidateTotal()
|
||||
{
|
||||
customBackButton.interactable = false;
|
||||
customPlayButton.interactable = false;
|
||||
customNormalizeButton.interactable = false;
|
||||
float total = 0f;
|
||||
total += GetValueFrom(normalBerryChance);
|
||||
total += GetValueFrom(poisonBerryChance);
|
||||
total += GetValueFrom(slowBerryChance);
|
||||
total += GetValueFrom(ultraBerryChance);
|
||||
total += GetValueFrom(speedyBerryChance);
|
||||
total += GetValueFrom(randomBerryChance);
|
||||
total += GetValueFrom(antiBerryChance);
|
||||
total += GetValueFrom(nothingBerryChance);
|
||||
total += GetValueFrom(timeSlowBerryChance);
|
||||
total += GetValueFrom(purpleBerryChance);
|
||||
total += GetValueFrom(timeFreezeBerryChance);
|
||||
total += GetValueFrom(evilBerryChance);
|
||||
if (total == 100f)
|
||||
{
|
||||
customBackButton.interactable = true;
|
||||
customPlayButton.interactable = true;
|
||||
validateTotalText.gameObject.SetActive(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
customNormalizeButton.interactable = true;
|
||||
validateTotalText.text = "Total must add up to 100%!";
|
||||
validateTotalText.gameObject.SetActive(true);
|
||||
}
|
||||
}
|
||||
|
||||
private float GetValueFrom(TMP_InputField inputField)
|
||||
{
|
||||
return GetValueFroText(inputField.text);
|
||||
}
|
||||
|
||||
private float GetValueFroText(string text)
|
||||
{
|
||||
try
|
||||
{
|
||||
return float.Parse(text.Replace("%", "").Trim());
|
||||
}
|
||||
catch
|
||||
{
|
||||
return 0f;
|
||||
}
|
||||
}
|
||||
|
||||
void OnSelect(string value, TMP_InputField inputField)
|
||||
{
|
||||
validateTotalText.gameObject.SetActive(false);
|
||||
customBackButton.interactable = false;
|
||||
customPlayButton.interactable = false;
|
||||
customNormalizeButton.interactable = false;
|
||||
inputField.text = value.Replace("%", "");
|
||||
inputField.stringPosition = inputField.text.Length;
|
||||
}
|
||||
|
||||
void OnDeselect(string value, TMP_InputField inputField)
|
||||
{
|
||||
if (float.TryParse(value, out var value2) && value2 < 0f)
|
||||
{
|
||||
value = "0";
|
||||
}
|
||||
inputField.text = value + "%";
|
||||
ValidateTotal();
|
||||
}
|
||||
|
||||
void NormalizeOne(TMP_InputField inputField, float berryChance, int divideBy, float difference)
|
||||
{
|
||||
inputField.text = (berryChance - (difference / divideBy)).ToString() + "%";
|
||||
inputField.stringPosition = inputField.text.Length;
|
||||
}
|
||||
|
||||
void NormalizeTwo(TMP_InputField inputField, bool fixedValues, float berryChance, float difference2)
|
||||
{
|
||||
if (!fixedValues)
|
||||
{
|
||||
inputField.text = (berryChance - difference2).ToString() + "%";
|
||||
inputField.stringPosition = inputField.text.Length;
|
||||
}
|
||||
else
|
||||
{
|
||||
inputField.text = berryChance.ToString() + "%";
|
||||
inputField.stringPosition = inputField.text.Length;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: dbc4899af328c47f6ad3eafd878a71a2
|
||||
@@ -0,0 +1,22 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class RainbowImage : MonoBehaviour
|
||||
{
|
||||
public float frequency = 1f;
|
||||
private Image targetImage;
|
||||
|
||||
void Awake()
|
||||
{
|
||||
targetImage = gameObject.GetComponent<Image>();
|
||||
}
|
||||
|
||||
void Update()
|
||||
{
|
||||
float t = Time.time * frequency;
|
||||
float r = Mathf.Sin(t) * 0.5f + 0.5f;
|
||||
float g = Mathf.Sin(t + 2f) * 0.5f + 0.5f;
|
||||
float b = Mathf.Sin(t + 4f) * 0.5f + 0.5f;
|
||||
targetImage.color = new Color(r, g, b);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ac59fc58d5aba496f8a52d26fcfe16b0
|
||||
@@ -0,0 +1,21 @@
|
||||
using UnityEngine;
|
||||
|
||||
public class RainbowSpriteRender : MonoBehaviour
|
||||
{
|
||||
public float frequency = 1f;
|
||||
private SpriteRenderer targetImage;
|
||||
|
||||
void Awake()
|
||||
{
|
||||
targetImage = gameObject.GetComponent<SpriteRenderer>();
|
||||
}
|
||||
|
||||
void Update()
|
||||
{
|
||||
float t = Time.time * frequency;
|
||||
float r = Mathf.Sin(t) * 0.5f + 0.5f;
|
||||
float g = Mathf.Sin(t + 2f) * 0.5f + 0.5f;
|
||||
float b = Mathf.Sin(t + 4f) * 0.5f + 0.5f;
|
||||
targetImage.color = new Color(r, g, b);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a21a35a47faba4555ab8f7fa25ebe2a0
|
||||
@@ -0,0 +1,22 @@
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
|
||||
public class RainbowText : MonoBehaviour
|
||||
{
|
||||
public float frequency = 1f;
|
||||
private TMP_Text targetImage;
|
||||
|
||||
void Awake()
|
||||
{
|
||||
targetImage = gameObject.GetComponent<TMP_Text>();
|
||||
}
|
||||
|
||||
void Update()
|
||||
{
|
||||
float t = Time.time * frequency;
|
||||
float r = Mathf.Sin(t) * 0.5f + 0.5f;
|
||||
float g = Mathf.Sin(t + 2f) * 0.5f + 0.5f;
|
||||
float b = Mathf.Sin(t + 4f) * 0.5f + 0.5f;
|
||||
targetImage.color = new Color(r, g, b);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ce9aecc05b9004e9eac23a76ea0cadeb
|
||||
@@ -1,33 +1,50 @@
|
||||
using Newtonsoft.Json.Linq;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class SettingsMenu : MonoBehaviour
|
||||
{
|
||||
public GameObject settingsMenu;
|
||||
public ColorPanel colorMenu;
|
||||
public Button toggleButton;
|
||||
|
||||
public Toggle setting1toggle;
|
||||
public Toggle setting2toggle;
|
||||
public Toggle setting3toggle;
|
||||
public Toggle setting4toggle;
|
||||
public Slider musicSlider;
|
||||
public Slider sfxSlider;
|
||||
public ColorPanel bgColorPanel;
|
||||
public Button bgPreviewModePanel;
|
||||
public GameObject settingsUI;
|
||||
|
||||
public Button switchColorTypeButton;
|
||||
public int colorType = 0;
|
||||
public bool colorCanSave = true;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
bgColorPanel.Init(BazookaManager.Instance.GetColorSettingBackground(), new Color(58 / 255f, 58 / 255f, 58 / 255f));
|
||||
bgColorPanel.OnColorChanged += color =>
|
||||
colorMenu.Init(Color.white, Color.white);
|
||||
colorMenu.OnColorChanged += color =>
|
||||
{
|
||||
BazookaManager.Instance.SetColorSettingBackground(color);
|
||||
if (!settingsUI.activeSelf) Camera.main.backgroundColor = new Color((int)color[0] / 255f, (int)color[1] / 255f, (int)color[2] / 255f);
|
||||
if (!colorCanSave) return;
|
||||
|
||||
if (colorType == 0) BazookaManager.Instance.SetColorSettingBackground(color);
|
||||
else if (colorType == 1) BazookaManager.Instance.SetColorSettingMenuBackground(color);
|
||||
else if (colorType == 2) BazookaManager.Instance.SetColorSettingButton(color);
|
||||
else if (colorType == 3) BazookaManager.Instance.SetColorSettingButtonContent(color);
|
||||
else if (colorType == 4) BazookaManager.Instance.SetColorSettingText(color);
|
||||
|
||||
foreach (CustomColorObject customColorObject in FindObjectsByType<CustomColorObject>(FindObjectsSortMode.None)) customColorObject.SetColor();
|
||||
};
|
||||
bgPreviewModePanel.onClick.AddListener(() =>
|
||||
toggleButton.onClick.AddListener(() =>
|
||||
{
|
||||
settingsUI.SetActive(!settingsUI.activeSelf);
|
||||
var value = BazookaManager.Instance.GetColorSettingBackground();
|
||||
Camera.main.backgroundColor = !settingsUI.activeSelf ? new Color((int)value[0] / 255f, (int)value[1] / 255f, (int)value[2] / 255f) : new Color(24 / 255f, 24 / 255f, 24 / 255f);
|
||||
bgPreviewModePanel.transform.GetChild(0).GetComponent<TMP_Text>().text = settingsUI.activeSelf ? "Preview On" : "Preview Off";
|
||||
settingsMenu.SetActive(!settingsMenu.activeSelf);
|
||||
colorMenu.gameObject.SetActive(!colorMenu.gameObject.activeSelf);
|
||||
toggleButton.transform.GetChild(0).GetComponent<TMP_Text>().text = settingsMenu.activeSelf ? "Colors" : "Settings";
|
||||
SwitchColorType(4);
|
||||
foreach (CustomColorObject customColorObject in FindObjectsByType<CustomColorObject>(FindObjectsSortMode.None)) customColorObject.SetColor();
|
||||
});
|
||||
switchColorTypeButton.onClick.AddListener(() => SwitchColorType());
|
||||
|
||||
musicSlider.value = BazookaManager.Instance.GetSettingMusicVolume();
|
||||
sfxSlider.value = BazookaManager.Instance.GetSettingSFXVolume();
|
||||
@@ -36,34 +53,81 @@ public class SettingsMenu : MonoBehaviour
|
||||
setting1toggle.isOn = BazookaManager.Instance.GetSettingFullScreen() == true;
|
||||
setting2toggle.isOn = BazookaManager.Instance.GetSettingShowFPS() == true;
|
||||
setting3toggle.isOn = BazookaManager.Instance.GetSettingVsync() == true;
|
||||
setting4toggle.isOn = BazookaManager.Instance.GetSettingRandomMusic() == true;
|
||||
setting1toggle.onValueChanged.AddListener(value =>
|
||||
{
|
||||
BazookaManager.Instance.SetSettingFullScreen(value);
|
||||
var width = Display.main.systemWidth;
|
||||
var height = Display.main.systemHeight;
|
||||
Screen.SetResolution(width, height, value);
|
||||
});
|
||||
setting3toggle.onValueChanged.AddListener(value =>
|
||||
{
|
||||
BazookaManager.Instance.SetSettingVsync(value);
|
||||
QualitySettings.vSyncCount = value ? 1 : -1;
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
setting1toggle.interactable = false;
|
||||
setting1toggle.gameObject.SetActive(false);
|
||||
setting2toggle.isOn = BazookaManager.Instance.GetSettingShowFPS() == true;
|
||||
setting3toggle.interactable = false;
|
||||
setting3toggle.gameObject.SetActive(false);
|
||||
setting4toggle.isOn = BazookaManager.Instance.GetSettingRandomMusic() == true;
|
||||
}
|
||||
setting1toggle.onValueChanged.AddListener(value =>
|
||||
{
|
||||
BazookaManager.Instance.SetSettingFullScreen(value);
|
||||
var width = Display.main.systemWidth;
|
||||
var height = Display.main.systemHeight;
|
||||
Screen.SetResolution(width, height, value);
|
||||
});
|
||||
setting2toggle.onValueChanged.AddListener(value =>
|
||||
{
|
||||
BazookaManager.Instance.SetSettingShowFPS(value);
|
||||
});
|
||||
setting3toggle.onValueChanged.AddListener(value =>
|
||||
{
|
||||
BazookaManager.Instance.SetSettingVsync(value);
|
||||
QualitySettings.vSyncCount = value ? 1 : -1;
|
||||
});
|
||||
setting4toggle.onValueChanged.AddListener(value => BazookaManager.Instance.SetSettingRandomMusic(value));
|
||||
musicSlider.onValueChanged.AddListener(value =>
|
||||
{
|
||||
BazookaManager.Instance.SetSettingMusicVolume(value);
|
||||
MenuMusic.Instance.GetComponent<AudioSource>().volume = value;
|
||||
});
|
||||
sfxSlider.onValueChanged.AddListener(value => BazookaManager.Instance.SetSettingSFXVolume(value));
|
||||
Tools.RefreshHierarchy(setting1toggle.transform.parent.gameObject);
|
||||
}
|
||||
|
||||
void SwitchColorType(int color = -1)
|
||||
{
|
||||
var type = color == -1 ? colorType : color;
|
||||
var text = colorMenu.transform.GetChild(0).GetComponent<TMP_Text>();
|
||||
var colorToSet = new JArray(255, 255, 255);
|
||||
switch (type)
|
||||
{
|
||||
case 0: //IGBGColor
|
||||
text.text = "Menu background color";
|
||||
colorType = 1;
|
||||
colorToSet = BazookaManager.Instance.GetColorSettingMenuBackground();
|
||||
colorMenu.defaultColor = new(24f / 255f, 24f / 255f, 24f / 255f);
|
||||
break;
|
||||
case 1: //MBGColor
|
||||
text.text = "Button color";
|
||||
colorType = 2;
|
||||
colorToSet = BazookaManager.Instance.GetColorSettingButton();
|
||||
colorMenu.defaultColor = new(1f, 1f, 1f);
|
||||
break;
|
||||
case 2: //BCColor
|
||||
text.text = "Button content color";
|
||||
colorType = 3;
|
||||
colorToSet = BazookaManager.Instance.GetColorSettingButtonContent();
|
||||
colorMenu.defaultColor = new(0f, 0f, 0f);
|
||||
break;
|
||||
case 3: //TColor
|
||||
text.text = "Text color";
|
||||
colorType = 4;
|
||||
colorToSet = BazookaManager.Instance.GetColorSettingText();
|
||||
colorMenu.defaultColor = new(1f, 1f, 1f);
|
||||
break;
|
||||
case 4: //IGColor
|
||||
text.text = "In game background color";
|
||||
colorType = 0;
|
||||
colorToSet = BazookaManager.Instance.GetColorSettingBackground();
|
||||
colorMenu.defaultColor = new(58f / 255f, 58f / 255f, 58f / 255f);
|
||||
break;
|
||||
}
|
||||
colorCanSave = false;
|
||||
colorMenu.SetColor(new Color((int)colorToSet[0] / 255f, (int)colorToSet[1] / 255f, (int)colorToSet[2] / 255f));
|
||||
colorCanSave = true;
|
||||
}
|
||||
}
|
||||
@@ -15,6 +15,8 @@ public class StatsMenu : MonoBehaviour
|
||||
text.AppendLine("Total Slow Berries: " + Tools.FormatWithCommas(BazookaManager.Instance.GetGameStoreTotalSlowBerries()));
|
||||
text.AppendLine("Total Ultra Berries: " + Tools.FormatWithCommas(BazookaManager.Instance.GetGameStoreTotalUltraBerries()));
|
||||
text.AppendLine("Total Speedy Berries: " + Tools.FormatWithCommas(BazookaManager.Instance.GetGameStoreTotalSpeedyBerries()));
|
||||
text.AppendLine("Total Random Berries: " + Tools.FormatWithCommas(BazookaManager.Instance.GetGameStoreTotalRandomBerries()));
|
||||
text.AppendLine("Total Anti Berries: " + Tools.FormatWithCommas(BazookaManager.Instance.GetGameStoreTotalAntiBerries()));
|
||||
text.AppendLine("Total Time Slow Berries: " + Tools.FormatWithCommas(BazookaManager.Instance.GetGameStoreTotalTimeSlowBerries()));
|
||||
text.AppendLine("Total Purple Berries: " + Tools.FormatWithCommas(BazookaManager.Instance.GetGameStoreTotalPurpleBerries()));
|
||||
text.AppendLine("Total Time Freeze Berries: " + Tools.FormatWithCommas(BazookaManager.Instance.GetGameStoreTotalTimeFreezeBerries()));
|
||||
|
||||
@@ -78,4 +78,10 @@ public static class Tools
|
||||
Sprite sprite = Sprite.Create(tex, new Rect(0, 0, tex.width, tex.height), new UnityEngine.Vector2(0.5f, 0.5f));
|
||||
targetImage.sprite = sprite;
|
||||
}
|
||||
|
||||
public static void RefreshHierarchy(GameObject root)
|
||||
{
|
||||
foreach (Transform child in root.transform) RefreshHierarchy(child.gameObject);
|
||||
if (root.TryGetComponent<RectTransform>(out var rect)) LayoutRebuilder.ForceRebuildLayoutImmediate(rect);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
public enum ColorObjectType
|
||||
{
|
||||
InGameBackgroundColor,
|
||||
MenuBackgroundColor,
|
||||
ButtonColor,
|
||||
ButtonColorText,
|
||||
TextColor,
|
||||
TextColorImage,
|
||||
MenuBackgroundColorImage,
|
||||
MenuBackgroundColorText,
|
||||
ButtonContentColorImage,
|
||||
ButtonContentColorText
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5d4d64e0ea37c40b3a4bb388144188cc
|
||||
Reference in new issue
Block a user