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:
3 files changed
+26
-13
No files matched your search
@@ -44,6 +44,7 @@ public class AutoGamePlayer : MonoBehaviour {
|
||||
[SerializeField] private RectTransform canvasRect;
|
||||
[SerializeField] private BoxCollider2D groundCollider;
|
||||
private UnityEngine.Vector2 velocityBeforePause = new();
|
||||
private readonly List<int> noGravityBerries = new();
|
||||
|
||||
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 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 (var berry in GameObject.FindGameObjectsWithTag(tag)) {
|
||||
@@ -233,7 +234,8 @@ public class AutoGamePlayer : MonoBehaviour {
|
||||
if (dir.magnitude < radius) {
|
||||
berryRect.position += speed * dir.normalized;
|
||||
ClampPosition(berry.GetComponent<Image>());
|
||||
}
|
||||
noGravityBerries.Add(berry.GetInstanceID());
|
||||
} else noGravityBerries.Remove(berry.GetInstanceID());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -367,7 +369,7 @@ public class AutoGamePlayer : MonoBehaviour {
|
||||
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;
|
||||
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();
|
||||
|
||||
@@ -48,6 +48,7 @@ public class CustomGamePlayer : MonoBehaviour {
|
||||
[SerializeField] private RectTransform canvasRect;
|
||||
[SerializeField] private BoxCollider2D groundCollider;
|
||||
private UnityEngine.Vector2 velocityBeforePause = new();
|
||||
private readonly List<int> noGravityBerries = new();
|
||||
|
||||
internal bool IsGrounded() => Physics2D.Distance(bird.GetComponent<CircleCollider2D>(), groundCollider).distance <= 0.1f;
|
||||
|
||||
@@ -353,15 +354,23 @@ public class CustomGamePlayer : MonoBehaviour {
|
||||
TogglePause();
|
||||
}
|
||||
if (antiLeft > 0f || goldenLeft > 0f) {
|
||||
string[] berryTags = { "NormalBerry", "SlowBerry", "UltraBerry", "SpeedyBerry", "RandomBerry", "AntiBerry", "GoldenBerry" };
|
||||
if (antiLeft > 0f) berryTags.Append("PoisonBerry");
|
||||
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 : 300f * scale;
|
||||
float speed = antiLeft > 0f ? 1.75f * scale : -1f * scale;
|
||||
|
||||
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)) {
|
||||
berry.GetComponent<Rigidbody2D>().linearVelocity = dir.normalized * (antiLeft > 0 ? 5f : -5f);
|
||||
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.GetInstanceID());
|
||||
} else noGravityBerries.Remove(berry.GetInstanceID());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -529,7 +538,7 @@ public class CustomGamePlayer : MonoBehaviour {
|
||||
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;
|
||||
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();
|
||||
|
||||
@@ -52,6 +52,7 @@ public class GamePlayer : MonoBehaviour {
|
||||
[SerializeField] private RectTransform canvasRect;
|
||||
[SerializeField] private BoxCollider2D groundCollider;
|
||||
private UnityEngine.Vector2 velocityBeforePause = new();
|
||||
private readonly List<int> noGravityBerries = new();
|
||||
|
||||
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 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 (var berry in GameObject.FindGameObjectsWithTag(tag)) {
|
||||
@@ -176,7 +177,8 @@ public class GamePlayer : MonoBehaviour {
|
||||
if (dir.magnitude < radius) {
|
||||
berryRect.position += speed * dir.normalized;
|
||||
ClampPosition(berry.GetComponent<Image>());
|
||||
}
|
||||
noGravityBerries.Add(berry.GetInstanceID());
|
||||
} else noGravityBerries.Remove(berry.GetInstanceID());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -316,7 +318,7 @@ public class GamePlayer : MonoBehaviour {
|
||||
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;
|
||||
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();
|
||||
|
||||
Reference in new issue
Block a user