Use new entity id system
This commit is contained in:
3 files changed
+35
-35
No files matched your search
@@ -46,7 +46,7 @@ public class AutoGamePlayer : MonoBehaviour {
|
||||
private UnityEngine.Vector2 velocityBeforePause = new();
|
||||
|
||||
public readonly List<GameObject> berries = new();
|
||||
private readonly List<int> noGravityBerries = new();
|
||||
private readonly List<EntityId> noGravityBerries = new();
|
||||
private bool hasJumped = false;
|
||||
|
||||
internal bool IsGrounded() => Physics2D.Distance(bird.GetComponent<CircleCollider2D>(), groundCollider).distance <= 0.1f;
|
||||
@@ -239,8 +239,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());
|
||||
noGravityBerries.Add(berry.GetEntityId());
|
||||
} else noGravityBerries.Remove(berry.GetEntityId());
|
||||
}
|
||||
}
|
||||
} else if (noGravityBerries.Count() != 0) noGravityBerries.Clear();
|
||||
@@ -337,7 +337,7 @@ public class AutoGamePlayer : MonoBehaviour {
|
||||
continue;
|
||||
}
|
||||
if (berry.GetComponent<RectTransform>().anchoredPosition.y < -(canvasRect.rect.height / 2) - berry.GetComponent<RectTransform>().rect.height) {
|
||||
noGravityBerries.Remove(berry.GetInstanceID());
|
||||
noGravityBerries.Remove(berry.GetEntityId());
|
||||
Destroy(berry);
|
||||
} else if (Physics2D.Distance(bird.GetComponent<CircleCollider2D>(), berry.GetComponent<CircleCollider2D>()).distance <= 0.1f) {
|
||||
switch (berry.tag) {
|
||||
@@ -367,7 +367,7 @@ public class AutoGamePlayer : MonoBehaviour {
|
||||
break;
|
||||
}
|
||||
}
|
||||
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));
|
||||
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();
|
||||
@@ -459,7 +459,7 @@ public class AutoGamePlayer : MonoBehaviour {
|
||||
if (increment) totalNormalBerries++;
|
||||
AudioSource.PlayClipAtPoint(Resources.Load<AudioClip>("Sounds/Eat"), Camera.main.transform.position, 1.2f * BazookaManager.Instance.GetSettingSFXVolume());
|
||||
berries.Remove(berry);
|
||||
noGravityBerries.Remove(berry.GetInstanceID());
|
||||
noGravityBerries.Remove(berry.GetEntityId());
|
||||
Destroy(berry);
|
||||
UpdateStats(1, 0);
|
||||
}
|
||||
@@ -475,7 +475,7 @@ public class AutoGamePlayer : MonoBehaviour {
|
||||
if (increment) totalSlowBerries++;
|
||||
AudioSource.PlayClipAtPoint(Resources.Load<AudioClip>("Sounds/Downgrade"), Camera.main.transform.position, 0.35f * BazookaManager.Instance.GetSettingSFXVolume());
|
||||
berries.Remove(berry);
|
||||
noGravityBerries.Remove(berry.GetInstanceID());
|
||||
noGravityBerries.Remove(berry.GetEntityId());
|
||||
Destroy(berry);
|
||||
boostLeft = 0f;
|
||||
slownessLeft = 10f;
|
||||
@@ -491,7 +491,7 @@ public class AutoGamePlayer : MonoBehaviour {
|
||||
if (increment) totalUltraBerries++;
|
||||
AudioSource.PlayClipAtPoint(Resources.Load<AudioClip>("Sounds/Powerup"), Camera.main.transform.position, 0.35f * BazookaManager.Instance.GetSettingSFXVolume());
|
||||
berries.Remove(berry);
|
||||
noGravityBerries.Remove(berry.GetInstanceID());
|
||||
noGravityBerries.Remove(berry.GetEntityId());
|
||||
Destroy(berry);
|
||||
speedyLeft = 0f;
|
||||
antiLeft = 0f;
|
||||
@@ -509,7 +509,7 @@ public class AutoGamePlayer : MonoBehaviour {
|
||||
if (increment) totalSpeedyBerries++;
|
||||
AudioSource.PlayClipAtPoint(Resources.Load<AudioClip>("Sounds/SpeedyPowerup"), Camera.main.transform.position, 0.35f * BazookaManager.Instance.GetSettingSFXVolume());
|
||||
berries.Remove(berry);
|
||||
noGravityBerries.Remove(berry.GetInstanceID());
|
||||
noGravityBerries.Remove(berry.GetEntityId());
|
||||
Destroy(berry);
|
||||
boostLeft = 0f;
|
||||
slownessLeft = 0f;
|
||||
@@ -536,7 +536,7 @@ public class AutoGamePlayer : MonoBehaviour {
|
||||
if (increment) totalAntiBerries++;
|
||||
AudioSource.PlayClipAtPoint(Resources.Load<AudioClip>("Sounds/Downgrade"), Camera.main.transform.position, 0.35f * BazookaManager.Instance.GetSettingSFXVolume());
|
||||
berries.Remove(berry);
|
||||
noGravityBerries.Remove(berry.GetInstanceID());
|
||||
noGravityBerries.Remove(berry.GetEntityId());
|
||||
Destroy(berry);
|
||||
boostLeft = 0f;
|
||||
slownessLeft = 0f;
|
||||
@@ -550,7 +550,7 @@ public class AutoGamePlayer : MonoBehaviour {
|
||||
if (increment) totalGoldenBerries++;
|
||||
AudioSource.PlayClipAtPoint(Resources.Load<AudioClip>("Sounds/Powerup"), Camera.main.transform.position, 0.35f * BazookaManager.Instance.GetSettingSFXVolume());
|
||||
berries.Remove(berry);
|
||||
noGravityBerries.Remove(berry.GetInstanceID());
|
||||
noGravityBerries.Remove(berry.GetEntityId());
|
||||
Destroy(berry);
|
||||
boostLeft = 0f;
|
||||
slownessLeft = 0f;
|
||||
|
||||
@@ -50,7 +50,7 @@ public class CustomGamePlayer : MonoBehaviour {
|
||||
private UnityEngine.Vector2 velocityBeforePause = new();
|
||||
|
||||
public readonly List<GameObject> berries = new();
|
||||
private readonly List<int> noGravityBerries = new();
|
||||
private readonly List<EntityId> noGravityBerries = new();
|
||||
private bool hasJumped = false;
|
||||
|
||||
internal bool IsGrounded() => Physics2D.Distance(bird.GetComponent<CircleCollider2D>(), groundCollider).distance <= 0.1f;
|
||||
@@ -376,8 +376,8 @@ public class CustomGamePlayer : MonoBehaviour {
|
||||
if (dir.magnitude < radius) {
|
||||
berryRect.position += speed * dir.normalized;
|
||||
ClampPosition(berry.GetComponent<Image>());
|
||||
noGravityBerries.Add(berry.GetInstanceID());
|
||||
} else noGravityBerries.Remove(berry.GetInstanceID());
|
||||
noGravityBerries.Add(berry.GetEntityId());
|
||||
} else noGravityBerries.Remove(berry.GetEntityId());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -505,7 +505,7 @@ public class CustomGamePlayer : MonoBehaviour {
|
||||
continue;
|
||||
}
|
||||
if (berry.GetComponent<RectTransform>().anchoredPosition.y < -(canvasRect.rect.height / 2) - berry.GetComponent<RectTransform>().rect.height) {
|
||||
noGravityBerries.Remove(berry.GetInstanceID());
|
||||
noGravityBerries.Remove(berry.GetEntityId());
|
||||
Destroy(berry);
|
||||
} else if (Physics2D.Distance(bird.GetComponent<CircleCollider2D>(), berry.GetComponent<CircleCollider2D>()).distance <= 0.1f) {
|
||||
switch (berry.tag) {
|
||||
@@ -538,7 +538,7 @@ public class CustomGamePlayer : MonoBehaviour {
|
||||
break;
|
||||
}
|
||||
}
|
||||
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));
|
||||
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();
|
||||
@@ -613,7 +613,7 @@ public class CustomGamePlayer : MonoBehaviour {
|
||||
void DoNormalBerry(GameObject berry) {
|
||||
AudioSource.PlayClipAtPoint(Resources.Load<AudioClip>("Sounds/Eat"), Camera.main.transform.position, 1.2f * BazookaManager.Instance.GetSettingSFXVolume());
|
||||
berries.Remove(berry);
|
||||
noGravityBerries.Remove(berry.GetInstanceID());
|
||||
noGravityBerries.Remove(berry.GetEntityId());
|
||||
Destroy(berry);
|
||||
UpdateStats(1, 0);
|
||||
}
|
||||
@@ -627,7 +627,7 @@ public class CustomGamePlayer : MonoBehaviour {
|
||||
void DoSlowBerry(GameObject berry) {
|
||||
AudioSource.PlayClipAtPoint(Resources.Load<AudioClip>("Sounds/Downgrade"), Camera.main.transform.position, 0.35f * BazookaManager.Instance.GetSettingSFXVolume());
|
||||
berries.Remove(berry);
|
||||
noGravityBerries.Remove(berry.GetInstanceID());
|
||||
noGravityBerries.Remove(berry.GetEntityId());
|
||||
Destroy(berry);
|
||||
boostLeft = 0f;
|
||||
slownessLeft = 10f;
|
||||
@@ -642,7 +642,7 @@ public class CustomGamePlayer : MonoBehaviour {
|
||||
void DoUltraBerry(GameObject berry) {
|
||||
AudioSource.PlayClipAtPoint(Resources.Load<AudioClip>("Sounds/Powerup"), Camera.main.transform.position, 0.35f * BazookaManager.Instance.GetSettingSFXVolume());
|
||||
berries.Remove(berry);
|
||||
noGravityBerries.Remove(berry.GetInstanceID());
|
||||
noGravityBerries.Remove(berry.GetEntityId());
|
||||
Destroy(berry);
|
||||
speedyLeft = 0f;
|
||||
antiLeft = 0f;
|
||||
@@ -659,7 +659,7 @@ public class CustomGamePlayer : MonoBehaviour {
|
||||
void DoSpeedyBerry(GameObject berry) {
|
||||
AudioSource.PlayClipAtPoint(Resources.Load<AudioClip>("Sounds/SpeedyPowerup"), Camera.main.transform.position, 0.35f * BazookaManager.Instance.GetSettingSFXVolume());
|
||||
berries.Remove(berry);
|
||||
noGravityBerries.Remove(berry.GetInstanceID());
|
||||
noGravityBerries.Remove(berry.GetEntityId());
|
||||
Destroy(berry);
|
||||
boostLeft = 0f;
|
||||
slownessLeft = 0f;
|
||||
@@ -684,7 +684,7 @@ public class CustomGamePlayer : MonoBehaviour {
|
||||
void DoAntiBerry(GameObject berry) {
|
||||
AudioSource.PlayClipAtPoint(Resources.Load<AudioClip>("Sounds/Downgrade"), Camera.main.transform.position, 0.35f * BazookaManager.Instance.GetSettingSFXVolume());
|
||||
berries.Remove(berry);
|
||||
noGravityBerries.Remove(berry.GetInstanceID());
|
||||
noGravityBerries.Remove(berry.GetEntityId());
|
||||
Destroy(berry);
|
||||
boostLeft = 0f;
|
||||
slownessLeft = 0f;
|
||||
@@ -697,7 +697,7 @@ public class CustomGamePlayer : MonoBehaviour {
|
||||
void DoGoldenBerry(GameObject berry) {
|
||||
AudioSource.PlayClipAtPoint(Resources.Load<AudioClip>("Sounds/Powerup"), Camera.main.transform.position, 0.35f * BazookaManager.Instance.GetSettingSFXVolume());
|
||||
berries.Remove(berry);
|
||||
noGravityBerries.Remove(berry.GetInstanceID());
|
||||
noGravityBerries.Remove(berry.GetEntityId());
|
||||
Destroy(berry);
|
||||
boostLeft = 0f;
|
||||
slownessLeft = 0f;
|
||||
@@ -710,7 +710,7 @@ public class CustomGamePlayer : MonoBehaviour {
|
||||
void DoNothingBerry(GameObject berry) {
|
||||
AudioSource.PlayClipAtPoint(Resources.Load<AudioClip>("Sounds/Eat"), Camera.main.transform.position, 1.2f * BazookaManager.Instance.GetSettingSFXVolume());
|
||||
berries.Remove(berry);
|
||||
noGravityBerries.Remove(berry.GetInstanceID());
|
||||
noGravityBerries.Remove(berry.GetEntityId());
|
||||
Destroy(berry);
|
||||
}
|
||||
}
|
||||
@@ -54,7 +54,7 @@ public class GamePlayer : MonoBehaviour {
|
||||
private UnityEngine.Vector2 velocityBeforePause = new();
|
||||
|
||||
public readonly List<GameObject> berries = new();
|
||||
private readonly List<int> noGravityBerries = new();
|
||||
private readonly List<EntityId> noGravityBerries = new();
|
||||
private bool hasJumped = false;
|
||||
|
||||
internal bool IsGrounded() => Physics2D.Distance(bird.GetComponent<CircleCollider2D>(), groundCollider).distance <= 0.1f;
|
||||
@@ -182,8 +182,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());
|
||||
noGravityBerries.Add(berry.GetEntityId());
|
||||
} else noGravityBerries.Remove(berry.GetEntityId());
|
||||
}
|
||||
}
|
||||
} else if (noGravityBerries.Count() != 0) noGravityBerries.Clear();
|
||||
@@ -283,7 +283,7 @@ public class GamePlayer : MonoBehaviour {
|
||||
continue;
|
||||
}
|
||||
if (berry.GetComponent<RectTransform>().anchoredPosition.y < -(canvasRect.rect.height / 2) - berry.GetComponent<RectTransform>().rect.height) {
|
||||
noGravityBerries.Remove(berry.GetInstanceID());
|
||||
noGravityBerries.Remove(berry.GetEntityId());
|
||||
Destroy(berry);
|
||||
} else if (Physics2D.Distance(bird.GetComponent<CircleCollider2D>(), berry.GetComponent<CircleCollider2D>()).distance <= 0.1f) {
|
||||
switch (berry.tag) {
|
||||
@@ -316,7 +316,7 @@ public class GamePlayer : MonoBehaviour {
|
||||
break;
|
||||
}
|
||||
}
|
||||
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));
|
||||
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();
|
||||
@@ -424,7 +424,7 @@ public class GamePlayer : MonoBehaviour {
|
||||
if (increment) totalNormalBerries++;
|
||||
AudioSource.PlayClipAtPoint(Resources.Load<AudioClip>("Sounds/Eat"), Camera.main.transform.position, 1.2f * BazookaManager.Instance.GetSettingSFXVolume());
|
||||
berries.Remove(berry);
|
||||
noGravityBerries.Remove(berry.GetInstanceID());
|
||||
noGravityBerries.Remove(berry.GetEntityId());
|
||||
Destroy(berry);
|
||||
UpdateStats(1, 0);
|
||||
}
|
||||
@@ -440,7 +440,7 @@ public class GamePlayer : MonoBehaviour {
|
||||
if (increment) totalSlowBerries++;
|
||||
AudioSource.PlayClipAtPoint(Resources.Load<AudioClip>("Sounds/Downgrade"), Camera.main.transform.position, 0.35f * BazookaManager.Instance.GetSettingSFXVolume());
|
||||
berries.Remove(berry);
|
||||
noGravityBerries.Remove(berry.GetInstanceID());
|
||||
noGravityBerries.Remove(berry.GetEntityId());
|
||||
Destroy(berry);
|
||||
boostLeft = 0f;
|
||||
slownessLeft = 10f;
|
||||
@@ -456,7 +456,7 @@ public class GamePlayer : MonoBehaviour {
|
||||
if (increment) totalUltraBerries++;
|
||||
AudioSource.PlayClipAtPoint(Resources.Load<AudioClip>("Sounds/Powerup"), Camera.main.transform.position, 0.35f * BazookaManager.Instance.GetSettingSFXVolume());
|
||||
berries.Remove(berry);
|
||||
noGravityBerries.Remove(berry.GetInstanceID());
|
||||
noGravityBerries.Remove(berry.GetEntityId());
|
||||
Destroy(berry);
|
||||
speedyLeft = 0f;
|
||||
antiLeft = 0f;
|
||||
@@ -474,7 +474,7 @@ public class GamePlayer : MonoBehaviour {
|
||||
if (increment) totalSpeedyBerries++;
|
||||
AudioSource.PlayClipAtPoint(Resources.Load<AudioClip>("Sounds/SpeedyPowerup"), Camera.main.transform.position, 0.35f * BazookaManager.Instance.GetSettingSFXVolume());
|
||||
berries.Remove(berry);
|
||||
noGravityBerries.Remove(berry.GetInstanceID());
|
||||
noGravityBerries.Remove(berry.GetEntityId());
|
||||
Destroy(berry);
|
||||
boostLeft = 0f;
|
||||
slownessLeft = 0f;
|
||||
@@ -488,7 +488,7 @@ public class GamePlayer : MonoBehaviour {
|
||||
if (increment) totalCoinBerries++;
|
||||
AudioSource.PlayClipAtPoint(Resources.Load<AudioClip>("Sounds/CoinCollect"), Camera.main.transform.position, 0.35f * BazookaManager.Instance.GetSettingSFXVolume());
|
||||
berries.Remove(berry);
|
||||
noGravityBerries.Remove(berry.GetInstanceID());
|
||||
noGravityBerries.Remove(berry.GetEntityId());
|
||||
Destroy(berry);
|
||||
totalCoins += 10;
|
||||
UpdateStats(0, 0);
|
||||
@@ -512,7 +512,7 @@ public class GamePlayer : MonoBehaviour {
|
||||
if (increment) totalAntiBerries++;
|
||||
AudioSource.PlayClipAtPoint(Resources.Load<AudioClip>("Sounds/Downgrade"), Camera.main.transform.position, 0.35f * BazookaManager.Instance.GetSettingSFXVolume());
|
||||
berries.Remove(berry);
|
||||
noGravityBerries.Remove(berry.GetInstanceID());
|
||||
noGravityBerries.Remove(berry.GetEntityId());
|
||||
Destroy(berry);
|
||||
boostLeft = 0f;
|
||||
slownessLeft = 0f;
|
||||
@@ -526,7 +526,7 @@ public class GamePlayer : MonoBehaviour {
|
||||
if (increment) totalGoldenBerries++;
|
||||
AudioSource.PlayClipAtPoint(Resources.Load<AudioClip>("Sounds/Powerup"), Camera.main.transform.position, 0.35f * BazookaManager.Instance.GetSettingSFXVolume());
|
||||
berries.Remove(berry);
|
||||
noGravityBerries.Remove(berry.GetInstanceID());
|
||||
noGravityBerries.Remove(berry.GetEntityId());
|
||||
Destroy(berry);
|
||||
boostLeft = 0f;
|
||||
slownessLeft = 0f;
|
||||
|
||||
Reference in new issue
Block a user