Fix custom mode not using new anti/golden berry logic, reduce anti berry force and disable affected berry gravity when golden/anti is active

This commit is contained in:
Lncvrt committed 2026-03-05 13:53:59 -07:00
1 parent 9918923824
commit 469a30300d
3 files changed
+26 -13

No files matched your search

+5 -3
View File
@@ -44,6 +44,7 @@ public class AutoGamePlayer : MonoBehaviour {
[SerializeField] private RectTransform canvasRect; [SerializeField] private RectTransform canvasRect;
[SerializeField] private BoxCollider2D groundCollider; [SerializeField] private BoxCollider2D groundCollider;
private UnityEngine.Vector2 velocityBeforePause = new(); private UnityEngine.Vector2 velocityBeforePause = new();
private readonly List<int> noGravityBerries = new();
internal bool IsGrounded() => Physics2D.Distance(bird.GetComponent<CircleCollider2D>(), groundCollider).distance <= 0.1f; internal bool IsGrounded() => Physics2D.Distance(bird.GetComponent<CircleCollider2D>(), groundCollider).distance <= 0.1f;
@@ -223,7 +224,7 @@ public class AutoGamePlayer : MonoBehaviour {
float scale = (canvasRect.lossyScale.x + canvasRect.lossyScale.y) / 2f; float scale = (canvasRect.lossyScale.x + canvasRect.lossyScale.y) / 2f;
float radius = antiLeft > 0f ? 250f * scale : 300f * scale; float radius = antiLeft > 0f ? 250f * scale : 300f * scale;
float speed = antiLeft > 0f ? 2.5f * scale : -1f * scale; float speed = antiLeft > 0f ? 1.75f * scale : -1f * scale;
foreach (string tag in berryTags) { foreach (string tag in berryTags) {
foreach (var berry in GameObject.FindGameObjectsWithTag(tag)) { foreach (var berry in GameObject.FindGameObjectsWithTag(tag)) {
@@ -233,7 +234,8 @@ public class AutoGamePlayer : MonoBehaviour {
if (dir.magnitude < radius) { if (dir.magnitude < radius) {
berryRect.position += speed * dir.normalized; berryRect.position += speed * dir.normalized;
ClampPosition(berry.GetComponent<Image>()); ClampPosition(berry.GetComponent<Image>());
} noGravityBerries.Add(berry.GetInstanceID());
} else noGravityBerries.Remove(berry.GetInstanceID());
} }
} }
} }
@@ -367,7 +369,7 @@ public class AutoGamePlayer : MonoBehaviour {
break; break;
} }
} }
if (berry != null) berry.GetComponent<Rigidbody2D>().linearVelocity = 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.GetInstanceID()) ? UnityEngine.Vector2.zero : new UnityEngine.Vector2(0f, speedyLeft == 0.0f ? (-300f * canvasRect.lossyScale.y) : (-550f * canvasRect.lossyScale.y));
} }
else foreach (GameObject berry in allBerries) berry.GetComponent<Rigidbody2D>().linearVelocity = UnityEngine.Vector2.zero; else 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(); 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();
+16 -7
View File
@@ -48,6 +48,7 @@ public class CustomGamePlayer : MonoBehaviour {
[SerializeField] private RectTransform canvasRect; [SerializeField] private RectTransform canvasRect;
[SerializeField] private BoxCollider2D groundCollider; [SerializeField] private BoxCollider2D groundCollider;
private UnityEngine.Vector2 velocityBeforePause = new(); private UnityEngine.Vector2 velocityBeforePause = new();
private readonly List<int> noGravityBerries = new();
internal bool IsGrounded() => Physics2D.Distance(bird.GetComponent<CircleCollider2D>(), groundCollider).distance <= 0.1f; internal bool IsGrounded() => Physics2D.Distance(bird.GetComponent<CircleCollider2D>(), groundCollider).distance <= 0.1f;
@@ -353,15 +354,23 @@ public class CustomGamePlayer : MonoBehaviour {
TogglePause(); TogglePause();
} }
if (antiLeft > 0f || goldenLeft > 0f) { if (antiLeft > 0f || goldenLeft > 0f) {
string[] berryTags = { "NormalBerry", "SlowBerry", "UltraBerry", "SpeedyBerry", "RandomBerry", "AntiBerry", "GoldenBerry" }; List<string> berryTags = new() { "NormalBerry", "SlowBerry", "UltraBerry", "SpeedyBerry", "CoinBerry", "RandomBerry", "AntiBerry", "GoldenBerry" };
if (antiLeft > 0f) berryTags.Append("PoisonBerry"); if (antiLeft > 0f) berryTags.Add("PoisonBerry");
float scale = (canvasRect.lossyScale.x + canvasRect.lossyScale.y) / 2f;
float radius = antiLeft > 0f ? 250f * scale : 300f * scale;
float speed = antiLeft > 0f ? 1.75f * scale : -1f * scale;
foreach (string tag in berryTags) { foreach (string tag in berryTags) {
foreach (var berry in GameObject.FindGameObjectsWithTag(tag)) { foreach (var berry in GameObject.FindGameObjectsWithTag(tag)) {
UnityEngine.Vector3 dir = berry.transform.position - bird.transform.position; RectTransform berryRect = berry.GetComponent<RectTransform>();
if (dir.magnitude < (antiLeft > 0 ? 3f : 4.5f)) { UnityEngine.Vector3 dir = berryRect.position - bird.GetComponent<RectTransform>().position;
berry.GetComponent<Rigidbody2D>().linearVelocity = dir.normalized * (antiLeft > 0 ? 5f : -5f);
if (dir.magnitude < radius) {
berryRect.position += speed * dir.normalized;
ClampPosition(berry.GetComponent<Image>()); ClampPosition(berry.GetComponent<Image>());
} noGravityBerries.Add(berry.GetInstanceID());
} else noGravityBerries.Remove(berry.GetInstanceID());
} }
} }
} }
@@ -529,7 +538,7 @@ public class CustomGamePlayer : MonoBehaviour {
break; break;
} }
} }
if (berry != null) berry.GetComponent<Rigidbody2D>().linearVelocity = 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.GetInstanceID()) ? UnityEngine.Vector2.zero : new UnityEngine.Vector2(0f, speedyLeft == 0.0f ? (-300f * canvasRect.lossyScale.y) : (-550f * canvasRect.lossyScale.y));
} }
else foreach (GameObject berry in allBerries) berry.GetComponent<Rigidbody2D>().linearVelocity = UnityEngine.Vector2.zero; else 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(); 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();
+5 -3
View File
@@ -52,6 +52,7 @@ public class GamePlayer : MonoBehaviour {
[SerializeField] private RectTransform canvasRect; [SerializeField] private RectTransform canvasRect;
[SerializeField] private BoxCollider2D groundCollider; [SerializeField] private BoxCollider2D groundCollider;
private UnityEngine.Vector2 velocityBeforePause = new(); private UnityEngine.Vector2 velocityBeforePause = new();
private readonly List<int> noGravityBerries = new();
internal bool IsGrounded() => Physics2D.Distance(bird.GetComponent<CircleCollider2D>(), groundCollider).distance <= 0.1f; internal bool IsGrounded() => Physics2D.Distance(bird.GetComponent<CircleCollider2D>(), groundCollider).distance <= 0.1f;
@@ -166,7 +167,7 @@ public class GamePlayer : MonoBehaviour {
float scale = (canvasRect.lossyScale.x + canvasRect.lossyScale.y) / 2f; float scale = (canvasRect.lossyScale.x + canvasRect.lossyScale.y) / 2f;
float radius = antiLeft > 0f ? 250f * scale : 300f * scale; float radius = antiLeft > 0f ? 250f * scale : 300f * scale;
float speed = antiLeft > 0f ? 2.5f * scale : -1f * scale; float speed = antiLeft > 0f ? 1.75f * scale : -1f * scale;
foreach (string tag in berryTags) { foreach (string tag in berryTags) {
foreach (var berry in GameObject.FindGameObjectsWithTag(tag)) { foreach (var berry in GameObject.FindGameObjectsWithTag(tag)) {
@@ -176,7 +177,8 @@ public class GamePlayer : MonoBehaviour {
if (dir.magnitude < radius) { if (dir.magnitude < radius) {
berryRect.position += speed * dir.normalized; berryRect.position += speed * dir.normalized;
ClampPosition(berry.GetComponent<Image>()); ClampPosition(berry.GetComponent<Image>());
} noGravityBerries.Add(berry.GetInstanceID());
} else noGravityBerries.Remove(berry.GetInstanceID());
} }
} }
} }
@@ -316,7 +318,7 @@ public class GamePlayer : MonoBehaviour {
break; break;
} }
} }
if (berry != null) berry.GetComponent<Rigidbody2D>().linearVelocity = 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.GetInstanceID()) ? UnityEngine.Vector2.zero : new UnityEngine.Vector2(0f, speedyLeft == 0.0f ? (-300f * canvasRect.lossyScale.y) : (-550f * canvasRect.lossyScale.y));
} }
else foreach (GameObject berry in allBerries) berry.GetComponent<Rigidbody2D>().linearVelocity = UnityEngine.Vector2.zero; else 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(); 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();