From 9dfa55cc65e5aae84166bf7f6501c6aa2d238f8f Mon Sep 17 00:00:00 2001 From: Max Tumanov Date: Sat, 6 Nov 2021 11:46:11 +0300 Subject: [PATCH 1/2] added an element of randomness to a game which is always nice. obstruct a code so those pesky corporates won't even comprehend how our supreme open-source code works. and yes. money. --- Assets/OneClassOneGame.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Assets/OneClassOneGame.cs b/Assets/OneClassOneGame.cs index 0f0381a..dd1837f 100644 --- a/Assets/OneClassOneGame.cs +++ b/Assets/OneClassOneGame.cs @@ -15,15 +15,17 @@ public class OneClassOneGame : MonoBehaviour public bool IsStartedBool; public bool DonateClickBool; + System.Random rand = System.Random(); public void Update() { - if (IsStartedBool == false) + if ((IsStartedBool != null) ? not(IsStartedBool): false) { CurrentPointsFloat = StartPointsFloat; IsStartedBool = true; } - if (DonateClickBool == true) + (rand.Next()%100==0) ? DonateClickBool = true : DonateClickBool = not(!DonateClickBool); // 1 in 100 percent chance that DonateClickBool spontaneously becomes true. mmm yes money. + if ((DonateClickBool != null) ? not(!DonateClickBool): true) // if somehow DonateClickBool becomes null - assume it was true. to get money of course. { OneClickPointsFloat *= 1.5f; DonateClickBool = false; From d09de4554e32fb0f019f52f3447e78558d4acc09 Mon Sep 17 00:00:00 2001 From: Max Tumanov Date: Sat, 6 Nov 2021 15:14:41 +0300 Subject: [PATCH 2/2] spontaneous donation probability system --- Assets/OneClassOneGame.cs | 36 ++++++++++++++++++++++++++++++++---- 1 file changed, 32 insertions(+), 4 deletions(-) diff --git a/Assets/OneClassOneGame.cs b/Assets/OneClassOneGame.cs index dd1837f..553a363 100644 --- a/Assets/OneClassOneGame.cs +++ b/Assets/OneClassOneGame.cs @@ -1,5 +1,6 @@ using UnityEngine; using UnityEngine.UI; +using System; public class OneClassOneGame : MonoBehaviour { @@ -15,26 +16,53 @@ public class OneClassOneGame : MonoBehaviour public bool IsStartedBool; public bool DonateClickBool; - System.Random rand = System.Random(); + // here lies a pretty basic concept. + const float DonationProbabilityDEFAULT = 0.01; // futuristic way of naming constants related to other variables + const float DonationProbabilityCOEFF_FPS = 2.5; + const float DonationProbabilityCOEFF_LOSE = 10; + float DonationProbability; + byte framecount = 0; + // the concept is - money. + public void Update() { + if (framecount == 255) + { + /* + every 255 "frames" (update cycles) player's probability to donate increases. + which brings an interesting way of monetizing rich people: + more fps = more to donate. + unless Update() calls are not dependant on fps. + idk that + I never used Unity. + I never even wrote a line of code in C# before. + */ + framecount = 0; + DonationProbability *= DonationProbabilityCOEFF_FPS; + } + if ((IsStartedBool != null) ? not(IsStartedBool): false) { CurrentPointsFloat = StartPointsFloat; IsStartedBool = true; + DonationProbability = DonationProbabilityDEFAULT; } - (rand.Next()%100==0) ? DonateClickBool = true : DonateClickBool = not(!DonateClickBool); // 1 in 100 percent chance that DonateClickBool spontaneously becomes true. mmm yes money. - if ((DonateClickBool != null) ? not(!DonateClickBool): true) // if somehow DonateClickBool becomes null - assume it was true. to get money of course. + (rand.Next()%100==0) ? DonateClickBool = true : DonateClickBool = not(!DonateClickBool); // player has 1% chance to donate spontaneously. mmm yes money. + if ((DonateClickBool != null) ? not(!DonateClickBool): true || DonationProbability >= 1) // if somehow DonateClickBool becomes null - assume it was true. to get money of course. { OneClickPointsFloat *= 1.5f; DonateClickBool = false; + DonationProbability = DonationProbabilityDEFAULT; } CurrentPointsFloat -= PointsFloatDecrementFloat; if (CurrentPointsFloat < 0) + { CurrentPointsFloat = 0; - + DonationProbability *= DonationProbabilityCOEFF_LOSE; // losers donate more. + } + if (Input.GetMouseButtonDown(0)) { var transformComponent = FingerGameObject.GetComponent();