Reformat code
This commit is contained in:
77 files changed
+1041
-2187
No files matched your search
+136
-313
@@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Numerics;
|
||||
using TMPro;
|
||||
@@ -6,8 +6,7 @@ using UnityEngine;
|
||||
using UnityEngine.InputSystem;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class GamePlayer : MonoBehaviour
|
||||
{
|
||||
public class GamePlayer : MonoBehaviour {
|
||||
public static GamePlayer instance;
|
||||
private readonly float spawnRate = 1f;
|
||||
private float nextSpawnTime;
|
||||
@@ -52,8 +51,7 @@ public class GamePlayer : MonoBehaviour
|
||||
[SerializeField] private Button rightButton;
|
||||
[SerializeField] private Button leftButton;
|
||||
|
||||
void Start()
|
||||
{
|
||||
void Start() {
|
||||
var backgroundColor = BazookaManager.Instance.GetColorSettingBackground();
|
||||
Camera.main.backgroundColor = new Color(
|
||||
int.Parse(backgroundColor[0].ToString()) / 255f,
|
||||
@@ -63,8 +61,7 @@ public class GamePlayer : MonoBehaviour
|
||||
|
||||
var customIconData = BazookaManager.Instance.GetCustomBirdIconData();
|
||||
SpriteRenderer birdRender = bird.GetComponent<SpriteRenderer>();
|
||||
if (customIconData.Selected == null)
|
||||
{
|
||||
if (customIconData.Selected == null) {
|
||||
var birdColor = BazookaManager.Instance.GetColorSettingIcon();
|
||||
var overlayColor = BazookaManager.Instance.GetColorSettingOverlay();
|
||||
bird.GetComponent<SpriteRenderer>().color = new Color(
|
||||
@@ -80,49 +77,35 @@ public class GamePlayer : MonoBehaviour
|
||||
|
||||
int icon = BazookaManager.Instance.GetBirdIcon();
|
||||
int iconOverlay = BazookaManager.Instance.GetBirdOverlay();
|
||||
if (icon == 1)
|
||||
{
|
||||
if (icon == 1) {
|
||||
birdRender.sprite = Tools.GetIconForUser(BazookaManager.Instance.GetAccountID() ?? 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
birdRender.sprite = Resources.Load<Sprite>("Icons/Icons/bird_" + icon);
|
||||
}
|
||||
if (iconOverlay == 8)
|
||||
{
|
||||
if (iconOverlay == 8) {
|
||||
overlayRender.sprite = Resources.Load<Sprite>("Icons/Overlays/overlay_" + iconOverlay);
|
||||
overlayRender.transform.localPosition = new UnityEngine.Vector3(-0.37f, 0.32f, 0f);
|
||||
}
|
||||
else if (iconOverlay == 11)
|
||||
{
|
||||
} else if (iconOverlay == 11) {
|
||||
overlayRender.sprite = Resources.Load<Sprite>("Icons/Overlays/overlay_" + iconOverlay);
|
||||
overlayRender.transform.localScale = new UnityEngine.Vector3(1.1f, 1.1f, 1.1f); //yea i didnt feel like doing it for all lmao
|
||||
overlayRender.transform.localPosition = new UnityEngine.Vector3(-0.3141809f, 0.4324968f, 0f);
|
||||
}
|
||||
else if (iconOverlay == 13)
|
||||
{
|
||||
} else if (iconOverlay == 13) {
|
||||
overlayRender.sprite = Resources.Load<Sprite>("Icons/Overlays/overlay_" + iconOverlay);
|
||||
overlayRender.transform.localPosition = new UnityEngine.Vector3(-0.3559977f, 0.3179995f, 0f);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
overlayRender.sprite = Resources.Load<Sprite>("Icons/Overlays/overlay_" + iconOverlay);
|
||||
}
|
||||
if (birdRender.sprite == null)
|
||||
{
|
||||
if (birdRender.sprite == null) {
|
||||
birdRender.sprite = Resources.Load<Sprite>("Icons/Icons/bird_1");
|
||||
BazookaManager.Instance.SetBirdIcon(1);
|
||||
}
|
||||
if (overlayRender.sprite == null && iconOverlay != 0)
|
||||
{
|
||||
if (overlayRender.sprite == null && iconOverlay != 0) {
|
||||
overlayRender.sprite = Resources.Load<Sprite>("Icons/Overlays/overlay_1");
|
||||
BazookaManager.Instance.SetBirdOverlay(1);
|
||||
}
|
||||
}
|
||||
else if (customIconData.Selected != null)
|
||||
} else if (customIconData.Selected != null)
|
||||
foreach (var icon in customIconData.Purchased)
|
||||
if (icon == customIconData.Selected)
|
||||
{
|
||||
if (icon == customIconData.Selected) {
|
||||
var waitingForCustomIcon = birdRender.gameObject.AddComponent<WaitingForCustomIcon>();
|
||||
waitingForCustomIcon.ID = customIconData.Selected;
|
||||
CustomIconLoader.Init(new[] { waitingForCustomIcon });
|
||||
@@ -152,8 +135,7 @@ public class GamePlayer : MonoBehaviour
|
||||
UpdateStats(0, 1);
|
||||
}
|
||||
|
||||
void MoveBird()
|
||||
{
|
||||
void MoveBird() {
|
||||
float screenWidth = Camera.main.orthographicSize * 2f * Camera.main.aspect;
|
||||
float baseSpeed = 0.18f * (screenWidth / 20.19257f);
|
||||
bool doMoveRight = false;
|
||||
@@ -162,42 +144,31 @@ public class GamePlayer : MonoBehaviour
|
||||
bool doRestart = false;
|
||||
bool doBack = false;
|
||||
float movespeed = baseSpeed;
|
||||
if (boostLeft > 0f || speedyLeft > 0f)
|
||||
{
|
||||
if (boostLeft > 0f || speedyLeft > 0f) {
|
||||
movespeed = baseSpeed * 1.39f;
|
||||
}
|
||||
else if (slownessLeft > 0f)
|
||||
{
|
||||
} else if (slownessLeft > 0f) {
|
||||
movespeed = baseSpeed * 0.56f;
|
||||
}
|
||||
CheckIfGrounded();
|
||||
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 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);
|
||||
if (!Application.isMobilePlatform)
|
||||
{
|
||||
if (controllerLeft || Keyboard.current.leftArrowKey.isPressed || Keyboard.current.aKey.isPressed || Keyboard.current.jKey.isPressed)
|
||||
{
|
||||
if (!Application.isMobilePlatform) {
|
||||
if (controllerLeft || Keyboard.current.leftArrowKey.isPressed || Keyboard.current.aKey.isPressed || Keyboard.current.jKey.isPressed) {
|
||||
doMoveLeft = true;
|
||||
}
|
||||
if (controllerRight || Keyboard.current.rightArrowKey.isPressed || Keyboard.current.dKey.isPressed || Keyboard.current.lKey.isPressed)
|
||||
{
|
||||
if (controllerRight || Keyboard.current.rightArrowKey.isPressed || Keyboard.current.dKey.isPressed || Keyboard.current.lKey.isPressed) {
|
||||
doMoveRight = true;
|
||||
}
|
||||
if (controllerJump || Keyboard.current.spaceKey.isPressed || Keyboard.current.upArrowKey.isPressed || Keyboard.current.wKey.isPressed || Keyboard.current.downArrowKey.isPressed || Keyboard.current.sKey.isPressed || Keyboard.current.kKey.isPressed || Keyboard.current.iKey.isPressed || Mouse.current.leftButton.isPressed || (Gamepad.current != null && Gamepad.current.buttonSouth.isPressed))
|
||||
{
|
||||
if (controllerJump || Keyboard.current.spaceKey.isPressed || Keyboard.current.upArrowKey.isPressed || Keyboard.current.wKey.isPressed || Keyboard.current.downArrowKey.isPressed || Keyboard.current.sKey.isPressed || Keyboard.current.kKey.isPressed || Keyboard.current.iKey.isPressed || Mouse.current.leftButton.isPressed || (Gamepad.current != null && Gamepad.current.buttonSouth.isPressed)) {
|
||||
doJump = true;
|
||||
}
|
||||
if (Keyboard.current.rKey.isPressed)
|
||||
{
|
||||
if (Keyboard.current.rKey.isPressed) {
|
||||
doRestart = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
var touches = UnityEngine.InputSystem.EnhancedTouch.Touch.activeTouches;
|
||||
for (int i = 0; i < touches.Count; i++)
|
||||
{
|
||||
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;
|
||||
@@ -208,56 +179,42 @@ public class GamePlayer : MonoBehaviour
|
||||
if (pauseButton.GetComponent<HoldableButton>().isPressed) doBack = true;
|
||||
}
|
||||
}
|
||||
if (doMoveLeft && !doMoveRight)
|
||||
{
|
||||
if (doMoveLeft && !doMoveRight) {
|
||||
lastMoveTime = Time.time;
|
||||
bird.transform.position += new UnityEngine.Vector3(-movespeed, 0f, 0f);
|
||||
ClampPosition(bird);
|
||||
bird.transform.localScale = new UnityEngine.Vector3(1.35f, 1.35f, 1.35f);
|
||||
}
|
||||
if (doMoveRight && !doMoveLeft)
|
||||
{
|
||||
if (doMoveRight && !doMoveLeft) {
|
||||
lastMoveTime = Time.time;
|
||||
bird.transform.position += new UnityEngine.Vector3(movespeed, 0f, 0f);
|
||||
ClampPosition(bird);
|
||||
bird.transform.localScale = new UnityEngine.Vector3(-1.35f, 1.35f, 1.35f);
|
||||
}
|
||||
if (doJump && isGrounded)
|
||||
{
|
||||
if (doJump && isGrounded) {
|
||||
lastMoveTime = Time.time;
|
||||
AudioSource.PlayClipAtPoint(Resources.Load<AudioClip>("Sounds/Jump"), Camera.main.transform.position, 0.75f * BazookaManager.Instance.GetSettingSFXVolume());
|
||||
if (boostLeft > 0f || speedyLeft > 0f)
|
||||
{
|
||||
if (boostLeft > 0f || speedyLeft > 0f) {
|
||||
rb.linearVelocity = UnityEngine.Vector2.up * 12f;
|
||||
}
|
||||
else if (slownessLeft > 0f)
|
||||
{
|
||||
} else if (slownessLeft > 0f) {
|
||||
rb.linearVelocity = UnityEngine.Vector2.up * 6f;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
rb.linearVelocity = UnityEngine.Vector2.up * 9f;
|
||||
}
|
||||
}
|
||||
if (doBack)
|
||||
{
|
||||
if (doBack) {
|
||||
TogglePause();
|
||||
}
|
||||
if (doRestart)
|
||||
{
|
||||
if (doRestart) {
|
||||
if (score != 0) Respawn();
|
||||
}
|
||||
if (antiLeft > 0f || goldenLeft > 0f)
|
||||
{
|
||||
if (antiLeft > 0f || goldenLeft > 0f) {
|
||||
string[] berryTags = { "NormalBerry", "SlowBerry", "UltraBerry", "SpeedyBerry", "CoinBerry", "RandomBerry", "AntiBerry", "GoldenBerry" };
|
||||
if (antiLeft > 0f) berryTags.Append("PoisonBerry");
|
||||
foreach (string tag in berryTags)
|
||||
{
|
||||
foreach (var berry in GameObject.FindGameObjectsWithTag(tag))
|
||||
{
|
||||
foreach (string tag in berryTags) {
|
||||
foreach (var berry in GameObject.FindGameObjectsWithTag(tag)) {
|
||||
UnityEngine.Vector3 dir = berry.transform.position - bird.transform.position;
|
||||
if (dir.magnitude < (antiLeft > 0 ? 3f : 4.5f))
|
||||
{
|
||||
if (dir.magnitude < (antiLeft > 0 ? 3f : 4.5f)) {
|
||||
berry.GetComponent<Rigidbody2D>().linearVelocity = dir.normalized * (antiLeft > 0 ? 5f : -5f);
|
||||
ClampPosition(berry, false);
|
||||
}
|
||||
@@ -266,8 +223,7 @@ public class GamePlayer : MonoBehaviour
|
||||
}
|
||||
}
|
||||
|
||||
void ClampPosition(GameObject obj, bool modifyY = true)
|
||||
{
|
||||
void ClampPosition(GameObject obj, bool modifyY = true) {
|
||||
var cam = Camera.main;
|
||||
var pos = obj.transform.position;
|
||||
var bounds = obj.GetComponent<Renderer>().bounds.extents;
|
||||
@@ -283,108 +239,72 @@ public class GamePlayer : MonoBehaviour
|
||||
obj.transform.position = pos;
|
||||
}
|
||||
|
||||
void FixedUpdate()
|
||||
{
|
||||
void FixedUpdate() {
|
||||
SpawnBerries();
|
||||
if (!pausePanel.activeSelf)
|
||||
{
|
||||
if (!pausePanel.activeSelf) {
|
||||
MoveBird();
|
||||
if (boostLeft > 0f)
|
||||
{
|
||||
if (boostLeft > 0f) {
|
||||
boostLeft -= Time.deltaTime;
|
||||
boostText.text = "Boost expires in " + string.Format("{0:0.0}", boostLeft) + "s";
|
||||
}
|
||||
else if (slownessLeft > 0f)
|
||||
{
|
||||
} else if (slownessLeft > 0f) {
|
||||
slownessLeft -= Time.deltaTime;
|
||||
boostText.text = "Slowness expires in " + string.Format("{0:0.0}", slownessLeft) + "s";
|
||||
}
|
||||
else if (speedyLeft > 0f)
|
||||
{
|
||||
} else if (speedyLeft > 0f) {
|
||||
speedyLeft -= Time.deltaTime;
|
||||
boostText.text = "Speed expires in " + string.Format("{0:0.0}", speedyLeft) + "s";
|
||||
}
|
||||
else if (antiLeft > 0f)
|
||||
{
|
||||
} else if (antiLeft > 0f) {
|
||||
antiLeft -= Time.deltaTime;
|
||||
boostText.text = "Berry repellent expires in " + string.Format("{0:0.0}", antiLeft) + "s";
|
||||
}
|
||||
else if (goldenLeft > 0f)
|
||||
{
|
||||
} else if (goldenLeft > 0f) {
|
||||
goldenLeft -= Time.deltaTime;
|
||||
boostText.text = "Berry magnet expires in " + string.Format("{0:0.0}", goldenLeft) + "s";
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
boostText.text = "";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void SpawnBerries()
|
||||
{
|
||||
if (Time.time < nextSpawnTime)
|
||||
{
|
||||
void SpawnBerries() {
|
||||
if (Time.time < nextSpawnTime) {
|
||||
return;
|
||||
}
|
||||
if (speedyLeft > 0)
|
||||
{
|
||||
if (speedyLeft > 0) {
|
||||
nextSpawnTime = Time.time + 1f / (spawnRate * 1.875f);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
nextSpawnTime = Time.time + 1f / spawnRate;
|
||||
}
|
||||
float spawnProbability = UnityEngine.Random.value;
|
||||
if (!pausePanel.activeSelf)
|
||||
{
|
||||
if (!pausePanel.activeSelf) {
|
||||
GameObject newBerry = new("Berry");
|
||||
newBerry.transform.SetParent(berryParent.transform);
|
||||
SpriteRenderer spriteRenderer = newBerry.AddComponent<SpriteRenderer>();
|
||||
if (spawnProbability <= 0.375f)
|
||||
{
|
||||
if (spawnProbability <= 0.375f) {
|
||||
spriteRenderer.sprite = Resources.Load<Sprite>("Berries/Berry");
|
||||
newBerry.tag = "NormalBerry";
|
||||
}
|
||||
else if (spawnProbability <= 0.550)
|
||||
{
|
||||
} else if (spawnProbability <= 0.550) {
|
||||
spriteRenderer.sprite = Resources.Load<Sprite>("Berries/PoisonBerry");
|
||||
newBerry.tag = "PoisonBerry";
|
||||
}
|
||||
else if (spawnProbability <= 0.60f)
|
||||
{
|
||||
} else if (spawnProbability <= 0.60f) {
|
||||
spriteRenderer.sprite = Resources.Load<Sprite>("Berries/SlowBerry");
|
||||
newBerry.tag = "SlowBerry";
|
||||
}
|
||||
else if (spawnProbability <= 0.70f)
|
||||
{
|
||||
} else if (spawnProbability <= 0.70f) {
|
||||
spriteRenderer.sprite = Resources.Load<Sprite>("Berries/UltraBerry");
|
||||
newBerry.tag = "UltraBerry";
|
||||
}
|
||||
else if (spawnProbability <= 0.80f)
|
||||
{
|
||||
} else if (spawnProbability <= 0.80f) {
|
||||
spriteRenderer.sprite = Resources.Load<Sprite>("Berries/SpeedyBerry");
|
||||
newBerry.tag = "SpeedyBerry";
|
||||
}
|
||||
else if (spawnProbability <= 0.85f)
|
||||
{
|
||||
} else if (spawnProbability <= 0.85f) {
|
||||
spriteRenderer.sprite = Resources.Load<Sprite>("Berries/CoinBerry");
|
||||
newBerry.tag = "CoinBerry";
|
||||
}
|
||||
else if (spawnProbability <= 0.90f)
|
||||
{
|
||||
} else if (spawnProbability <= 0.90f) {
|
||||
spriteRenderer.sprite = Resources.Load<Sprite>("Berries/BerryNoColor");
|
||||
newBerry.tag = "RandomBerry";
|
||||
RainbowSpriteRender randomBerryRainbowImage = newBerry.AddComponent<RainbowSpriteRender>();
|
||||
randomBerryRainbowImage.frequency = 5f;
|
||||
}
|
||||
else if (spawnProbability <= 0.95f)
|
||||
{
|
||||
} else if (spawnProbability <= 0.95f) {
|
||||
spriteRenderer.sprite = Resources.Load<Sprite>("Berries/AntiBerry");
|
||||
newBerry.tag = "AntiBerry";
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
spriteRenderer.sprite = Resources.Load<Sprite>("Berries/GoldenBerry");
|
||||
newBerry.tag = "GoldenBerry";
|
||||
}
|
||||
@@ -400,14 +320,11 @@ public class GamePlayer : MonoBehaviour
|
||||
}
|
||||
}
|
||||
|
||||
void Update()
|
||||
{
|
||||
foreach (AudioSource audio in FindObjectsByType<AudioSource>(FindObjectsSortMode.None))
|
||||
{
|
||||
void Update() {
|
||||
foreach (AudioSource audio in FindObjectsByType<AudioSource>(FindObjectsSortMode.None)) {
|
||||
audio.pitch = speedyLeft > 0f ? 1.3f : 1f;
|
||||
}
|
||||
if (screenWidth != Camera.main.orthographicSize * 2f * Camera.main.aspect)
|
||||
{
|
||||
if (screenWidth != Camera.main.orthographicSize * 2f * Camera.main.aspect) {
|
||||
screenWidth = Camera.main.orthographicSize * 2f * Camera.main.aspect;
|
||||
ClampPosition(bird);
|
||||
GameObject[] allberries = GameObject.FindGameObjectsWithTag("NormalBerry")
|
||||
@@ -420,8 +337,7 @@ public class GamePlayer : MonoBehaviour
|
||||
.Concat(GameObject.FindGameObjectsWithTag("AntiBerry"))
|
||||
.Concat(GameObject.FindGameObjectsWithTag("GoldenBerry"))
|
||||
.ToArray();
|
||||
foreach (GameObject berry in allberries)
|
||||
{
|
||||
foreach (GameObject berry in allberries) {
|
||||
ClampPosition(berry, false);
|
||||
}
|
||||
}
|
||||
@@ -435,142 +351,94 @@ public class GamePlayer : MonoBehaviour
|
||||
GameObject[] antiBerries = GameObject.FindGameObjectsWithTag("AntiBerry");
|
||||
GameObject[] goldenBerries = GameObject.FindGameObjectsWithTag("GoldenBerry");
|
||||
|
||||
if (!pausePanel.activeSelf)
|
||||
{
|
||||
if (Time.time - lastMoveTime > 20)
|
||||
{
|
||||
if (!pausePanel.activeSelf) {
|
||||
if (Time.time - lastMoveTime > 20) {
|
||||
lastMoveTime = float.MaxValue;
|
||||
EnablePause();
|
||||
}
|
||||
CheckIfGrounded();
|
||||
foreach (GameObject normalBerry in normalBerries)
|
||||
{
|
||||
if (normalBerry.transform.position.y < 0f - Camera.main.orthographicSize - 1f)
|
||||
{
|
||||
foreach (GameObject normalBerry in normalBerries) {
|
||||
if (normalBerry.transform.position.y < 0f - Camera.main.orthographicSize - 1f) {
|
||||
Destroy(normalBerry);
|
||||
}
|
||||
else if (UnityEngine.Vector3.Distance(bird.transform.position, normalBerry.transform.position) < 1.5f)
|
||||
{
|
||||
} else if (UnityEngine.Vector3.Distance(bird.transform.position, normalBerry.transform.position) < 1.5f) {
|
||||
totalNormalBerries++;
|
||||
DoNormalBerry(normalBerry);
|
||||
}
|
||||
if (speedyLeft > 0)
|
||||
{
|
||||
if (speedyLeft > 0) {
|
||||
normalBerry.GetComponent<Rigidbody2D>().linearVelocity = new UnityEngine.Vector2(0f, -7.5f);
|
||||
}
|
||||
else
|
||||
{
|
||||
} 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)
|
||||
{
|
||||
foreach (GameObject poisonBerry in poisonBerries) {
|
||||
if (poisonBerry.transform.position.y < 0f - Camera.main.orthographicSize - 1f) {
|
||||
Destroy(poisonBerry);
|
||||
}
|
||||
else if (UnityEngine.Vector3.Distance(bird.transform.position, poisonBerry.transform.position) < 1.5f)
|
||||
{
|
||||
} else if (UnityEngine.Vector3.Distance(bird.transform.position, poisonBerry.transform.position) < 1.5f) {
|
||||
totalPoisonBerries++;
|
||||
DoPoisonBerry();
|
||||
}
|
||||
if (speedyLeft > 0)
|
||||
{
|
||||
if (speedyLeft > 0) {
|
||||
poisonBerry.GetComponent<Rigidbody2D>().linearVelocity = new UnityEngine.Vector2(0f, -7.5f);
|
||||
}
|
||||
else
|
||||
{
|
||||
} 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)
|
||||
{
|
||||
foreach (GameObject slowBerry in slowBerries) {
|
||||
if (slowBerry.transform.position.y < 0f - Camera.main.orthographicSize - 1f) {
|
||||
Destroy(slowBerry);
|
||||
}
|
||||
else if (UnityEngine.Vector3.Distance(bird.transform.position, slowBerry.transform.position) < 1.5f)
|
||||
{
|
||||
} else if (UnityEngine.Vector3.Distance(bird.transform.position, slowBerry.transform.position) < 1.5f) {
|
||||
totalSlowBerries++;
|
||||
DoSlowBerry(slowBerry);
|
||||
}
|
||||
if (speedyLeft > 0)
|
||||
{
|
||||
if (speedyLeft > 0) {
|
||||
slowBerry.GetComponent<Rigidbody2D>().linearVelocity = new UnityEngine.Vector2(0f, -7.5f);
|
||||
}
|
||||
else
|
||||
{
|
||||
} 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)
|
||||
{
|
||||
foreach (GameObject ultraBerry in ultraBerries) {
|
||||
if (ultraBerry.transform.position.y < 0f - Camera.main.orthographicSize - 1f) {
|
||||
Destroy(ultraBerry);
|
||||
}
|
||||
else if (UnityEngine.Vector3.Distance(bird.transform.position, ultraBerry.transform.position) < 1.5f)
|
||||
{
|
||||
} else if (UnityEngine.Vector3.Distance(bird.transform.position, ultraBerry.transform.position) < 1.5f) {
|
||||
totalUltraBerries++;
|
||||
DoUltraBerry(ultraBerry);
|
||||
}
|
||||
if (speedyLeft > 0)
|
||||
{
|
||||
if (speedyLeft > 0) {
|
||||
ultraBerry.GetComponent<Rigidbody2D>().linearVelocity = new UnityEngine.Vector2(0f, -7.5f);
|
||||
}
|
||||
else
|
||||
{
|
||||
} 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)
|
||||
{
|
||||
foreach (GameObject speedyBerry in speedyBerries) {
|
||||
if (speedyBerry.transform.position.y < 0f - Camera.main.orthographicSize - 1f) {
|
||||
Destroy(speedyBerry);
|
||||
}
|
||||
else if (UnityEngine.Vector3.Distance(bird.transform.position, speedyBerry.transform.position) < 1.5f)
|
||||
{
|
||||
} else if (UnityEngine.Vector3.Distance(bird.transform.position, speedyBerry.transform.position) < 1.5f) {
|
||||
totalSpeedyBerries++;
|
||||
DoSpeedyBerry(speedyBerry);
|
||||
}
|
||||
if (speedyLeft > 0)
|
||||
{
|
||||
if (speedyLeft > 0) {
|
||||
speedyBerry.GetComponent<Rigidbody2D>().linearVelocity = new UnityEngine.Vector2(0f, -7.5f);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
speedyBerry.GetComponent<Rigidbody2D>().linearVelocity = new UnityEngine.Vector2(0f, -4f);
|
||||
}
|
||||
}
|
||||
foreach (GameObject coinBerry in coinBerries)
|
||||
{
|
||||
if (coinBerry.transform.position.y < 0f - Camera.main.orthographicSize - 1f)
|
||||
{
|
||||
foreach (GameObject coinBerry in coinBerries) {
|
||||
if (coinBerry.transform.position.y < 0f - Camera.main.orthographicSize - 1f) {
|
||||
Destroy(coinBerry);
|
||||
}
|
||||
else if (UnityEngine.Vector3.Distance(bird.transform.position, coinBerry.transform.position) < 1.5f)
|
||||
{
|
||||
} else if (UnityEngine.Vector3.Distance(bird.transform.position, coinBerry.transform.position) < 1.5f) {
|
||||
totalCoinBerries++;
|
||||
DoCoinBerry(coinBerry);
|
||||
}
|
||||
if (speedyLeft > 0)
|
||||
{
|
||||
if (speedyLeft > 0) {
|
||||
coinBerry.GetComponent<Rigidbody2D>().linearVelocity = new UnityEngine.Vector2(0f, -7.5f);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
coinBerry.GetComponent<Rigidbody2D>().linearVelocity = new UnityEngine.Vector2(0f, -4f);
|
||||
}
|
||||
}
|
||||
foreach (GameObject randomBerry in randomBerries)
|
||||
{
|
||||
if (randomBerry.transform.position.y < 0f - Camera.main.orthographicSize - 1f)
|
||||
{
|
||||
foreach (GameObject randomBerry in randomBerries) {
|
||||
if (randomBerry.transform.position.y < 0f - Camera.main.orthographicSize - 1f) {
|
||||
Destroy(randomBerry);
|
||||
}
|
||||
else if (UnityEngine.Vector3.Distance(bird.transform.position, randomBerry.transform.position) < 1.5f)
|
||||
{
|
||||
} else if (UnityEngine.Vector3.Distance(bird.transform.position, randomBerry.transform.position) < 1.5f) {
|
||||
totalRandomBerries++;
|
||||
Action[] funcs = {
|
||||
() => DoNormalBerry(randomBerry),
|
||||
@@ -582,58 +450,39 @@ public class GamePlayer : MonoBehaviour
|
||||
};
|
||||
funcs[UnityEngine.Random.Range(0, funcs.Length)]();
|
||||
}
|
||||
if (speedyLeft > 0)
|
||||
{
|
||||
if (speedyLeft > 0) {
|
||||
randomBerry.GetComponent<Rigidbody2D>().linearVelocity = new UnityEngine.Vector2(0f, -7.5f);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
randomBerry.GetComponent<Rigidbody2D>().linearVelocity = new UnityEngine.Vector2(0f, -4f);
|
||||
}
|
||||
}
|
||||
foreach (GameObject antiBerry in antiBerries)
|
||||
{
|
||||
if (antiBerry.transform.position.y < 0f - Camera.main.orthographicSize - 1f)
|
||||
{
|
||||
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)
|
||||
{
|
||||
} else if (UnityEngine.Vector3.Distance(bird.transform.position, antiBerry.transform.position) < 1.5f) {
|
||||
totalAntiBerries++;
|
||||
DoAntiBerry(antiBerry);
|
||||
}
|
||||
if (speedyLeft > 0)
|
||||
{
|
||||
if (speedyLeft > 0) {
|
||||
antiBerry.GetComponent<Rigidbody2D>().linearVelocity = new UnityEngine.Vector2(0f, -7.5f);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
antiBerry.GetComponent<Rigidbody2D>().linearVelocity = new UnityEngine.Vector2(0f, -4f);
|
||||
}
|
||||
}
|
||||
foreach (GameObject goldenBerry in goldenBerries)
|
||||
{
|
||||
if (goldenBerry.transform.position.y < 0f - Camera.main.orthographicSize - 1f)
|
||||
{
|
||||
foreach (GameObject goldenBerry in goldenBerries) {
|
||||
if (goldenBerry.transform.position.y < 0f - Camera.main.orthographicSize - 1f) {
|
||||
Destroy(goldenBerry);
|
||||
}
|
||||
else if (UnityEngine.Vector3.Distance(bird.transform.position, goldenBerry.transform.position) < 1.5f)
|
||||
{
|
||||
} else if (UnityEngine.Vector3.Distance(bird.transform.position, goldenBerry.transform.position) < 1.5f) {
|
||||
totalGoldenBerries++;
|
||||
DoGoldenBerry(goldenBerry);
|
||||
}
|
||||
if (speedyLeft > 0)
|
||||
{
|
||||
if (speedyLeft > 0) {
|
||||
goldenBerry.GetComponent<Rigidbody2D>().linearVelocity = new UnityEngine.Vector2(0f, -7.5f);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
goldenBerry.GetComponent<Rigidbody2D>().linearVelocity = new UnityEngine.Vector2(0f, -4f);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
rb.gravityScale = 0f;
|
||||
rb.linearVelocity = UnityEngine.Vector2.zero;
|
||||
GameObject[] allberries = normalBerries
|
||||
@@ -646,16 +495,14 @@ public class GamePlayer : MonoBehaviour
|
||||
.Concat(antiBerries)
|
||||
.Concat(goldenBerries)
|
||||
.ToArray();
|
||||
foreach (GameObject berry in allberries)
|
||||
{
|
||||
foreach (GameObject berry in allberries) {
|
||||
berry.GetComponent<Rigidbody2D>().linearVelocity = UnityEngine.Vector2.zero;
|
||||
}
|
||||
}
|
||||
if ((Application.platform == RuntimePlatform.Android && Keyboard.current.escapeKey.wasPressedThisFrame) || !Application.isMobilePlatform && (Keyboard.current.escapeKey.wasPressedThisFrame || (Gamepad.current != null && (Gamepad.current.startButton.wasPressedThisFrame || Gamepad.current.buttonEast.wasPressedThisFrame)))) TogglePause();
|
||||
}
|
||||
|
||||
void Respawn()
|
||||
{
|
||||
void Respawn() {
|
||||
bird.transform.position = new UnityEngine.Vector3(0f, -4.3f, 0f);
|
||||
bird.transform.localScale = new UnityEngine.Vector3(1.35f, 1.35f, 1.35f);
|
||||
rb.gravityScale = 0f;
|
||||
@@ -677,22 +524,19 @@ public class GamePlayer : MonoBehaviour
|
||||
.Concat(GameObject.FindGameObjectsWithTag("AntiBerry"))
|
||||
.Concat(GameObject.FindGameObjectsWithTag("GoldenBerry"))
|
||||
.ToArray();
|
||||
foreach (GameObject berry in allberries)
|
||||
{
|
||||
foreach (GameObject berry in allberries) {
|
||||
Destroy(berry);
|
||||
}
|
||||
}
|
||||
|
||||
void UpdateStats(BigInteger scoreAddAmount, BigInteger attemptAddAmount)
|
||||
{
|
||||
void UpdateStats(BigInteger scoreAddAmount, BigInteger attemptAddAmount) {
|
||||
var levelBefore = Tools.GetLevelInfo().level;
|
||||
var prefix = "";
|
||||
var suffix = "";
|
||||
score += scoreAddAmount;
|
||||
totalAttempts += attemptAddAmount;
|
||||
attempts += attemptAddAmount;
|
||||
if (score >= highscore)
|
||||
{
|
||||
if (score >= highscore) {
|
||||
highscore = score;
|
||||
prefix = "<color=#7FFFD4>";
|
||||
suffix = "</color>";
|
||||
@@ -722,14 +566,12 @@ public class GamePlayer : MonoBehaviour
|
||||
if (level != levelBefore) AudioSource.PlayClipAtPoint(Resources.Load<AudioClip>("Sounds/Levelup"), Camera.main.transform.position, 1f * BazookaManager.Instance.GetSettingSFXVolume());
|
||||
}
|
||||
|
||||
void CheckIfGrounded()
|
||||
{
|
||||
void CheckIfGrounded() {
|
||||
isGrounded = bird.transform.position.y <= -4.1299996f;
|
||||
|
||||
rb.gravityScale = isGrounded ? 0f : 1.5f;
|
||||
|
||||
if (bird.transform.position.y < -4.1359f)
|
||||
{
|
||||
if (bird.transform.position.y < -4.1359f) {
|
||||
bird.transform.position = new UnityEngine.Vector2(bird.transform.position.x, -4.1359f);
|
||||
rb.linearVelocity = new UnityEngine.Vector2(rb.linearVelocity.x, 0f);
|
||||
}
|
||||
@@ -737,29 +579,24 @@ public class GamePlayer : MonoBehaviour
|
||||
if (Application.isMobilePlatform) jumpButton.transform.GetChild(0).GetComponent<TMP_Text>().color = isGrounded ? new Color(int.Parse(btnColor[0].ToString()) / 255f, int.Parse(btnColor[1].ToString()) / 255f, int.Parse(btnColor[2].ToString()) / 255f) : Color.red;
|
||||
}
|
||||
|
||||
internal void TogglePause()
|
||||
{
|
||||
internal void TogglePause() {
|
||||
if (pausePanel.activeSelf) DisablePause();
|
||||
else EnablePause();
|
||||
}
|
||||
|
||||
internal void EnablePause()
|
||||
{
|
||||
internal void EnablePause() {
|
||||
Cursor.visible = true;
|
||||
Cursor.lockState = CursorLockMode.None;
|
||||
backgroundMusic.GetComponent<GameMusicHandler>().PauseMusic();
|
||||
pausePanel.SetActive(true);
|
||||
}
|
||||
|
||||
internal void DisablePause()
|
||||
{
|
||||
if (GamePlayerPauseMenu.Instance.statsMenu.activeSelf)
|
||||
{
|
||||
internal void DisablePause() {
|
||||
if (GamePlayerPauseMenu.Instance.statsMenu.activeSelf) {
|
||||
GamePlayerPauseMenu.Instance.statsMenuExitButton.onClick.Invoke();
|
||||
return;
|
||||
}
|
||||
if (GamePlayerPauseMenu.Instance.editingUI == true)
|
||||
{
|
||||
if (GamePlayerPauseMenu.Instance.editingUI == true) {
|
||||
GamePlayerPauseMenu.Instance.ToggleEditingUI();
|
||||
return;
|
||||
}
|
||||
@@ -770,33 +607,28 @@ public class GamePlayer : MonoBehaviour
|
||||
pausePanel.SetActive(false);
|
||||
}
|
||||
|
||||
void OnApplicationPause(bool pause)
|
||||
{
|
||||
void OnApplicationPause(bool pause) {
|
||||
if (pause) EnablePause();
|
||||
}
|
||||
|
||||
void OnApplicationQuit()
|
||||
{
|
||||
void OnApplicationQuit() {
|
||||
Cursor.visible = true;
|
||||
Cursor.lockState = CursorLockMode.None;
|
||||
}
|
||||
|
||||
void DoNormalBerry(GameObject berry)
|
||||
{
|
||||
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()
|
||||
{
|
||||
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)
|
||||
{
|
||||
void DoSlowBerry(GameObject berry) {
|
||||
AudioSource.PlayClipAtPoint(Resources.Load<AudioClip>("Sounds/Downgrade"), Camera.main.transform.position, 0.35f * BazookaManager.Instance.GetSettingSFXVolume());
|
||||
Destroy(berry);
|
||||
boostLeft = 0f;
|
||||
@@ -804,33 +636,27 @@ public class GamePlayer : MonoBehaviour
|
||||
speedyLeft = 0f;
|
||||
antiLeft = 0f;
|
||||
goldenLeft = 0f;
|
||||
if (score > 0)
|
||||
{
|
||||
if (score > 0) {
|
||||
UpdateStats(-1, 0);
|
||||
}
|
||||
}
|
||||
|
||||
void DoUltraBerry(GameObject berry)
|
||||
{
|
||||
void DoUltraBerry(GameObject berry) {
|
||||
AudioSource.PlayClipAtPoint(Resources.Load<AudioClip>("Sounds/Powerup"), Camera.main.transform.position, 0.35f * BazookaManager.Instance.GetSettingSFXVolume());
|
||||
Destroy(berry);
|
||||
speedyLeft = 0f;
|
||||
antiLeft = 0f;
|
||||
goldenLeft = 0f;
|
||||
if (slownessLeft > 0f)
|
||||
{
|
||||
if (slownessLeft > 0f) {
|
||||
slownessLeft = 0f;
|
||||
UpdateStats(1, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
boostLeft += 10f;
|
||||
UpdateStats(5, 0);
|
||||
}
|
||||
}
|
||||
|
||||
void DoSpeedyBerry(GameObject berry)
|
||||
{
|
||||
void DoSpeedyBerry(GameObject berry) {
|
||||
AudioSource.PlayClipAtPoint(Resources.Load<AudioClip>("Sounds/SpeedyPowerup"), Camera.main.transform.position, 0.35f * BazookaManager.Instance.GetSettingSFXVolume());
|
||||
Destroy(berry);
|
||||
boostLeft = 0f;
|
||||
@@ -841,16 +667,14 @@ public class GamePlayer : MonoBehaviour
|
||||
UpdateStats(10, 0);
|
||||
}
|
||||
|
||||
void DoCoinBerry(GameObject berry)
|
||||
{
|
||||
void DoCoinBerry(GameObject berry) {
|
||||
AudioSource.PlayClipAtPoint(Resources.Load<AudioClip>("Sounds/CoinCollect"), Camera.main.transform.position, 0.35f * BazookaManager.Instance.GetSettingSFXVolume());
|
||||
Destroy(berry);
|
||||
totalCoins += 10;
|
||||
UpdateStats(0, 0);
|
||||
}
|
||||
|
||||
void DoAntiBerry(GameObject berry)
|
||||
{
|
||||
void DoAntiBerry(GameObject berry) {
|
||||
AudioSource.PlayClipAtPoint(Resources.Load<AudioClip>("Sounds/Downgrade"), Camera.main.transform.position, 0.35f * BazookaManager.Instance.GetSettingSFXVolume());
|
||||
Destroy(berry);
|
||||
boostLeft = 0f;
|
||||
@@ -861,8 +685,7 @@ public class GamePlayer : MonoBehaviour
|
||||
UpdateStats(0, 0);
|
||||
}
|
||||
|
||||
void DoGoldenBerry(GameObject berry)
|
||||
{
|
||||
void DoGoldenBerry(GameObject berry) {
|
||||
AudioSource.PlayClipAtPoint(Resources.Load<AudioClip>("Sounds/Powerup"), Camera.main.transform.position, 0.35f * BazookaManager.Instance.GetSettingSFXVolume());
|
||||
Destroy(berry);
|
||||
boostLeft = 0f;
|
||||
|
||||
Reference in new issue
Block a user