Add Golden Berry
This commit is contained in:
@@ -711,4 +711,23 @@ public class BazookaManager : MonoBehaviour
|
||||
if (saveFile["gameStore"] == null) return;
|
||||
(saveFile["gameStore"] as JObject)?.Remove("totalAntiBerries");
|
||||
}
|
||||
|
||||
public void SetGameStoreTotalGoldenBerries(BigInteger value)
|
||||
{
|
||||
if (saveFile["gameStore"] == null) saveFile["gameStore"] = new JObject();
|
||||
saveFile["gameStore"]["totalGoldenBerries"] = value.ToString();
|
||||
}
|
||||
|
||||
public BigInteger GetGameStoreTotalGoldenBerries()
|
||||
{
|
||||
if (saveFile["gameStore"] == null) return 0;
|
||||
if (saveFile["gameStore"]["totalGoldenBerries"] == null) return 0;
|
||||
return BigInteger.Parse(saveFile["gameStore"]["totalGoldenBerries"].ToString());
|
||||
}
|
||||
|
||||
public void UnsetGameStoreTotalGoldenBerries()
|
||||
{
|
||||
if (saveFile["gameStore"] == null) return;
|
||||
(saveFile["gameStore"] as JObject)?.Remove("totalGoldenBerries");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@ public class CustomGamePlayer : MonoBehaviour
|
||||
private float slownessLeft;
|
||||
private float speedyLeft;
|
||||
private float antiLeft;
|
||||
private float goldenLeft;
|
||||
private float screenWidth;
|
||||
internal bool isGrounded;
|
||||
[SerializeField] private TMP_Text scoreText;
|
||||
@@ -42,6 +43,7 @@ public class CustomGamePlayer : MonoBehaviour
|
||||
private float speedyBerryChance;
|
||||
private float randomBerryChance;
|
||||
private float antiBerryChance;
|
||||
private float goldenBerryChance;
|
||||
private float nothingBerryChance;
|
||||
|
||||
void Start()
|
||||
@@ -59,6 +61,7 @@ public class CustomGamePlayer : MonoBehaviour
|
||||
speedyBerryChance = customGameTempData.speedyBerryChance;
|
||||
randomBerryChance = customGameTempData.randomBerryChance;
|
||||
antiBerryChance = customGameTempData.antiBerryChance;
|
||||
goldenBerryChance = customGameTempData.goldenBerryChance;
|
||||
nothingBerryChance = customGameTempData.nothingBerryChance;
|
||||
Destroy(customGameTempData.gameObject);
|
||||
|
||||
@@ -243,17 +246,18 @@ public class CustomGamePlayer : MonoBehaviour
|
||||
{
|
||||
if (score != 0) Respawn();
|
||||
}
|
||||
if (antiLeft > 0f)
|
||||
if (antiLeft > 0f || goldenLeft > 0f)
|
||||
{
|
||||
string[] berryTags = { "NormalBerry", "PoisonBerry", "SlowBerry", "UltraBerry", "SpeedyBerry", "RandomBerry", "AntiBerry" };
|
||||
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))
|
||||
{
|
||||
UnityEngine.Vector3 dir = berry.transform.position - bird.transform.position;
|
||||
if (dir.magnitude < 3f)
|
||||
if (dir.magnitude < (antiLeft > 0 ? 3f : 4.5f))
|
||||
{
|
||||
berry.GetComponent<Rigidbody2D>().linearVelocity = dir.normalized * 5f;
|
||||
berry.GetComponent<Rigidbody2D>().linearVelocity = dir.normalized * (antiLeft > 0 ? 5f : -5f);
|
||||
ClampPosition(berry, false);
|
||||
}
|
||||
}
|
||||
@@ -304,6 +308,11 @@ public class CustomGamePlayer : MonoBehaviour
|
||||
antiLeft -= Time.deltaTime;
|
||||
boostText.text = "Berry repellent expires in " + string.Format("{0:0.0}", antiLeft) + "s";
|
||||
}
|
||||
else if (goldenLeft > 0f)
|
||||
{
|
||||
goldenLeft -= Time.deltaTime;
|
||||
boostText.text = "Berry magnet expires in " + string.Format("{0:0.0}", goldenLeft) + "s";
|
||||
}
|
||||
else
|
||||
{
|
||||
boostText.text = "";
|
||||
@@ -383,6 +392,13 @@ public class CustomGamePlayer : MonoBehaviour
|
||||
newBerry.tag = "AntiBerry";
|
||||
goto finish;
|
||||
}
|
||||
cumulative += goldenBerryChance / 100f;
|
||||
if (spawnProbability <= cumulative)
|
||||
{
|
||||
spriteRenderer.sprite = Resources.Load<Sprite>("Berries/GoldenBerry");
|
||||
newBerry.tag = "GoldenBerry";
|
||||
goto finish;
|
||||
}
|
||||
cumulative += nothingBerryChance / 100f;
|
||||
if (spawnProbability <= cumulative)
|
||||
{
|
||||
@@ -420,6 +436,8 @@ public class CustomGamePlayer : MonoBehaviour
|
||||
.Concat(GameObject.FindGameObjectsWithTag("SpeedyBerry"))
|
||||
.Concat(GameObject.FindGameObjectsWithTag("RandomBerry"))
|
||||
.Concat(GameObject.FindGameObjectsWithTag("AntiBerry"))
|
||||
.Concat(GameObject.FindGameObjectsWithTag("GoldenBerry"))
|
||||
.Concat(GameObject.FindGameObjectsWithTag("NothingBerry"))
|
||||
.ToArray();
|
||||
foreach (GameObject berry in allberries)
|
||||
{
|
||||
@@ -433,6 +451,7 @@ public class CustomGamePlayer : MonoBehaviour
|
||||
GameObject[] speedyBerries = GameObject.FindGameObjectsWithTag("SpeedyBerry");
|
||||
GameObject[] randomBerries = GameObject.FindGameObjectsWithTag("RandomBerry");
|
||||
GameObject[] antiBerries = GameObject.FindGameObjectsWithTag("AntiBerry");
|
||||
GameObject[] goldenBerries = GameObject.FindGameObjectsWithTag("GoldenBerry");
|
||||
GameObject[] nothingBerries = GameObject.FindGameObjectsWithTag("NothingBerry");
|
||||
|
||||
if (!pausePanel.activeSelf)
|
||||
@@ -583,6 +602,25 @@ public class CustomGamePlayer : MonoBehaviour
|
||||
antiBerry.GetComponent<Rigidbody2D>().linearVelocity = new UnityEngine.Vector2(0f, -4f);
|
||||
}
|
||||
}
|
||||
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)
|
||||
{
|
||||
DoGoldenBerry(goldenBerry);
|
||||
}
|
||||
if (speedyLeft > 0)
|
||||
{
|
||||
goldenBerry.GetComponent<Rigidbody2D>().linearVelocity = new UnityEngine.Vector2(0f, -7.5f);
|
||||
}
|
||||
else
|
||||
{
|
||||
goldenBerry.GetComponent<Rigidbody2D>().linearVelocity = new UnityEngine.Vector2(0f, -4f);
|
||||
}
|
||||
}
|
||||
foreach (GameObject nothingBerry in nothingBerries)
|
||||
{
|
||||
if (nothingBerry.transform.position.y < 0f - Camera.main.orthographicSize - 1f)
|
||||
@@ -614,6 +652,7 @@ public class CustomGamePlayer : MonoBehaviour
|
||||
.Concat(speedyBerries)
|
||||
.Concat(randomBerries)
|
||||
.Concat(antiBerries)
|
||||
.Concat(goldenBerries)
|
||||
.Concat(nothingBerries)
|
||||
.ToArray();
|
||||
foreach (GameObject berry in allberries)
|
||||
@@ -644,6 +683,7 @@ public class CustomGamePlayer : MonoBehaviour
|
||||
.Concat(GameObject.FindGameObjectsWithTag("SpeedyBerry"))
|
||||
.Concat(GameObject.FindGameObjectsWithTag("RandomBerry"))
|
||||
.Concat(GameObject.FindGameObjectsWithTag("AntiBerry"))
|
||||
.Concat(GameObject.FindGameObjectsWithTag("GoldenBerry"))
|
||||
.Concat(GameObject.FindGameObjectsWithTag("NothingBerry"))
|
||||
.ToArray();
|
||||
foreach (GameObject berry in allberries)
|
||||
@@ -741,6 +781,7 @@ public class CustomGamePlayer : MonoBehaviour
|
||||
slownessLeft = 10f;
|
||||
speedyLeft = 0f;
|
||||
antiLeft = 0f;
|
||||
goldenLeft = 0f;
|
||||
if (score > 0)
|
||||
{
|
||||
UpdateStats(-1);
|
||||
@@ -753,6 +794,7 @@ public class CustomGamePlayer : MonoBehaviour
|
||||
Destroy(berry);
|
||||
speedyLeft = 0f;
|
||||
antiLeft = 0f;
|
||||
goldenLeft = 0f;
|
||||
if (slownessLeft > 0f)
|
||||
{
|
||||
slownessLeft = 0f;
|
||||
@@ -773,6 +815,7 @@ public class CustomGamePlayer : MonoBehaviour
|
||||
slownessLeft = 0f;
|
||||
speedyLeft = 10f;
|
||||
antiLeft = 0f;
|
||||
goldenLeft = 0f;
|
||||
UpdateStats(10);
|
||||
}
|
||||
|
||||
@@ -784,6 +827,19 @@ public class CustomGamePlayer : MonoBehaviour
|
||||
slownessLeft = 0f;
|
||||
speedyLeft = 0f;
|
||||
antiLeft = 10f;
|
||||
goldenLeft = 0f;
|
||||
UpdateStats(0);
|
||||
}
|
||||
|
||||
void DoGoldenBerry(GameObject berry)
|
||||
{
|
||||
AudioSource.PlayClipAtPoint(Resources.Load<AudioClip>("Sounds/Powerup"), Camera.main.transform.position, 0.35f * BazookaManager.Instance.GetSettingSFXVolume());
|
||||
Destroy(berry);
|
||||
boostLeft = 0f;
|
||||
slownessLeft = 0f;
|
||||
speedyLeft = 0f;
|
||||
antiLeft = 0f;
|
||||
goldenLeft = 10f;
|
||||
UpdateStats(0);
|
||||
}
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@ public class CustomGameTempData : MonoBehaviour
|
||||
public float speedyBerryChance;
|
||||
public float randomBerryChance;
|
||||
public float antiBerryChance;
|
||||
public float goldenBerryChance;
|
||||
public float nothingBerryChance;
|
||||
|
||||
void Awake()
|
||||
|
||||
@@ -22,12 +22,14 @@ public class GamePlayer : MonoBehaviour
|
||||
private BigInteger totalCoinBerries;
|
||||
private BigInteger totalRandomBerries;
|
||||
private BigInteger totalAntiBerries;
|
||||
private BigInteger totalGoldenBerries;
|
||||
private BigInteger totalAttempts;
|
||||
private BigInteger totalCoins;
|
||||
private float boostLeft;
|
||||
private float slownessLeft;
|
||||
private float speedyLeft;
|
||||
private float antiLeft;
|
||||
private float goldenLeft;
|
||||
private float screenWidth;
|
||||
internal bool isGrounded;
|
||||
[SerializeField] private TMP_Text scoreText;
|
||||
@@ -138,6 +140,7 @@ public class GamePlayer : MonoBehaviour
|
||||
totalCoinBerries = BazookaManager.Instance.GetGameStoreTotalCoinBerries();
|
||||
totalRandomBerries = BazookaManager.Instance.GetGameStoreTotalRandomBerries();
|
||||
totalAntiBerries = BazookaManager.Instance.GetGameStoreTotalAntiBerries();
|
||||
totalGoldenBerries = BazookaManager.Instance.GetGameStoreTotalGoldenBerries();
|
||||
totalAttempts = BazookaManager.Instance.GetGameStoreTotalAttepts();
|
||||
totalCoins = BazookaManager.Instance.GetCustomBirdIconData().Balance;
|
||||
|
||||
@@ -244,17 +247,18 @@ public class GamePlayer : MonoBehaviour
|
||||
{
|
||||
if (score != 0) Respawn();
|
||||
}
|
||||
if (antiLeft > 0f)
|
||||
if (antiLeft > 0f || goldenLeft > 0f)
|
||||
{
|
||||
string[] berryTags = { "NormalBerry", "PoisonBerry", "SlowBerry", "UltraBerry", "SpeedyBerry", "CoinBerry", "RandomBerry", "AntiBerry" };
|
||||
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))
|
||||
{
|
||||
UnityEngine.Vector3 dir = berry.transform.position - bird.transform.position;
|
||||
if (dir.magnitude < 3f)
|
||||
if (dir.magnitude < (antiLeft > 0 ? 3f : 4.5f))
|
||||
{
|
||||
berry.GetComponent<Rigidbody2D>().linearVelocity = dir.normalized * 5f;
|
||||
berry.GetComponent<Rigidbody2D>().linearVelocity = dir.normalized * (antiLeft > 0 ? 5f : -5f);
|
||||
ClampPosition(berry, false);
|
||||
}
|
||||
}
|
||||
@@ -305,6 +309,11 @@ public class GamePlayer : MonoBehaviour
|
||||
antiLeft -= Time.deltaTime;
|
||||
boostText.text = "Berry repellent expires in " + string.Format("{0:0.0}", antiLeft) + "s";
|
||||
}
|
||||
else if (goldenLeft > 0f)
|
||||
{
|
||||
goldenLeft -= Time.deltaTime;
|
||||
boostText.text = "Berry magnet expires in " + string.Format("{0:0.0}", goldenLeft) + "s";
|
||||
}
|
||||
else
|
||||
{
|
||||
boostText.text = "";
|
||||
@@ -332,48 +341,53 @@ public class GamePlayer : MonoBehaviour
|
||||
GameObject newBerry = new("Berry");
|
||||
newBerry.transform.SetParent(berryParent.transform);
|
||||
SpriteRenderer spriteRenderer = newBerry.AddComponent<SpriteRenderer>();
|
||||
if (spawnProbability <= 0.425f)
|
||||
if (spawnProbability <= 0.375f)
|
||||
{
|
||||
spriteRenderer.sprite = Resources.Load<Sprite>("Berries/Berry");
|
||||
newBerry.tag = "NormalBerry";
|
||||
}
|
||||
else if (spawnProbability <= 0.55f)
|
||||
else if (spawnProbability <= 0.550)
|
||||
{
|
||||
spriteRenderer.sprite = Resources.Load<Sprite>("Berries/PoisonBerry");
|
||||
newBerry.tag = "PoisonBerry";
|
||||
}
|
||||
else if (spawnProbability <= 0.65f)
|
||||
else if (spawnProbability <= 0.60f)
|
||||
{
|
||||
spriteRenderer.sprite = Resources.Load<Sprite>("Berries/SlowBerry");
|
||||
newBerry.tag = "SlowBerry";
|
||||
}
|
||||
else if (spawnProbability <= 0.75f)
|
||||
else if (spawnProbability <= 0.70f)
|
||||
{
|
||||
spriteRenderer.sprite = Resources.Load<Sprite>("Berries/UltraBerry");
|
||||
newBerry.tag = "UltraBerry";
|
||||
}
|
||||
else if (spawnProbability <= 0.85f)
|
||||
else if (spawnProbability <= 0.80f)
|
||||
{
|
||||
spriteRenderer.sprite = Resources.Load<Sprite>("Berries/SpeedyBerry");
|
||||
newBerry.tag = "SpeedyBerry";
|
||||
}
|
||||
else if (spawnProbability <= 0.90f)
|
||||
else if (spawnProbability <= 0.85f)
|
||||
{
|
||||
spriteRenderer.sprite = Resources.Load<Sprite>("Berries/CoinBerry");
|
||||
newBerry.tag = "CoinBerry";
|
||||
}
|
||||
else if (spawnProbability <= 0.95f)
|
||||
else if (spawnProbability <= 0.90f)
|
||||
{
|
||||
spriteRenderer.sprite = Resources.Load<Sprite>("Berries/BerryNoColor");
|
||||
newBerry.tag = "RandomBerry";
|
||||
RainbowSpriteRender randomBerryRainbowImage = newBerry.AddComponent<RainbowSpriteRender>();
|
||||
randomBerryRainbowImage.frequency = 5f;
|
||||
}
|
||||
else
|
||||
else if (spawnProbability <= 0.95f)
|
||||
{
|
||||
spriteRenderer.sprite = Resources.Load<Sprite>("Berries/AntiBerry");
|
||||
newBerry.tag = "AntiBerry";
|
||||
}
|
||||
else
|
||||
{
|
||||
spriteRenderer.sprite = Resources.Load<Sprite>("Berries/GoldenBerry");
|
||||
newBerry.tag = "GoldenBerry";
|
||||
}
|
||||
spriteRenderer.sortingOrder = -5;
|
||||
|
||||
float screenWidth = Camera.main.orthographicSize * 2 * Camera.main.aspect;
|
||||
@@ -404,6 +418,7 @@ public class GamePlayer : MonoBehaviour
|
||||
.Concat(GameObject.FindGameObjectsWithTag("CoinBerry"))
|
||||
.Concat(GameObject.FindGameObjectsWithTag("RandomBerry"))
|
||||
.Concat(GameObject.FindGameObjectsWithTag("AntiBerry"))
|
||||
.Concat(GameObject.FindGameObjectsWithTag("GoldenBerry"))
|
||||
.ToArray();
|
||||
foreach (GameObject berry in allberries)
|
||||
{
|
||||
@@ -418,6 +433,7 @@ public class GamePlayer : MonoBehaviour
|
||||
GameObject[] coinBerries = GameObject.FindGameObjectsWithTag("CoinBerry");
|
||||
GameObject[] randomBerries = GameObject.FindGameObjectsWithTag("RandomBerry");
|
||||
GameObject[] antiBerries = GameObject.FindGameObjectsWithTag("AntiBerry");
|
||||
GameObject[] goldenBerries = GameObject.FindGameObjectsWithTag("GoldenBerry");
|
||||
|
||||
if (!pausePanel.activeSelf)
|
||||
{
|
||||
@@ -556,12 +572,13 @@ public class GamePlayer : MonoBehaviour
|
||||
else if (UnityEngine.Vector3.Distance(bird.transform.position, randomBerry.transform.position) < 1.5f)
|
||||
{
|
||||
totalRandomBerries++;
|
||||
System.Action[] funcs = {
|
||||
Action[] funcs = {
|
||||
() => DoNormalBerry(randomBerry),
|
||||
() => DoSlowBerry(randomBerry),
|
||||
() => DoUltraBerry(randomBerry),
|
||||
() => DoSpeedyBerry(randomBerry),
|
||||
() => DoAntiBerry(randomBerry)
|
||||
() => DoAntiBerry(randomBerry),
|
||||
() => DoGoldenBerry(randomBerry)
|
||||
};
|
||||
funcs[UnityEngine.Random.Range(0, funcs.Length)]();
|
||||
}
|
||||
@@ -594,6 +611,26 @@ public class GamePlayer : MonoBehaviour
|
||||
antiBerry.GetComponent<Rigidbody2D>().linearVelocity = new UnityEngine.Vector2(0f, -4f);
|
||||
}
|
||||
}
|
||||
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)
|
||||
{
|
||||
totalGoldenBerries++;
|
||||
DoGoldenBerry(goldenBerry);
|
||||
}
|
||||
if (speedyLeft > 0)
|
||||
{
|
||||
goldenBerry.GetComponent<Rigidbody2D>().linearVelocity = new UnityEngine.Vector2(0f, -7.5f);
|
||||
}
|
||||
else
|
||||
{
|
||||
goldenBerry.GetComponent<Rigidbody2D>().linearVelocity = new UnityEngine.Vector2(0f, -4f);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -607,6 +644,7 @@ public class GamePlayer : MonoBehaviour
|
||||
.Concat(coinBerries)
|
||||
.Concat(randomBerries)
|
||||
.Concat(antiBerries)
|
||||
.Concat(goldenBerries)
|
||||
.ToArray();
|
||||
foreach (GameObject berry in allberries)
|
||||
{
|
||||
@@ -637,6 +675,7 @@ public class GamePlayer : MonoBehaviour
|
||||
.Concat(GameObject.FindGameObjectsWithTag("CoinBerry"))
|
||||
.Concat(GameObject.FindGameObjectsWithTag("RandomBerry"))
|
||||
.Concat(GameObject.FindGameObjectsWithTag("AntiBerry"))
|
||||
.Concat(GameObject.FindGameObjectsWithTag("GoldenBerry"))
|
||||
.ToArray();
|
||||
foreach (GameObject berry in allberries)
|
||||
{
|
||||
@@ -667,6 +706,7 @@ public class GamePlayer : MonoBehaviour
|
||||
BazookaManager.Instance.SetGameStoreTotalCoinBerries(totalCoinBerries);
|
||||
BazookaManager.Instance.SetGameStoreTotalRandomBerries(totalRandomBerries);
|
||||
BazookaManager.Instance.SetGameStoreTotalAntiBerries(totalAntiBerries);
|
||||
BazookaManager.Instance.SetGameStoreTotalGoldenBerries(totalGoldenBerries);
|
||||
BazookaManager.Instance.SetGameStoreTotalAttepts(totalAttempts);
|
||||
var customBirdIconData = BazookaManager.Instance.GetCustomBirdIconData();
|
||||
customBirdIconData.Balance = totalCoins;
|
||||
@@ -763,6 +803,7 @@ public class GamePlayer : MonoBehaviour
|
||||
slownessLeft = 10f;
|
||||
speedyLeft = 0f;
|
||||
antiLeft = 0f;
|
||||
goldenLeft = 0f;
|
||||
if (score > 0)
|
||||
{
|
||||
UpdateStats(-1, 0);
|
||||
@@ -775,6 +816,7 @@ public class GamePlayer : MonoBehaviour
|
||||
Destroy(berry);
|
||||
speedyLeft = 0f;
|
||||
antiLeft = 0f;
|
||||
goldenLeft = 0f;
|
||||
if (slownessLeft > 0f)
|
||||
{
|
||||
slownessLeft = 0f;
|
||||
@@ -795,6 +837,7 @@ public class GamePlayer : MonoBehaviour
|
||||
slownessLeft = 0f;
|
||||
speedyLeft = 10f;
|
||||
antiLeft = 0f;
|
||||
goldenLeft = 0f;
|
||||
UpdateStats(10, 0);
|
||||
}
|
||||
|
||||
@@ -814,6 +857,19 @@ public class GamePlayer : MonoBehaviour
|
||||
slownessLeft = 0f;
|
||||
speedyLeft = 0f;
|
||||
antiLeft = 10f;
|
||||
goldenLeft = 0f;
|
||||
UpdateStats(0, 0);
|
||||
}
|
||||
|
||||
void DoGoldenBerry(GameObject berry)
|
||||
{
|
||||
AudioSource.PlayClipAtPoint(Resources.Load<AudioClip>("Sounds/Powerup"), Camera.main.transform.position, 0.35f * BazookaManager.Instance.GetSettingSFXVolume());
|
||||
Destroy(berry);
|
||||
boostLeft = 0f;
|
||||
slownessLeft = 0f;
|
||||
speedyLeft = 0f;
|
||||
antiLeft = 0f;
|
||||
goldenLeft = 10f;
|
||||
UpdateStats(0, 0);
|
||||
}
|
||||
}
|
||||
@@ -21,17 +21,19 @@ public class PlayMenu : MonoBehaviour
|
||||
[SerializeField] private TMP_InputField speedyBerryChance;
|
||||
[SerializeField] private TMP_InputField randomBerryChance;
|
||||
[SerializeField] private TMP_InputField antiBerryChance;
|
||||
[SerializeField] private TMP_InputField goldenBerryChance;
|
||||
[SerializeField] private TMP_InputField nothingBerryChance;
|
||||
|
||||
[SerializeField] private TMP_Text validateTotalText;
|
||||
|
||||
private readonly float defaultNormalBerryChance = 47.5f;
|
||||
private readonly float defaultNormalBerryChance = 32.5f;
|
||||
private readonly float defaultPoisonBerryChance = 12.5f;
|
||||
private readonly float defaultSlowBerryChance = 10f;
|
||||
private readonly float defaultUltraBerryChance = 10f;
|
||||
private readonly float defaultSpeedyBerryChance = 10f;
|
||||
private readonly float defaultRandomBerryChance = 5f;
|
||||
private readonly float defaultAntiBerryChance = 5f;
|
||||
private readonly float defaultGoldenBerryChance = 5f;
|
||||
private readonly float defaultNothingBerryChance = 0f;
|
||||
|
||||
void Awake()
|
||||
@@ -55,6 +57,7 @@ public class PlayMenu : MonoBehaviour
|
||||
speedyBerryChance.text = defaultSpeedyBerryChance.ToString();
|
||||
randomBerryChance.text = defaultRandomBerryChance.ToString();
|
||||
antiBerryChance.text = defaultAntiBerryChance.ToString();
|
||||
goldenBerryChance.text = defaultGoldenBerryChance.ToString();
|
||||
nothingBerryChance.text = defaultNothingBerryChance.ToString();
|
||||
ValidateTotal();
|
||||
if (DiscordRPCHandler.Instance != null)
|
||||
@@ -69,6 +72,7 @@ public class PlayMenu : MonoBehaviour
|
||||
float speedyBerry = GetValueFrom(speedyBerryChance);
|
||||
float randomBerry = GetValueFrom(randomBerryChance);
|
||||
float antiBerry = GetValueFrom(antiBerryChance);
|
||||
float goldenBerry = GetValueFrom(goldenBerryChance);
|
||||
float nothingBerry = GetValueFrom(nothingBerryChance);
|
||||
|
||||
int divideBy = 0;
|
||||
@@ -80,9 +84,10 @@ public class PlayMenu : MonoBehaviour
|
||||
divideBy += speedyBerry > 0 ? 1 : 0;
|
||||
divideBy += randomBerry > 0 ? 1 : 0;
|
||||
divideBy += antiBerry > 0 ? 1 : 0;
|
||||
divideBy += goldenBerry > 0 ? 1 : 0;
|
||||
divideBy += nothingBerry > 0 ? 1 : 0;
|
||||
|
||||
float addedChances = normalBerry + poisonBerry + slowBerry + ultraBerry + speedyBerry + randomBerry + antiBerry + nothingBerry;
|
||||
float addedChances = normalBerry + poisonBerry + slowBerry + ultraBerry + speedyBerry + randomBerry + antiBerry + goldenBerry + nothingBerry;
|
||||
float difference = addedChances - 100f;
|
||||
|
||||
if (normalBerry > 0) NormalizeOne(normalBerryChance, normalBerry, divideBy, difference);
|
||||
@@ -92,6 +97,7 @@ public class PlayMenu : MonoBehaviour
|
||||
if (speedyBerry > 0) NormalizeOne(speedyBerryChance, speedyBerry, divideBy, difference);
|
||||
if (randomBerry > 0) NormalizeOne(randomBerryChance, randomBerry, divideBy, difference);
|
||||
if (antiBerry > 0) NormalizeOne(antiBerryChance, antiBerry, divideBy, difference);
|
||||
if (goldenBerry > 0) NormalizeOne(goldenBerryChance, goldenBerry, divideBy, difference);
|
||||
if (nothingBerry > 0) NormalizeOne(nothingBerryChance, nothingBerry, divideBy, difference);
|
||||
|
||||
normalBerry = GetValueFrom(normalBerryChance);
|
||||
@@ -101,6 +107,7 @@ public class PlayMenu : MonoBehaviour
|
||||
speedyBerry = GetValueFrom(speedyBerryChance);
|
||||
randomBerry = GetValueFrom(randomBerryChance);
|
||||
antiBerry = GetValueFrom(antiBerryChance);
|
||||
goldenBerry = GetValueFrom(goldenBerryChance);
|
||||
nothingBerry = GetValueFrom(nothingBerryChance);
|
||||
|
||||
if (normalBerry > 0) normalBerry = (float)Math.Floor(normalBerry);
|
||||
@@ -110,9 +117,10 @@ public class PlayMenu : MonoBehaviour
|
||||
if (speedyBerry > 0) speedyBerry = (float)Math.Floor(speedyBerry);
|
||||
if (randomBerry > 0) randomBerry = (float)Math.Floor(randomBerry);
|
||||
if (antiBerry > 0) antiBerry = (float)Math.Floor(antiBerry);
|
||||
if (goldenBerry > 0) goldenBerry = (float)Math.Floor(goldenBerry);
|
||||
if (nothingBerry > 0) nothingBerry = (float)Math.Floor(nothingBerry);
|
||||
|
||||
float addedChances2 = normalBerry + poisonBerry + slowBerry + ultraBerry + speedyBerry + randomBerry + antiBerry + nothingBerry;
|
||||
float addedChances2 = normalBerry + poisonBerry + slowBerry + ultraBerry + speedyBerry + randomBerry + antiBerry + goldenBerry + nothingBerry;
|
||||
float difference2 = addedChances2 - 100f;
|
||||
bool fixedValues = false;
|
||||
|
||||
@@ -151,6 +159,11 @@ public class PlayMenu : MonoBehaviour
|
||||
NormalizeTwo(antiBerryChance, fixedValues, antiBerry, difference2);
|
||||
fixedValues = true;
|
||||
}
|
||||
if (goldenBerry > 0)
|
||||
{
|
||||
NormalizeTwo(goldenBerryChance, fixedValues, goldenBerry, difference2);
|
||||
fixedValues = true;
|
||||
}
|
||||
if (nothingBerry > 0)
|
||||
{
|
||||
NormalizeTwo(nothingBerryChance, fixedValues, nothingBerry, difference2);
|
||||
@@ -171,6 +184,7 @@ public class PlayMenu : MonoBehaviour
|
||||
customGameTempData.speedyBerryChance = GetValueFrom(speedyBerryChance);
|
||||
customGameTempData.randomBerryChance = GetValueFrom(randomBerryChance);
|
||||
customGameTempData.antiBerryChance = GetValueFrom(antiBerryChance);
|
||||
customGameTempData.goldenBerryChance = GetValueFrom(goldenBerryChance);
|
||||
customGameTempData.nothingBerryChance = GetValueFrom(nothingBerryChance);
|
||||
await SceneManager.LoadSceneAsync("CustomGamePlayer");
|
||||
});
|
||||
@@ -189,6 +203,8 @@ public class PlayMenu : MonoBehaviour
|
||||
randomBerryChance.onDeselect.AddListener((value) => OnDeselect(value, randomBerryChance));
|
||||
antiBerryChance.onSelect.AddListener((value) => OnSelect(value, antiBerryChance));
|
||||
antiBerryChance.onDeselect.AddListener((value) => OnDeselect(value, antiBerryChance));
|
||||
goldenBerryChance.onSelect.AddListener((value) => OnSelect(value, goldenBerryChance));
|
||||
goldenBerryChance.onDeselect.AddListener((value) => OnDeselect(value, goldenBerryChance));
|
||||
nothingBerryChance.onSelect.AddListener((value) => OnSelect(value, nothingBerryChance));
|
||||
nothingBerryChance.onDeselect.AddListener((value) => OnDeselect(value, nothingBerryChance));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user