Initial commit

This commit is contained in:
Lncvrt committed 2025-10-04 11:20:33 -07:00
commit 89c3c2f625
234 files changed
+85827

No files matched your search

+266
View File
@@ -0,0 +1,266 @@
using System.IO;
using System.Numerics;
using System.Text;
using Newtonsoft.Json.Linq;
using UnityEngine;
public class BazookaManager : MonoBehaviour
{
public static BazookaManager Instance;
private bool firstLoadDone = false;
public JObject saveFile = new()
{
["version"] = "0"
};
void Awake()
{
if (Instance == null)
{
Instance = this;
DontDestroyOnLoad(gameObject);
if (!firstLoadDone)
{
firstLoadDone = true;
Load();
}
}
else
{
Destroy(gameObject);
}
}
void OnApplicationQuit()
{
Save();
}
void OnApplicationPause(bool pause)
{
if (pause)
{
Save();
}
}
public void Load()
{
string path = Path.Join(Application.persistentDataPath, "save.json");
if (!File.Exists(path))
{
File.Create(path).Dispose();
}
else
{
try
{
var tempSaveFile = JObject.Parse(Encoding.UTF8.GetString(File.ReadAllBytes(path)));
if (tempSaveFile != null) saveFile = tempSaveFile;
}
catch
{
Debug.LogWarning("Failed to load save file");
}
}
}
public void Save()
{
#if UNITY_EDITOR
return;
#else
string path = Path.Join(Application.persistentDataPath, "save.json");
var encoded = Encoding.UTF8.GetBytes(saveFile.ToString(Newtonsoft.Json.Formatting.None));
using var fileStream = new FileStream(path, FileMode.Create, FileAccess.Write, FileShare.None);
fileStream.Write(encoded, 0, encoded.Length);
fileStream.Flush(true);
#endif
}
//Settings stuff
public void SetSettingFullScreen(bool value)
{
if (saveFile["settings"] == null) saveFile["settings"] = new JObject();
saveFile["settings"]["fullScreen"] = value;
}
public bool GetSettingFullScreen()
{
if (saveFile["settings"] == null) return true;
if (saveFile["settings"]["fullScreen"] == null) return true;
return bool.Parse(saveFile["settings"]["fullScreen"].ToString());
}
public void SetSettingVsync(bool value)
{
if (saveFile["settings"] == null) saveFile["settings"] = new JObject();
saveFile["settings"]["vsync"] = value;
}
public bool GetSettingVsync()
{
if (saveFile["settings"] == null) return true;
if (saveFile["settings"]["vsync"] == null) return true;
return bool.Parse(saveFile["settings"]["vsync"].ToString());
}
public void SetSettingRandomMusic(bool value)
{
if (saveFile["settings"] == null) saveFile["settings"] = new JObject();
saveFile["settings"]["randomMusic"] = value;
}
public bool GetSettingRandomMusic()
{
if (saveFile["settings"] == null) return true;
if (saveFile["settings"]["randomMusic"] == null) return true;
return bool.Parse(saveFile["settings"]["randomMusic"].ToString());
}
public void SetSettingMusicVolume(float value)
{
if (saveFile["settings"] == null) saveFile["settings"] = new JObject();
saveFile["settings"]["musicVolume"] = value;
}
public float GetSettingMusicVolume()
{
if (saveFile["settings"] == null) return 1f;
if (saveFile["settings"]["musicVolume"] == null) return 1f;
return float.Parse(saveFile["settings"]["musicVolume"].ToString());
}
public void SetSettingSFXVolume(float value)
{
if (saveFile["settings"] == null) saveFile["settings"] = new JObject();
saveFile["settings"]["sfxVolume"] = value;
}
public float GetSettingSFXVolume()
{
if (saveFile["settings"] == null) return 1f;
if (saveFile["settings"]["sfxVolume"] == null) return 1f;
return float.Parse(saveFile["settings"]["sfxVolume"].ToString());
}
//Game store stuff
public void SetGameStoreHighScore(BigInteger value)
{
if (saveFile["gameStore"] == null) saveFile["gameStore"] = new JObject();
saveFile["gameStore"]["highScore"] = value.ToString();
}
public BigInteger GetGameStoreHighScore()
{
if (saveFile["gameStore"] == null) return 0;
if (saveFile["gameStore"]["highScore"] == null) return 0;
return BigInteger.Parse(saveFile["gameStore"]["highScore"].ToString());
}
public void SetGameStoreTotalAttepts(BigInteger value)
{
if (saveFile["gameStore"] == null) saveFile["gameStore"] = new JObject();
saveFile["gameStore"]["totalAttempts"] = value.ToString();
}
public BigInteger GetGameStoreTotalAttepts()
{
if (saveFile["gameStore"] == null) return 0;
if (saveFile["gameStore"]["totalAttempts"] == null) return 0;
return BigInteger.Parse(saveFile["gameStore"]["totalAttempts"].ToString());
}
public void SetGameStoreTotalNormalBerries(BigInteger value)
{
if (saveFile["gameStore"] == null) saveFile["gameStore"] = new JObject();
saveFile["gameStore"]["totalNormalBerries"] = value.ToString();
}
public BigInteger GetGameStoreTotalNormalBerries()
{
if (saveFile["gameStore"] == null) return 0;
if (saveFile["gameStore"]["totalNormalBerries"] == null) return 0;
return BigInteger.Parse(saveFile["gameStore"]["totalNormalBerries"].ToString());
}
public void SetGameStoreTotalPoisonBerries(BigInteger value)
{
if (saveFile["gameStore"] == null) saveFile["gameStore"] = new JObject();
saveFile["gameStore"]["totalPoisonBerries"] = value.ToString();
}
public BigInteger GetGameStoreTotalPoisonBerries()
{
if (saveFile["gameStore"] == null) return 0;
if (saveFile["gameStore"]["totalPoisonBerries"] == null) return 0;
return BigInteger.Parse(saveFile["gameStore"]["totalPoisonBerries"].ToString());
}
public void SetGameStoreTotalSlowBerries(BigInteger value)
{
if (saveFile["gameStore"] == null) saveFile["gameStore"] = new JObject();
saveFile["gameStore"]["totalSlowBerries"] = value.ToString();
}
public BigInteger GetGameStoreTotalSlowBerries()
{
if (saveFile["gameStore"] == null) return 0;
if (saveFile["gameStore"]["totalSlowBerries"] == null) return 0;
return BigInteger.Parse(saveFile["gameStore"]["totalSlowBerries"].ToString());
}
public void SetGameStoreTotalUltraBerries(BigInteger value)
{
if (saveFile["gameStore"] == null) saveFile["gameStore"] = new JObject();
saveFile["gameStore"]["totalUltraBerries"] = value.ToString();
}
public BigInteger GetGameStoreTotalUltraBerries()
{
if (saveFile["gameStore"] == null) return 0;
if (saveFile["gameStore"]["totalUltraBerries"] == null) return 0;
return BigInteger.Parse(saveFile["gameStore"]["totalUltraBerries"].ToString());
}
public void SetGameStoreTotalSpeedyBerries(BigInteger value)
{
if (saveFile["gameStore"] == null) saveFile["gameStore"] = new JObject();
saveFile["gameStore"]["totalSpeedyBerries"] = value.ToString();
}
public BigInteger GetGameStoreTotalSpeedyBerries()
{
if (saveFile["gameStore"] == null) return 0;
if (saveFile["gameStore"]["totalSpeedyBerries"] == null) return 0;
return BigInteger.Parse(saveFile["gameStore"]["totalSpeedyBerries"].ToString());
}
public void SetGameStoreTotalRandomBerries(BigInteger value)
{
if (saveFile["gameStore"] == null) saveFile["gameStore"] = new JObject();
saveFile["gameStore"]["totalRandomBerries"] = value.ToString();
}
public BigInteger GetGameStoreTotalRandomBerries()
{
if (saveFile["gameStore"] == null) return 0;
if (saveFile["gameStore"]["totalRandomBerries"] == null) return 0;
return BigInteger.Parse(saveFile["gameStore"]["totalRandomBerries"].ToString());
}
public void SetGameStoreTotalAntiBerries(BigInteger value)
{
if (saveFile["gameStore"] == null) saveFile["gameStore"] = new JObject();
saveFile["gameStore"]["totalAntiBerries"] = value.ToString();
}
public BigInteger GetGameStoreTotalAntiBerries()
{
if (saveFile["gameStore"] == null) return 0;
if (saveFile["gameStore"]["totalAntiBerries"] == null) return 0;
return BigInteger.Parse(saveFile["gameStore"]["totalAntiBerries"].ToString());
}
}
+2
View File
@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: a0df255fc60e6e3c88ebb94d2d88db4d
+10
View File
@@ -0,0 +1,10 @@
using UnityEngine;
public class BulletCleanup : MonoBehaviour
{
void Update()
{
Vector3 screenPos = Camera.main.WorldToViewportPoint(transform.position);
if (screenPos.x < 0f || screenPos.x > 1f || screenPos.y < 0f || screenPos.y > 1f) Destroy(gameObject);
}
}
+2
View File
@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 9b69d7605a1a8494a8629a549836c168
+21
View File
@@ -0,0 +1,21 @@
using TMPro;
using UnityEngine;
public class ImageColorSync : MonoBehaviour
{
public TMP_Text originalText;
public TMP_Text toSync;
void Update()
{
Color baseColor = originalText.color;
Color graphicColor = originalText.canvasRenderer.GetColor();
toSync.color = new Color(
baseColor.r * graphicColor.r,
baseColor.g * graphicColor.g,
baseColor.b * graphicColor.b,
baseColor.a * graphicColor.a
);
}
}
@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: a3e765e68473d4e5cb86a7b42c5377f2
+67
View File
@@ -0,0 +1,67 @@
using UnityEngine;
[RequireComponent(typeof(AudioSource))]
public class GameMusicHandler : MonoBehaviour
{
public AudioClip[] audioClips;
private AudioSource audioSource;
private int lastIndex = -1;
private int currentIndex = 0;
private bool isPaused = false;
void Start()
{
audioSource = GetComponent<AudioSource>();
PlayNextClip();
}
void Update()
{
if (!audioSource.isPlaying && !isPaused) PlayNextClip();
}
void PlayNextClip()
{
if (audioClips.Length == 0) return;
int index;
if (BazookaManager.Instance.GetSettingRandomMusic())
{
do index = Random.Range(0, audioClips.Length);
while (audioClips.Length > 1 && index == lastIndex);
}
else
{
index = currentIndex;
currentIndex = (currentIndex + 1) % audioClips.Length;
}
lastIndex = index;
audioSource.clip = audioClips[index];
audioSource.Play();
}
public void PauseMusic()
{
if (audioSource.isPlaying)
{
audioSource.Pause();
isPaused = true;
}
}
public void ResumeMusic()
{
if (isPaused)
{
audioSource.Play();
isPaused = false;
}
}
public void RestartMusic()
{
audioSource.Stop();
audioSource.Play();
}
}
+2
View File
@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 81a98a63df08841c4b3fdc71ceecda4c
+763
View File
@@ -0,0 +1,763 @@
using System.Linq;
using System.Numerics;
using TMPro;
using UnityEngine;
using UnityEngine.InputSystem;
using UnityEngine.UI;
public class GamePlayer : MonoBehaviour
{
public static GamePlayer instance;
private readonly float spawnRate = 1f;
private float nextSpawnTime;
internal BigInteger score;
private BigInteger attempts;
private BigInteger highscore;
private BigInteger totalNormalBerries;
private BigInteger totalPoisonBerries;
private BigInteger totalSlowBerries;
private BigInteger totalUltraBerries;
private BigInteger totalSpeedyBerries;
private BigInteger totalRandomBerries;
private BigInteger totalAntiBerries;
private BigInteger totalAttempts;
private float boostLeft;
private float slownessLeft;
private float speedyLeft;
private float antiLeft;
private float screenWidth;
internal bool isGrounded;
public TMP_Text scoreText;
public TMP_Text highScoreText;
public TMP_Text boostText;
public GameObject bird;
public GameObject pausePanel;
public GameObject statsPanel;
public Rigidbody2D rb;
public AudioSource backgroundMusic;
public GameObject berryParent;
public GameObject mobileButtons;
public Button pauseButton;
public Button restartButton;
public Button jumpButton;
public Button rightButton;
public Button leftButton;
void Start()
{
UnityEngine.InputSystem.EnhancedTouch.EnhancedTouchSupport.Enable();
instance = this;
highscore = BazookaManager.Instance.GetGameStoreHighScore();
totalNormalBerries = BazookaManager.Instance.GetGameStoreTotalNormalBerries();
totalPoisonBerries = BazookaManager.Instance.GetGameStoreTotalPoisonBerries();
totalSlowBerries = BazookaManager.Instance.GetGameStoreTotalSlowBerries();
totalUltraBerries = BazookaManager.Instance.GetGameStoreTotalUltraBerries();
totalSpeedyBerries = BazookaManager.Instance.GetGameStoreTotalSpeedyBerries();
totalRandomBerries = BazookaManager.Instance.GetGameStoreTotalRandomBerries();
totalAntiBerries = BazookaManager.Instance.GetGameStoreTotalAntiBerries();
totalAttempts = BazookaManager.Instance.GetGameStoreTotalAttepts();
backgroundMusic.volume = BazookaManager.Instance.GetSettingMusicVolume();
screenWidth = Camera.main.orthographicSize * 2f * Camera.main.aspect;
if (Application.isMobilePlatform) mobileButtons.SetActive(true);
UpdateStats(0, 1);
}
void MoveBird()
{
float screenWidth = Camera.main.orthographicSize * 2f * Camera.main.aspect;
float baseSpeed = 0.18f * (screenWidth / 20.19257f);
bool doMoveRight = false;
bool doMoveLeft = false;
bool doJump = false;
bool doRestart = false;
bool doBack = false;
float movespeed = baseSpeed;
if (boostLeft > 0f || speedyLeft > 0f)
{
movespeed = baseSpeed * 1.39f;
}
else if (slownessLeft > 0f)
{
movespeed = baseSpeed * 0.56f;
}
CheckIfGrounded();
bool controllerLeft = Gamepad.current != null && (Gamepad.current.leftStick.left.isPressed || Gamepad.current.dpad.left.isPressed || Gamepad.current.rightStick.left.isPressed);
bool controllerRight = Gamepad.current != null && (Gamepad.current.leftStick.right.isPressed || Gamepad.current.dpad.right.isPressed || Gamepad.current.rightStick.right.isPressed);
bool controllerJump = Gamepad.current != null && (Gamepad.current.leftStick.up.isPressed || Gamepad.current.leftStick.down.isPressed || Gamepad.current.dpad.up.isPressed || Gamepad.current.dpad.down.isPressed || Gamepad.current.rightStick.up.isPressed || Gamepad.current.rightStick.down.isPressed);
if (!Application.isMobilePlatform)
{
if (controllerLeft || Keyboard.current.leftArrowKey.isPressed || Keyboard.current.aKey.isPressed || Keyboard.current.jKey.isPressed)
{
doMoveLeft = true;
}
if (controllerRight || Keyboard.current.rightArrowKey.isPressed || Keyboard.current.dKey.isPressed || Keyboard.current.lKey.isPressed)
{
doMoveRight = true;
}
if (controllerJump || Keyboard.current.spaceKey.isPressed || Keyboard.current.upArrowKey.isPressed || Keyboard.current.wKey.isPressed || Keyboard.current.downArrowKey.isPressed || Keyboard.current.sKey.isPressed || Keyboard.current.kKey.isPressed || Keyboard.current.iKey.isPressed || Mouse.current.leftButton.isPressed || (Gamepad.current != null && Gamepad.current.buttonSouth.isPressed))
{
doJump = true;
}
if (Keyboard.current.rKey.isPressed)
{
doRestart = true;
}
}
else
{
var touches = UnityEngine.InputSystem.EnhancedTouch.Touch.activeTouches;
for (int i = 0; i < touches.Count; i++)
{
var pos = touches[i].screenPosition;
UnityEngine.Vector3 clickPosition = Camera.main.ScreenToWorldPoint(new UnityEngine.Vector3(pos.x, pos.y, 0f));
clickPosition.z = 0f;
if (leftButton.GetComponent<HoldableButton>().isPressed) doMoveLeft = true;
if (rightButton.GetComponent<HoldableButton>().isPressed) doMoveRight = true;
if (jumpButton.GetComponent<HoldableButton>().isPressed) doJump = true;
if (restartButton.GetComponent<HoldableButton>().isPressed) doRestart = true;
if (pauseButton.GetComponent<HoldableButton>().isPressed) doBack = true;
}
}
if (doMoveLeft && !doMoveRight)
{
bird.transform.position += new UnityEngine.Vector3(-movespeed, 0f, 0f);
ClampPosition(bird);
bird.transform.localScale = new UnityEngine.Vector3(1.35f, 1.35f, 1.35f);
}
if (doMoveRight && !doMoveLeft)
{
bird.transform.position += new UnityEngine.Vector3(movespeed, 0f, 0f);
ClampPosition(bird);
bird.transform.localScale = new UnityEngine.Vector3(-1.35f, 1.35f, 1.35f);
}
if (doJump && isGrounded)
{
AudioSource.PlayClipAtPoint(Resources.Load<AudioClip>("Sounds/Jump"), Camera.main.transform.position, 0.75f * BazookaManager.Instance.GetSettingSFXVolume());
if (boostLeft > 0f || speedyLeft > 0f)
{
rb.linearVelocity = UnityEngine.Vector2.up * 12f;
}
else if (slownessLeft > 0f)
{
rb.linearVelocity = UnityEngine.Vector2.up * 6f;
}
else
{
rb.linearVelocity = UnityEngine.Vector2.up * 9f;
}
}
if (doBack)
{
TogglePause();
}
if (doRestart)
{
if (score != 0) Respawn();
}
if (antiLeft > 0f)
{
string[] berryTags = { "NormalBerry", "PoisonBerry", "SlowBerry", "UltraBerry", "SpeedyBerry", "RandomBerry", "AntiBerry" };
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)
{
berry.GetComponent<Rigidbody2D>().linearVelocity = dir.normalized * 5f;
ClampPosition(berry, false);
}
}
}
}
}
void ClampPosition(GameObject obj, bool modifyY = true)
{
var cam = Camera.main;
var pos = obj.transform.position;
var bounds = obj.GetComponent<Renderer>().bounds.extents;
float zDist = Mathf.Abs(cam.transform.position.z - pos.z);
UnityEngine.Vector3 min = cam.ViewportToWorldPoint(new UnityEngine.Vector3(0, 0, zDist));
UnityEngine.Vector3 max = cam.ViewportToWorldPoint(new UnityEngine.Vector3(1, 1, zDist));
pos.x = Mathf.Clamp(pos.x, min.x + bounds.x, max.x - bounds.x);
if (modifyY) pos.y = Mathf.Clamp(pos.y, min.y + bounds.y, max.y - bounds.y);
obj.transform.position = pos;
}
void FixedUpdate()
{
SpawnBerries();
if (!pausePanel.activeSelf)
{
MoveBird();
if (boostLeft > 0f)
{
boostLeft -= Time.deltaTime;
boostText.text = "Boost expires in " + string.Format("{0:0.0}", boostLeft) + "s";
}
else if (slownessLeft > 0f)
{
slownessLeft -= Time.deltaTime;
boostText.text = "Slowness expires in " + string.Format("{0:0.0}", slownessLeft) + "s";
}
else if (speedyLeft > 0f)
{
speedyLeft -= Time.deltaTime;
boostText.text = "Speed expires in " + string.Format("{0:0.0}", speedyLeft) + "s";
}
else if (antiLeft > 0f)
{
antiLeft -= Time.deltaTime;
boostText.text = "Berry repellent expires in " + string.Format("{0:0.0}", antiLeft) + "s";
}
else
{
boostText.text = "";
}
}
}
void SpawnBerries()
{
if (Time.time < nextSpawnTime)
{
return;
}
if (speedyLeft > 0)
{
nextSpawnTime = Time.time + 1f / (spawnRate * 1.875f);
}
else
{
nextSpawnTime = Time.time + 1f / spawnRate;
}
float spawnProbability = Random.value;
if (!pausePanel.activeSelf)
{
GameObject newBerry = new("Berry");
newBerry.transform.SetParent(berryParent.transform);
SpriteRenderer spriteRenderer = newBerry.AddComponent<SpriteRenderer>();
if (spawnProbability <= 0.475f)
{
spriteRenderer.sprite = Resources.Load<Sprite>("Berries/Berry");
newBerry.tag = "NormalBerry";
}
else if (spawnProbability <= 0.60f)
{
spriteRenderer.sprite = Resources.Load<Sprite>("Berries/PoisonBerry");
newBerry.tag = "PoisonBerry";
}
else if (spawnProbability <= 0.70f)
{
spriteRenderer.sprite = Resources.Load<Sprite>("Berries/SlowBerry");
newBerry.tag = "SlowBerry";
}
else if (spawnProbability <= 0.80f)
{
spriteRenderer.sprite = Resources.Load<Sprite>("Berries/UltraBerry");
newBerry.tag = "UltraBerry";
}
else if (spawnProbability <= 0.90f)
{
spriteRenderer.sprite = Resources.Load<Sprite>("Berries/SpeedyBerry");
newBerry.tag = "SpeedyBerry";
}
else if (spawnProbability <= 0.95f)
{
spriteRenderer.sprite = Resources.Load<Sprite>("Berries/BerryNoColor");
newBerry.tag = "RandomBerry";
RainbowSpriteRender randomBerryRainbowImage = newBerry.AddComponent<RainbowSpriteRender>();
randomBerryRainbowImage.frequency = 5f;
}
else
{
spriteRenderer.sprite = Resources.Load<Sprite>("Berries/AntiBerry");
newBerry.tag = "AntiBerry";
}
spriteRenderer.sortingOrder = -5;
float screenWidth = Camera.main.orthographicSize * 2 * Camera.main.aspect;
float spawnPositionX = Random.Range(-screenWidth / 2.17f, screenWidth / 2.17f);
newBerry.transform.position = new UnityEngine.Vector3(spawnPositionX, Camera.main.orthographicSize + 1f, 0f);
Rigidbody2D rb = newBerry.AddComponent<Rigidbody2D>();
rb.gravityScale = 0f;
rb.linearVelocity = new UnityEngine.Vector2(0f, -4f);
}
}
void Update()
{
foreach (AudioSource audio in FindObjectsByType<AudioSource>(FindObjectsSortMode.None))
{
audio.pitch = speedyLeft > 0f ? 1.3f : 1f;
}
if (screenWidth != Camera.main.orthographicSize * 2f * Camera.main.aspect)
{
screenWidth = Camera.main.orthographicSize * 2f * Camera.main.aspect;
ClampPosition(bird);
GameObject[] allberries = GameObject.FindGameObjectsWithTag("NormalBerry")
.Concat(GameObject.FindGameObjectsWithTag("PoisonBerry"))
.Concat(GameObject.FindGameObjectsWithTag("SlowBerry"))
.Concat(GameObject.FindGameObjectsWithTag("UltraBerry"))
.Concat(GameObject.FindGameObjectsWithTag("SpeedyBerry"))
.Concat(GameObject.FindGameObjectsWithTag("RandomBerry"))
.Concat(GameObject.FindGameObjectsWithTag("AntiBerry"))
.ToArray();
foreach (GameObject berry in allberries)
{
ClampPosition(berry, false);
}
}
GameObject[] normalBerries = GameObject.FindGameObjectsWithTag("NormalBerry");
GameObject[] poisonBerries = GameObject.FindGameObjectsWithTag("PoisonBerry");
GameObject[] slowBerries = GameObject.FindGameObjectsWithTag("SlowBerry");
GameObject[] ultraBerries = GameObject.FindGameObjectsWithTag("UltraBerry");
GameObject[] speedyBerries = GameObject.FindGameObjectsWithTag("SpeedyBerry");
GameObject[] randomBerries = GameObject.FindGameObjectsWithTag("RandomBerry");
GameObject[] antiBerries = GameObject.FindGameObjectsWithTag("AntiBerry");
GameObject[] bullets = GameObject.FindGameObjectsWithTag("Bullet");
if (!pausePanel.activeSelf)
{
CheckIfGrounded();
foreach (GameObject normalBerry in normalBerries)
{
if (normalBerry.transform.position.y < 0f - Camera.main.orthographicSize - 1f)
{
Destroy(normalBerry);
}
else if (UnityEngine.Vector3.Distance(bird.transform.position, normalBerry.transform.position) < 1.5f)
{
totalNormalBerries++;
DoNormalBerry(normalBerry);
}
else
{
foreach (GameObject bullet in bullets)
{
if (UnityEngine.Vector3.Distance(bullet.transform.position, normalBerry.transform.position) < 0.5f)
{
totalNormalBerries++;
DoNormalBerry(normalBerry);
Destroy(bullet);
break;
}
}
}
if (speedyLeft > 0)
{
normalBerry.GetComponent<Rigidbody2D>().linearVelocity = new UnityEngine.Vector2(0f, -7.5f);
}
else
{
normalBerry.GetComponent<Rigidbody2D>().linearVelocity = new UnityEngine.Vector2(0f, -4f);
}
}
foreach (GameObject poisonBerry in poisonBerries)
{
if (poisonBerry.transform.position.y < 0f - Camera.main.orthographicSize - 1f)
{
Destroy(poisonBerry);
}
else if (UnityEngine.Vector3.Distance(bird.transform.position, poisonBerry.transform.position) < 1.5f)
{
totalPoisonBerries++;
DoPoisonBerry();
}
else
{
foreach (GameObject bullet in bullets)
{
if (UnityEngine.Vector3.Distance(bullet.transform.position, poisonBerry.transform.position) < 0.5f)
{
totalPoisonBerries++;
Destroy(poisonBerry);
Destroy(bullet);
break;
}
}
}
if (speedyLeft > 0)
{
poisonBerry.GetComponent<Rigidbody2D>().linearVelocity = new UnityEngine.Vector2(0f, -7.5f);
}
else
{
poisonBerry.GetComponent<Rigidbody2D>().linearVelocity = new UnityEngine.Vector2(0f, -4f);
}
}
foreach (GameObject slowBerry in slowBerries)
{
if (slowBerry.transform.position.y < 0f - Camera.main.orthographicSize - 1f)
{
Destroy(slowBerry);
}
else if (UnityEngine.Vector3.Distance(bird.transform.position, slowBerry.transform.position) < 1.5f)
{
totalSlowBerries++;
DoSlowBerry(slowBerry);
}
else
{
foreach (GameObject bullet in bullets)
{
if (UnityEngine.Vector3.Distance(bullet.transform.position, slowBerry.transform.position) < 0.5f)
{
totalSlowBerries++;
Destroy(slowBerry);
Destroy(bullet);
break;
}
}
}
if (speedyLeft > 0)
{
slowBerry.GetComponent<Rigidbody2D>().linearVelocity = new UnityEngine.Vector2(0f, -7.5f);
}
else
{
slowBerry.GetComponent<Rigidbody2D>().linearVelocity = new UnityEngine.Vector2(0f, -4f);
}
}
foreach (GameObject ultraBerry in ultraBerries)
{
if (ultraBerry.transform.position.y < 0f - Camera.main.orthographicSize - 1f)
{
Destroy(ultraBerry);
}
else if (UnityEngine.Vector3.Distance(bird.transform.position, ultraBerry.transform.position) < 1.5f)
{
totalUltraBerries++;
DoUltraBerry(ultraBerry);
}
else
{
foreach (GameObject bullet in bullets)
{
if (UnityEngine.Vector3.Distance(bullet.transform.position, ultraBerry.transform.position) < 0.5f)
{
totalUltraBerries++;
DoUltraBerry(ultraBerry);
Destroy(bullet);
break;
}
}
}
if (speedyLeft > 0)
{
ultraBerry.GetComponent<Rigidbody2D>().linearVelocity = new UnityEngine.Vector2(0f, -7.5f);
}
else
{
ultraBerry.GetComponent<Rigidbody2D>().linearVelocity = new UnityEngine.Vector2(0f, -4f);
}
}
foreach (GameObject speedyBerry in speedyBerries)
{
if (speedyBerry.transform.position.y < 0f - Camera.main.orthographicSize - 1f)
{
Destroy(speedyBerry);
}
else if (UnityEngine.Vector3.Distance(bird.transform.position, speedyBerry.transform.position) < 1.5f)
{
totalSpeedyBerries++;
DoSpeedyBerry(speedyBerry);
}
else
{
foreach (GameObject bullet in bullets)
{
if (UnityEngine.Vector3.Distance(bullet.transform.position, speedyBerry.transform.position) < 0.5f)
{
totalSpeedyBerries++;
DoSpeedyBerry(speedyBerry);
Destroy(bullet);
break;
}
}
}
if (speedyLeft > 0)
{
speedyBerry.GetComponent<Rigidbody2D>().linearVelocity = new UnityEngine.Vector2(0f, -7.5f);
}
else
{
speedyBerry.GetComponent<Rigidbody2D>().linearVelocity = new UnityEngine.Vector2(0f, -4f);
}
}
foreach (GameObject randomBerry in randomBerries)
{
if (randomBerry.transform.position.y < 0f - Camera.main.orthographicSize - 1f)
{
Destroy(randomBerry);
}
else if (UnityEngine.Vector3.Distance(bird.transform.position, randomBerry.transform.position) < 1.5f)
{
totalRandomBerries++;
System.Action[] funcs = {
() => DoNormalBerry(randomBerry),
() => DoSlowBerry(randomBerry),
() => DoUltraBerry(randomBerry),
() => DoSpeedyBerry(randomBerry),
() => DoAntiBerry(randomBerry)
};
funcs[Random.Range(0, funcs.Length)]();
}
else
{
foreach (GameObject bullet in bullets)
{
if (UnityEngine.Vector3.Distance(bullet.transform.position, randomBerry.transform.position) < 0.5f)
{
totalRandomBerries++;
System.Action[] funcs = {
() => DoNormalBerry(randomBerry),
() => DoSlowBerry(randomBerry),
() => DoUltraBerry(randomBerry),
() => DoSpeedyBerry(randomBerry),
() => DoAntiBerry(randomBerry)
};
funcs[Random.Range(0, funcs.Length)]();
Destroy(bullet);
break;
}
}
}
if (speedyLeft > 0)
{
randomBerry.GetComponent<Rigidbody2D>().linearVelocity = new UnityEngine.Vector2(0f, -7.5f);
}
else
{
randomBerry.GetComponent<Rigidbody2D>().linearVelocity = new UnityEngine.Vector2(0f, -4f);
}
}
foreach (GameObject antiBerry in antiBerries)
{
if (antiBerry.transform.position.y < 0f - Camera.main.orthographicSize - 1f)
{
Destroy(antiBerry);
}
else if (UnityEngine.Vector3.Distance(bird.transform.position, antiBerry.transform.position) < 1.5f)
{
totalAntiBerries++;
DoAntiBerry(antiBerry);
}
else
{
foreach (GameObject bullet in bullets)
{
if (UnityEngine.Vector3.Distance(bullet.transform.position, antiBerry.transform.position) < 0.5f)
{
totalAntiBerries++;
DoAntiBerry(antiBerry);
Destroy(bullet);
break;
}
}
}
if (speedyLeft > 0)
{
antiBerry.GetComponent<Rigidbody2D>().linearVelocity = new UnityEngine.Vector2(0f, -7.5f);
}
else
{
antiBerry.GetComponent<Rigidbody2D>().linearVelocity = new UnityEngine.Vector2(0f, -4f);
}
}
}
else
{
rb.gravityScale = 0f;
rb.linearVelocity = UnityEngine.Vector2.zero;
GameObject[] allberries = normalBerries
.Concat(poisonBerries)
.Concat(slowBerries)
.Concat(ultraBerries)
.Concat(speedyBerries)
.Concat(randomBerries)
.Concat(antiBerries)
.ToArray();
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();
}
void Respawn()
{
bird.transform.position = new UnityEngine.Vector3(0f, -4.3f, 0f);
bird.transform.localScale = new UnityEngine.Vector3(1.35f, 1.35f, 1.35f);
rb.gravityScale = 0f;
rb.linearVelocity = UnityEngine.Vector2.zero;
score = 0;
boostLeft = 0f;
slownessLeft = 0f;
speedyLeft = 0f;
antiLeft = 0f;
UpdateStats(0, 1);
GameObject[] allberries = GameObject.FindGameObjectsWithTag("NormalBerry")
.Concat(GameObject.FindGameObjectsWithTag("PoisonBerry"))
.Concat(GameObject.FindGameObjectsWithTag("SlowBerry"))
.Concat(GameObject.FindGameObjectsWithTag("UltraBerry"))
.Concat(GameObject.FindGameObjectsWithTag("SpeedyBerry"))
.Concat(GameObject.FindGameObjectsWithTag("RandomBerry"))
.Concat(GameObject.FindGameObjectsWithTag("AntiBerry"))
.ToArray();
foreach (GameObject berry in allberries)
{
Destroy(berry);
}
}
void UpdateStats(BigInteger scoreAddAmount, BigInteger attemptAddAmount)
{
var prefix = "";
var suffix = "";
score += scoreAddAmount;
totalAttempts += attemptAddAmount;
attempts += attemptAddAmount;
if (score >= highscore)
{
highscore = score;
prefix = "<color=#7FFFD4>";
suffix = "</color>";
}
BazookaManager.Instance.SetGameStoreHighScore(highscore);
BazookaManager.Instance.SetGameStoreTotalNormalBerries(totalNormalBerries);
BazookaManager.Instance.SetGameStoreTotalPoisonBerries(totalPoisonBerries);
BazookaManager.Instance.SetGameStoreTotalSlowBerries(totalSlowBerries);
BazookaManager.Instance.SetGameStoreTotalUltraBerries(totalUltraBerries);
BazookaManager.Instance.SetGameStoreTotalSpeedyBerries(totalSpeedyBerries);
BazookaManager.Instance.SetGameStoreTotalRandomBerries(totalRandomBerries);
BazookaManager.Instance.SetGameStoreTotalAntiBerries(totalAntiBerries);
BazookaManager.Instance.SetGameStoreTotalAttepts(totalAttempts);
scoreText.text = $"Score: {Tools.FormatWithCommas(score)} \\u2022 Attempts: {Tools.FormatWithCommas(attempts)}";
highScoreText.text = prefix + $"High Score: {Tools.FormatWithCommas(highscore) + suffix} \\u2022 Total Attempts: {Tools.FormatWithCommas(totalAttempts)}";
if (Application.isMobilePlatform) restartButton.interactable = score != 0;
}
void CheckIfGrounded()
{
isGrounded = bird.transform.position.y <= -4.1299996f;
rb.gravityScale = isGrounded ? 0f : 1.5f;
if (bird.transform.position.y < -4.1359f)
{
bird.transform.position = new UnityEngine.Vector2(bird.transform.position.x, -4.1359f);
rb.linearVelocity = new UnityEngine.Vector2(rb.linearVelocity.x, 0f);
}
if (Application.isMobilePlatform) jumpButton.transform.GetChild(0).GetComponent<TMP_Text>().color = isGrounded ? Color.white : Color.red;
}
internal void TogglePause()
{
if (statsPanel.activeSelf) return;
if (pausePanel.activeSelf)
{
DisablePause();
}
else
{
EnablePause();
}
}
internal void EnablePause()
{
backgroundMusic.GetComponent<GameMusicHandler>().PauseMusic();
pausePanel.SetActive(true);
}
internal void DisablePause()
{
backgroundMusic.GetComponent<GameMusicHandler>().ResumeMusic();
pausePanel.SetActive(false);
}
void OnApplicationPause(bool pause)
{
if (pause) EnablePause();
}
void DoNormalBerry(GameObject berry)
{
AudioSource.PlayClipAtPoint(Resources.Load<AudioClip>("Sounds/Eat"), Camera.main.transform.position, 1.2f * BazookaManager.Instance.GetSettingSFXVolume());
Destroy(berry);
UpdateStats(1, 0);
}
void DoPoisonBerry()
{
AudioSource.PlayClipAtPoint(Resources.Load<AudioClip>("Sounds/Death"), Camera.main.transform.position, 1.2f * BazookaManager.Instance.GetSettingSFXVolume());
Respawn();
UpdateStats(0, 0);
}
void DoSlowBerry(GameObject berry)
{
AudioSource.PlayClipAtPoint(Resources.Load<AudioClip>("Sounds/Downgrade"), Camera.main.transform.position, 0.35f * BazookaManager.Instance.GetSettingSFXVolume());
Destroy(berry);
boostLeft = 0f;
slownessLeft = 10f;
speedyLeft = 0f;
antiLeft = 0f;
if (score > 0)
{
UpdateStats(-1, 0);
}
}
void DoUltraBerry(GameObject berry)
{
AudioSource.PlayClipAtPoint(Resources.Load<AudioClip>("Sounds/Powerup"), Camera.main.transform.position, 0.35f * BazookaManager.Instance.GetSettingSFXVolume());
Destroy(berry);
speedyLeft = 0f;
antiLeft = 0f;
if (slownessLeft > 0f)
{
slownessLeft = 0f;
UpdateStats(1, 0);
}
else
{
boostLeft += 10f;
UpdateStats(5, 0);
}
}
void DoSpeedyBerry(GameObject berry)
{
AudioSource.PlayClipAtPoint(Resources.Load<AudioClip>("Sounds/SpeedyPowerup"), Camera.main.transform.position, 0.35f * BazookaManager.Instance.GetSettingSFXVolume());
Destroy(berry);
boostLeft = 0f;
slownessLeft = 0f;
speedyLeft = 10f;
antiLeft = 0f;
UpdateStats(10, 0);
}
void DoAntiBerry(GameObject berry)
{
AudioSource.PlayClipAtPoint(Resources.Load<AudioClip>("Sounds/Downgrade"), Camera.main.transform.position, 0.35f * BazookaManager.Instance.GetSettingSFXVolume());
Destroy(berry);
boostLeft = 0f;
slownessLeft = 0f;
speedyLeft = 0f;
antiLeft = 10f;
UpdateStats(0, 0);
}
}
+2
View File
@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: e438446dc0ab8b6419c6cb63e0e72487
+94
View File
@@ -0,0 +1,94 @@
using System.Text;
using TMPro;
using UnityEngine;
using UnityEngine.UI;
public class GamePlayerPauseMenu : MonoBehaviour
{
public static GamePlayerPauseMenu Instance;
public Button continueButton;
public Button statsButton;
public Button exitButton;
public TMP_Text versionText;
public GameObject statsMenu;
public Button statsMenuExitButton;
public TMP_Text statsText;
public Toggle settingFullscreenToggle;
public Toggle settingVSyncToggle;
public Toggle settingRandomMusicToggle;
public Slider musicSlider;
public Slider sfxSlider;
void Awake()
{
if (Application.isMobilePlatform || Application.isEditor)
{
exitButton.gameObject.SetActive(false);
continueButton.gameObject.transform.localPosition = new(-175, 0, 0);
statsButton.gameObject.transform.localPosition = new(175, 0, 0);
}
else
{
exitButton.onClick.AddListener(() => Application.Quit());
}
Instance = this;
continueButton.onClick.AddListener(GamePlayer.instance.DisablePause);
statsButton.onClick.AddListener(() =>
{
statsMenu.SetActive(true);
var text = new StringBuilder();
text.AppendLine("High Score: " + Tools.FormatWithCommas(BazookaManager.Instance.GetGameStoreHighScore()));
text.AppendLine("Total Normal Berries: " + Tools.FormatWithCommas(BazookaManager.Instance.GetGameStoreTotalNormalBerries()));
text.AppendLine("Total Poison Berries: " + Tools.FormatWithCommas(BazookaManager.Instance.GetGameStoreTotalPoisonBerries()));
text.AppendLine("Total Slow Berries: " + Tools.FormatWithCommas(BazookaManager.Instance.GetGameStoreTotalSlowBerries()));
text.AppendLine("Total Ultra Berries: " + Tools.FormatWithCommas(BazookaManager.Instance.GetGameStoreTotalUltraBerries()));
text.AppendLine("Total Speedy Berries: " + Tools.FormatWithCommas(BazookaManager.Instance.GetGameStoreTotalSpeedyBerries()));
text.AppendLine("Total Random Berries: " + Tools.FormatWithCommas(BazookaManager.Instance.GetGameStoreTotalRandomBerries()));
text.AppendLine("Total Anti Berries: " + Tools.FormatWithCommas(BazookaManager.Instance.GetGameStoreTotalAntiBerries()));
text.AppendLine("Total Attempts: " + Tools.FormatWithCommas(BazookaManager.Instance.GetGameStoreTotalAttepts()));
statsText.text = text.ToString();
});
statsMenuExitButton.onClick.AddListener(() =>
{
statsMenu.SetActive(false);
statsText.text = string.Empty;
});
versionText.text = Application.version;
musicSlider.value = BazookaManager.Instance.GetSettingMusicVolume();
sfxSlider.value = BazookaManager.Instance.GetSettingSFXVolume();
if (!Application.isMobilePlatform)
{
settingFullscreenToggle.isOn = BazookaManager.Instance.GetSettingFullScreen() == true;
settingVSyncToggle.isOn = BazookaManager.Instance.GetSettingVsync() == true;
settingRandomMusicToggle.isOn = BazookaManager.Instance.GetSettingRandomMusic() == true;
settingFullscreenToggle.onValueChanged.AddListener(value =>
{
BazookaManager.Instance.SetSettingFullScreen(value);
var width = Display.main.systemWidth;
var height = Display.main.systemHeight;
Screen.SetResolution(width, height, value);
});
settingVSyncToggle.onValueChanged.AddListener(value =>
{
BazookaManager.Instance.SetSettingVsync(value);
QualitySettings.vSyncCount = value ? 1 : -1;
});
}
else
{
settingFullscreenToggle.interactable = false;
settingVSyncToggle.interactable = false;
settingRandomMusicToggle.isOn = BazookaManager.Instance.GetSettingRandomMusic() == true;
}
settingRandomMusicToggle.onValueChanged.AddListener(value => BazookaManager.Instance.SetSettingRandomMusic(value));
musicSlider.onValueChanged.AddListener(value =>
{
BazookaManager.Instance.SetSettingMusicVolume(value);
GamePlayer.instance.backgroundMusic.volume = value;
});
sfxSlider.onValueChanged.AddListener(value => BazookaManager.Instance.SetSettingSFXVolume(value));
}
}
@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 526bd5fe5c100694d963377bfb11c47c
+69
View File
@@ -0,0 +1,69 @@
using UnityEngine;
using UnityEngine.InputSystem;
public class GunHandler : MonoBehaviour
{
public SpriteRenderer bulletTemplate;
private bool hasAutoRotated = false;
void Update()
{
if (GamePlayer.instance.pausePanel.activeSelf) return;
Vector2 mouseScreenPos = Mouse.current.position.ReadValue();
Vector3 mouseWorldPos = Camera.main.ScreenToWorldPoint(
new Vector3(mouseScreenPos.x, mouseScreenPos.y, -Camera.main.transform.position.z)
);
Vector2 direction = mouseWorldPos - transform.position;
bool flipped = transform.parent.localScale.x > 0f;
if (flipped)
{
direction.x = -direction.x;
direction.y = -direction.y;
}
float angle = Mathf.Atan2(direction.y, direction.x) * Mathf.Rad2Deg;
float minAngle = flipped ? -70f : -75f;
float maxAngle = flipped ? 75f : 70f;
float clamped = Mathf.Clamp(angle, minAngle, maxAngle);
if (angle < minAngle || angle > maxAngle)
{
if (!hasAutoRotated)
{
hasAutoRotated = true;
Vector3 scale = transform.parent.localScale;
scale.x *= -1;
transform.parent.localScale = scale;
flipped = !flipped;
direction.x = -direction.x;
direction.y = -direction.y;
clamped = Mathf.Clamp(Mathf.Atan2(direction.y, direction.x) * Mathf.Rad2Deg, flipped ? -70f : -75f, flipped ? 75f : 70f);
}
}
else if (hasAutoRotated)
{
hasAutoRotated = false;
}
transform.rotation = Quaternion.Euler(0f, 0f, clamped);
if (Keyboard.current.leftShiftKey.wasPressedThisFrame || Keyboard.current.rightShiftKey.wasPressedThisFrame)
{
Vector3 offset = new(0.6932073f, 0.352302f, 0f);
if (flipped) offset.x = -offset.x;
Vector3 spawnPos = transform.position + transform.rotation * offset;
var bullet = Instantiate(bulletTemplate, spawnPos, Quaternion.identity);
bullet.transform.rotation = Quaternion.Euler(0f, 0f, transform.rotation.eulerAngles.z + (flipped ? 0 : 180f));
bullet.gameObject.name = "Bullet";
bullet.gameObject.SetActive(true);
float angleRad = bullet.transform.eulerAngles.z * Mathf.Deg2Rad;
Vector2 dir = new(-Mathf.Cos(angleRad), -Mathf.Sin(angleRad));
bullet.GetComponent<Rigidbody2D>().linearVelocity = dir * 10f;
}
}
}
+2
View File
@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 99925664e1b4e403ea674c8646fcf842
+17
View File
@@ -0,0 +1,17 @@
using UnityEngine;
using UnityEngine.EventSystems;
public class HoldableButton : MonoBehaviour, IPointerDownHandler, IPointerUpHandler
{
public bool isPressed;
public void OnPointerDown(PointerEventData eventData)
{
isPressed = true;
}
public void OnPointerUp(PointerEventData eventData)
{
isPressed = false;
}
}
+2
View File
@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 0a636dfa538b0bae0bd00c2d37217ae9
+87
View File
@@ -0,0 +1,87 @@
using System;
using TMPro;
using UnityEngine;
using UnityEngine.Networking;
using UnityEngine.SceneManagement;
using UnityEngine.UI;
public class LoadingMenu : MonoBehaviour
{
public TMP_Text text;
public Button updateButton;
public Button continueButton;
void Start()
{
if (!Application.isMobilePlatform)
{
var width = Display.main.systemWidth;
var height = Display.main.systemHeight;
Screen.SetResolution(width, height, BazookaManager.Instance.GetSettingFullScreen());
QualitySettings.vSyncCount = BazookaManager.Instance.GetSettingVsync() ? 1 : -1;
}
else
{
Application.targetFrameRate = 360;
QualitySettings.vSyncCount = 0;
}
PlayerPrefs.SetString("latestVersion", Application.version);
updateButton.onClick.AddListener(() =>
{
Application.OpenURL("https://berrydashwithguns.lncvrt.xyz/download");
});
CheckUpdate();
}
async void CheckUpdate()
{
using UnityWebRequest request = UnityWebRequest.Get("https://berrydashwithguns.lncvrt.xyz/database/canLoadClient.php");
request.SetRequestHeader("Requester", "BerryDashClient");
request.SetRequestHeader("ClientVersion", Application.version);
request.SetRequestHeader("ClientPlatform", Application.platform.ToString());
await request.SendWebRequest();
if (request.result != UnityWebRequest.Result.Success)
{
text.text = "Failed to check version";
return;
}
string response = request.downloadHandler.text;
if (response == "1")
{
await SceneManager.LoadSceneAsync("GamePlayer");
}
else if (response == "2")
{
text.text = "Outdated client! You can still play the game and access the servers, but it isn't recommended.";
var updateButtonPos = updateButton.transform.localPosition;
updateButtonPos.x = -135;
updateButton.transform.localPosition = updateButtonPos;
updateButton.gameObject.SetActive(true);
continueButton.gameObject.SetActive(true);
}
else if (response == "3")
{
text.text = "Outdated client! You can still load into the game, but online features may not be available.";
var updateButtonPos = updateButton.transform.localPosition;
updateButtonPos.x = -135;
updateButton.transform.localPosition = updateButtonPos;
updateButton.gameObject.SetActive(true);
continueButton.gameObject.SetActive(true);
}
else if (response == "4")
{
text.text = "You are on a beta version of the game. You can still play the game and access the servers, but it is recommended to use the latest stable version.";
continueButton.transform.position = updateButton.transform.position;
continueButton.gameObject.SetActive(true);
}
else
{
text.text = "Outdated client! Please update your client to play";
updateButton.gameObject.SetActive(true);
}
}
}
+2
View File
@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 366bbfa9592e8084db2e1eadd8986c19
+21
View File
@@ -0,0 +1,21 @@
using UnityEngine;
public class RainbowSpriteRender : MonoBehaviour
{
public float frequency = 1f;
private SpriteRenderer targetImage;
void Awake()
{
targetImage = gameObject.GetComponent<SpriteRenderer>();
}
void Update()
{
float t = Time.time * frequency;
float r = Mathf.Sin(t) * 0.5f + 0.5f;
float g = Mathf.Sin(t + 2f) * 0.5f + 0.5f;
float b = Mathf.Sin(t + 4f) * 0.5f + 0.5f;
targetImage.color = new Color(r, g, b);
}
}
@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: a21a35a47faba4555ab8f7fa25ebe2a0
+9
View File
@@ -0,0 +1,9 @@
using System.Numerics;
public static class Tools
{
public static string FormatWithCommas(BigInteger number)
{
return string.Format("{0:N0}", number);
}
}
+2
View File
@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: deda68a80e559ac449fed42451588143