New pause menu for game players (not multiplayer pause menu yet) + FIx custom mode
This commit is contained in:
12 files changed
+7406
-11474
No files matched your search
@@ -3464,6 +3464,7 @@ Canvas:
|
|||||||
m_OverridePixelPerfect: 0
|
m_OverridePixelPerfect: 0
|
||||||
m_SortingBucketNormalizedSize: 0
|
m_SortingBucketNormalizedSize: 0
|
||||||
m_VertexColorAlwaysGammaSpace: 0
|
m_VertexColorAlwaysGammaSpace: 0
|
||||||
|
m_UseReflectionProbes: 0
|
||||||
m_AdditionalShaderChannelsFlag: 25
|
m_AdditionalShaderChannelsFlag: 25
|
||||||
m_UpdateRectTransformForStandalone: 0
|
m_UpdateRectTransformForStandalone: 0
|
||||||
m_SortingLayerID: 0
|
m_SortingLayerID: 0
|
||||||
|
|||||||
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
+1856
-3745
File diff suppressed because it is too large.
Load diff
@@ -31,7 +31,7 @@ public class AutoGamePlayer : MonoBehaviour {
|
|||||||
[SerializeField] private TMP_Text scoreText;
|
[SerializeField] private TMP_Text scoreText;
|
||||||
[SerializeField] private TMP_Text highScoreText;
|
[SerializeField] private TMP_Text highScoreText;
|
||||||
[SerializeField] private TMP_Text boostText;
|
[SerializeField] private TMP_Text boostText;
|
||||||
[SerializeField] private GameObject pausePanel;
|
[SerializeField] private AutoGamePlayerPauseMenu pausePanel;
|
||||||
[SerializeField] internal AudioSource backgroundMusic;
|
[SerializeField] internal AudioSource backgroundMusic;
|
||||||
[SerializeField] private GameObject berryParent;
|
[SerializeField] private GameObject berryParent;
|
||||||
[SerializeField] private TMP_Text levelText;
|
[SerializeField] private TMP_Text levelText;
|
||||||
@@ -192,15 +192,6 @@ public class AutoGamePlayer : MonoBehaviour {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Application.isMobilePlatform) {
|
|
||||||
var touches = UnityEngine.InputSystem.EnhancedTouch.Touch.activeTouches;
|
|
||||||
for (int i = 0; i < touches.Count; i++) {
|
|
||||||
var pos = touches[i].screenPosition;
|
|
||||||
UnityEngine.Vector3 clickPosition = Camera.main.ScreenToWorldPoint(new UnityEngine.Vector3(pos.x, pos.y, 0f));
|
|
||||||
clickPosition.z = 0f;
|
|
||||||
if (pauseButton.GetComponent<HoldableButton>().isPressed) doBack = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (doMoveLeft && !doMoveRight) {
|
if (doMoveLeft && !doMoveRight) {
|
||||||
bird.transform.position += new UnityEngine.Vector3(-(576f * (speedModifier * canvasRect.lossyScale.x) * Time.deltaTime), 0f, 0f);
|
bird.transform.position += new UnityEngine.Vector3(-(576f * (speedModifier * canvasRect.lossyScale.x) * Time.deltaTime), 0f, 0f);
|
||||||
ClampPosition(bird);
|
ClampPosition(bird);
|
||||||
@@ -266,7 +257,7 @@ public class AutoGamePlayer : MonoBehaviour {
|
|||||||
nextSpawnTime = Time.time + 1f / spawnRate;
|
nextSpawnTime = Time.time + 1f / spawnRate;
|
||||||
}
|
}
|
||||||
float spawnProbability = UnityEngine.Random.value;
|
float spawnProbability = UnityEngine.Random.value;
|
||||||
if (!pausePanel.activeSelf) {
|
if (!pausePanel.gameObject.activeSelf) {
|
||||||
Image newBerry = Instantiate(berryTemplate).GetComponent<Image>();
|
Image newBerry = Instantiate(berryTemplate).GetComponent<Image>();
|
||||||
newBerry.transform.SetParent(berryParent.transform, false);
|
newBerry.transform.SetParent(berryParent.transform, false);
|
||||||
|
|
||||||
@@ -307,11 +298,11 @@ public class AutoGamePlayer : MonoBehaviour {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Update() {
|
void Update() {
|
||||||
if (!pausePanel.activeSelf && rb.gravityScale != 100f * canvasRect.lossyScale.y) rb.gravityScale = 100f * canvasRect.lossyScale.y;
|
if (!pausePanel.gameObject.activeSelf && rb.gravityScale != 100f * canvasRect.lossyScale.y) rb.gravityScale = 100f * canvasRect.lossyScale.y;
|
||||||
foreach (AudioSource audio in FindObjectsByType<AudioSource>()) audio.pitch = speedyLeft > 0f ? 1.3f : 1f;
|
foreach (AudioSource audio in FindObjectsByType<AudioSource>()) audio.pitch = speedyLeft > 0f ? 1.3f : 1f;
|
||||||
|
|
||||||
SpawnBerries();
|
SpawnBerries();
|
||||||
if (!pausePanel.activeSelf) {
|
if (!pausePanel.gameObject.activeSelf) {
|
||||||
MoveBird();
|
MoveBird();
|
||||||
if (boostLeft > 0f) {
|
if (boostLeft > 0f) {
|
||||||
boostLeft -= Time.deltaTime;
|
boostLeft -= Time.deltaTime;
|
||||||
@@ -370,7 +361,7 @@ public class AutoGamePlayer : MonoBehaviour {
|
|||||||
if (berry != null) berry.GetComponent<Rigidbody2D>().linearVelocity = noGravityBerries.Contains(berry.GetEntityId()) ? UnityEngine.Vector2.zero : new UnityEngine.Vector2(0f, speedyLeft == 0.0f ? (-300f * canvasRect.lossyScale.y) : (-550f * canvasRect.lossyScale.y));
|
if (berry != null) berry.GetComponent<Rigidbody2D>().linearVelocity = noGravityBerries.Contains(berry.GetEntityId()) ? UnityEngine.Vector2.zero : new UnityEngine.Vector2(0f, speedyLeft == 0.0f ? (-300f * canvasRect.lossyScale.y) : (-550f * canvasRect.lossyScale.y));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ((Application.platform == RuntimePlatform.Android && Keyboard.current.escapeKey.wasPressedThisFrame) || !Application.isMobilePlatform && (Keyboard.current.escapeKey.wasPressedThisFrame || (Gamepad.current != null && (Gamepad.current.startButton.wasPressedThisFrame || Gamepad.current.buttonEast.wasPressedThisFrame)))) TogglePause();
|
if (Keyboard.current.escapeKey.wasPressedThisFrame || (Gamepad.current != null && Gamepad.current.startButton.wasPressedThisFrame)) TogglePause();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Respawn() {
|
void Respawn() {
|
||||||
@@ -412,7 +403,8 @@ public class AutoGamePlayer : MonoBehaviour {
|
|||||||
}
|
}
|
||||||
|
|
||||||
internal void TogglePause() {
|
internal void TogglePause() {
|
||||||
if (pausePanel.activeSelf) DisablePause();
|
if (GameObject.Find("Prefab")) return;
|
||||||
|
if (pausePanel.gameObject.activeSelf) DisablePause();
|
||||||
else EnablePause();
|
else EnablePause();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -423,18 +415,14 @@ public class AutoGamePlayer : MonoBehaviour {
|
|||||||
Cursor.visible = true;
|
Cursor.visible = true;
|
||||||
Cursor.lockState = CursorLockMode.None;
|
Cursor.lockState = CursorLockMode.None;
|
||||||
backgroundMusic.GetComponent<GameMusicHandler>().PauseMusic();
|
backgroundMusic.GetComponent<GameMusicHandler>().PauseMusic();
|
||||||
pausePanel.SetActive(true);
|
pausePanel.gameObject.SetActive(true);
|
||||||
|
|
||||||
foreach (GameObject berry in berries) berry.GetComponent<Rigidbody2D>().linearVelocity = UnityEngine.Vector2.zero;
|
foreach (GameObject berry in berries) berry.GetComponent<Rigidbody2D>().linearVelocity = UnityEngine.Vector2.zero;
|
||||||
}
|
}
|
||||||
|
|
||||||
internal void DisablePause() {
|
internal void DisablePause() {
|
||||||
if (AutoGamePlayerPauseMenu.Instance.statsMenu.activeSelf) {
|
if (pausePanel.editingUI == true) {
|
||||||
AutoGamePlayerPauseMenu.Instance.statsMenuExitButton.onClick.Invoke();
|
pausePanel.ToggleEditingUI();
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (AutoGamePlayerPauseMenu.Instance.editingUI == true) {
|
|
||||||
AutoGamePlayerPauseMenu.Instance.ToggleEditingUI();
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
rb.gravityScale = 100f * canvasRect.lossyScale.y;
|
rb.gravityScale = 100f * canvasRect.lossyScale.y;
|
||||||
@@ -443,7 +431,7 @@ public class AutoGamePlayer : MonoBehaviour {
|
|||||||
Cursor.visible = false;
|
Cursor.visible = false;
|
||||||
Cursor.lockState = CursorLockMode.Locked;
|
Cursor.lockState = CursorLockMode.Locked;
|
||||||
backgroundMusic.GetComponent<GameMusicHandler>().ResumeMusic();
|
backgroundMusic.GetComponent<GameMusicHandler>().ResumeMusic();
|
||||||
pausePanel.SetActive(false);
|
pausePanel.gameObject.SetActive(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void OnApplicationPause(bool pause) {
|
void OnApplicationPause(bool pause) {
|
||||||
|
|||||||
@@ -1,15 +1,8 @@
|
|||||||
using System.Text;
|
|
||||||
using TMPro;
|
using TMPro;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEngine.UI;
|
using UnityEngine.UI;
|
||||||
|
|
||||||
public class AutoGamePlayerPauseMenu : MonoBehaviour {
|
public class AutoGamePlayerPauseMenu : MonoBehaviour {
|
||||||
public static AutoGamePlayerPauseMenu Instance;
|
|
||||||
[SerializeField] private Button backButton;
|
|
||||||
[SerializeField] private Button continueButton;
|
|
||||||
[SerializeField] private Button statsButton;
|
|
||||||
[SerializeField] private Button editUiButton;
|
|
||||||
[SerializeField] private Button resetUiButton;
|
|
||||||
[SerializeField] private AudioSource songLoop;
|
[SerializeField] private AudioSource songLoop;
|
||||||
[SerializeField] private TMP_Text scoreText;
|
[SerializeField] private TMP_Text scoreText;
|
||||||
[SerializeField] private TMP_Text highScoreText;
|
[SerializeField] private TMP_Text highScoreText;
|
||||||
@@ -18,31 +11,26 @@ public class AutoGamePlayerPauseMenu : MonoBehaviour {
|
|||||||
[SerializeField] private Button pauseButton;
|
[SerializeField] private Button pauseButton;
|
||||||
internal bool editingUI = false;
|
internal bool editingUI = false;
|
||||||
|
|
||||||
public GameObject statsMenu;
|
[SerializeField] private Button leaderboardsButton;
|
||||||
public Button statsMenuExitButton;
|
[SerializeField] private Button continueButton;
|
||||||
[SerializeField] private TMP_Text statsText;
|
[SerializeField] private Button mainMenuButton;
|
||||||
|
|
||||||
[SerializeField] private Toggle settingFullscreenToggle;
|
[SerializeField] private Button settingsButton;
|
||||||
[SerializeField] private Toggle settingVSyncToggle;
|
[SerializeField] private Button editUiButton;
|
||||||
[SerializeField] private Toggle settingRandomMusicToggle;
|
[SerializeField] private Button resetUiButton;
|
||||||
[SerializeField] private Slider musicSlider;
|
[SerializeField] private Button doneEditingUiButton;
|
||||||
[SerializeField] private Slider sfxSlider;
|
[SerializeField] private Button chatroomButton;
|
||||||
[SerializeField] private TMP_Text musicSliderText;
|
[SerializeField] private Button statsButton;
|
||||||
[SerializeField] private TMP_Text sfxSliderText;
|
|
||||||
|
[SerializeField] private SettingsMenu settingsPrefab;
|
||||||
|
[SerializeField] private StatsPrefab statsPrefab;
|
||||||
|
[SerializeField] private ChatroomPrefab chatroomPrefab;
|
||||||
|
[SerializeField] private LeaderboardsPrefab leaderboardsPrefab;
|
||||||
|
|
||||||
void Awake() {
|
void Awake() {
|
||||||
Instance = this;
|
|
||||||
continueButton.onClick.AddListener(AutoGamePlayer.Instance.DisablePause);
|
continueButton.onClick.AddListener(AutoGamePlayer.Instance.DisablePause);
|
||||||
musicSlider.onValueChanged.AddListener(value => {
|
editUiButton.onClick.AddListener(() => ToggleEditingUI());
|
||||||
BazookaManager.Instance.SetSettingMusicVolume(value);
|
doneEditingUiButton.onClick.AddListener(() => ToggleEditingUI());
|
||||||
songLoop.volume = value;
|
|
||||||
});
|
|
||||||
sfxSlider.onValueChanged.AddListener(value => {
|
|
||||||
BazookaManager.Instance.SetSettingSFXVolume(value);
|
|
||||||
});
|
|
||||||
editUiButton.onClick.AddListener(() => {
|
|
||||||
ToggleEditingUI();
|
|
||||||
});
|
|
||||||
resetUiButton.onClick.AddListener(() => {
|
resetUiButton.onClick.AddListener(() => {
|
||||||
scoreText.transform.GetComponent<RectTransform>().anchoredPosition = new Vector2(0f, -70f);
|
scoreText.transform.GetComponent<RectTransform>().anchoredPosition = new Vector2(0f, -70f);
|
||||||
highScoreText.transform.GetComponent<RectTransform>().anchoredPosition = new Vector2(0f, -140f);
|
highScoreText.transform.GetComponent<RectTransform>().anchoredPosition = new Vector2(0f, -140f);
|
||||||
@@ -53,79 +41,45 @@ public class AutoGamePlayerPauseMenu : MonoBehaviour {
|
|||||||
PlayerPrefs.DeleteKey("DraggedUIBoostText");
|
PlayerPrefs.DeleteKey("DraggedUIBoostText");
|
||||||
PlayerPrefs.DeleteKey("DraggedUICoinsText");
|
PlayerPrefs.DeleteKey("DraggedUICoinsText");
|
||||||
PlayerPrefs.DeleteKey("DraggedUILevelText");
|
PlayerPrefs.DeleteKey("DraggedUILevelText");
|
||||||
if (Application.isMobilePlatform) {
|
|
||||||
pauseButton.transform.GetComponent<RectTransform>().anchoredPosition = new Vector2(128f, -128f);
|
|
||||||
PlayerPrefs.DeleteKey("DraggedUIPauseButton");
|
|
||||||
PlayerPrefs.DeleteKey("DraggedUIRestartButton");
|
|
||||||
PlayerPrefs.DeleteKey("DraggedUIJumpButton");
|
|
||||||
PlayerPrefs.DeleteKey("DraggedUIRightButton");
|
|
||||||
PlayerPrefs.DeleteKey("DraggedUILeftButton");
|
|
||||||
}
|
|
||||||
});
|
|
||||||
statsButton.onClick.AddListener(() => {
|
|
||||||
statsMenu.SetActive(true);
|
|
||||||
var text = new StringBuilder();
|
|
||||||
text.AppendLine("High Score: " + Tools.FormatWithCommas(AutoGamePlayer.Instance.highscore));
|
|
||||||
text.AppendLine("Total Normal Berries: " + Tools.FormatWithCommas(AutoGamePlayer.Instance.totalNormalBerries));
|
|
||||||
text.AppendLine("Total Poison Berries: " + Tools.FormatWithCommas(AutoGamePlayer.Instance.totalPoisonBerries));
|
|
||||||
text.AppendLine("Total Slow Berries: " + Tools.FormatWithCommas(AutoGamePlayer.Instance.totalSlowBerries));
|
|
||||||
text.AppendLine("Total Ultra Berries: " + Tools.FormatWithCommas(AutoGamePlayer.Instance.totalUltraBerries));
|
|
||||||
text.AppendLine("Total Speedy Berries: " + Tools.FormatWithCommas(AutoGamePlayer.Instance.totalSpeedyBerries));
|
|
||||||
text.AppendLine("Total Random Berries: " + Tools.FormatWithCommas(AutoGamePlayer.Instance.totalRandomBerries));
|
|
||||||
text.AppendLine("Total Anti Berries: " + Tools.FormatWithCommas(AutoGamePlayer.Instance.totalAntiBerries));
|
|
||||||
text.AppendLine("Total Golden Berries: " + Tools.FormatWithCommas(AutoGamePlayer.Instance.totalGoldenBerries));
|
|
||||||
text.AppendLine("Total Attempts: " + Tools.FormatWithCommas(AutoGamePlayer.Instance.totalAttempts));
|
|
||||||
text.AppendLine("Note: This is the AI stats");
|
|
||||||
statsText.text = text.ToString();
|
|
||||||
});
|
|
||||||
statsMenuExitButton.onClick.AddListener(() => {
|
|
||||||
statsMenu.SetActive(false);
|
|
||||||
statsText.text = string.Empty;
|
|
||||||
});
|
});
|
||||||
|
|
||||||
musicSlider.value = BazookaManager.Instance.GetSettingMusicVolume();
|
leaderboardsButton.onClick.AddListener(() => {
|
||||||
sfxSlider.value = BazookaManager.Instance.GetSettingSFXVolume();
|
var clone = Instantiate(leaderboardsPrefab.gameObject, leaderboardsPrefab.gameObject.transform.parent);
|
||||||
if (!Application.isMobilePlatform) {
|
clone.name = "Prefab";
|
||||||
settingFullscreenToggle.isOn = BazookaManager.Instance.GetSettingFullScreen() == true;
|
clone.SetActive(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);
|
settingsButton.onClick.AddListener(() => {
|
||||||
QualitySettings.vSyncCount = value ? 1 : -1;
|
var clone = Instantiate(settingsPrefab.gameObject, settingsPrefab.gameObject.transform.parent);
|
||||||
|
clone.name = "Prefab";
|
||||||
|
clone.SetActive(true);
|
||||||
});
|
});
|
||||||
} else {
|
chatroomButton.onClick.AddListener(() => {
|
||||||
settingFullscreenToggle.interactable = false;
|
var clone = Instantiate(chatroomPrefab.gameObject, chatroomPrefab.gameObject.transform.parent);
|
||||||
settingVSyncToggle.interactable = false;
|
clone.name = "Prefab";
|
||||||
settingRandomMusicToggle.isOn = BazookaManager.Instance.GetSettingRandomMusic() == true;
|
clone.SetActive(true);
|
||||||
}
|
});
|
||||||
settingRandomMusicToggle.onValueChanged.AddListener(value => BazookaManager.Instance.SetSettingRandomMusic(value));
|
statsButton.onClick.AddListener(() => {
|
||||||
musicSlider.onValueChanged.AddListener(value => {
|
var clone = Instantiate(statsPrefab.gameObject, statsPrefab.gameObject.transform.parent);
|
||||||
BazookaManager.Instance.SetSettingMusicVolume(value);
|
clone.name = "Prefab";
|
||||||
AutoGamePlayer.Instance.backgroundMusic.volume = value;
|
clone.SetActive(true);
|
||||||
});
|
});
|
||||||
sfxSlider.onValueChanged.AddListener(value => BazookaManager.Instance.SetSettingSFXVolume(value));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ToggleEditingUI() {
|
public void ToggleEditingUI() {
|
||||||
editingUI = !editingUI;
|
editingUI = !editingUI;
|
||||||
musicSlider.gameObject.SetActive(!musicSlider.gameObject.activeSelf);
|
|
||||||
sfxSlider.gameObject.SetActive(!sfxSlider.gameObject.activeSelf);
|
leaderboardsButton.gameObject.SetActive(!leaderboardsButton.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);
|
continueButton.gameObject.SetActive(!continueButton.gameObject.activeSelf);
|
||||||
statsButton.gameObject.SetActive(!statsButton.gameObject.activeSelf);
|
mainMenuButton.gameObject.SetActive(!mainMenuButton.gameObject.activeSelf);
|
||||||
editUiButton.transform.GetChild(0).GetComponent<TMP_Text>().text = editUiButton.transform.GetChild(0).GetComponent<TMP_Text>().text == "Edit UI" ? "Done" : "Edit UI";
|
|
||||||
|
settingsButton.gameObject.SetActive(!settingsButton.gameObject.activeSelf);
|
||||||
|
editUiButton.gameObject.SetActive(!editUiButton.gameObject.activeSelf);
|
||||||
resetUiButton.gameObject.SetActive(!resetUiButton.gameObject.activeSelf);
|
resetUiButton.gameObject.SetActive(!resetUiButton.gameObject.activeSelf);
|
||||||
|
doneEditingUiButton.gameObject.SetActive(!doneEditingUiButton.gameObject.activeSelf);
|
||||||
|
chatroomButton.gameObject.SetActive(!chatroomButton.gameObject.activeSelf);
|
||||||
|
statsButton.gameObject.SetActive(!statsButton.gameObject.activeSelf);
|
||||||
|
|
||||||
scoreText.GetComponent<DraggableUI>().canDrag = !scoreText.GetComponent<DraggableUI>().canDrag;
|
scoreText.GetComponent<DraggableUI>().canDrag = !scoreText.GetComponent<DraggableUI>().canDrag;
|
||||||
highScoreText.GetComponent<DraggableUI>().canDrag = !highScoreText.GetComponent<DraggableUI>().canDrag;
|
highScoreText.GetComponent<DraggableUI>().canDrag = !highScoreText.GetComponent<DraggableUI>().canDrag;
|
||||||
boostText.GetComponent<DraggableUI>().canDrag = !boostText.GetComponent<DraggableUI>().canDrag;
|
boostText.GetComponent<DraggableUI>().canDrag = !boostText.GetComponent<DraggableUI>().canDrag;
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ public class CustomGamePlayer : MonoBehaviour {
|
|||||||
private float goldenLeft;
|
private float goldenLeft;
|
||||||
[SerializeField] private TMP_Text scoreText;
|
[SerializeField] private TMP_Text scoreText;
|
||||||
[SerializeField] private TMP_Text boostText;
|
[SerializeField] private TMP_Text boostText;
|
||||||
[SerializeField] private GameObject pausePanel;
|
[SerializeField] private CustomGamePlayerPauseMenu pausePanel;
|
||||||
[SerializeField] internal AudioSource backgroundMusic;
|
[SerializeField] internal AudioSource backgroundMusic;
|
||||||
[SerializeField] private GameObject berryParent;
|
[SerializeField] private GameObject berryParent;
|
||||||
|
|
||||||
@@ -82,13 +82,6 @@ public class CustomGamePlayer : MonoBehaviour {
|
|||||||
if (useAI) aiText.gameObject.SetActive(true);
|
if (useAI) aiText.gameObject.SetActive(true);
|
||||||
|
|
||||||
if (!useAI) {
|
if (!useAI) {
|
||||||
var backgroundColor = BazookaManager.Instance.GetColorSettingBackground();
|
|
||||||
Camera.main.backgroundColor = new Color(
|
|
||||||
int.Parse(backgroundColor[0].ToString()) / 255f,
|
|
||||||
int.Parse(backgroundColor[1].ToString()) / 255f,
|
|
||||||
int.Parse(backgroundColor[2].ToString()) / 255f
|
|
||||||
);
|
|
||||||
|
|
||||||
Tools.LoadIcon(
|
Tools.LoadIcon(
|
||||||
bird,
|
bird,
|
||||||
bird.transform.GetChild(0).GetComponent<Image>(),
|
bird.transform.GetChild(0).GetComponent<Image>(),
|
||||||
@@ -101,6 +94,7 @@ public class CustomGamePlayer : MonoBehaviour {
|
|||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
Destroy(bird.transform.GetChild(0).gameObject);
|
Destroy(bird.transform.GetChild(0).gameObject);
|
||||||
|
Destroy(Camera.main.gameObject.GetComponent<CustomColorObject>());
|
||||||
var rainbowCam = Camera.main.gameObject.AddComponent<RainbowCamera>();
|
var rainbowCam = Camera.main.gameObject.AddComponent<RainbowCamera>();
|
||||||
rainbowCam.frequency = 4f;
|
rainbowCam.frequency = 4f;
|
||||||
rainbowCam.brightness = 24;
|
rainbowCam.brightness = 24;
|
||||||
@@ -128,6 +122,8 @@ public class CustomGamePlayer : MonoBehaviour {
|
|||||||
bool doBack = false;
|
bool doBack = false;
|
||||||
if (boostLeft > 0f || speedyLeft > 0f) speedModifier = 1.39f;
|
if (boostLeft > 0f || speedyLeft > 0f) speedModifier = 1.39f;
|
||||||
else if (slownessLeft > 0f) speedModifier = 0.56f;
|
else if (slownessLeft > 0f) speedModifier = 0.56f;
|
||||||
|
|
||||||
|
if (!useAI) {
|
||||||
bool controllerLeft = Gamepad.current != null && (Gamepad.current.leftStick.left.isPressed || Gamepad.current.dpad.left.isPressed || Gamepad.current.rightStick.left.isPressed);
|
bool controllerLeft = Gamepad.current != null && (Gamepad.current.leftStick.left.isPressed || Gamepad.current.dpad.left.isPressed || Gamepad.current.rightStick.left.isPressed);
|
||||||
bool controllerRight = Gamepad.current != null && (Gamepad.current.leftStick.right.isPressed || Gamepad.current.dpad.right.isPressed || Gamepad.current.rightStick.right.isPressed);
|
bool controllerRight = Gamepad.current != null && (Gamepad.current.leftStick.right.isPressed || Gamepad.current.dpad.right.isPressed || Gamepad.current.rightStick.right.isPressed);
|
||||||
bool controllerJump = Gamepad.current != null && (Gamepad.current.leftStick.up.isPressed || Gamepad.current.leftStick.down.isPressed || Gamepad.current.dpad.up.isPressed || Gamepad.current.dpad.down.isPressed || Gamepad.current.rightStick.up.isPressed || Gamepad.current.rightStick.down.isPressed);
|
bool controllerJump = Gamepad.current != null && (Gamepad.current.leftStick.up.isPressed || Gamepad.current.leftStick.down.isPressed || Gamepad.current.dpad.up.isPressed || Gamepad.current.dpad.down.isPressed || Gamepad.current.rightStick.up.isPressed || Gamepad.current.rightStick.down.isPressed);
|
||||||
@@ -157,66 +153,7 @@ public class CustomGamePlayer : MonoBehaviour {
|
|||||||
if (pauseButton.GetComponent<HoldableButton>().isPressed) doBack = true;
|
if (pauseButton.GetComponent<HoldableButton>().isPressed) doBack = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (doMoveLeft && !doMoveRight) {
|
} else {
|
||||||
lastMoveTime = Time.time;
|
|
||||||
bird.transform.position += new UnityEngine.Vector3(-(576f * (speedModifier * canvasRect.lossyScale.x) * Time.deltaTime), 0f, 0f);
|
|
||||||
ClampPosition(bird);
|
|
||||||
bird.transform.localScale = new UnityEngine.Vector3(1f, 1f, 1f);
|
|
||||||
}
|
|
||||||
if (doMoveRight && !doMoveLeft) {
|
|
||||||
lastMoveTime = Time.time;
|
|
||||||
bird.transform.position += new UnityEngine.Vector3(576f * (speedModifier * canvasRect.lossyScale.x) * Time.deltaTime, 0f, 0f);
|
|
||||||
ClampPosition(bird);
|
|
||||||
bird.transform.localScale = new UnityEngine.Vector3(-1f, 1f, 1f);
|
|
||||||
}
|
|
||||||
if (doMoveLeft || doMoveRight) groundCollider.transform.position = new(bird.transform.position.x, groundCollider.transform.position.y);
|
|
||||||
if (doJump && IsGrounded() && !hasJumped) {
|
|
||||||
lastMoveTime = Time.time;
|
|
||||||
hasJumped = true;
|
|
||||||
AudioSource.PlayClipAtPoint(Resources.Load<AudioClip>("Sounds/Jump"), Camera.main.transform.position, 0.75f * BazookaManager.Instance.GetSettingSFXVolume());
|
|
||||||
if (boostLeft > 0f || speedyLeft > 0f) rb.linearVelocity = new UnityEngine.Vector2(rb.linearVelocity.x, 380f);
|
|
||||||
else if (slownessLeft > 0f) rb.linearVelocity = new UnityEngine.Vector2(rb.linearVelocity.x, 220f);
|
|
||||||
else rb.linearVelocity = new UnityEngine.Vector2(rb.linearVelocity.x, 300f);
|
|
||||||
}
|
|
||||||
if (!IsGrounded()) hasJumped = false;
|
|
||||||
if (doBack) {
|
|
||||||
TogglePause();
|
|
||||||
}
|
|
||||||
if (doRestart) {
|
|
||||||
if (score != 0) Respawn();
|
|
||||||
}
|
|
||||||
if (antiLeft > 0f || goldenLeft > 0f) {
|
|
||||||
List<string> berryTags = new() { "NormalBerry", "SlowBerry", "UltraBerry", "SpeedyBerry", "CoinBerry", "RandomBerry", "AntiBerry", "GoldenBerry" };
|
|
||||||
if (antiLeft > 0f) berryTags.Add("PoisonBerry");
|
|
||||||
|
|
||||||
float scale = (canvasRect.lossyScale.x + canvasRect.lossyScale.y) / 2f;
|
|
||||||
float radius = antiLeft > 0f ? 250f * scale : 325f * scale;
|
|
||||||
float speed = antiLeft > 0f ? (300f * scale * Time.deltaTime) : -(420f * scale * Time.deltaTime);
|
|
||||||
|
|
||||||
foreach (string tag in berryTags) {
|
|
||||||
foreach (var berry in GameObject.FindGameObjectsWithTag(tag)) {
|
|
||||||
RectTransform berryRect = berry.GetComponent<RectTransform>();
|
|
||||||
UnityEngine.Vector3 dir = berryRect.position - bird.GetComponent<RectTransform>().position;
|
|
||||||
|
|
||||||
if (dir.magnitude < radius) {
|
|
||||||
berryRect.position += speed * dir.normalized;
|
|
||||||
ClampPosition(berry.GetComponent<Image>());
|
|
||||||
noGravityBerries.Add(berry.GetEntityId());
|
|
||||||
} else noGravityBerries.Remove(berry.GetEntityId());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else if (noGravityBerries.Count() != 0) noGravityBerries.Clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
void MoveBirdAI() {
|
|
||||||
float speedModifier = 1f;
|
|
||||||
bool doMoveRight = false;
|
|
||||||
bool doMoveLeft = false;
|
|
||||||
bool doJump = false;
|
|
||||||
bool doBack = false;
|
|
||||||
if (boostLeft > 0f || speedyLeft > 0f) speedModifier = 1.39f;
|
|
||||||
else if (slownessLeft > 0f) speedModifier = 0.56f;
|
|
||||||
|
|
||||||
float birdX = bird.GetComponent<RectTransform>().anchoredPosition.x;
|
float birdX = bird.GetComponent<RectTransform>().anchoredPosition.x;
|
||||||
float birdY = bird.GetComponent<RectTransform>().anchoredPosition.y;
|
float birdY = bird.GetComponent<RectTransform>().anchoredPosition.y;
|
||||||
|
|
||||||
@@ -334,16 +271,8 @@ public class CustomGamePlayer : MonoBehaviour {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (Application.isMobilePlatform) {
|
|
||||||
var touches = UnityEngine.InputSystem.EnhancedTouch.Touch.activeTouches;
|
|
||||||
for (int i = 0; i < touches.Count; i++) {
|
|
||||||
var pos = touches[i].screenPosition;
|
|
||||||
UnityEngine.Vector3 clickPosition = Camera.main.ScreenToWorldPoint(new UnityEngine.Vector3(pos.x, pos.y, 0f));
|
|
||||||
clickPosition.z = 0f;
|
|
||||||
if (pauseButton.GetComponent<HoldableButton>().isPressed) doBack = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (doMoveLeft && !doMoveRight) {
|
if (doMoveLeft && !doMoveRight) {
|
||||||
lastMoveTime = Time.time;
|
lastMoveTime = Time.time;
|
||||||
bird.transform.position += new UnityEngine.Vector3(-(576f * (speedModifier * canvasRect.lossyScale.x) * Time.deltaTime), 0f, 0f);
|
bird.transform.position += new UnityEngine.Vector3(-(576f * (speedModifier * canvasRect.lossyScale.x) * Time.deltaTime), 0f, 0f);
|
||||||
@@ -369,6 +298,9 @@ public class CustomGamePlayer : MonoBehaviour {
|
|||||||
if (doBack) {
|
if (doBack) {
|
||||||
TogglePause();
|
TogglePause();
|
||||||
}
|
}
|
||||||
|
if (doRestart) {
|
||||||
|
if (score != 0) Respawn();
|
||||||
|
}
|
||||||
if (antiLeft > 0f || goldenLeft > 0f) {
|
if (antiLeft > 0f || goldenLeft > 0f) {
|
||||||
List<string> berryTags = new() { "NormalBerry", "SlowBerry", "UltraBerry", "SpeedyBerry", "CoinBerry", "RandomBerry", "AntiBerry", "GoldenBerry" };
|
List<string> berryTags = new() { "NormalBerry", "SlowBerry", "UltraBerry", "SpeedyBerry", "CoinBerry", "RandomBerry", "AntiBerry", "GoldenBerry" };
|
||||||
if (antiLeft > 0f) berryTags.Add("PoisonBerry");
|
if (antiLeft > 0f) berryTags.Add("PoisonBerry");
|
||||||
@@ -412,7 +344,7 @@ public class CustomGamePlayer : MonoBehaviour {
|
|||||||
nextSpawnTime = Time.time + 1f / spawnRate;
|
nextSpawnTime = Time.time + 1f / spawnRate;
|
||||||
}
|
}
|
||||||
float spawnProbability = Random.value;
|
float spawnProbability = Random.value;
|
||||||
if (!pausePanel.activeSelf) {
|
if (!pausePanel.gameObject.activeSelf) {
|
||||||
float cumulative = 0f;
|
float cumulative = 0f;
|
||||||
Image newBerry = Instantiate(berryTemplate).GetComponent<Image>();
|
Image newBerry = Instantiate(berryTemplate).GetComponent<Image>();
|
||||||
newBerry.transform.SetParent(berryParent.transform, false);
|
newBerry.transform.SetParent(berryParent.transform, false);
|
||||||
@@ -483,19 +415,18 @@ public class CustomGamePlayer : MonoBehaviour {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Update() {
|
void Update() {
|
||||||
if (!pausePanel.activeSelf && rb.gravityScale != 100f * canvasRect.lossyScale.y) rb.gravityScale = 100f * canvasRect.lossyScale.y;
|
if (!pausePanel.gameObject.activeSelf && rb.gravityScale != 100f * canvasRect.lossyScale.y) rb.gravityScale = 100f * canvasRect.lossyScale.y;
|
||||||
foreach (AudioSource audio in FindObjectsByType<AudioSource>()) audio.pitch = speedyLeft > 0f ? 1.3f : 1f;
|
foreach (AudioSource audio in FindObjectsByType<AudioSource>()) audio.pitch = speedyLeft > 0f ? 1.3f : 1f;
|
||||||
|
|
||||||
SpawnBerries();
|
SpawnBerries();
|
||||||
if (!pausePanel.activeSelf) {
|
if (!pausePanel.gameObject.activeSelf) {
|
||||||
if (Time.time - lastMoveTime > 20) {
|
if (Time.time - lastMoveTime > 20) {
|
||||||
lastMoveTime = float.MaxValue;
|
lastMoveTime = float.MaxValue;
|
||||||
EnablePause();
|
EnablePause();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (useAI) MoveBirdAI();
|
MoveBird();
|
||||||
else MoveBird();
|
|
||||||
if (boostLeft > 0f) {
|
if (boostLeft > 0f) {
|
||||||
boostLeft -= Time.deltaTime;
|
boostLeft -= Time.deltaTime;
|
||||||
boostText.text = "Boost expires in " + string.Format("{0:0.0}", boostLeft) + "s";
|
boostText.text = "Boost expires in " + string.Format("{0:0.0}", boostLeft) + "s";
|
||||||
@@ -556,7 +487,7 @@ public class CustomGamePlayer : MonoBehaviour {
|
|||||||
if (berry != null) berry.GetComponent<Rigidbody2D>().linearVelocity = noGravityBerries.Contains(berry.GetEntityId()) ? UnityEngine.Vector2.zero : new UnityEngine.Vector2(0f, speedyLeft == 0.0f ? (-300f * canvasRect.lossyScale.y) : (-550f * canvasRect.lossyScale.y));
|
if (berry != null) berry.GetComponent<Rigidbody2D>().linearVelocity = noGravityBerries.Contains(berry.GetEntityId()) ? UnityEngine.Vector2.zero : new UnityEngine.Vector2(0f, speedyLeft == 0.0f ? (-300f * canvasRect.lossyScale.y) : (-550f * canvasRect.lossyScale.y));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ((Application.platform == RuntimePlatform.Android && Keyboard.current.escapeKey.wasPressedThisFrame) || !Application.isMobilePlatform && (Keyboard.current.escapeKey.wasPressedThisFrame || (Gamepad.current != null && (Gamepad.current.startButton.wasPressedThisFrame || Gamepad.current.buttonEast.wasPressedThisFrame)))) TogglePause();
|
if (Keyboard.current.escapeKey.wasPressedThisFrame || (Gamepad.current != null && Gamepad.current.startButton.wasPressedThisFrame)) TogglePause();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Respawn() {
|
void Respawn() {
|
||||||
@@ -586,7 +517,8 @@ public class CustomGamePlayer : MonoBehaviour {
|
|||||||
}
|
}
|
||||||
|
|
||||||
internal void TogglePause() {
|
internal void TogglePause() {
|
||||||
if (pausePanel.activeSelf) DisablePause();
|
if (GameObject.Find("Prefab")) return;
|
||||||
|
if (pausePanel.gameObject.activeSelf) DisablePause();
|
||||||
else EnablePause();
|
else EnablePause();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -597,14 +529,14 @@ public class CustomGamePlayer : MonoBehaviour {
|
|||||||
Cursor.visible = true;
|
Cursor.visible = true;
|
||||||
Cursor.lockState = CursorLockMode.None;
|
Cursor.lockState = CursorLockMode.None;
|
||||||
backgroundMusic.GetComponent<GameMusicHandler>().PauseMusic();
|
backgroundMusic.GetComponent<GameMusicHandler>().PauseMusic();
|
||||||
pausePanel.SetActive(true);
|
pausePanel.gameObject.SetActive(true);
|
||||||
|
|
||||||
foreach (GameObject berry in berries) berry.GetComponent<Rigidbody2D>().linearVelocity = UnityEngine.Vector2.zero;
|
foreach (GameObject berry in berries) berry.GetComponent<Rigidbody2D>().linearVelocity = UnityEngine.Vector2.zero;
|
||||||
}
|
}
|
||||||
|
|
||||||
internal void DisablePause() {
|
internal void DisablePause() {
|
||||||
if (CustomGamePlayerPauseMenu.Instance.editingUI == true) {
|
if (pausePanel.editingUI == true) {
|
||||||
CustomGamePlayerPauseMenu.Instance.ToggleEditingUI();
|
pausePanel.ToggleEditingUI();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
lastMoveTime = Time.time;
|
lastMoveTime = Time.time;
|
||||||
@@ -614,7 +546,7 @@ public class CustomGamePlayer : MonoBehaviour {
|
|||||||
Cursor.visible = false;
|
Cursor.visible = false;
|
||||||
Cursor.lockState = CursorLockMode.Locked;
|
Cursor.lockState = CursorLockMode.Locked;
|
||||||
backgroundMusic.GetComponent<GameMusicHandler>().ResumeMusic();
|
backgroundMusic.GetComponent<GameMusicHandler>().ResumeMusic();
|
||||||
pausePanel.SetActive(false);
|
pausePanel.gameObject.SetActive(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void OnApplicationPause(bool pause) {
|
void OnApplicationPause(bool pause) {
|
||||||
|
|||||||
@@ -3,11 +3,6 @@ using UnityEngine;
|
|||||||
using UnityEngine.UI;
|
using UnityEngine.UI;
|
||||||
|
|
||||||
public class CustomGamePlayerPauseMenu : MonoBehaviour {
|
public class CustomGamePlayerPauseMenu : MonoBehaviour {
|
||||||
public static CustomGamePlayerPauseMenu Instance;
|
|
||||||
[SerializeField] private Button backButton;
|
|
||||||
[SerializeField] private Button continueButton;
|
|
||||||
[SerializeField] private Button editUiButton;
|
|
||||||
[SerializeField] private Button resetUiButton;
|
|
||||||
[SerializeField] private AudioSource songLoop;
|
[SerializeField] private AudioSource songLoop;
|
||||||
[SerializeField] private TMP_Text scoreText;
|
[SerializeField] private TMP_Text scoreText;
|
||||||
[SerializeField] private TMP_Text boostText;
|
[SerializeField] private TMP_Text boostText;
|
||||||
@@ -18,27 +13,26 @@ public class CustomGamePlayerPauseMenu : MonoBehaviour {
|
|||||||
[SerializeField] private Button leftButton;
|
[SerializeField] private Button leftButton;
|
||||||
internal bool editingUI = false;
|
internal bool editingUI = false;
|
||||||
|
|
||||||
[SerializeField] private Toggle settingFullscreenToggle;
|
[SerializeField] private Button leaderboardsButton;
|
||||||
[SerializeField] private Toggle settingVSyncToggle;
|
[SerializeField] private Button continueButton;
|
||||||
[SerializeField] private Toggle settingRandomMusicToggle;
|
[SerializeField] private Button mainMenuButton;
|
||||||
[SerializeField] private Slider musicSlider;
|
|
||||||
[SerializeField] private Slider sfxSlider;
|
[SerializeField] private Button settingsButton;
|
||||||
[SerializeField] private TMP_Text musicSliderText;
|
[SerializeField] private Button editUiButton;
|
||||||
[SerializeField] private TMP_Text sfxSliderText;
|
[SerializeField] private Button resetUiButton;
|
||||||
|
[SerializeField] private Button doneEditingUiButton;
|
||||||
|
[SerializeField] private Button chatroomButton;
|
||||||
|
[SerializeField] private Button statsButton;
|
||||||
|
|
||||||
|
[SerializeField] private SettingsMenu settingsPrefab;
|
||||||
|
[SerializeField] private StatsPrefab statsPrefab;
|
||||||
|
[SerializeField] private ChatroomPrefab chatroomPrefab;
|
||||||
|
[SerializeField] private LeaderboardsPrefab leaderboardsPrefab;
|
||||||
|
|
||||||
void Awake() {
|
void Awake() {
|
||||||
Instance = this;
|
|
||||||
continueButton.onClick.AddListener(CustomGamePlayer.Instance.DisablePause);
|
continueButton.onClick.AddListener(CustomGamePlayer.Instance.DisablePause);
|
||||||
musicSlider.onValueChanged.AddListener(value => {
|
editUiButton.onClick.AddListener(() => ToggleEditingUI());
|
||||||
BazookaManager.Instance.SetSettingMusicVolume(value);
|
doneEditingUiButton.onClick.AddListener(() => ToggleEditingUI());
|
||||||
songLoop.volume = value;
|
|
||||||
});
|
|
||||||
sfxSlider.onValueChanged.AddListener(value => {
|
|
||||||
BazookaManager.Instance.SetSettingSFXVolume(value);
|
|
||||||
});
|
|
||||||
editUiButton.onClick.AddListener(() => {
|
|
||||||
ToggleEditingUI();
|
|
||||||
});
|
|
||||||
resetUiButton.onClick.AddListener(() => {
|
resetUiButton.onClick.AddListener(() => {
|
||||||
scoreText.transform.GetComponent<RectTransform>().anchoredPosition = new Vector2(0f, -70f);
|
scoreText.transform.GetComponent<RectTransform>().anchoredPosition = new Vector2(0f, -70f);
|
||||||
boostText.transform.GetComponent<RectTransform>().anchoredPosition = new Vector2(0f, -140f);
|
boostText.transform.GetComponent<RectTransform>().anchoredPosition = new Vector2(0f, -140f);
|
||||||
@@ -58,48 +52,43 @@ public class CustomGamePlayerPauseMenu : MonoBehaviour {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
musicSlider.value = BazookaManager.Instance.GetSettingMusicVolume();
|
leaderboardsButton.onClick.AddListener(() => {
|
||||||
sfxSlider.value = BazookaManager.Instance.GetSettingSFXVolume();
|
var clone = Instantiate(leaderboardsPrefab.gameObject, leaderboardsPrefab.gameObject.transform.parent);
|
||||||
if (!Application.isMobilePlatform) {
|
clone.name = "Prefab";
|
||||||
settingFullscreenToggle.isOn = BazookaManager.Instance.GetSettingFullScreen() == true;
|
clone.SetActive(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);
|
settingsButton.onClick.AddListener(() => {
|
||||||
QualitySettings.vSyncCount = value ? 1 : -1;
|
var clone = Instantiate(settingsPrefab.gameObject, settingsPrefab.gameObject.transform.parent);
|
||||||
|
clone.name = "Prefab";
|
||||||
|
clone.SetActive(true);
|
||||||
});
|
});
|
||||||
} else {
|
chatroomButton.onClick.AddListener(() => {
|
||||||
settingFullscreenToggle.interactable = false;
|
var clone = Instantiate(chatroomPrefab.gameObject, chatroomPrefab.gameObject.transform.parent);
|
||||||
settingVSyncToggle.interactable = false;
|
clone.name = "Prefab";
|
||||||
settingRandomMusicToggle.isOn = BazookaManager.Instance.GetSettingRandomMusic() == true;
|
clone.SetActive(true);
|
||||||
}
|
});
|
||||||
settingRandomMusicToggle.onValueChanged.AddListener(value => BazookaManager.Instance.SetSettingRandomMusic(value));
|
statsButton.onClick.AddListener(() => {
|
||||||
musicSlider.onValueChanged.AddListener(value => {
|
var clone = Instantiate(statsPrefab.gameObject, statsPrefab.gameObject.transform.parent);
|
||||||
BazookaManager.Instance.SetSettingMusicVolume(value);
|
clone.name = "Prefab";
|
||||||
CustomGamePlayer.Instance.backgroundMusic.volume = value;
|
clone.SetActive(true);
|
||||||
});
|
});
|
||||||
sfxSlider.onValueChanged.AddListener(value => BazookaManager.Instance.SetSettingSFXVolume(value));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ToggleEditingUI() {
|
public void ToggleEditingUI() {
|
||||||
editingUI = !editingUI;
|
editingUI = !editingUI;
|
||||||
musicSlider.gameObject.SetActive(!musicSlider.gameObject.activeSelf);
|
|
||||||
sfxSlider.gameObject.SetActive(!sfxSlider.gameObject.activeSelf);
|
leaderboardsButton.gameObject.SetActive(!leaderboardsButton.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);
|
continueButton.gameObject.SetActive(!continueButton.gameObject.activeSelf);
|
||||||
editUiButton.transform.GetChild(0).GetComponent<TMP_Text>().text = editUiButton.transform.GetChild(0).GetComponent<TMP_Text>().text == "Edit UI" ? "Done" : "Edit UI";
|
mainMenuButton.gameObject.SetActive(!mainMenuButton.gameObject.activeSelf);
|
||||||
|
|
||||||
|
settingsButton.gameObject.SetActive(!settingsButton.gameObject.activeSelf);
|
||||||
|
editUiButton.gameObject.SetActive(!editUiButton.gameObject.activeSelf);
|
||||||
resetUiButton.gameObject.SetActive(!resetUiButton.gameObject.activeSelf);
|
resetUiButton.gameObject.SetActive(!resetUiButton.gameObject.activeSelf);
|
||||||
|
doneEditingUiButton.gameObject.SetActive(!doneEditingUiButton.gameObject.activeSelf);
|
||||||
|
chatroomButton.gameObject.SetActive(!chatroomButton.gameObject.activeSelf);
|
||||||
|
statsButton.gameObject.SetActive(!statsButton.gameObject.activeSelf);
|
||||||
|
|
||||||
scoreText.GetComponent<DraggableUI>().canDrag = !scoreText.GetComponent<DraggableUI>().canDrag;
|
scoreText.GetComponent<DraggableUI>().canDrag = !scoreText.GetComponent<DraggableUI>().canDrag;
|
||||||
boostText.GetComponent<DraggableUI>().canDrag = !boostText.GetComponent<DraggableUI>().canDrag;
|
boostText.GetComponent<DraggableUI>().canDrag = !boostText.GetComponent<DraggableUI>().canDrag;
|
||||||
if (Application.isMobilePlatform) {
|
if (Application.isMobilePlatform) {
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ public class GamePlayer : MonoBehaviour {
|
|||||||
[SerializeField] private TMP_Text highScoreText;
|
[SerializeField] private TMP_Text highScoreText;
|
||||||
[SerializeField] private TMP_Text boostText;
|
[SerializeField] private TMP_Text boostText;
|
||||||
[SerializeField] private TMP_Text coinText;
|
[SerializeField] private TMP_Text coinText;
|
||||||
[SerializeField] private GameObject pausePanel;
|
[SerializeField] private GamePlayerPauseMenu pausePanel;
|
||||||
[SerializeField] internal AudioSource backgroundMusic;
|
[SerializeField] internal AudioSource backgroundMusic;
|
||||||
[SerializeField] private GameObject berryParent;
|
[SerializeField] private GameObject berryParent;
|
||||||
[SerializeField] private TMP_Text levelText;
|
[SerializeField] private TMP_Text levelText;
|
||||||
@@ -65,13 +65,6 @@ public class GamePlayer : MonoBehaviour {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Start() {
|
void Start() {
|
||||||
var backgroundColor = BazookaManager.Instance.GetColorSettingBackground();
|
|
||||||
Camera.main.backgroundColor = new Color(
|
|
||||||
int.Parse(backgroundColor[0].ToString()) / 255f,
|
|
||||||
int.Parse(backgroundColor[1].ToString()) / 255f,
|
|
||||||
int.Parse(backgroundColor[2].ToString()) / 255f
|
|
||||||
);
|
|
||||||
|
|
||||||
Tools.LoadIcon(
|
Tools.LoadIcon(
|
||||||
bird,
|
bird,
|
||||||
bird.transform.GetChild(0).GetComponent<Image>(),
|
bird.transform.GetChild(0).GetComponent<Image>(),
|
||||||
@@ -214,7 +207,7 @@ public class GamePlayer : MonoBehaviour {
|
|||||||
nextSpawnTime = Time.time + 1f / spawnRate;
|
nextSpawnTime = Time.time + 1f / spawnRate;
|
||||||
}
|
}
|
||||||
float spawnProbability = UnityEngine.Random.value;
|
float spawnProbability = UnityEngine.Random.value;
|
||||||
if (!pausePanel.activeSelf) {
|
if (!pausePanel.gameObject.activeSelf) {
|
||||||
Image newBerry = Instantiate(berryTemplate).GetComponent<Image>();
|
Image newBerry = Instantiate(berryTemplate).GetComponent<Image>();
|
||||||
newBerry.transform.SetParent(berryParent.transform, false);
|
newBerry.transform.SetParent(berryParent.transform, false);
|
||||||
|
|
||||||
@@ -258,11 +251,11 @@ public class GamePlayer : MonoBehaviour {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Update() {
|
void Update() {
|
||||||
if (!pausePanel.activeSelf && rb.gravityScale != 100f * canvasRect.lossyScale.y) rb.gravityScale = 100f * canvasRect.lossyScale.y;
|
if (!pausePanel.gameObject.activeSelf && rb.gravityScale != 100f * canvasRect.lossyScale.y) rb.gravityScale = 100f * canvasRect.lossyScale.y;
|
||||||
foreach (AudioSource audio in FindObjectsByType<AudioSource>()) audio.pitch = speedyLeft > 0f ? 1.3f : 1f;
|
foreach (AudioSource audio in FindObjectsByType<AudioSource>()) audio.pitch = speedyLeft > 0f ? 1.3f : 1f;
|
||||||
|
|
||||||
SpawnBerries();
|
SpawnBerries();
|
||||||
if (!pausePanel.activeSelf) {
|
if (!pausePanel.gameObject.activeSelf) {
|
||||||
if (Time.time - lastMoveTime > 20) {
|
if (Time.time - lastMoveTime > 20) {
|
||||||
lastMoveTime = float.MaxValue;
|
lastMoveTime = float.MaxValue;
|
||||||
EnablePause();
|
EnablePause();
|
||||||
@@ -330,7 +323,7 @@ public class GamePlayer : MonoBehaviour {
|
|||||||
if (berry != null) berry.GetComponent<Rigidbody2D>().linearVelocity = noGravityBerries.Contains(berry.GetEntityId()) ? UnityEngine.Vector2.zero : new UnityEngine.Vector2(0f, speedyLeft == 0.0f ? (-300f * canvasRect.lossyScale.y) : (-550f * canvasRect.lossyScale.y));
|
if (berry != null) berry.GetComponent<Rigidbody2D>().linearVelocity = noGravityBerries.Contains(berry.GetEntityId()) ? UnityEngine.Vector2.zero : new UnityEngine.Vector2(0f, speedyLeft == 0.0f ? (-300f * canvasRect.lossyScale.y) : (-550f * canvasRect.lossyScale.y));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ((Application.platform == RuntimePlatform.Android && Keyboard.current.escapeKey.wasPressedThisFrame) || !Application.isMobilePlatform && (Keyboard.current.escapeKey.wasPressedThisFrame || (Gamepad.current != null && (Gamepad.current.startButton.wasPressedThisFrame || Gamepad.current.buttonEast.wasPressedThisFrame)))) TogglePause();
|
if (Keyboard.current.escapeKey.wasPressedThisFrame || (Gamepad.current != null && Gamepad.current.startButton.wasPressedThisFrame)) TogglePause();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Respawn() {
|
void Respawn() {
|
||||||
@@ -388,7 +381,8 @@ public class GamePlayer : MonoBehaviour {
|
|||||||
}
|
}
|
||||||
|
|
||||||
internal void TogglePause() {
|
internal void TogglePause() {
|
||||||
if (pausePanel.activeSelf) DisablePause();
|
if (GameObject.Find("Prefab")) return;
|
||||||
|
if (pausePanel.gameObject.activeSelf) DisablePause();
|
||||||
else EnablePause();
|
else EnablePause();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -399,18 +393,14 @@ public class GamePlayer : MonoBehaviour {
|
|||||||
Cursor.visible = true;
|
Cursor.visible = true;
|
||||||
Cursor.lockState = CursorLockMode.None;
|
Cursor.lockState = CursorLockMode.None;
|
||||||
backgroundMusic.GetComponent<GameMusicHandler>().PauseMusic();
|
backgroundMusic.GetComponent<GameMusicHandler>().PauseMusic();
|
||||||
pausePanel.SetActive(true);
|
pausePanel.gameObject.SetActive(true);
|
||||||
|
|
||||||
foreach (GameObject berry in berries) berry.GetComponent<Rigidbody2D>().linearVelocity = UnityEngine.Vector2.zero;
|
foreach (GameObject berry in berries) berry.GetComponent<Rigidbody2D>().linearVelocity = UnityEngine.Vector2.zero;
|
||||||
}
|
}
|
||||||
|
|
||||||
internal void DisablePause() {
|
internal void DisablePause() {
|
||||||
if (GamePlayerPauseMenu.Instance.statsMenu.activeSelf) {
|
if (pausePanel.editingUI == true) {
|
||||||
GamePlayerPauseMenu.Instance.statsMenuExitButton.onClick.Invoke();
|
pausePanel.ToggleEditingUI();
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (GamePlayerPauseMenu.Instance.editingUI == true) {
|
|
||||||
GamePlayerPauseMenu.Instance.ToggleEditingUI();
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
lastMoveTime = Time.time;
|
lastMoveTime = Time.time;
|
||||||
@@ -420,7 +410,7 @@ public class GamePlayer : MonoBehaviour {
|
|||||||
Cursor.visible = false;
|
Cursor.visible = false;
|
||||||
Cursor.lockState = CursorLockMode.Locked;
|
Cursor.lockState = CursorLockMode.Locked;
|
||||||
backgroundMusic.GetComponent<GameMusicHandler>().ResumeMusic();
|
backgroundMusic.GetComponent<GameMusicHandler>().ResumeMusic();
|
||||||
pausePanel.SetActive(false);
|
pausePanel.gameObject.SetActive(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void OnApplicationPause(bool pause) {
|
void OnApplicationPause(bool pause) {
|
||||||
|
|||||||
@@ -1,15 +1,8 @@
|
|||||||
using System.Text;
|
|
||||||
using TMPro;
|
using TMPro;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEngine.UI;
|
using UnityEngine.UI;
|
||||||
|
|
||||||
public class GamePlayerPauseMenu : MonoBehaviour {
|
public class GamePlayerPauseMenu : MonoBehaviour {
|
||||||
public static GamePlayerPauseMenu Instance;
|
|
||||||
[SerializeField] private Button backButton;
|
|
||||||
[SerializeField] private Button continueButton;
|
|
||||||
[SerializeField] private Button statsButton;
|
|
||||||
[SerializeField] private Button editUiButton;
|
|
||||||
[SerializeField] private Button resetUiButton;
|
|
||||||
[SerializeField] private AudioSource songLoop;
|
[SerializeField] private AudioSource songLoop;
|
||||||
[SerializeField] private TMP_Text scoreText;
|
[SerializeField] private TMP_Text scoreText;
|
||||||
[SerializeField] private TMP_Text highScoreText;
|
[SerializeField] private TMP_Text highScoreText;
|
||||||
@@ -23,31 +16,26 @@ public class GamePlayerPauseMenu : MonoBehaviour {
|
|||||||
[SerializeField] private Button leftButton;
|
[SerializeField] private Button leftButton;
|
||||||
internal bool editingUI = false;
|
internal bool editingUI = false;
|
||||||
|
|
||||||
public GameObject statsMenu;
|
[SerializeField] private Button leaderboardsButton;
|
||||||
public Button statsMenuExitButton;
|
[SerializeField] private Button continueButton;
|
||||||
[SerializeField] private TMP_Text statsText;
|
[SerializeField] private Button mainMenuButton;
|
||||||
|
|
||||||
[SerializeField] private Toggle settingFullscreenToggle;
|
[SerializeField] private Button settingsButton;
|
||||||
[SerializeField] private Toggle settingVSyncToggle;
|
[SerializeField] private Button editUiButton;
|
||||||
[SerializeField] private Toggle settingRandomMusicToggle;
|
[SerializeField] private Button resetUiButton;
|
||||||
[SerializeField] private Slider musicSlider;
|
[SerializeField] private Button doneEditingUiButton;
|
||||||
[SerializeField] private Slider sfxSlider;
|
[SerializeField] private Button chatroomButton;
|
||||||
[SerializeField] private TMP_Text musicSliderText;
|
[SerializeField] private Button statsButton;
|
||||||
[SerializeField] private TMP_Text sfxSliderText;
|
|
||||||
|
[SerializeField] private SettingsMenu settingsPrefab;
|
||||||
|
[SerializeField] private StatsPrefab statsPrefab;
|
||||||
|
[SerializeField] private ChatroomPrefab chatroomPrefab;
|
||||||
|
[SerializeField] private LeaderboardsPrefab leaderboardsPrefab;
|
||||||
|
|
||||||
void Awake() {
|
void Awake() {
|
||||||
Instance = this;
|
|
||||||
continueButton.onClick.AddListener(GamePlayer.Instance.DisablePause);
|
continueButton.onClick.AddListener(GamePlayer.Instance.DisablePause);
|
||||||
musicSlider.onValueChanged.AddListener(value => {
|
editUiButton.onClick.AddListener(() => ToggleEditingUI());
|
||||||
BazookaManager.Instance.SetSettingMusicVolume(value);
|
doneEditingUiButton.onClick.AddListener(() => ToggleEditingUI());
|
||||||
songLoop.volume = value;
|
|
||||||
});
|
|
||||||
sfxSlider.onValueChanged.AddListener(value => {
|
|
||||||
BazookaManager.Instance.SetSettingSFXVolume(value);
|
|
||||||
});
|
|
||||||
editUiButton.onClick.AddListener(() => {
|
|
||||||
ToggleEditingUI();
|
|
||||||
});
|
|
||||||
resetUiButton.onClick.AddListener(() => {
|
resetUiButton.onClick.AddListener(() => {
|
||||||
scoreText.transform.GetComponent<RectTransform>().anchoredPosition = new Vector2(0f, -70f);
|
scoreText.transform.GetComponent<RectTransform>().anchoredPosition = new Vector2(0f, -70f);
|
||||||
highScoreText.transform.GetComponent<RectTransform>().anchoredPosition = new Vector2(0f, -140f);
|
highScoreText.transform.GetComponent<RectTransform>().anchoredPosition = new Vector2(0f, -140f);
|
||||||
@@ -72,70 +60,44 @@ public class GamePlayerPauseMenu : MonoBehaviour {
|
|||||||
PlayerPrefs.DeleteKey("DraggedUILeftButton");
|
PlayerPrefs.DeleteKey("DraggedUILeftButton");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
statsButton.onClick.AddListener(() => {
|
|
||||||
statsMenu.SetActive(true);
|
leaderboardsButton.onClick.AddListener(() => {
|
||||||
var text = new StringBuilder();
|
var clone = Instantiate(leaderboardsPrefab.gameObject, leaderboardsPrefab.gameObject.transform.parent);
|
||||||
text.AppendLine("High Score: " + Tools.FormatWithCommas(GamePlayer.Instance.highscore));
|
clone.name = "Prefab";
|
||||||
text.AppendLine("Total Normal Berries: " + Tools.FormatWithCommas(GamePlayer.Instance.totalNormalBerries));
|
clone.SetActive(true);
|
||||||
text.AppendLine("Total Poison Berries: " + Tools.FormatWithCommas(GamePlayer.Instance.totalPoisonBerries));
|
|
||||||
text.AppendLine("Total Slow Berries: " + Tools.FormatWithCommas(GamePlayer.Instance.totalSlowBerries));
|
|
||||||
text.AppendLine("Total Ultra Berries: " + Tools.FormatWithCommas(GamePlayer.Instance.totalUltraBerries));
|
|
||||||
text.AppendLine("Total Coin Berries: " + Tools.FormatWithCommas(GamePlayer.Instance.totalCoinBerries));
|
|
||||||
text.AppendLine("Total Speedy Berries: " + Tools.FormatWithCommas(GamePlayer.Instance.totalSpeedyBerries));
|
|
||||||
text.AppendLine("Total Random Berries: " + Tools.FormatWithCommas(GamePlayer.Instance.totalRandomBerries));
|
|
||||||
text.AppendLine("Total Anti Berries: " + Tools.FormatWithCommas(GamePlayer.Instance.totalAntiBerries));
|
|
||||||
text.AppendLine("Total Golden Berries: " + Tools.FormatWithCommas(GamePlayer.Instance.totalGoldenBerries));
|
|
||||||
text.AppendLine("Total Attempts: " + Tools.FormatWithCommas(GamePlayer.Instance.totalAttempts));
|
|
||||||
statsText.text = text.ToString();
|
|
||||||
});
|
|
||||||
statsMenuExitButton.onClick.AddListener(() => {
|
|
||||||
statsMenu.SetActive(false);
|
|
||||||
statsText.text = string.Empty;
|
|
||||||
});
|
});
|
||||||
|
|
||||||
musicSlider.value = BazookaManager.Instance.GetSettingMusicVolume();
|
settingsButton.onClick.AddListener(() => {
|
||||||
sfxSlider.value = BazookaManager.Instance.GetSettingSFXVolume();
|
var clone = Instantiate(settingsPrefab.gameObject, settingsPrefab.gameObject.transform.parent);
|
||||||
if (!Application.isMobilePlatform) {
|
clone.name = "Prefab";
|
||||||
settingFullscreenToggle.isOn = BazookaManager.Instance.GetSettingFullScreen() == true;
|
clone.SetActive(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 => {
|
chatroomButton.onClick.AddListener(() => {
|
||||||
BazookaManager.Instance.SetSettingVsync(value);
|
var clone = Instantiate(chatroomPrefab.gameObject, chatroomPrefab.gameObject.transform.parent);
|
||||||
QualitySettings.vSyncCount = value ? 1 : -1;
|
clone.name = "Prefab";
|
||||||
|
clone.SetActive(true);
|
||||||
});
|
});
|
||||||
} else {
|
statsButton.onClick.AddListener(() => {
|
||||||
settingFullscreenToggle.interactable = false;
|
var clone = Instantiate(statsPrefab.gameObject, statsPrefab.gameObject.transform.parent);
|
||||||
settingVSyncToggle.interactable = false;
|
clone.name = "Prefab";
|
||||||
settingRandomMusicToggle.isOn = BazookaManager.Instance.GetSettingRandomMusic() == true;
|
clone.SetActive(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() {
|
public void ToggleEditingUI() {
|
||||||
editingUI = !editingUI;
|
editingUI = !editingUI;
|
||||||
musicSlider.gameObject.SetActive(!musicSlider.gameObject.activeSelf);
|
|
||||||
sfxSlider.gameObject.SetActive(!sfxSlider.gameObject.activeSelf);
|
leaderboardsButton.gameObject.SetActive(!leaderboardsButton.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);
|
continueButton.gameObject.SetActive(!continueButton.gameObject.activeSelf);
|
||||||
statsButton.gameObject.SetActive(!statsButton.gameObject.activeSelf);
|
mainMenuButton.gameObject.SetActive(!mainMenuButton.gameObject.activeSelf);
|
||||||
editUiButton.transform.GetChild(0).GetComponent<TMP_Text>().text = editUiButton.transform.GetChild(0).GetComponent<TMP_Text>().text == "Edit UI" ? "Done" : "Edit UI";
|
|
||||||
|
settingsButton.gameObject.SetActive(!settingsButton.gameObject.activeSelf);
|
||||||
|
editUiButton.gameObject.SetActive(!editUiButton.gameObject.activeSelf);
|
||||||
resetUiButton.gameObject.SetActive(!resetUiButton.gameObject.activeSelf);
|
resetUiButton.gameObject.SetActive(!resetUiButton.gameObject.activeSelf);
|
||||||
|
doneEditingUiButton.gameObject.SetActive(!doneEditingUiButton.gameObject.activeSelf);
|
||||||
|
chatroomButton.gameObject.SetActive(!chatroomButton.gameObject.activeSelf);
|
||||||
|
statsButton.gameObject.SetActive(!statsButton.gameObject.activeSelf);
|
||||||
|
|
||||||
scoreText.GetComponent<DraggableUI>().canDrag = !scoreText.GetComponent<DraggableUI>().canDrag;
|
scoreText.GetComponent<DraggableUI>().canDrag = !scoreText.GetComponent<DraggableUI>().canDrag;
|
||||||
highScoreText.GetComponent<DraggableUI>().canDrag = !highScoreText.GetComponent<DraggableUI>().canDrag;
|
highScoreText.GetComponent<DraggableUI>().canDrag = !highScoreText.GetComponent<DraggableUI>().canDrag;
|
||||||
boostText.GetComponent<DraggableUI>().canDrag = !boostText.GetComponent<DraggableUI>().canDrag;
|
boostText.GetComponent<DraggableUI>().canDrag = !boostText.GetComponent<DraggableUI>().canDrag;
|
||||||
|
|||||||
@@ -24,6 +24,10 @@ public class SettingsMenu : MonoBehaviour {
|
|||||||
[SerializeField] private int colorType = 0;
|
[SerializeField] private int colorType = 0;
|
||||||
[SerializeField] private bool colorCanSave = true;
|
[SerializeField] private bool colorCanSave = true;
|
||||||
|
|
||||||
|
void Awake() {
|
||||||
|
if (SceneManager.GetActiveScene().name != "MainMenu") setting4toggle.gameObject.SetActive(false);
|
||||||
|
}
|
||||||
|
|
||||||
private void Start() {
|
private void Start() {
|
||||||
colorMenu.Init(Color.white, Color.white);
|
colorMenu.Init(Color.white, Color.white);
|
||||||
colorMenu.OnColorChanged += color => {
|
colorMenu.OnColorChanged += color => {
|
||||||
@@ -52,7 +56,7 @@ public class SettingsMenu : MonoBehaviour {
|
|||||||
setting1toggle.isOn = BazookaManager.Instance.GetSettingFullScreen() == true;
|
setting1toggle.isOn = BazookaManager.Instance.GetSettingFullScreen() == true;
|
||||||
setting2toggle.isOn = BazookaManager.Instance.GetSettingShowFPS() == true;
|
setting2toggle.isOn = BazookaManager.Instance.GetSettingShowFPS() == true;
|
||||||
setting3toggle.isOn = BazookaManager.Instance.GetSettingVsync() == true;
|
setting3toggle.isOn = BazookaManager.Instance.GetSettingVsync() == true;
|
||||||
setting4toggle.isOn = BazookaManager.Instance.GetSettingHideSocials() == true;
|
if (setting4toggle.gameObject.activeSelf) setting4toggle.isOn = BazookaManager.Instance.GetSettingHideSocials() == true;
|
||||||
setting5toggle.isOn = BazookaManager.Instance.GetSettingRandomMusic() == true;
|
setting5toggle.isOn = BazookaManager.Instance.GetSettingRandomMusic() == true;
|
||||||
setting1toggle.onValueChanged.AddListener(value => {
|
setting1toggle.onValueChanged.AddListener(value => {
|
||||||
BazookaManager.Instance.SetSettingFullScreen(value);
|
BazookaManager.Instance.SetSettingFullScreen(value);
|
||||||
@@ -68,12 +72,13 @@ public class SettingsMenu : MonoBehaviour {
|
|||||||
setting1toggle.gameObject.SetActive(false);
|
setting1toggle.gameObject.SetActive(false);
|
||||||
setting2toggle.isOn = BazookaManager.Instance.GetSettingShowFPS() == true;
|
setting2toggle.isOn = BazookaManager.Instance.GetSettingShowFPS() == true;
|
||||||
setting3toggle.gameObject.SetActive(false);
|
setting3toggle.gameObject.SetActive(false);
|
||||||
setting4toggle.isOn = BazookaManager.Instance.GetSettingHideSocials() == true;
|
if (setting4toggle.gameObject.activeSelf) setting4toggle.isOn = BazookaManager.Instance.GetSettingHideSocials() == true;
|
||||||
setting5toggle.isOn = BazookaManager.Instance.GetSettingRandomMusic() == true;
|
setting5toggle.isOn = BazookaManager.Instance.GetSettingRandomMusic() == true;
|
||||||
}
|
}
|
||||||
setting2toggle.onValueChanged.AddListener(value => {
|
setting2toggle.onValueChanged.AddListener(value => {
|
||||||
BazookaManager.Instance.SetSettingShowFPS(value);
|
BazookaManager.Instance.SetSettingShowFPS(value);
|
||||||
});
|
});
|
||||||
|
if (setting4toggle.gameObject.activeSelf)
|
||||||
setting4toggle.onValueChanged.AddListener(value => {
|
setting4toggle.onValueChanged.AddListener(value => {
|
||||||
BazookaManager.Instance.SetSettingHideSocials(value);
|
BazookaManager.Instance.SetSettingHideSocials(value);
|
||||||
|
|
||||||
@@ -84,7 +89,8 @@ public class SettingsMenu : MonoBehaviour {
|
|||||||
setting5toggle.onValueChanged.AddListener(value => BazookaManager.Instance.SetSettingRandomMusic(value));
|
setting5toggle.onValueChanged.AddListener(value => BazookaManager.Instance.SetSettingRandomMusic(value));
|
||||||
musicSlider.onValueChanged.AddListener(value => {
|
musicSlider.onValueChanged.AddListener(value => {
|
||||||
BazookaManager.Instance.SetSettingMusicVolume(value);
|
BazookaManager.Instance.SetSettingMusicVolume(value);
|
||||||
MenuMusic.Instance.GetComponent<AudioSource>().volume = value;
|
if (SceneManager.GetActiveScene().name == "MainMenu") MenuMusic.Instance.GetComponent<AudioSource>().volume = value;
|
||||||
|
else GamePlayer.Instance.backgroundMusic.volume = value;
|
||||||
});
|
});
|
||||||
sfxSlider.onValueChanged.AddListener(value => BazookaManager.Instance.SetSettingSFXVolume(value));
|
sfxSlider.onValueChanged.AddListener(value => BazookaManager.Instance.SetSettingSFXVolume(value));
|
||||||
Tools.RefreshHierarchy(setting1toggle.transform.parent.gameObject);
|
Tools.RefreshHierarchy(setting1toggle.transform.parent.gameObject);
|
||||||
|
|||||||
Reference in new issue
Block a user