Finish nothing berry

This commit is contained in:
2025-09-12 12:55:18 -07:00
parent b40e4a5279
commit d7b6bbd0ab
5 changed files with 69 additions and 7 deletions

View File

@@ -552,7 +552,7 @@ GameObject:
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
m_IsActive: 0
--- !u!224 &164218987
RectTransform:
m_ObjectHideFlags: 0
@@ -1385,7 +1385,7 @@ RectTransform:
m_AnchorMin: {x: 0.5, y: 1}
m_AnchorMax: {x: 0.5, y: 1}
m_AnchoredPosition: {x: 0, y: -100}
m_SizeDelta: {x: 0, y: 0}
m_SizeDelta: {x: 658.25, y: 45.01}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &459138108
MonoBehaviour:
@@ -2192,6 +2192,7 @@ MonoBehaviour:
speedyBerryChance: {fileID: 1878332340}
randomBerryChance: {fileID: 2018765150}
antiBerryChance: {fileID: 1230511725}
nothingBerryChance: {fileID: 830548777}
validateTotalText: {fileID: 598155839}
jumpscareImage: {fileID: 972157958}
jumpscareAudio: {fileID: 1202270393}
@@ -3392,7 +3393,7 @@ MonoBehaviour:
m_CaretColor: {r: 0.19607843, g: 0.19607843, b: 0.19607843, a: 1}
m_CustomCaretColor: 0
m_SelectionColor: {r: 0.65882355, g: 0.80784315, b: 1, a: 0.7529412}
m_Text: 5%
m_Text: 0%
m_CaretBlinkRate: 0.85
m_CaretWidth: 1
m_ReadOnly: 0
@@ -5052,7 +5053,7 @@ RectTransform:
m_AnchorMin: {x: 0.5, y: 1}
m_AnchorMax: {x: 0.5, y: 1}
m_AnchoredPosition: {x: 0, y: -100}
m_SizeDelta: {x: 400.43, y: 70.01}
m_SizeDelta: {x: 0, y: 0}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &1447186681
MonoBehaviour:
@@ -6074,7 +6075,7 @@ GameObject:
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 0
m_IsActive: 1
--- !u!224 &1723463929
RectTransform:
m_ObjectHideFlags: 0

View File

@@ -45,6 +45,7 @@ public class CustomGamePlayer : MonoBehaviour
private float speedyBerryChance;
private float randomBerryChance;
private float antiBerryChance;
private float nothingBerryChance;
void Start()
{
@@ -61,6 +62,7 @@ public class CustomGamePlayer : MonoBehaviour
speedyBerryChance = customGameTempData.speedyBerryChance;
randomBerryChance = customGameTempData.randomBerryChance;
antiBerryChance = customGameTempData.antiBerryChance;
nothingBerryChance = customGameTempData.nothingBerryChance;
Destroy(customGameTempData.gameObject);
var backgroundColor = BazookaManager.Instance.GetColorSettingBackground();
@@ -389,6 +391,13 @@ public class CustomGamePlayer : MonoBehaviour
newBerry.tag = "AntiBerry";
goto finish;
}
cumulative += nothingBerryChance / 100f;
if (spawnProbability <= cumulative)
{
spriteRenderer.sprite = Resources.Load<Sprite>("Berries/BerryNoColor");
newBerry.tag = "NothingBerry";
goto finish;
}
finish:
spriteRenderer.sortingOrder = -5;
@@ -438,6 +447,7 @@ public class CustomGamePlayer : MonoBehaviour
GameObject[] speedyBerries = GameObject.FindGameObjectsWithTag("SpeedyBerry");
GameObject[] randomBerries = GameObject.FindGameObjectsWithTag("RandomBerry");
GameObject[] antiBerries = GameObject.FindGameObjectsWithTag("AntiBerry");
GameObject[] nothingBerries = GameObject.FindGameObjectsWithTag("NothingBerry");
if (!pausePanel.activeSelf)
{
@@ -587,6 +597,25 @@ public class CustomGamePlayer : MonoBehaviour
antiBerry.GetComponent<Rigidbody2D>().linearVelocity = new UnityEngine.Vector2(0f, -4f);
}
}
foreach (GameObject nothingBerry in nothingBerries)
{
if (nothingBerry.transform.position.y < 0f - Camera.main.orthographicSize - 1f)
{
Destroy(nothingBerry);
}
else if (UnityEngine.Vector3.Distance(bird.transform.position, nothingBerry.transform.position) < 1.5f)
{
DoNothingBerry(nothingBerry);
}
if (speedyLeft > 0)
{
nothingBerry.GetComponent<Rigidbody2D>().linearVelocity = new UnityEngine.Vector2(0f, -7.5f);
}
else
{
nothingBerry.GetComponent<Rigidbody2D>().linearVelocity = new UnityEngine.Vector2(0f, -4f);
}
}
}
else
{
@@ -599,6 +628,7 @@ public class CustomGamePlayer : MonoBehaviour
.Concat(speedyBerries)
.Concat(randomBerries)
.Concat(antiBerries)
.Concat(nothingBerries)
.ToArray();
foreach (GameObject berry in allberries)
{
@@ -628,6 +658,7 @@ public class CustomGamePlayer : MonoBehaviour
.Concat(GameObject.FindGameObjectsWithTag("SpeedyBerry"))
.Concat(GameObject.FindGameObjectsWithTag("RandomBerry"))
.Concat(GameObject.FindGameObjectsWithTag("AntiBerry"))
.Concat(GameObject.FindGameObjectsWithTag("NothingBerry"))
.ToArray();
foreach (GameObject berry in allberries)
{
@@ -764,4 +795,10 @@ public class CustomGamePlayer : MonoBehaviour
antiLeft = 10f;
UpdateStats(0, 0);
}
void DoNothingBerry(GameObject berry)
{
AudioSource.PlayClipAtPoint(Resources.Load<AudioClip>("Sounds/Eat"), Camera.main.transform.position, 1.2f * BazookaManager.Instance.GetSettingSFXVolume());
Destroy(berry);
}
}

View File

@@ -9,6 +9,7 @@ public class CustomGameTempData : MonoBehaviour
public float speedyBerryChance;
public float randomBerryChance;
public float antiBerryChance;
public float nothingBerryChance;
void Awake()
{

View File

@@ -7,8 +7,8 @@ using UnityEngine.UI;
public class PlayMenu : MonoBehaviour
{
private static WaitForSeconds _waitForSeconds7 = new WaitForSeconds(7);
private static WaitForSeconds _waitForSeconds3 = new WaitForSeconds(3);
private static WaitForSeconds _waitForSeconds7 = new(7);
private static WaitForSeconds _waitForSeconds3 = new(3);
public GameObject selectionMenu;
public GameObject customMenu;
public Button customButton;
@@ -22,6 +22,7 @@ public class PlayMenu : MonoBehaviour
public TMP_InputField speedyBerryChance;
public TMP_InputField randomBerryChance;
public TMP_InputField antiBerryChance;
public TMP_InputField nothingBerryChance;
public TMP_Text validateTotalText;
@@ -48,6 +49,7 @@ public class PlayMenu : MonoBehaviour
speedyBerryChance.text = "10%";
randomBerryChance.text = "5%";
antiBerryChance.text = "5%";
nothingBerryChance.text = "0%";
ValidateTotal();
});
customPlayButton.onClick.AddListener(async () =>
@@ -62,6 +64,7 @@ public class PlayMenu : MonoBehaviour
customGameTempData.speedyBerryChance = float.Parse(speedyBerryChance.text.Replace("%", "").Trim());
customGameTempData.randomBerryChance = float.Parse(randomBerryChance.text.Replace("%", "").Trim());
customGameTempData.antiBerryChance = float.Parse(antiBerryChance.text.Replace("%", "").Trim());
customGameTempData.nothingBerryChance = float.Parse(nothingBerryChance.text.Replace("%", "").Trim());
await SceneManager.LoadSceneAsync("CustomGamePlayer");
});
@@ -190,6 +193,24 @@ public class PlayMenu : MonoBehaviour
customBackButton.interactable = true;
ValidateTotal();
});
nothingBerryChance.onSelect.AddListener((value) =>
{
validateTotalText.gameObject.SetActive(false);
customBackButton.interactable = false;
customPlayButton.interactable = false;
nothingBerryChance.text = value.Replace("%", "");
nothingBerryChance.stringPosition = nothingBerryChance.text.Length;
});
nothingBerryChance.onDeselect.AddListener((value) =>
{
if (float.TryParse(value, out var value2) && value2 < 0f)
{
value = "0";
}
nothingBerryChance.text = value + "%";
customBackButton.interactable = true;
ValidateTotal();
});
jumpscareButton.onClick.AddListener(() =>
{
jumpscareButton.GetComponent<Image>().color = Color.red;
@@ -211,6 +232,7 @@ public class PlayMenu : MonoBehaviour
total += float.Parse(speedyBerryChance.text.Replace("%", ""));
total += float.Parse(randomBerryChance.text.Replace("%", ""));
total += float.Parse(antiBerryChance.text.Replace("%", ""));
total += float.Parse(nothingBerryChance.text.Replace("%", ""));
}
catch (Exception)
{

View File

@@ -12,6 +12,7 @@ TagManager:
- CoinBerry
- RandomBerry
- AntiBerry
- NothingBerry
layers:
- Default
- TransparentFX