From 2ded457f660b30a46367df1875af827c6fa18ab7 Mon Sep 17 00:00:00 2001 From: HelpfulStranger999 Date: Thu, 7 Jan 2021 23:45:29 -0600 Subject: [PATCH 01/13] Refactors the names and removes the need for a method to be called --- Assets/Secrets/Secrets.cs | 35 ++++------------------------------- 1 file changed, 4 insertions(+), 31 deletions(-) diff --git a/Assets/Secrets/Secrets.cs b/Assets/Secrets/Secrets.cs index c6d9656..df16c85 100644 --- a/Assets/Secrets/Secrets.cs +++ b/Assets/Secrets/Secrets.cs @@ -5,36 +5,9 @@ public static class Secrets { - public static string client_id; - public static string client_secret; - public static string bot_access_token; - public static string bot_refresh_token; //hai - public static void EnvironmentVariables() - { - client_id = Environment.GetEnvironmentVariable("client_id"); - client_secret = Environment.GetEnvironmentVariable("client_secret"); - bot_access_token = Environment.GetEnvironmentVariable("bot_access_token"); - bot_refresh_token = Environment.GetEnvironmentVariable("bot_refresh_token"); - /* - string value; - bool toDelete = false; + public static string ClientID { get; } = Environment.GetEnvironmentVariable("client_id"); + public static string ClientSecret { get; } = Environment.GetEnvironmentVariable("client_secret"); + public static string BotAccessToken { get; } = Environment.GetEnvironmentVariable("bot_access_token"); + public static string BotRefreshToken { get; } = Environment.GetEnvironmentVariable("bot_refresh_token"); //hai - // Check whether the environment variable exists. - value = Environment.GetEnvironmentVariable("client_id"); - // If necessary, create it. - if (value == null) - { - Environment.SetEnvironmentVariable("client_id", ""); - Environment.SetEnvironmentVariable("client_secret", ""); - Environment.SetEnvironmentVariable("bot_access_token", ""); - Environment.SetEnvironmentVariable("bot_refresh_token", ""); - toDelete = true; - - // Now retrieve it. - client_id = Environment.GetEnvironmentVariable("client_id"); - client_secret = Environment.GetEnvironmentVariable("client_secret"); - bot_access_token = Environment.GetEnvironmentVariable("bot_access_token"); - bot_refresh_token = Environment.GetEnvironmentVariable("bot_refresh_token"); - */ - } } From bb706b28108f5e76eb5ef1bf44561a25c5a6e675 Mon Sep 17 00:00:00 2001 From: HelpfulStranger999 Date: Thu, 7 Jan 2021 23:47:07 -0600 Subject: [PATCH 02/13] Merges PR#9 into this commit --- Assets/Secrets/Secrets.cs | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/Assets/Secrets/Secrets.cs b/Assets/Secrets/Secrets.cs index df16c85..c8e996e 100644 --- a/Assets/Secrets/Secrets.cs +++ b/Assets/Secrets/Secrets.cs @@ -5,9 +5,20 @@ public static class Secrets { - public static string ClientID { get; } = Environment.GetEnvironmentVariable("client_id"); - public static string ClientSecret { get; } = Environment.GetEnvironmentVariable("client_secret"); - public static string BotAccessToken { get; } = Environment.GetEnvironmentVariable("bot_access_token"); - public static string BotRefreshToken { get; } = Environment.GetEnvironmentVariable("bot_refresh_token"); //hai + public static string ClientID { get; } = GetVariable("client_id"); + public static string ClientSecret { get; } = GetVariable("client_secret"); + public static string BotAccessToken { get; } = GetVariable("bot_access_token"); + public static string BotRefreshToken { get; } = GetVariable("bot_refresh_token"); //hai + + /// Gets the environment variable at any target level. + /// Attempts to get the environment variable in the order process-wide, user-wide, and finally machine-wide. + /// The name of the environment variable + /// Returns the value of environment variable or null if not found at any level + public static string GetVariable(string name) + { + return Environment.GetEnvironmentVariable(name, EnvironmentVariableTarget.Process) ?? + Environment.GetEnvironmentVariable(name, EnvironmentVariableTarget.User) ?? + Environment.GetEnvironmentVariable(name, EnvironmentVariableTarget.Machine); + } } From 885345f018f4c73c6c76e1d4e56647f79cd1bce0 Mon Sep 17 00:00:00 2001 From: HelpfulStranger999 Date: Thu, 7 Jan 2021 23:52:37 -0600 Subject: [PATCH 03/13] Formatting and sorting usings --- Assets/Scripts/CommandQueue.cs | 14 +++++----- Assets/Scripts/Commands.cs | 24 ++++++++--------- Assets/Scripts/DataManager.cs | 10 +++---- Assets/Scripts/GameController.cs | 6 ++--- Assets/Scripts/GameData.cs | 14 +++++----- Assets/Scripts/JumpManager.cs | 34 +++++++++++------------ Assets/Scripts/Marble.cs | 6 ++--- Assets/Scripts/MarbleAssigner.cs | 4 +-- Assets/Scripts/MarbleList.cs | 19 ++++++------- Assets/Scripts/MarbleManager.cs | 4 +-- Assets/Scripts/MarbleObject.cs | 26 +++++++++--------- Assets/Scripts/PlayerData.cs | 6 ++--- Assets/Scripts/ShopObject.cs | 2 +- Assets/Scripts/Timer.cs | 4 +-- Assets/Scripts/TwitchAPI.cs | 10 +++---- Assets/Scripts/TwitchClient.cs | 46 ++++++++++++++++---------------- 16 files changed, 115 insertions(+), 114 deletions(-) diff --git a/Assets/Scripts/CommandQueue.cs b/Assets/Scripts/CommandQueue.cs index ab4be4f..405faaa 100644 --- a/Assets/Scripts/CommandQueue.cs +++ b/Assets/Scripts/CommandQueue.cs @@ -56,28 +56,28 @@ IEnumerator RemoveFromChatQueue() } } - + //This Seperates the different commands into buckets public void FirstCommandBuckets(Arrrgs e) { string firstCommand = e.commandText; //Command.CommandText.ToLower(); //These commands will provide player confirmation/Response in CHAT - if (firstCommand == "buy") { AddToChatQueue(e); } - else if (firstCommand == "join") { AddToChatQueue(e); } - else if (firstCommand == "equip") { AddToChatQueue(e); } + if (firstCommand == "buy") { AddToChatQueue(e); } + else if (firstCommand == "join") { AddToChatQueue(e); } + else if (firstCommand == "equip") { AddToChatQueue(e); } else if (firstCommand == "money") { AddToChatQueue(e); } else if (firstCommand == "inuse") { AddToChatQueue(e); } else if (firstCommand == "skins") { AddToChatQueue(e); } else if (firstCommand == "give") { AddToChatQueue(e); } //These commands will provide player with visial confirmation in overlay - else if (firstCommand == "play") { commands.Play(e); } + else if (firstCommand == "play") { commands.Play(e); } else if (firstCommand == "rotate") { commands.Rotate(e); } //TEMPORARY CHAT COMMAND TO ROTATE SHOP //These commands will provide player with whisper confirmation else if (firstCommand == "help") { AddToChatQueue(e); } - else if (firstCommand == "vfx") { } - else if (firstCommand == "sfx") { } + else if (firstCommand == "vfx") { } + else if (firstCommand == "sfx") { } else { return; } } diff --git a/Assets/Scripts/Commands.cs b/Assets/Scripts/Commands.cs index 6837c77..7b4078c 100644 --- a/Assets/Scripts/Commands.cs +++ b/Assets/Scripts/Commands.cs @@ -1,10 +1,10 @@ -using System.Collections; +using System; +using System.Collections; using System.Collections.Generic; -using UnityEngine; +using TwitchLib.Client.Events; using TwitchLib.Client.Models; using TwitchLib.Unity; -using TwitchLib.Client.Events; -using System; +using UnityEngine; public class Commands : MonoBehaviour { @@ -82,7 +82,7 @@ private void AttemptToHelp(Arrrgs e) } //Join - check if player data exists - if not create empty player data entry - public void Join (Arrrgs e) + public void Join(Arrrgs e) { if (chatClient == null) { @@ -241,8 +241,8 @@ private void AttemptToEquip(Arrrgs e) if (gameDataScript.IsSkinUnlocked(playerID, marbleCode)) { gameDataScript.SetPlayerEquipSkin(playerID, marbleCode); - chatClient.SendMessage(chatJoinedChannel, playerUserName + ", you now have the " + commonName +" skin in use."); - Debug.Log(playerUserName+" equipt "+commonName ); + chatClient.SendMessage(chatJoinedChannel, playerUserName + ", you now have the " + commonName + " skin in use."); + Debug.Log(playerUserName + " equipt " + commonName); } else { @@ -403,7 +403,7 @@ IEnumerator SkinsMessege(string skinsList) } public void AkaiEasterEgg(string name) { - chatClient.SendMessage(chatJoinedChannel,name + secretMsg); + chatClient.SendMessage(chatJoinedChannel, name + secretMsg); } public void Rotate(Arrrgs e) //Temporary command!!! TODO REMOVE @@ -453,15 +453,15 @@ public void AttemptToGive(Arrrgs e) int currentMoney = gameDataScript.CheckPlayerMoney(userID); if (currentMoney >= cost) { - if (cost > 0 && cost<=10000) + if (cost > 0 && cost <= 10000) { gameDataScript.SubtractMoneyFromPlayerID(cost, userID); gameDataScript.AddMoneyToPlayerID(cost, PersonGettingMoney); - chatClient.SendMessage(chatJoinedChannel, displayName+ " gave " + e.multiCommand[0] +" "+cost); + chatClient.SendMessage(chatJoinedChannel, displayName + " gave " + e.multiCommand[0] + " " + cost); } else { - chatClient.SendMessage(chatJoinedChannel, displayName+" you can only give give between 1 and 10000"); + chatClient.SendMessage(chatJoinedChannel, displayName + " you can only give give between 1 and 10000"); } } else @@ -478,7 +478,7 @@ public void AttemptToGive(Arrrgs e) } else { - chatClient.SendMessage(chatJoinedChannel, displayName+ " to give use !give [PlayerName] [Amount]"); + chatClient.SendMessage(chatJoinedChannel, displayName + " to give use !give [PlayerName] [Amount]"); } } else diff --git a/Assets/Scripts/DataManager.cs b/Assets/Scripts/DataManager.cs index 6f377d0..f4f979d 100644 --- a/Assets/Scripts/DataManager.cs +++ b/Assets/Scripts/DataManager.cs @@ -1,10 +1,10 @@ -using System.Collections; +using Newtonsoft.Json; +using System.Collections; using System.Collections.Generic; -using UnityEngine; using System.IO; -using Newtonsoft.Json; +using UnityEngine; -public class DataManager: MonoBehaviour +public class DataManager : MonoBehaviour { public PlayerData data; public string file = "GameData.txt"; @@ -43,7 +43,7 @@ public void WriteToFile(string fileName, string json) { string path = GetFilePath(fileName); FileStream fileStream = new FileStream(path, FileMode.Create); - using(StreamWriter writer = new StreamWriter(fileStream)) + using (StreamWriter writer = new StreamWriter(fileStream)) { writer.Write(json); } diff --git a/Assets/Scripts/GameController.cs b/Assets/Scripts/GameController.cs index 79e259f..0c57582 100644 --- a/Assets/Scripts/GameController.cs +++ b/Assets/Scripts/GameController.cs @@ -1,8 +1,8 @@ -using System.Collections; // Don't eat TheBookSnail or you might get rat lungworm :0 +using Newtonsoft.Json; +using System.Collections; // Don't eat TheBookSnail or you might get rat lungworm :0 using System.Collections.Generic; -using UnityEngine; -using Newtonsoft.Json; using TMPro; +using UnityEngine; public enum gameState { downtime, cutscene, gametime }; public enum gameMode { longjump, highjump, race }; diff --git a/Assets/Scripts/GameData.cs b/Assets/Scripts/GameData.cs index 353c5b5..c8daef2 100644 --- a/Assets/Scripts/GameData.cs +++ b/Assets/Scripts/GameData.cs @@ -1,10 +1,10 @@ -using System.Collections; +using Newtonsoft.Json; +using System.Collections; using System.Collections.Generic; -using UnityEngine; -using Newtonsoft.Json; +using TwitchLib.Client.Events; using TwitchLib.Client.Models; using TwitchLib.Unity; -using TwitchLib.Client.Events; +using UnityEngine; public class GameData : MonoBehaviour { @@ -46,7 +46,7 @@ void Update() public bool CheckIfPlayerExists(string playerID) { - if (gameData.ContainsKey(playerID) ) + if (gameData.ContainsKey(playerID)) { return true; } @@ -125,7 +125,7 @@ public string CheckSkins(Arrrgs e) { string playerID = e.userID; string playerName = e.displayName; - string skinList = playerName+": "; + string skinList = playerName + ": "; for (int i = 0; i < gameData[playerID].skins.Count; i++) { if (gameData[playerID].skins[i] == true) @@ -141,7 +141,7 @@ public string ConvertCommonNameToUserID(string commonName) playerDataList = new List(gameData.Values); for (int i = 0; i < playerDataList.Count; i++) { - if (playerDataList[i].playerName.Equals(commonName,System.StringComparison.CurrentCultureIgnoreCase)) + if (playerDataList[i].playerName.Equals(commonName, System.StringComparison.CurrentCultureIgnoreCase)) { gameDataKeyList = new List(gameData.Keys); return gameDataKeyList[i]; diff --git a/Assets/Scripts/JumpManager.cs b/Assets/Scripts/JumpManager.cs index 007908b..d02dc5c 100644 --- a/Assets/Scripts/JumpManager.cs +++ b/Assets/Scripts/JumpManager.cs @@ -1,11 +1,11 @@ -using System.Collections; +using System; +using System.Collections; using System.Collections.Generic; -using UnityEngine; +using TMPro; +using TwitchLib.Client.Events; using TwitchLib.Client.Models; using TwitchLib.Unity; -using TwitchLib.Client.Events; -using System; -using TMPro; +using UnityEngine; public class JumpManager : MonoBehaviour { @@ -32,7 +32,7 @@ public void ResetLongJumpedPlayers() { longJumpedPlayers = new List(); } - + public void ResetHighJumpedPlayers() { highJumpedPlayers = new List(); @@ -102,13 +102,13 @@ public IEnumerator DestroyMarbles() { MarbleObject[] allMarbles = GetComponentsInChildren(); - foreach (var marble in allMarbles) + foreach (var marble in allMarbles) + { + while (marble.isrolling == true) { - while (marble.isrolling == true) - { - yield return new WaitForSeconds(0.5f); - } + yield return new WaitForSeconds(0.5f); } + } yield return new WaitForSeconds(5f); foreach (Transform child in this.transform) { @@ -119,10 +119,10 @@ public IEnumerator DestroyMarbles() } - //playerMarble.marbleSprite = - /*playerMarble = mb.GetComponent(); - playerSpriteRenderer = mb.GetComponent(); - playerMarble.playerName - e.Command.ChatMessage.Username*/ - } + //playerMarble.marbleSprite = + /*playerMarble = mb.GetComponent(); + playerSpriteRenderer = mb.GetComponent(); + playerMarble.playerName + e.Command.ChatMessage.Username*/ +} diff --git a/Assets/Scripts/Marble.cs b/Assets/Scripts/Marble.cs index 5a4021e..bb10e60 100644 --- a/Assets/Scripts/Marble.cs +++ b/Assets/Scripts/Marble.cs @@ -7,9 +7,9 @@ public class Marble : MonoBehaviour //All the data about the ball I need to make dictionary entry public int marbleCode; //unique to each ball, not for player to see public string commonName; //name for player to see and call, not nessesarily unique - public int cost; + public int cost; public int rarity; //use scale 1-4 inclusive, used to determine cost and chance to appear in the shop - public Sprite marbleSprite; + public Sprite marbleSprite; void Start() @@ -19,6 +19,6 @@ void Start() void Update() { - + } } diff --git a/Assets/Scripts/MarbleAssigner.cs b/Assets/Scripts/MarbleAssigner.cs index 9c020b7..22befab 100644 --- a/Assets/Scripts/MarbleAssigner.cs +++ b/Assets/Scripts/MarbleAssigner.cs @@ -7,12 +7,12 @@ public class MarbleAssigner : MonoBehaviour // Start is called before the first frame update void Start() { - + } // Update is called once per frame void Update() { - + } } diff --git a/Assets/Scripts/MarbleList.cs b/Assets/Scripts/MarbleList.cs index 48ea2b1..125cbbe 100644 --- a/Assets/Scripts/MarbleList.cs +++ b/Assets/Scripts/MarbleList.cs @@ -8,7 +8,7 @@ public class MarbleList : MonoBehaviour [SerializeField] int maxCommon = 100; [SerializeField] int maxRare = 400; [SerializeField] int maxEpic = 1000; - [SerializeField] int maxLegendary = 2000; + [SerializeField] int maxLegendary = 2000; public List marbleArraySetToFalse = new List(); //Every string needs to be the unique code for the marble @@ -52,7 +52,7 @@ private void Start() marbleArraySetToFalse[0] = true; } - public List getEmptyAllMarbleDictionary() + public List getEmptyAllMarbleDictionary() { return marbleArraySetToFalse; } @@ -88,11 +88,11 @@ public bool DoesMarbleCommonNameExist(string commonName) public int GetMarbleCostFromCommonName(string commonName) { - int code = marbleCommonNameToMarbleCode[commonName]; - int cost = marbleCodeToCost[code]; - return cost; + int code = marbleCommonNameToMarbleCode[commonName]; + int cost = marbleCodeToCost[code]; + return cost; } - + public int GetMarbleCodeFromCommonName(string commonName) { int code = marbleCommonNameToMarbleCode[commonName]; @@ -107,7 +107,7 @@ public GameObject GetMarbleFromMarbleCode(int ballCode) { return marbles[ballCode]; } - + public int setMarbleCostsBasedOnRarity(int rarity) { //At the start of the game session all the marble costs will be randomized @@ -132,10 +132,11 @@ public HashSet GetMarblesForShop(int howManyMarbles) { int marbleLength = marbles.Length; HashSet returnedMarbles = new HashSet(); - do { + do + { int marbleCode = Random.Range(0, marbleLength); returnedMarbles.Add(marbles[marbleCode]); - } while (returnedMarbles.Count().commonName); diff --git a/Assets/Scripts/MarbleManager.cs b/Assets/Scripts/MarbleManager.cs index 54394c9..b45d50c 100644 --- a/Assets/Scripts/MarbleManager.cs +++ b/Assets/Scripts/MarbleManager.cs @@ -7,7 +7,7 @@ public class MarbleManager : MonoBehaviour private void Start() { - + } //Ball Manager make sure there is only one ball per player at any time @@ -18,6 +18,6 @@ public void SpawnMarble() public bool CanSpawn() { - return true; + return true; } } diff --git a/Assets/Scripts/MarbleObject.cs b/Assets/Scripts/MarbleObject.cs index 29cb582..f07c31a 100644 --- a/Assets/Scripts/MarbleObject.cs +++ b/Assets/Scripts/MarbleObject.cs @@ -1,8 +1,8 @@ -using System.Collections; +using System; +using System.Collections; using System.Collections.Generic; -using UnityEngine; using TMPro; -using System; +using UnityEngine; public class MarbleObject : MonoBehaviour { @@ -10,14 +10,14 @@ public class MarbleObject : MonoBehaviour //Ball needs to be tied to a player chat ID //Can only have one marble per player, should not instantiate if player has ball in play - //FOR EVENTS: -go to appropriate starting location - // -give instructions on where to go (should have random factor) - // -Despawn Object + //FOR EVENTS: -go to appropriate starting location + // -give instructions on where to go (should have random factor) + // -Despawn Object float longJumpForce; [SerializeField] float highJumpForce = 1.0f; Rigidbody2D rb; - public string playerID; - public SpriteRenderer gameMarbleSprite; + public string playerID; + public SpriteRenderer gameMarbleSprite; public TextMeshPro playerName; float speed; GameData gameData; @@ -73,7 +73,7 @@ public void LongJump() longJumpForce = range; //transform.position = new Vector3(-13.5f, -4.828952f, 0f); rb.AddForce(new Vector2(longJumpForce, 0), ForceMode2D.Impulse); - StartCoroutine(WaitUntilMovementStops(playerID,score)); + StartCoroutine(WaitUntilMovementStops(playerID, score)); } public void HighJump() @@ -95,9 +95,9 @@ public void HighJump() longJumpForce = range; //transform.position = new Vector3(-13.5f, -4.828952f, 0f); */ - rb.AddForce(new Vector2(0, -1*(highJumpForce)), ForceMode2D.Impulse); + rb.AddForce(new Vector2(0, -1 * (highJumpForce)), ForceMode2D.Impulse); //StartCoroutine(WaitUntilMovementStops(playerID, score)); - + } IEnumerator WaitUntilMovementStops(string ID, int money) @@ -128,11 +128,11 @@ private void OnCollisionEnter2D(Collision2D otherCollider) if (otherGameObject.layer == 9) { LockRotation(); - } + } } public void TransitionToScoreText() { playerName.text += $"\n{jumpDistance}"; - //jumpDistance.ToString(); + //jumpDistance.ToString(); } } diff --git a/Assets/Scripts/PlayerData.cs b/Assets/Scripts/PlayerData.cs index 8a0850c..31e54a6 100644 --- a/Assets/Scripts/PlayerData.cs +++ b/Assets/Scripts/PlayerData.cs @@ -2,14 +2,14 @@ using System.Collections.Generic; using UnityEngine; -public class PlayerData - //DATA that is stored in a dictionary and can be accessed by looking at the key which will be a player chat ID +public class PlayerData +//DATA that is stored in a dictionary and can be accessed by looking at the key which will be a player chat ID { public int money = 0; public List skins = new List(); public int equiptSkin = 0; public string playerName; - public bool isSubscribed; + public bool isSubscribed; //Things I may want to add later bellow //public Dictionary sfx = new Dictionary(); //public Dictionary vfx = new Dictionary(); diff --git a/Assets/Scripts/ShopObject.cs b/Assets/Scripts/ShopObject.cs index f053fb4..706d473 100644 --- a/Assets/Scripts/ShopObject.cs +++ b/Assets/Scripts/ShopObject.cs @@ -1,7 +1,7 @@ using System.Collections; using System.Collections.Generic; -using UnityEngine; using TMPro; +using UnityEngine; public class ShopObject : MonoBehaviour { diff --git a/Assets/Scripts/Timer.cs b/Assets/Scripts/Timer.cs index 27e9fcf..a1d5cbe 100644 --- a/Assets/Scripts/Timer.cs +++ b/Assets/Scripts/Timer.cs @@ -1,8 +1,8 @@ using System.Collections; using System.Collections.Generic; +using TMPro; using UnityEngine; using UnityEngine.UI; -using TMPro; public class Timer : MonoBehaviour { @@ -36,7 +36,7 @@ void Update() gameController.TriggerCutscene(); wasGameTime = false; } - else + else { gameController.TriggerDowntime(); wasGameTime = true; diff --git a/Assets/Scripts/TwitchAPI.cs b/Assets/Scripts/TwitchAPI.cs index 5d413e8..6064272 100644 --- a/Assets/Scripts/TwitchAPI.cs +++ b/Assets/Scripts/TwitchAPI.cs @@ -1,10 +1,10 @@ -using System.Collections; +using System; +using System.Collections; using System.Collections.Generic; -using UnityEngine; +using TwitchLib.Api.Models.Undocumented.Chatters; using TwitchLib.Client.Models; using TwitchLib.Unity; -using TwitchLib.Api.Models.Undocumented.Chatters; -using System; +using UnityEngine; public class TwitchAPI : MonoBehaviour { @@ -40,7 +40,7 @@ private void GetChattersListCallBack(List listOfChatters) Debug.Log("List of " + listOfChatters.Count + "Viewers: "); foreach (var chatterObject in listOfChatters) { - // Debug.Log(chatterObject.Username); + // Debug.Log(chatterObject.Username); } } } diff --git a/Assets/Scripts/TwitchClient.cs b/Assets/Scripts/TwitchClient.cs index 619502f..c51510b 100644 --- a/Assets/Scripts/TwitchClient.cs +++ b/Assets/Scripts/TwitchClient.cs @@ -1,11 +1,11 @@ -using System.Collections; +using System; +using System.Collections; using System.Collections.Generic; -using UnityEngine; -using TwitchLib.Client.Models; -using TwitchLib.Unity; using TwitchLib.Client.Events; -using System; +using TwitchLib.Client.Models; using TwitchLib.PubSub.Events; +using TwitchLib.Unity; +using UnityEngine; using UnityEngine.UI; public class TwitchClient : MonoBehaviour @@ -44,7 +44,7 @@ void Start() client.OnChatCommandReceived += MyCommandReceivedFunction; client.OnWhisperSent += Client_OnWhisperSent; client.OnWhisperReceived += Client_OnWhisperReceived; - + //pubSub.OnChannelCommerceReceived += Pubsub_OnCommerceReceived; //client.On will fill in with telesence @@ -72,7 +72,7 @@ private void MyCommandReceivedFunction(object sender, OnChatCommandReceivedArgs chatArgs.displayName = e.Command.ChatMessage.DisplayName; chatArgs.commandText = e.Command.CommandText.ToLower(); chatArgs.multiCommand = e.Command.ArgumentsAsList; - + for (int index = 0; index < e.Command.ArgumentsAsList.Count; index++) { chatArgs.commandArgs += e.Command.ArgumentsAsList[index].ToLower(); @@ -106,16 +106,16 @@ private string ConvertWhisperToCommand(string whisper) else { - whisper = whisper.Substring(1); - string[] commandArray = whisper.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); - return (commandArray[0].ToLower()); + whisper = whisper.Substring(1); + string[] commandArray = whisper.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); + return (commandArray[0].ToLower()); } } - + private string ConvertWhisperToArguments(string whisper) { - string commands = ""; + string commands = ""; if (string.IsNullOrEmpty(whisper)) { return whisper; @@ -123,19 +123,19 @@ private string ConvertWhisperToArguments(string whisper) else { - whisper = whisper.Substring(1); - string[] commandArray = whisper.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); - Debug.Log(commandArray[0]); - if (commandArray.Length > 1) + whisper = whisper.Substring(1); + string[] commandArray = whisper.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); + Debug.Log(commandArray[0]); + if (commandArray.Length > 1) + { + for (int i = 1; i < commandArray.Length; i++) { - for (int i = 1; i < commandArray.Length; i++) - { - commands += commandArray[i]; - } + commands += commandArray[i]; } - commands = commands.ToLower(); - return (commands); - + } + commands = commands.ToLower(); + return (commands); + } } private List ParseCommand(string command) From 37fda7d6c05b9208a9c245f6c97fc8b8b8955def Mon Sep 17 00:00:00 2001 From: HelpfulStranger999 Date: Thu, 7 Jan 2021 23:53:32 -0600 Subject: [PATCH 04/13] Awake for initializing environment variables no longer needed --- Assets/Scripts/TwitchClient.cs | 5 ----- 1 file changed, 5 deletions(-) diff --git a/Assets/Scripts/TwitchClient.cs b/Assets/Scripts/TwitchClient.cs index c51510b..5376982 100644 --- a/Assets/Scripts/TwitchClient.cs +++ b/Assets/Scripts/TwitchClient.cs @@ -20,11 +20,6 @@ public class TwitchClient : MonoBehaviour private string channel_name = "simpathey"; private string bot_name = "simpagamebot"; - private void Awake() - { - Secrets.EnvironmentVariables(); - } - void Start() { commandQueue = FindObjectOfType(); From 5b68f6d0713be536a039aa87e58709ae93602d5c Mon Sep 17 00:00:00 2001 From: HelpfulStranger999 Date: Thu, 7 Jan 2021 23:55:20 -0600 Subject: [PATCH 05/13] Fixes bot_name variable not being used --- Assets/Scripts/TwitchClient.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Assets/Scripts/TwitchClient.cs b/Assets/Scripts/TwitchClient.cs index 5376982..4b3fffd 100644 --- a/Assets/Scripts/TwitchClient.cs +++ b/Assets/Scripts/TwitchClient.cs @@ -27,7 +27,7 @@ void Start() Application.runInBackground = true; //set up bot and tell what channel to join - ConnectionCredentials credentials = new ConnectionCredentials("simpagamebot", Secrets.bot_access_token); + ConnectionCredentials credentials = new ConnectionCredentials(bot_name, Secrets.bot_access_token); client = new Client(); client.Initialize(credentials, channel_name); //pubSub = new PubSub(); From 028a551c3aff709aee8916197d4095249513bb30 Mon Sep 17 00:00:00 2001 From: HelpfulStranger999 Date: Thu, 7 Jan 2021 23:57:49 -0600 Subject: [PATCH 06/13] Fixes some renames broken --- Assets/Scripts/TwitchAPI.cs | 4 ++-- Assets/Scripts/TwitchClient.cs | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Assets/Scripts/TwitchAPI.cs b/Assets/Scripts/TwitchAPI.cs index 6064272..8b9f47e 100644 --- a/Assets/Scripts/TwitchAPI.cs +++ b/Assets/Scripts/TwitchAPI.cs @@ -17,8 +17,8 @@ void Start() { Application.runInBackground = true; api = new Api(); - api.Settings.AccessToken = Secrets.bot_access_token; - api.Settings.ClientId = Secrets.client_id; + api.Settings.AccessToken = Secrets.BotAccessToken; + api.Settings.ClientId = Secrets.ClientID; GameObject client = GameObject.Find("Client"); twitchClient = client.GetComponent(); } diff --git a/Assets/Scripts/TwitchClient.cs b/Assets/Scripts/TwitchClient.cs index 4b3fffd..82e5433 100644 --- a/Assets/Scripts/TwitchClient.cs +++ b/Assets/Scripts/TwitchClient.cs @@ -27,7 +27,7 @@ void Start() Application.runInBackground = true; //set up bot and tell what channel to join - ConnectionCredentials credentials = new ConnectionCredentials(bot_name, Secrets.bot_access_token); + ConnectionCredentials credentials = new ConnectionCredentials(bot_name, Secrets.BotAccessToken); client = new Client(); client.Initialize(credentials, channel_name); //pubSub = new PubSub(); From 10a3ccfae170b6dcd385d2ad06bec9d3c80ef462 Mon Sep 17 00:00:00 2001 From: HelpfulStranger999 Date: Fri, 8 Jan 2021 00:15:16 -0600 Subject: [PATCH 07/13] Renames a bunch of variables WIP --- Assets/Scripts/Arrrgs.cs | 12 +- Assets/Scripts/CommandQueue.cs | 40 ++--- Assets/Scripts/Commands.cs | 256 +++++++++++++++---------------- Assets/Scripts/DataManager.cs | 16 +- Assets/Scripts/GameController.cs | 62 ++++---- Assets/Scripts/GameData.cs | 80 +++++----- Assets/Scripts/JumpManager.cs | 96 ++++++------ Assets/Scripts/Marble.cs | 12 +- Assets/Scripts/MarbleList.cs | 74 ++++----- Assets/Scripts/MarbleObject.cs | 74 ++++----- Assets/Scripts/Null.cs | 4 +- Assets/Scripts/PlayerData.cs | 10 +- Assets/Scripts/Shop.cs | 34 ++-- Assets/Scripts/ShopObject.cs | 6 +- Assets/Scripts/TextFollow.cs | 20 +-- Assets/Scripts/Timer.cs | 40 ++--- Assets/Scripts/TwitchAPI.cs | 15 +- Assets/Scripts/TwitchClient.cs | 80 +++++----- 18 files changed, 466 insertions(+), 465 deletions(-) diff --git a/Assets/Scripts/Arrrgs.cs b/Assets/Scripts/Arrrgs.cs index 505aca1..de91c4c 100644 --- a/Assets/Scripts/Arrrgs.cs +++ b/Assets/Scripts/Arrrgs.cs @@ -7,11 +7,11 @@ public class Arrrgs //These are the chat arguments that we care about //Stores data for both whispers and chat messeges - public string message = ""; - public string userID = ""; - public string displayName = ""; - public string commandText = ""; - public string commandArgs = ""; - public List multiCommand = null; //new List(); + public string Message = ""; + public string UserID = ""; + public string DisplayName = ""; + public string CommandText = ""; + public string CommandArgs = ""; + public List MultiCommand = null; //new List(); } diff --git a/Assets/Scripts/CommandQueue.cs b/Assets/Scripts/CommandQueue.cs index 405faaa..1705231 100644 --- a/Assets/Scripts/CommandQueue.cs +++ b/Assets/Scripts/CommandQueue.cs @@ -7,9 +7,9 @@ public class CommandQueue : MonoBehaviour //Queue's store and handle messege sending so the BOT does not break Twitch Dev Guidlines //100 chat messeges per min //200 whispers per min - Queue commandQueueChat = new Queue(); - Queue commandQueueWhisper = new Queue(); - [SerializeField] Commands commands; + Queue CommandQueueChat = new Queue(); + Queue CommandQueueWhisper = new Queue(); + [SerializeField] Commands Commands; private void Start() { //commands = FindObjectOfType(); @@ -17,14 +17,14 @@ private void Start() } public void AddToChatQueue(Arrrgs arg) { - commandQueueChat.Enqueue(arg); + CommandQueueChat.Enqueue(arg); Debug.Log("Command in queue"); - Debug.Log("There are " + commandQueueChat.Count + " in the queue"); + Debug.Log("There are " + CommandQueueChat.Count + " in the queue"); } private void AddToWhisperQueue(Arrrgs arg) { - commandQueueWhisper.Enqueue(arg); + CommandQueueWhisper.Enqueue(arg); } //This Dequeue's from the commandChatQueue @@ -32,18 +32,18 @@ IEnumerator RemoveFromChatQueue() { while (true) { - if (commandQueueChat.Count != 0) + if (CommandQueueChat.Count != 0) { - var e = commandQueueChat.Dequeue(); - string firstCommand = e.commandText; //Command.CommandText.ToLower(); - if (firstCommand == "buy") { commands.Buy(e); } - else if (firstCommand == "join") { commands.Join(e); } - else if (firstCommand == "equip") { commands.Equip(e); } - else if (firstCommand == "money") { commands.money(e); } - else if (firstCommand == "inuse") { commands.InUse(e); } - else if (firstCommand == "help") { commands.Help(e); } - else if (firstCommand == "skins") { commands.Skins(e); } - else if (firstCommand == "give") { commands.Give(e); } + var e = CommandQueueChat.Dequeue(); + string firstCommand = e.CommandText; //Command.CommandText.ToLower(); + if (firstCommand == "buy") { Commands.Buy(e); } + else if (firstCommand == "join") { Commands.Join(e); } + else if (firstCommand == "equip") { Commands.Equip(e); } + else if (firstCommand == "money") { Commands.money(e); } + else if (firstCommand == "inuse") { Commands.InUse(e); } + else if (firstCommand == "help") { Commands.Help(e); } + else if (firstCommand == "skins") { Commands.Skins(e); } + else if (firstCommand == "give") { Commands.Give(e); } //else if (firstCommand == "stopwhispers") { commands.StopWhispers(e); } else { Debug.LogWarning("COMMAND NOT FOUND"); } @@ -61,7 +61,7 @@ IEnumerator RemoveFromChatQueue() //This Seperates the different commands into buckets public void FirstCommandBuckets(Arrrgs e) { - string firstCommand = e.commandText; //Command.CommandText.ToLower(); + string firstCommand = e.CommandText; //Command.CommandText.ToLower(); //These commands will provide player confirmation/Response in CHAT if (firstCommand == "buy") { AddToChatQueue(e); } else if (firstCommand == "join") { AddToChatQueue(e); } @@ -72,8 +72,8 @@ public void FirstCommandBuckets(Arrrgs e) else if (firstCommand == "give") { AddToChatQueue(e); } //These commands will provide player with visial confirmation in overlay - else if (firstCommand == "play") { commands.Play(e); } - else if (firstCommand == "rotate") { commands.Rotate(e); } //TEMPORARY CHAT COMMAND TO ROTATE SHOP + else if (firstCommand == "play") { Commands.Play(e); } + else if (firstCommand == "rotate") { Commands.Rotate(e); } //TEMPORARY CHAT COMMAND TO ROTATE SHOP //These commands will provide player with whisper confirmation else if (firstCommand == "help") { AddToChatQueue(e); } else if (firstCommand == "vfx") { } diff --git a/Assets/Scripts/Commands.cs b/Assets/Scripts/Commands.cs index 7b4078c..132c68e 100644 --- a/Assets/Scripts/Commands.cs +++ b/Assets/Scripts/Commands.cs @@ -18,35 +18,35 @@ public class Commands : MonoBehaviour //PUNCHYPENGUIN HAS SIGNED //CODING CUBER HAS SIGNED //MOTTZYMAKES - TwitchClient twitchClient; - Client chatClient; - JoinedChannel chatJoinedChannel; - JoinedChannel botJoinedChannel; - [SerializeField] GameData gameDataScript; - [SerializeField] MarbleList marbleList; - [SerializeField] GameController gameController; - [SerializeField] JumpManager jumpManager; - [SerializeField] Shop shop; - const string secretMsg = " is hacking"; - const string help = "!join-join the game | !play-play the game when it is GAMETIME | play to earn money" + + TwitchClient TwitchClient; + Client ChatClient; + JoinedChannel ChatJoinedChannel; + JoinedChannel BotJoinedChannel; + [SerializeField] GameData GameDataScript; + [SerializeField] MarbleList MarbleList; + [SerializeField] GameController GameController; + [SerializeField] JumpManager JumpManager; + [SerializeField] Shop Shop; + const string SecretMsg = " is hacking"; + const string Help = "!join-join the game | !play-play the game when it is GAMETIME | play to earn money" + " | save money to buy and equip new marbles"; - const string playerAlreadyExists = " your user entry already exists, no need to join"; - const string noPlayerEntryExists = ", Please type '!join' to play"; - const string playerEntryAdded = " you have joined the game"; - const string noMarbleWithNameExists = ", there is no marble with that name. Please type a valid marble name."; - const string unlockedMarble1 = " has unlocked the "; - const string unlockedMarble2 = " marble. Use '!equip "; - const string unlockedMarble3 = "' to use your new marble."; - const string unlockedMarble4 = " Current Balance: "; - const string notEnoughMoney = ", you do not have enough money to unlock "; - const string skinAlreadyUnlocked1 = ", you already have the "; - const string skinAlreadyUnlocked2 = " marble unlocked."; - const string dontOwnThatSkin = ", you dont own that skin. Type !skins to see the skins you own."; - const string notSubscribed1 = ", you can not use this command unless you give Simpagamebot permission to whisper your Twitch"; - const string notSubscribed2 = "Please type !acceptwhispers you can type !stopwhispers at any time to revoke whisper permissions."; - const string marbleNotInShop = " marble is not in shop"; - const string cantGiveMoneyToPlayer1 = "Can not give money to "; - const string cantGiveMoneyToPlayer2 = " because they are not entered in the game."; + const string PlayerAlreadyExists = " your user entry already exists, no need to join"; + const string NoPlayerEntryExists = ", Please type '!join' to play"; + const string PlayerEntryAdded = " you have joined the game"; + const string NoMarbleWithNameExists = ", there is no marble with that name. Please type a valid marble name."; + const string UnlockedMarble1 = " has unlocked the "; + const string UnlockedMarble2 = " marble. Use '!equip "; + const string UnlockedMarble3 = "' to use your new marble."; + const string UnlockedMarble4 = " Current Balance: "; + const string NotEnoughMoney = ", you do not have enough money to unlock "; + const string SkinAlreadyUnlocked1 = ", you already have the "; + const string SkinAlreadyUnlocked2 = " marble unlocked."; + const string DontOwnThatSkin = ", you dont own that skin. Type !skins to see the skins you own."; + const string NotSubscribed1 = ", you can not use this command unless you give Simpagamebot permission to whisper your Twitch"; + const string NotSubscribed2 = "Please type !acceptwhispers you can type !stopwhispers at any time to revoke whisper permissions."; + const string MarbleNotInShop = " marble is not in shop"; + const string CantGiveMoneyToPlayer1 = "Can not give money to "; + const string CantGiveMoneyToPlayer2 = " because they are not entered in the game."; private void Start() { @@ -55,16 +55,16 @@ private void Start() } public void Setup() { - twitchClient = FindObjectOfType(); - chatClient = twitchClient.client; - chatJoinedChannel = twitchClient.joinedChannel; - botJoinedChannel = twitchClient.botChannel; + TwitchClient = FindObjectOfType(); + ChatClient = TwitchClient.Client; + ChatJoinedChannel = TwitchClient.JoinedChannel; + BotJoinedChannel = TwitchClient.BotChannel; } //Help - provids a list of commands public void Help(Arrrgs e) { - if (chatClient == null) + if (ChatClient == null) { Setup(); //chatClient.SendMessage(chatJoinedChannel, help); @@ -78,13 +78,13 @@ public void Help(Arrrgs e) private void AttemptToHelp(Arrrgs e) { - chatClient.SendMessage(chatJoinedChannel, help); + ChatClient.SendMessage(ChatJoinedChannel, help); } //Join - check if player data exists - if not create empty player data entry public void Join(Arrrgs e) { - if (chatClient == null) + if (ChatClient == null) { Setup(); AttemptToJoin(e); @@ -96,14 +96,14 @@ public void Join(Arrrgs e) } private void AttemptToJoin(Arrrgs e) { - if (gameDataScript.CheckIfPlayerExists(e.userID)) + if (GameDataScript.CheckIfPlayerExists(e.UserID)) { - chatClient.SendMessage(chatJoinedChannel, e.displayName + playerAlreadyExists); + ChatClient.SendMessage(ChatJoinedChannel, e.DisplayName + playerAlreadyExists); } else { - gameDataScript.CreateNewPlayerEntry(e); - chatClient.SendMessage(chatJoinedChannel, e.displayName + playerEntryAdded); + GameDataScript.CreateNewPlayerEntry(e); + ChatClient.SendMessage(ChatJoinedChannel, e.DisplayName + playerEntryAdded); } } @@ -111,7 +111,7 @@ private void AttemptToJoin(Arrrgs e) //Money - checks if player data exists - if so returns how much money they have in chat public void money(Arrrgs e) { - if (chatClient == null) + if (ChatClient == null) { Setup(); AttemptToCheckMoney(e); @@ -123,16 +123,16 @@ public void money(Arrrgs e) } private void AttemptToCheckMoney(Arrrgs e) { - string playerID = e.userID; - string userName = e.displayName; + string playerID = e.UserID; + string userName = e.DisplayName; - if (gameDataScript.CheckIfPlayerExists(playerID)) + if (GameDataScript.CheckIfPlayerExists(playerID)) { - chatClient.SendMessage(chatJoinedChannel, userName + " money: " + gameDataScript.CheckPlayerMoney(playerID)); + ChatClient.SendMessage(ChatJoinedChannel, userName + " money: " + GameDataScript.CheckPlayerMoney(playerID)); } else { - chatClient.SendMessage(chatJoinedChannel, userName + noPlayerEntryExists); + ChatClient.SendMessage(ChatJoinedChannel, userName + noPlayerEntryExists); } } @@ -140,7 +140,7 @@ private void AttemptToCheckMoney(Arrrgs e) //Buy - checks if player data exists - if so checks if has enough money - if so then unlock skin public void Buy(Arrrgs e) { - if (chatClient == null) + if (ChatClient == null) { Setup(); AttemptToBuy(e); @@ -153,57 +153,57 @@ public void Buy(Arrrgs e) public void AttemptToBuy(Arrrgs e) { string commonName = ""; - string playerID = e.userID; //Command.ChatMessage.UserId; - string playerUserName = e.displayName; //Command.ChatMessage.Username; - if (gameDataScript.CheckIfPlayerExists(playerID)) + string playerID = e.UserID; //Command.ChatMessage.UserId; + string playerUserName = e.DisplayName; //Command.ChatMessage.Username; + if (GameDataScript.CheckIfPlayerExists(playerID)) { - commonName = e.commandArgs; + commonName = e.CommandArgs; /* for (int index = 0; index < e.Command.ArgumentsAsList.Count; index++) { commonName += e.Command.ArgumentsAsList[index].ToLower(); }*/ Debug.Log(commonName); - if (marbleList.DoesMarbleCommonNameExist(commonName)) + if (MarbleList.DoesMarbleCommonNameExist(commonName)) { - if (shop.MarbleNamesInShop(commonName)) + if (Shop.MarbleNamesInShop(commonName)) { - int playerMoney = gameDataScript.CheckPlayerMoney(playerID); - int marbleCost = marbleList.GetMarbleCostFromCommonName(commonName); - int marbleCode = marbleList.GetMarbleCodeFromCommonName(commonName); - if (gameDataScript.IsSkinUnlocked(playerID, marbleCode)) + int playerMoney = GameDataScript.CheckPlayerMoney(playerID); + int marbleCost = MarbleList.GetMarbleCostFromCommonName(commonName); + int marbleCode = MarbleList.GetMarbleCodeFromCommonName(commonName); + if (GameDataScript.IsSkinUnlocked(playerID, marbleCode)) { - chatClient.SendMessage(chatJoinedChannel, playerUserName + skinAlreadyUnlocked1 + commonName + skinAlreadyUnlocked2); + ChatClient.SendMessage(ChatJoinedChannel, playerUserName + skinAlreadyUnlocked1 + commonName + skinAlreadyUnlocked2); } else { if (playerMoney >= marbleCost) { - gameDataScript.SubtractMoneyFromPlayerID(marbleCost, playerID); - gameDataScript.UnlockSkinForPlayer(playerID, marbleCode); - int currentMoney = gameDataScript.CheckPlayerMoney(playerID); - chatClient.SendMessage(chatJoinedChannel, playerUserName + unlockedMarble1 + + GameDataScript.SubtractMoneyFromPlayerID(marbleCost, playerID); + GameDataScript.UnlockSkinForPlayer(playerID, marbleCode); + int currentMoney = GameDataScript.CheckPlayerMoney(playerID); + ChatClient.SendMessage(ChatJoinedChannel, playerUserName + unlockedMarble1 + commonName + unlockedMarble2 + commonName + unlockedMarble3 + unlockedMarble4 + currentMoney); } else { - chatClient.SendMessage(chatJoinedChannel, playerUserName + notEnoughMoney + commonName); + ChatClient.SendMessage(ChatJoinedChannel, playerUserName + notEnoughMoney + commonName); } } } else { - chatClient.SendMessage(chatJoinedChannel, commonName + marbleNotInShop); + ChatClient.SendMessage(ChatJoinedChannel, commonName + marbleNotInShop); } } else { - chatClient.SendMessage(chatJoinedChannel, playerUserName + noMarbleWithNameExists); + ChatClient.SendMessage(ChatJoinedChannel, playerUserName + noMarbleWithNameExists); } } else { - chatClient.SendMessage(chatJoinedChannel, playerUserName + noPlayerEntryExists); + ChatClient.SendMessage(ChatJoinedChannel, playerUserName + noPlayerEntryExists); } } @@ -211,7 +211,7 @@ public void AttemptToBuy(Arrrgs e) //Equip - checks if player data exists - checks if they own that skin - equips the skin public void Equip(Arrrgs e) { - if (chatClient == null) + if (ChatClient == null) { Setup(); AttemptToEquip(e); @@ -224,39 +224,39 @@ public void Equip(Arrrgs e) private void AttemptToEquip(Arrrgs e) { string commonName = ""; - string playerID = e.userID; - string playerUserName = e.displayName; - commonName = e.commandArgs; + string playerID = e.UserID; + string playerUserName = e.DisplayName; + commonName = e.CommandArgs; /* for (int index = 0; index < e.Command.ArgumentsAsList.Count; index++) { commonName += e.Command.ArgumentsAsList[index].ToLower(); }*/ - if (gameDataScript.CheckIfPlayerExists(playerID)) + if (GameDataScript.CheckIfPlayerExists(playerID)) { - if (marbleList.DoesMarbleCommonNameExist(commonName)) + if (MarbleList.DoesMarbleCommonNameExist(commonName)) { - int marbleCode = marbleList.GetMarbleCodeFromCommonName(commonName); - if (gameDataScript.IsSkinUnlocked(playerID, marbleCode)) + int marbleCode = MarbleList.GetMarbleCodeFromCommonName(commonName); + if (GameDataScript.IsSkinUnlocked(playerID, marbleCode)) { - gameDataScript.SetPlayerEquipSkin(playerID, marbleCode); - chatClient.SendMessage(chatJoinedChannel, playerUserName + ", you now have the " + commonName + " skin in use."); + GameDataScript.SetPlayerEquipSkin(playerID, marbleCode); + ChatClient.SendMessage(ChatJoinedChannel, playerUserName + ", you now have the " + commonName + " skin in use."); Debug.Log(playerUserName + " equipt " + commonName); } else { - chatClient.SendMessage(chatJoinedChannel, playerUserName + dontOwnThatSkin); + ChatClient.SendMessage(ChatJoinedChannel, playerUserName + dontOwnThatSkin); } } else { - chatClient.SendMessage(chatJoinedChannel, playerUserName + noMarbleWithNameExists); + ChatClient.SendMessage(ChatJoinedChannel, playerUserName + noMarbleWithNameExists); } } else { - chatClient.SendMessage(chatJoinedChannel, playerUserName + noPlayerEntryExists); + ChatClient.SendMessage(ChatJoinedChannel, playerUserName + noPlayerEntryExists); } } @@ -264,7 +264,7 @@ private void AttemptToEquip(Arrrgs e) //Equipted - checks if player data exists - checks what skin they have equipped - tells them what skin that is public void InUse(Arrrgs e) { - if (chatClient == null) + if (ChatClient == null) { Setup(); AttemptToInUse(e); @@ -276,24 +276,24 @@ public void InUse(Arrrgs e) } private void AttemptToInUse(Arrrgs e) { - string playerID = e.userID; - string playerUserName = e.displayName; + string playerID = e.UserID; + string playerUserName = e.DisplayName; - if (gameDataScript.CheckIfPlayerExists(playerID)) + if (GameDataScript.CheckIfPlayerExists(playerID)) { - int marbleCode = gameDataScript.GetPlayerEquipSkin(playerID); - string commonName = marbleList.GetCommonNameFromMarbleCode(marbleCode); - chatClient.SendMessage(chatJoinedChannel, playerUserName + " is using the " + commonName + " skin!"); + int marbleCode = GameDataScript.GetPlayerEquipSkin(playerID); + string commonName = MarbleList.GetCommonNameFromMarbleCode(marbleCode); + ChatClient.SendMessage(ChatJoinedChannel, playerUserName + " is using the " + commonName + " skin!"); } else { - chatClient.SendMessage(chatJoinedChannel, playerUserName + noPlayerEntryExists); + ChatClient.SendMessage(ChatJoinedChannel, playerUserName + noPlayerEntryExists); } } public void Play(Arrrgs e) { - if (chatClient == null) + if (ChatClient == null) { Setup(); AttemptToPlay(e); @@ -306,22 +306,22 @@ public void Play(Arrrgs e) private void AttemptToPlay(Arrrgs e) { - string userID = e.userID; - string displayName = e.displayName; + string userID = e.UserID; + string displayName = e.DisplayName; - if (gameDataScript.CheckIfPlayerExists(userID)) + if (GameDataScript.CheckIfPlayerExists(userID)) { - if (gameController.currentState == gameState.gametime) + if (GameController.CurrentState == gameState.gametime) { - if (gameController.currentGameMode == gameMode.longjump) + if (GameController.CurrentGameMode == gameMode.longjump) { - jumpManager.CreateMarbleAndJump(e); + JumpManager.CreateMarbleAndJump(e); } - else if (gameController.currentGameMode == gameMode.highjump) + else if (GameController.CurrentGameMode == gameMode.highjump) { - jumpManager.CreateMarbleAndHighJump(e); + JumpManager.CreateMarbleAndHighJump(e); } - else if (gameController.currentGameMode == gameMode.race) + else if (GameController.CurrentGameMode == gameMode.race) { } @@ -333,7 +333,7 @@ private void AttemptToPlay(Arrrgs e) } else { - chatClient.SendMessage(chatJoinedChannel, displayName + noPlayerEntryExists); + ChatClient.SendMessage(ChatJoinedChannel, displayName + noPlayerEntryExists); } } //AcceptWhispers @@ -370,7 +370,7 @@ public void AcceptWhispers(OnChatCommandReceivedArgs e) */ public void Skins(Arrrgs e) { - if (chatClient == null) + if (ChatClient == null) { Setup(); AttemptToSkins(e); @@ -382,40 +382,40 @@ public void Skins(Arrrgs e) } public void AttemptToSkins(Arrrgs e) { - string userID = e.userID; - string displayName = e.displayName; + string userID = e.UserID; + string displayName = e.DisplayName; - if (gameDataScript.CheckIfPlayerExists(userID)) + if (GameDataScript.CheckIfPlayerExists(userID)) { - string skinsPlayerOwns = gameDataScript.CheckSkins(e); + string skinsPlayerOwns = GameDataScript.CheckSkins(e); StartCoroutine(SkinsMessege(skinsPlayerOwns)); - chatClient.SendMessage(chatJoinedChannel, "https://www.twitch.tv/simpagamebot"); + ChatClient.SendMessage(ChatJoinedChannel, "https://www.twitch.tv/simpagamebot"); } else { - chatClient.SendMessage(chatJoinedChannel, displayName + noPlayerEntryExists); + ChatClient.SendMessage(ChatJoinedChannel, displayName + noPlayerEntryExists); } } IEnumerator SkinsMessege(string skinsList) { yield return new WaitForSeconds(7); - chatClient.SendMessage(botJoinedChannel, skinsList); + ChatClient.SendMessage(BotJoinedChannel, skinsList); } public void AkaiEasterEgg(string name) { - chatClient.SendMessage(chatJoinedChannel, name + secretMsg); + ChatClient.SendMessage(ChatJoinedChannel, name + secretMsg); } public void Rotate(Arrrgs e) //Temporary command!!! TODO REMOVE { - if (e.userID == "73184979") + if (e.UserID == "73184979") { FindObjectOfType().ResetShop(); } } public void Give(Arrrgs e) { - if (chatClient == null) + if (ChatClient == null) { Setup(); AttemptToGive(e); @@ -427,63 +427,63 @@ public void Give(Arrrgs e) } public void AttemptToGive(Arrrgs e) { - if (e.multiCommand != null) + if (e.MultiCommand != null) { - string userID = e.userID; - string displayName = e.displayName; - if (gameDataScript.CheckIfPlayerExists(userID)) + string userID = e.UserID; + string displayName = e.DisplayName; + if (GameDataScript.CheckIfPlayerExists(userID)) { - if (e.multiCommand.Count >= 2) + if (e.MultiCommand.Count >= 2) { - string otherPlayerDisplayName = e.multiCommand[0].TrimStart('@'); - string PersonGettingMoney = gameDataScript.ConvertCommonNameToUserID(otherPlayerDisplayName); + string otherPlayerDisplayName = e.MultiCommand[0].TrimStart('@'); + string PersonGettingMoney = GameDataScript.ConvertCommonNameToUserID(otherPlayerDisplayName); if (String.IsNullOrEmpty(PersonGettingMoney)) { - chatClient.SendMessage(chatJoinedChannel, cantGiveMoneyToPlayer1 + otherPlayerDisplayName + cantGiveMoneyToPlayer2); + ChatClient.SendMessage(ChatJoinedChannel, cantGiveMoneyToPlayer1 + otherPlayerDisplayName + cantGiveMoneyToPlayer2); } else { - if (gameDataScript.CheckIfPlayerExists(PersonGettingMoney) && - gameDataScript.CheckPlayerIDMatchesUserName(PersonGettingMoney, otherPlayerDisplayName)) + if (GameDataScript.CheckIfPlayerExists(PersonGettingMoney) && + GameDataScript.CheckPlayerIDMatchesUserName(PersonGettingMoney, otherPlayerDisplayName)) { int cost; //money = int.TryParse((e.multiCommand[1]), money); - if (int.TryParse((e.multiCommand[1]), out cost)) + if (int.TryParse((e.MultiCommand[1]), out cost)) { - int currentMoney = gameDataScript.CheckPlayerMoney(userID); + int currentMoney = GameDataScript.CheckPlayerMoney(userID); if (currentMoney >= cost) { if (cost > 0 && cost <= 10000) { - gameDataScript.SubtractMoneyFromPlayerID(cost, userID); - gameDataScript.AddMoneyToPlayerID(cost, PersonGettingMoney); - chatClient.SendMessage(chatJoinedChannel, displayName + " gave " + e.multiCommand[0] + " " + cost); + GameDataScript.SubtractMoneyFromPlayerID(cost, userID); + GameDataScript.AddMoneyToPlayerID(cost, PersonGettingMoney); + ChatClient.SendMessage(ChatJoinedChannel, displayName + " gave " + e.MultiCommand[0] + " " + cost); } else { - chatClient.SendMessage(chatJoinedChannel, displayName + " you can only give give between 1 and 10000"); + ChatClient.SendMessage(ChatJoinedChannel, displayName + " you can only give give between 1 and 10000"); } } else { - chatClient.SendMessage(chatJoinedChannel, displayName + " you can't give money you dont have."); + ChatClient.SendMessage(ChatJoinedChannel, displayName + " you can't give money you dont have."); } } } else { - chatClient.SendMessage(chatJoinedChannel, cantGiveMoneyToPlayer1 + e.multiCommand[0] + cantGiveMoneyToPlayer2); + ChatClient.SendMessage(ChatJoinedChannel, cantGiveMoneyToPlayer1 + e.MultiCommand[0] + cantGiveMoneyToPlayer2); } } } else { - chatClient.SendMessage(chatJoinedChannel, displayName + " to give use !give [PlayerName] [Amount]"); + ChatClient.SendMessage(ChatJoinedChannel, displayName + " to give use !give [PlayerName] [Amount]"); } } else { - chatClient.SendMessage(chatJoinedChannel, displayName + noPlayerEntryExists); + ChatClient.SendMessage(ChatJoinedChannel, displayName + noPlayerEntryExists); } } } diff --git a/Assets/Scripts/DataManager.cs b/Assets/Scripts/DataManager.cs index f4f979d..ea3182d 100644 --- a/Assets/Scripts/DataManager.cs +++ b/Assets/Scripts/DataManager.cs @@ -6,13 +6,13 @@ public class DataManager : MonoBehaviour { - public PlayerData data; - public string file = "GameData.txt"; + public PlayerData Data; + public string File = "GameData.txt"; public void Save() { - Debug.Log(data); - string json = JsonConvert.SerializeObject(data); + Debug.Log(Data); + string json = JsonConvert.SerializeObject(Data); //WriteToFile(file, json); System.IO.File.WriteAllText(@"D:\SimpaGameBotData\GameData.txt", json); } @@ -26,15 +26,15 @@ public void NewSave(Dictionary gameData) public void Backup(Dictionary gameData) { //Code saves at this point to our text file - Debug.Log(data); + Debug.Log(Data); string json = JsonConvert.SerializeObject(gameData, Formatting.Indented); System.IO.File.WriteAllText(@"D:\SimpaGameBotData\GameData.txt", json); } public string Load() { - data = new PlayerData(); - string json = ReadFromFile(file); + Data = new PlayerData(); + string json = ReadFromFile(File); return json; //JsonUtility.FromJsonOverwrite(json, data); } @@ -58,7 +58,7 @@ private string GetFilePath(string filename) private string ReadFromFile(string fileName) { string path = GetFilePath(fileName); - if (File.Exists(path)) + if (System.IO.File.Exists(path)) { using (StreamReader reader = new StreamReader(path)) { diff --git a/Assets/Scripts/GameController.cs b/Assets/Scripts/GameController.cs index 0c57582..663b3b2 100644 --- a/Assets/Scripts/GameController.cs +++ b/Assets/Scripts/GameController.cs @@ -8,40 +8,40 @@ public enum gameState { downtime, cutscene, gametime }; public enum gameMode { longjump, highjump, race }; public class GameController : MonoBehaviour { - public DataManager dataManager; - public gameState currentState; - public gameMode currentGameMode; - [SerializeField] TextMeshPro gameStateText; - JumpManager jumpManager; - public Shop gameShop; - [SerializeField] Null nullCharacter; - [SerializeField] Timer timer; - [SerializeField] Shop shop; + public DataManager DataManager; + public gameState CurrentState; + public gameMode CurrentGameMode; + [SerializeField] TextMeshPro GameStateText; + JumpManager JumpManager; + public Shop GameShop; + [SerializeField] Null NullCharacter; + [SerializeField] Timer Timer; + [SerializeField] Shop Shop; //The game has states Downtime, Cutscene, Gametime //Gametime can link to different game modes longJump, highJump, race void Start() { - currentGameMode = gameMode.longjump; - currentState = gameState.downtime; - jumpManager = FindObjectOfType(); + CurrentGameMode = gameMode.longjump; + CurrentState = gameState.downtime; + JumpManager = FindObjectOfType(); UpdateGameStateText(); } private void UpdateGameStateText() { - Debug.Log(currentState); - switch (currentState) + Debug.Log(CurrentState); + switch (CurrentState) { case gameState.downtime: - gameStateText.text = "Down Time"; + GameStateText.text = "Down Time"; break; case gameState.cutscene: - gameStateText.text = "Cut Scene"; + GameStateText.text = "Cut Scene"; break; case gameState.gametime: - gameStateText.text = "Game Time"; + GameStateText.text = "Game Time"; break; default: break; @@ -52,37 +52,37 @@ void Update() { if (Input.GetKeyDown("space")) { - jumpManager.DestroyMarbles(); + JumpManager.DestroyMarbles(); } } public void TriggerCutscene() { - currentState = gameState.cutscene; - gameShop.gameObject.SetActive(false); - nullCharacter.NullStartCutScene(); + CurrentState = gameState.cutscene; + GameShop.gameObject.SetActive(false); + NullCharacter.NullStartCutScene(); UpdateGameStateText(); } public void TriggerGame() { - currentState = gameState.gametime; + CurrentState = gameState.gametime; UpdateGameStateText(); - timer.ResetGameTimer(); + Timer.ResetGameTimer(); } public void TriggerDowntime() { - shop.ResetShop(); - currentState = gameState.downtime; + Shop.ResetShop(); + CurrentState = gameState.downtime; UpdateGameStateText(); - timer.ResetDowntimeTimer(); - StartCoroutine(jumpManager.DestroyMarbles()); - nullCharacter.HideCharacter(); - gameShop.gameObject.SetActive(true); + Timer.ResetDowntimeTimer(); + StartCoroutine(JumpManager.DestroyMarbles()); + NullCharacter.HideCharacter(); + GameShop.gameObject.SetActive(true); } public string FindGameState() { - Debug.Log(currentGameMode); - switch (currentGameMode) + Debug.Log(CurrentGameMode); + switch (CurrentGameMode) { case gameMode.longjump: return "Long Jump"; diff --git a/Assets/Scripts/GameData.cs b/Assets/Scripts/GameData.cs index c8daef2..aff6d70 100644 --- a/Assets/Scripts/GameData.cs +++ b/Assets/Scripts/GameData.cs @@ -9,20 +9,20 @@ public class GameData : MonoBehaviour { //game data is in the form keys (unique ID) and data in the form of Player Data (see Player Data Script) - Dictionary gameData = new Dictionary(); - public DataManager dataManager; - MarbleList marbleList; - List playerDataList;//GameData.values() - List gameDataKeyList; + Dictionary Data = new Dictionary(); + public DataManager Manager; + MarbleList MarbleList; + List PlayerDataList;//GameData.values() + List GameDataKeyList; void Start() { //Load game data at start of game from JSON - Dictionary deserializedProduct = JsonConvert.DeserializeObject>(dataManager.Load()); - gameData = deserializedProduct; - marbleList = FindObjectOfType(); - gameData = marbleList.AddNewMarblesToGameData(gameData); - dataManager.NewSave(gameData); + Dictionary deserializedProduct = JsonConvert.DeserializeObject>(Manager.Load()); + Data = deserializedProduct; + MarbleList = FindObjectOfType(); + Data = MarbleList.AddNewMarblesToGameData(Data); + Manager.NewSave(Data); } void Update() @@ -30,9 +30,9 @@ void Update() if (Input.GetKeyDown(KeyCode.Alpha7)) { PlayerData tempData = new PlayerData(); - tempData.money = 0; - tempData.skins = FindObjectOfType().getEmptyAllMarbleDictionary(); - gameData.Add("123456", tempData); + tempData.Money = 0; + tempData.Skins = FindObjectOfType().getEmptyAllMarbleDictionary(); + Data.Add("123456", tempData); //var convertedDictionary = FindObjectOfType().getEmptyAllSpritesDictionary().ToDictionary(item => item.Key.ToString(), item => item.Value.ToString()); Debug.Log("pressing 7"); //JsonConvert.SerializeObject(dataManager); @@ -46,7 +46,7 @@ void Update() public bool CheckIfPlayerExists(string playerID) { - if (gameData.ContainsKey(playerID)) + if (Data.ContainsKey(playerID)) { return true; } @@ -58,34 +58,34 @@ public bool CheckIfPlayerExists(string playerID) public void CreateNewPlayerEntry(Arrrgs e) { PlayerData tempData = new PlayerData(); - tempData.money = 0; - tempData.skins = FindObjectOfType().getEmptyAllMarbleDictionary(); - tempData.equiptSkin = 0; - tempData.playerName = e.displayName; - tempData.isSubscribed = false; - gameData.Add(e.userID, tempData); + tempData.Money = 0; + tempData.Skins = FindObjectOfType().getEmptyAllMarbleDictionary(); + tempData.ActiveSkin = 0; + tempData.PlayerName = e.DisplayName; + tempData.IsSubscribed = false; + Data.Add(e.UserID, tempData); SaveGameDataToTXT(); Debug.Log("GAME DATA SUCCESFULLY SAVED!!!!"); } public void AddMoneyToPlayerID(int money, string playerID) { - gameData[playerID].money += money; + Data[playerID].Money += money; SaveGameDataToTXT(); Debug.Log("GAME DATA SUCCESFULLY SAVED!!!!"); } public void SubtractMoneyFromPlayerID(int money, string playerID) { - gameData[playerID].money -= money; + Data[playerID].Money -= money; SaveGameDataToTXT(); Debug.Log("GAME DATA SUCCESFULLY SAVED!!!!"); } public int CheckPlayerMoney(string playerID) { - return gameData[playerID].money; + return Data[playerID].Money; } public bool IsSkinUnlocked(string playerID, int skinIndex) { - if (gameData[playerID].skins[skinIndex] == true) + if (Data[playerID].Skins[skinIndex] == true) { return true; } @@ -96,41 +96,41 @@ public bool IsSkinUnlocked(string playerID, int skinIndex) } public void UnlockSkinForPlayer(string playerID, int skinIndex) { - gameData[playerID].skins[skinIndex] = true; + Data[playerID].Skins[skinIndex] = true; SaveGameDataToTXT(); Debug.Log("GAME DATA SUCCESFULLY SAVED!!!!"); } public void SetPlayerEquipSkin(string playerID, int skinIndex) { - gameData[playerID].equiptSkin = skinIndex; + Data[playerID].ActiveSkin = skinIndex; SaveGameDataToTXT(); Debug.Log("GAME DATA SUCCESFULLY SAVED!!!!"); } public int GetPlayerEquipSkin(string playerID) { - return gameData[playerID].equiptSkin; + return Data[playerID].ActiveSkin; } public void SaveGameDataToTXT() { - dataManager.NewSave(gameData); + Manager.NewSave(Data); Debug.Log("GAME DATA SUCCESSFULLY SAVED!!!!"); } public bool CheckIfPlayerSubscribedToWhispers(string playerID) { - return gameData[playerID].isSubscribed; + return Data[playerID].IsSubscribed; //Returns true if player subscribed } public string CheckSkins(Arrrgs e) { - string playerID = e.userID; - string playerName = e.displayName; + string playerID = e.UserID; + string playerName = e.DisplayName; string skinList = playerName + ": "; - for (int i = 0; i < gameData[playerID].skins.Count; i++) + for (int i = 0; i < Data[playerID].Skins.Count; i++) { - if (gameData[playerID].skins[i] == true) + if (Data[playerID].Skins[i] == true) { - skinList += marbleList.marbleCodeToCommonName[i] + ", "; + skinList += MarbleList.MarbleCodeToCommonName[i] + ", "; } } return skinList; @@ -138,20 +138,20 @@ public string CheckSkins(Arrrgs e) public string ConvertCommonNameToUserID(string commonName) { //var myKey = dictionary.FirstOrDefault(x => x.Value == "one").Key; - playerDataList = new List(gameData.Values); - for (int i = 0; i < playerDataList.Count; i++) + PlayerDataList = new List(Data.Values); + for (int i = 0; i < PlayerDataList.Count; i++) { - if (playerDataList[i].playerName.Equals(commonName, System.StringComparison.CurrentCultureIgnoreCase)) + if (PlayerDataList[i].PlayerName.Equals(commonName, System.StringComparison.CurrentCultureIgnoreCase)) { - gameDataKeyList = new List(gameData.Keys); - return gameDataKeyList[i]; + GameDataKeyList = new List(Data.Keys); + return GameDataKeyList[i]; } } return ""; } public bool CheckPlayerIDMatchesUserName(string userID, string name) { - if (gameData[userID].playerName == name) + if (Data[userID].PlayerName == name) { return true; } diff --git a/Assets/Scripts/JumpManager.cs b/Assets/Scripts/JumpManager.cs index d02dc5c..ecc43a2 100644 --- a/Assets/Scripts/JumpManager.cs +++ b/Assets/Scripts/JumpManager.cs @@ -10,65 +10,65 @@ public class JumpManager : MonoBehaviour { // I have syntactic sugar - [SerializeField] GameObject marbleObject; - [SerializeField] Transform longJumpLocation; - MarbleList marbleList; - MarbleObject playerMarble; - SpriteRenderer playerSpriteRenderer; - GameData gameData; - List longJumpedPlayers = new List(); - List highJumpedPlayers = new List(); - public int orderInLayer; - public int costToReroll = 50; + [SerializeField] GameObject MarbleObject; + [SerializeField] Transform LongJumpLocation; + MarbleList MarbleList; + MarbleObject PlayerMarble; + SpriteRenderer PlayerSpriteRenderer; + GameData GameData; + List LongJumpedPlayers = new List(); + List HighJumpedPlayers = new List(); + public int OrderInLayer; + public int CostToReroll = 50; private void Start() { - gameData = FindObjectOfType(); - marbleList = FindObjectOfType(); - orderInLayer = 0; + GameData = FindObjectOfType(); + MarbleList = FindObjectOfType(); + OrderInLayer = 0; Dictionary kvp = new Dictionary(); } public void ResetLongJumpedPlayers() { - longJumpedPlayers = new List(); + LongJumpedPlayers = new List(); } public void ResetHighJumpedPlayers() { - highJumpedPlayers = new List(); + HighJumpedPlayers = new List(); } public void CreateMarbleAndJump(Arrrgs e) { - string userID = e.userID; - string displayName = e.displayName; + string userID = e.UserID; + string displayName = e.DisplayName; //if the player has not jumped yet - if (!(longJumpedPlayers.Contains(userID))) + if (!(LongJumpedPlayers.Contains(userID))) { - longJumpedPlayers.Add(userID); - var mb = Instantiate(marbleObject, longJumpLocation.position, transform.rotation); + LongJumpedPlayers.Add(userID); + var mb = Instantiate(MarbleObject, LongJumpLocation.position, transform.rotation); mb.transform.SetParent(transform); - mb.GetComponentInChildren().sortingOrder = orderInLayer; - orderInLayer++; - playerMarble = mb.GetComponentInChildren(); - playerMarble.playerName.text = displayName; - int marbleIndex = gameData.GetPlayerEquipSkin(userID); - GameObject marbleGameObject = marbleList.GetMarbleFromMarbleCode(marbleIndex); - playerMarble.gameMarbleSprite.sprite = marbleGameObject.GetComponent().marbleSprite; - playerMarble.playerID = userID; + mb.GetComponentInChildren().sortingOrder = OrderInLayer; + OrderInLayer++; + PlayerMarble = mb.GetComponentInChildren(); + PlayerMarble.PlayerName.text = displayName; + int marbleIndex = GameData.GetPlayerEquipSkin(userID); + GameObject marbleGameObject = MarbleList.GetMarbleFromMarbleCode(marbleIndex); + PlayerMarble.GameMarbleSprite.sprite = marbleGameObject.GetComponent().MarbleSprite; + PlayerMarble.PlayerId = userID; } else //if player has already rolled { - if (gameData.CheckPlayerMoney(userID) > costToReroll) + if (GameData.CheckPlayerMoney(userID) > CostToReroll) { MarbleObject[] allMarbles = GetComponentsInChildren(); foreach (var marble in allMarbles) { - if (marble.playerID == userID && !(marble.isrolling)) + if (marble.PlayerId == userID && !(marble.IsRolling)) { Destroy(marble.transform.parent.gameObject); - gameData.SubtractMoneyFromPlayerID(costToReroll, userID); - longJumpedPlayers.Remove(userID); + GameData.SubtractMoneyFromPlayerID(CostToReroll, userID); + LongJumpedPlayers.Remove(userID); CreateMarbleAndJump(e); } } @@ -80,21 +80,21 @@ public void CreateMarbleAndJump(Arrrgs e) public void CreateMarbleAndHighJump(Arrrgs e) { - string userID = e.userID; - string displayName = e.displayName; - if (!(highJumpedPlayers.Contains(userID))) + string userID = e.UserID; + string displayName = e.DisplayName; + if (!(HighJumpedPlayers.Contains(userID))) { - highJumpedPlayers.Add(userID); - var mb = Instantiate(marbleObject, longJumpLocation.position, transform.rotation); + HighJumpedPlayers.Add(userID); + var mb = Instantiate(MarbleObject, LongJumpLocation.position, transform.rotation); mb.transform.SetParent(transform); - mb.GetComponentInChildren().sortingOrder = orderInLayer; - orderInLayer++; - playerMarble = mb.GetComponentInChildren(); - playerMarble.playerName.text = displayName; - int marbleIndex = gameData.GetPlayerEquipSkin(userID); - GameObject marbleGameObject = marbleList.GetMarbleFromMarbleCode(marbleIndex); - playerMarble.gameMarbleSprite.sprite = marbleGameObject.GetComponent().marbleSprite; - playerMarble.playerID = userID; + mb.GetComponentInChildren().sortingOrder = OrderInLayer; + OrderInLayer++; + PlayerMarble = mb.GetComponentInChildren(); + PlayerMarble.PlayerName.text = displayName; + int marbleIndex = GameData.GetPlayerEquipSkin(userID); + GameObject marbleGameObject = MarbleList.GetMarbleFromMarbleCode(marbleIndex); + PlayerMarble.GameMarbleSprite.sprite = marbleGameObject.GetComponent().MarbleSprite; + PlayerMarble.PlayerId = userID; } } @@ -104,7 +104,7 @@ public IEnumerator DestroyMarbles() foreach (var marble in allMarbles) { - while (marble.isrolling == true) + while (marble.IsRolling == true) { yield return new WaitForSeconds(0.5f); } @@ -114,8 +114,8 @@ public IEnumerator DestroyMarbles() { Destroy(child.gameObject); } - longJumpedPlayers = new List(); - orderInLayer = 0; + LongJumpedPlayers = new List(); + OrderInLayer = 0; } diff --git a/Assets/Scripts/Marble.cs b/Assets/Scripts/Marble.cs index bb10e60..9f157eb 100644 --- a/Assets/Scripts/Marble.cs +++ b/Assets/Scripts/Marble.cs @@ -5,16 +5,16 @@ public class Marble : MonoBehaviour { //All the data about the ball I need to make dictionary entry - public int marbleCode; //unique to each ball, not for player to see - public string commonName; //name for player to see and call, not nessesarily unique - public int cost; - public int rarity; //use scale 1-4 inclusive, used to determine cost and chance to appear in the shop - public Sprite marbleSprite; + public int MarbleCode; //unique to each ball, not for player to see + public string CommonName; //name for player to see and call, not nessesarily unique + public int Cost; + public int Rarity; //use scale 1-4 inclusive, used to determine cost and chance to appear in the shop + public Sprite MarbleSprite; void Start() { - marbleSprite = GetComponent().sprite; + MarbleSprite = GetComponent().sprite; } void Update() diff --git a/Assets/Scripts/MarbleList.cs b/Assets/Scripts/MarbleList.cs index 125cbbe..a6a88e6 100644 --- a/Assets/Scripts/MarbleList.cs +++ b/Assets/Scripts/MarbleList.cs @@ -4,28 +4,28 @@ public class MarbleList : MonoBehaviour { - [SerializeField] int minCommon = 0; - [SerializeField] int maxCommon = 100; - [SerializeField] int maxRare = 400; - [SerializeField] int maxEpic = 1000; - [SerializeField] int maxLegendary = 2000; + [SerializeField] int MinimumCommon = 0; + [SerializeField] int MaximumCommon = 100; + [SerializeField] int MaximumRare = 400; + [SerializeField] int MaximumEpic = 1000; + [SerializeField] int MaxLegendary = 2000; - public List marbleArraySetToFalse = new List(); + public List MarbleArraySetToFalse = new List(); //Every string needs to be the unique code for the marble //The bool will be true or false depending on if the player has unlocked that marble - public Dictionary marbleCommonNameToMarbleCode = new Dictionary(); + public Dictionary MarbleCommonNameToMarbleCode = new Dictionary(); //This is a way for the game to quickly look up what the unique marble code is for a common name - public Dictionary marbleCodeToCost = new Dictionary(); + public Dictionary MarbleCodeToCost = new Dictionary(); //This lets us look up the cost of a marble if we have the keycode - public Dictionary marbleCodeToRarity = new Dictionary(); + public Dictionary MarbleCodeToRarity = new Dictionary(); //This links a marble code to its cost - public Dictionary marbleCodeToCommonName = new Dictionary(); + public Dictionary MarbleCodeToCommonName = new Dictionary(); - [SerializeField] GameObject[] marbles; + [SerializeField] GameObject[] Marbles; //This game objects stores the balls uniquecode,skin(sprite),cost and rarity private void Start() @@ -33,28 +33,28 @@ private void Start() int code = 0; //the goal here is to make a dictionary of every ball's unique code and //have it initialized to be false (not unlocked) - foreach (var item in marbles) + foreach (var item in Marbles) { //We grab the ball script at the start so we can build our dictionaries at start var marble = item.GetComponent(); - marble.marbleCode = code; + marble.MarbleCode = code; //We first need to set the code before we build the dictionaries - marbleArraySetToFalse.Add(false); - marbleCommonNameToMarbleCode.Add((marble.commonName.ToLower()), marble.marbleCode); - marbleCodeToCommonName.Add(marble.marbleCode, (marble.commonName.ToLower())); - int cost = setMarbleCostsBasedOnRarity(marble.rarity); - marbleCodeToCost.Add(marble.marbleCode, cost); - marble.cost = cost; + MarbleArraySetToFalse.Add(false); + MarbleCommonNameToMarbleCode.Add((marble.CommonName.ToLower()), marble.MarbleCode); + MarbleCodeToCommonName.Add(marble.MarbleCode, (marble.CommonName.ToLower())); + int cost = setMarbleCostsBasedOnRarity(marble.Rarity); + MarbleCodeToCost.Add(marble.MarbleCode, cost); + marble.Cost = cost; code = code + 1; } //The player always has marble 0 unlocked - marbleArraySetToFalse[0] = true; + MarbleArraySetToFalse[0] = true; } public List getEmptyAllMarbleDictionary() { - return marbleArraySetToFalse; + return MarbleArraySetToFalse; } //At the start of the game there may be new marbles that need to be added to the game data //We need to count the difference between the current # and the existing number in any game data entry @@ -62,13 +62,13 @@ public List getEmptyAllMarbleDictionary() public Dictionary AddNewMarblesToGameData(Dictionary gameData) { Debug.Log("ADD NEW MARBLES CALLED"); - int currentNumberOfMarbles = marbles.Length; + int currentNumberOfMarbles = Marbles.Length; foreach (var kvp in gameData) { - while (kvp.Value.skins.Count < currentNumberOfMarbles) + while (kvp.Value.Skins.Count < currentNumberOfMarbles) { Debug.Log("new skin added"); - kvp.Value.skins.Add(false); + kvp.Value.Skins.Add(false); } } return gameData; @@ -76,7 +76,7 @@ public Dictionary AddNewMarblesToGameData(Dictionary GetMarblesForShop(int howManyMarbles) { - int marbleLength = marbles.Length; + int marbleLength = Marbles.Length; HashSet returnedMarbles = new HashSet(); do { int marbleCode = Random.Range(0, marbleLength); - returnedMarbles.Add(marbles[marbleCode]); + returnedMarbles.Add(Marbles[marbleCode]); } while (returnedMarbles.Count < howManyMarbles); foreach (var item in returnedMarbles) { - Debug.Log(item.GetComponent().commonName); + Debug.Log(item.GetComponent().CommonName); } return returnedMarbles; diff --git a/Assets/Scripts/MarbleObject.cs b/Assets/Scripts/MarbleObject.cs index f07c31a..a15b70a 100644 --- a/Assets/Scripts/MarbleObject.cs +++ b/Assets/Scripts/MarbleObject.cs @@ -13,31 +13,31 @@ public class MarbleObject : MonoBehaviour //FOR EVENTS: -go to appropriate starting location // -give instructions on where to go (should have random factor) // -Despawn Object - float longJumpForce; - [SerializeField] float highJumpForce = 1.0f; - Rigidbody2D rb; - public string playerID; - public SpriteRenderer gameMarbleSprite; - public TextMeshPro playerName; - float speed; - GameData gameData; - private string jumpDistance; - [SerializeField] TextFollow marbleText; - public bool isrolling; - Commands commands; + float LongJumpForce; + [SerializeField] float HighJumpForce = 1.0f; + Rigidbody2D Rigidbody; + public string PlayerId; + public SpriteRenderer GameMarbleSprite; + public TextMeshPro PlayerName; + float Speed; + GameData GameData; + private string JumpDistance; + [SerializeField] TextFollow MarbleText; + public bool IsRolling; + Commands Commands; - GameController gameController; - string gameState; + GameController GameController; + string GameState; void Start() { - isrolling = true; - rb = GetComponent(); + IsRolling = true; + Rigidbody = GetComponent(); FreeRotation(); - gameData = FindObjectOfType(); - gameController = FindObjectOfType(); - gameState = gameController.FindGameState(); - ActivateGameState(gameState); + GameData = FindObjectOfType(); + GameController = FindObjectOfType(); + GameState = GameController.FindGameState(); + ActivateGameState(GameState); } private void ActivateGameState(string gameState) @@ -61,19 +61,19 @@ public void LongJump() int percentage = UnityEngine.Random.Range(0, 10001); if (percentage == 10000) { - commands = FindObjectOfType(); - commands.AkaiEasterEgg(playerName.text); + Commands = FindObjectOfType(); + Commands.AkaiEasterEgg(PlayerName.text); } //Force acting on the marble float range = 4.8f + (((7.9f / 10000f) * percentage)); Debug.Log(range); float distance = ((100f / 10000f) * percentage); - jumpDistance = System.String.Format("{0:0.00}", distance); + JumpDistance = System.String.Format("{0:0.00}", distance); int score = Mathf.RoundToInt(distance); - longJumpForce = range; + LongJumpForce = range; //transform.position = new Vector3(-13.5f, -4.828952f, 0f); - rb.AddForce(new Vector2(longJumpForce, 0), ForceMode2D.Impulse); - StartCoroutine(WaitUntilMovementStops(playerID, score)); + Rigidbody.AddForce(new Vector2(LongJumpForce, 0), ForceMode2D.Impulse); + StartCoroutine(WaitUntilMovementStops(PlayerId, score)); } public void HighJump() @@ -82,8 +82,8 @@ public void HighJump() int percentage = UnityEngine.Random.Range(0, 10000); if (percentage == 10000) { - commands = FindObjectOfType(); - commands.AkaiEasterEgg(playerName.text); + Commands = FindObjectOfType(); + Commands.AkaiEasterEgg(PlayerName.text); } //Force acting on the marble /* @@ -95,7 +95,7 @@ public void HighJump() longJumpForce = range; //transform.position = new Vector3(-13.5f, -4.828952f, 0f); */ - rb.AddForce(new Vector2(0, -1 * (highJumpForce)), ForceMode2D.Impulse); + Rigidbody.AddForce(new Vector2(0, -1 * (HighJumpForce)), ForceMode2D.Impulse); //StartCoroutine(WaitUntilMovementStops(playerID, score)); @@ -104,23 +104,23 @@ IEnumerator WaitUntilMovementStops(string ID, int money) { do { - speed = rb.velocity.magnitude; + Speed = Rigidbody.velocity.magnitude; yield return new WaitForSeconds(0.5f); } - while (speed > 0); + while (Speed > 0); Debug.Log("MOVEMENTSTOPPED"); - marbleText.TriggerAnimation(); - gameData.AddMoneyToPlayerID(money, ID); - isrolling = false; + MarbleText.TriggerAnimation(); + GameData.AddMoneyToPlayerID(money, ID); + IsRolling = false; } public void LockRotation() { - rb.constraints = RigidbodyConstraints2D.FreezeRotation; + Rigidbody.constraints = RigidbodyConstraints2D.FreezeRotation; } public void FreeRotation() { - rb.constraints = RigidbodyConstraints2D.None; + Rigidbody.constraints = RigidbodyConstraints2D.None; } private void OnCollisionEnter2D(Collision2D otherCollider) { @@ -132,7 +132,7 @@ private void OnCollisionEnter2D(Collision2D otherCollider) } public void TransitionToScoreText() { - playerName.text += $"\n{jumpDistance}"; + PlayerName.text += $"\n{JumpDistance}"; //jumpDistance.ToString(); } } diff --git a/Assets/Scripts/Null.cs b/Assets/Scripts/Null.cs index 1644a09..f0a5641 100644 --- a/Assets/Scripts/Null.cs +++ b/Assets/Scripts/Null.cs @@ -5,7 +5,7 @@ public class Null : MonoBehaviour { //NULL is a charasmatic Lady bug who is the master of ceremony for the stream marble games! - [SerializeField] GameController gameController; + [SerializeField] GameController Controller; void Start() { gameObject.SetActive(false); @@ -20,7 +20,7 @@ public void NullStartCutScene() IEnumerator StartingDialogue() { yield return new WaitForSeconds(10); - gameController.TriggerGame(); + Controller.TriggerGame(); } public void HideCharacter() { diff --git a/Assets/Scripts/PlayerData.cs b/Assets/Scripts/PlayerData.cs index 31e54a6..670e957 100644 --- a/Assets/Scripts/PlayerData.cs +++ b/Assets/Scripts/PlayerData.cs @@ -5,11 +5,11 @@ public class PlayerData //DATA that is stored in a dictionary and can be accessed by looking at the key which will be a player chat ID { - public int money = 0; - public List skins = new List(); - public int equiptSkin = 0; - public string playerName; - public bool isSubscribed; + public int Money = 0; + public List Skins = new List(); + public int ActiveSkin = 0; + public string PlayerName; + public bool IsSubscribed; //Things I may want to add later bellow //public Dictionary sfx = new Dictionary(); //public Dictionary vfx = new Dictionary(); diff --git a/Assets/Scripts/Shop.cs b/Assets/Scripts/Shop.cs index 0314659..d3da4e2 100644 --- a/Assets/Scripts/Shop.cs +++ b/Assets/Scripts/Shop.cs @@ -5,14 +5,14 @@ public class Shop : MonoBehaviour { //It was the salmonmoose - [SerializeField] GameObject shopObject; - [SerializeField] Transform[] shopObjectLocations; - MarbleList marbleList; - HashSet shopMarbles; + [SerializeField] GameObject ShopObject; + [SerializeField] Transform[] ShopObjectLocations; + MarbleList MarbleList; + HashSet ShopMarbles; void Start() { - marbleList = FindObjectOfType(); + MarbleList = FindObjectOfType(); DisplayShopItems(); } @@ -21,23 +21,23 @@ public void DisplayShopItems() { Generate3ShopItems(); int counter = 0; - foreach (var item in shopMarbles) + foreach (var item in ShopMarbles) { - GameObject shop = Instantiate(shopObject); + GameObject shop = Instantiate(ShopObject); shop.transform.SetParent(transform); Marble marble = item.GetComponent(); - string name = marble.commonName; - string cost = marble.cost.ToString(); - Sprite sprite = marble.marbleSprite; + string name = marble.CommonName; + string cost = marble.Cost.ToString(); + Sprite sprite = marble.MarbleSprite; ShopObject newShopObject = shop.GetComponent(); - newShopObject.marbleName.text = name; - newShopObject.marbleCost.text = "$" + cost; - newShopObject.marbleSpriteRenderer.sprite = sprite; + newShopObject.Name.text = name; + newShopObject.Cost.text = "$" + cost; + newShopObject.SpriteRender.sprite = sprite; - if (counter < shopObjectLocations.Length) + if (counter < ShopObjectLocations.Length) { - shop.transform.position = shopObjectLocations[counter].position; + shop.transform.position = ShopObjectLocations[counter].position; } counter++; } @@ -45,7 +45,7 @@ public void DisplayShopItems() private void Generate3ShopItems() { - shopMarbles = marbleList.GetMarblesForShop(3); + ShopMarbles = MarbleList.GetMarblesForShop(3); } public void ResetShop() @@ -70,7 +70,7 @@ public void DestroyShopObjectChildren() public bool MarbleNamesInShop(string checkedMarble) { bool marbleInShop = false; - foreach (var marble in shopMarbles) + foreach (var marble in ShopMarbles) { Debug.Log(marble.name); Debug.Log(checkedMarble); diff --git a/Assets/Scripts/ShopObject.cs b/Assets/Scripts/ShopObject.cs index 706d473..a2f1990 100644 --- a/Assets/Scripts/ShopObject.cs +++ b/Assets/Scripts/ShopObject.cs @@ -5,7 +5,7 @@ public class ShopObject : MonoBehaviour { - [SerializeField] public TMP_Text marbleName; - [SerializeField] public TextMeshPro marbleCost; - [SerializeField] public SpriteRenderer marbleSpriteRenderer; + [SerializeField] public TMP_Text Name; + [SerializeField] public TextMeshPro Cost; + [SerializeField] public SpriteRenderer SpriteRender; } diff --git a/Assets/Scripts/TextFollow.cs b/Assets/Scripts/TextFollow.cs index 1f527dc..538a9a1 100644 --- a/Assets/Scripts/TextFollow.cs +++ b/Assets/Scripts/TextFollow.cs @@ -4,28 +4,28 @@ public class TextFollow : MonoBehaviour { - [SerializeField] Transform marblePos; - Transform textPos; - Vector3 offset = new Vector3(0, .9f, 0); - [SerializeField] MarbleObject myMarbleObject; - Animator textAnimator; + [SerializeField] Transform MarblePos; + Transform TextPos; + Vector3 Offset = new Vector3(0, .9f, 0); + [SerializeField] MarbleObject MyMarbleObject; + Animator TextAnimator; private void Start() { - textPos = GetComponent(); - textAnimator = GetComponent(); + TextPos = GetComponent(); + TextAnimator = GetComponent(); } void Update() { - textPos.position = marblePos.position + offset; + TextPos.position = MarblePos.position + Offset; } public void DisplayScore() { - myMarbleObject.TransitionToScoreText(); + MyMarbleObject.TransitionToScoreText(); } public void TriggerAnimation() { - textAnimator.SetTrigger("showScore"); + TextAnimator.SetTrigger("showScore"); } } diff --git a/Assets/Scripts/Timer.cs b/Assets/Scripts/Timer.cs index a1d5cbe..77820f0 100644 --- a/Assets/Scripts/Timer.cs +++ b/Assets/Scripts/Timer.cs @@ -6,39 +6,39 @@ public class Timer : MonoBehaviour { - public float timeRemaining = 65; - public bool timerIsRunning = false; - public TextMeshPro timeText; - [SerializeField] float timeBetweenGames = 600; - [SerializeField] float timeOfGame = 90; - [SerializeField] GameController gameController; + public float TimeRemaining = 65; + public bool IsTimerRunning = false; + public TextMeshPro TimeText; + [SerializeField] float TimeBetweenGames = 600; + [SerializeField] float TimeOfGame = 90; + [SerializeField] GameController GameController; bool wasGameTime; void Start() { - timerIsRunning = true; + IsTimerRunning = true; wasGameTime = true; } void Update() { - if (timerIsRunning) + if (IsTimerRunning) { - if (timeRemaining > 0) + if (TimeRemaining > 0) { - timeRemaining -= Time.deltaTime; - DisplayTime(timeRemaining); + TimeRemaining -= Time.deltaTime; + DisplayTime(TimeRemaining); } else { - timerIsRunning = false; - timeRemaining = 0; + IsTimerRunning = false; + TimeRemaining = 0; if (wasGameTime == true) { - gameController.TriggerCutscene(); + GameController.TriggerCutscene(); wasGameTime = false; } else { - gameController.TriggerDowntime(); + GameController.TriggerDowntime(); wasGameTime = true; } } @@ -50,16 +50,16 @@ void DisplayTime(float timeToDisplay) float minutes = Mathf.FloorToInt(timeToDisplay / 60); float seconds = Mathf.FloorToInt(timeToDisplay % 60); - timeText.text = string.Format("{0:00}:{1:00}", minutes, seconds); + TimeText.text = string.Format("{0:00}:{1:00}", minutes, seconds); } public void ResetGameTimer() { - timeRemaining = timeOfGame; - timerIsRunning = true; + TimeRemaining = TimeOfGame; + IsTimerRunning = true; } public void ResetDowntimeTimer() { - timeRemaining = timeBetweenGames; - timerIsRunning = true; + TimeRemaining = TimeBetweenGames; + IsTimerRunning = true; } } diff --git a/Assets/Scripts/TwitchAPI.cs b/Assets/Scripts/TwitchAPI.cs index 8b9f47e..3e8910a 100644 --- a/Assets/Scripts/TwitchAPI.cs +++ b/Assets/Scripts/TwitchAPI.cs @@ -9,18 +9,19 @@ public class TwitchAPI : MonoBehaviour { - public Api api; - Client getClient; - TwitchClient twitchClient; + public Api API; + Client GetClient; + TwitchClient TwitchClient; + // Start is called before the first frame update void Start() { Application.runInBackground = true; - api = new Api(); - api.Settings.AccessToken = Secrets.BotAccessToken; - api.Settings.ClientId = Secrets.ClientID; + API = new Api(); + API.Settings.AccessToken = Secrets.BotAccessToken; + API.Settings.ClientId = Secrets.ClientID; GameObject client = GameObject.Find("Client"); - twitchClient = client.GetComponent(); + TwitchClient = client.GetComponent(); } // Update is called once per frame diff --git a/Assets/Scripts/TwitchClient.cs b/Assets/Scripts/TwitchClient.cs index 82e5433..d2b09c6 100644 --- a/Assets/Scripts/TwitchClient.cs +++ b/Assets/Scripts/TwitchClient.cs @@ -11,34 +11,34 @@ public class TwitchClient : MonoBehaviour { // Client Object is defined in Twitch Lib - public Client client; - public JoinedChannel joinedChannel; - public JoinedChannel botChannel; - CommandQueue commandQueue; - private PubSub pubSub; - [SerializeField] Text debug; - private string channel_name = "simpathey"; - private string bot_name = "simpagamebot"; + public Client Client; + public JoinedChannel JoinedChannel; + public JoinedChannel BotChannel; + CommandQueue CommandQueue; + private PubSub PubSub; + [SerializeField] Text Debug; + private string ChannelName = "simpathey"; + private string BotName = "simpagamebot"; void Start() { - commandQueue = FindObjectOfType(); + CommandQueue = FindObjectOfType(); //This script should always run in background if game application is running Application.runInBackground = true; //set up bot and tell what channel to join - ConnectionCredentials credentials = new ConnectionCredentials(bot_name, Secrets.BotAccessToken); - client = new Client(); - client.Initialize(credentials, channel_name); + ConnectionCredentials credentials = new ConnectionCredentials(BotName, Secrets.BotAccessToken); + Client = new Client(); + Client.Initialize(credentials, ChannelName); //pubSub = new PubSub(); //connect bot to channel - client.Connect(); - client.OnJoinedChannel += ClientOnJoinedChannel; - client.OnMessageReceived += MyMessageReceivedFunction; - client.OnChatCommandReceived += MyCommandReceivedFunction; - client.OnWhisperSent += Client_OnWhisperSent; - client.OnWhisperReceived += Client_OnWhisperReceived; + Client.Connect(); + Client.OnJoinedChannel += ClientOnJoinedChannel; + Client.OnMessageReceived += MyMessageReceivedFunction; + Client.OnChatCommandReceived += MyCommandReceivedFunction; + Client.OnWhisperSent += Client_OnWhisperSent; + Client.OnWhisperReceived += Client_OnWhisperReceived; //pubSub.OnChannelCommerceReceived += Pubsub_OnCommerceReceived; @@ -48,49 +48,49 @@ void Start() private void Client_OnWhisperSent(object sender, OnWhisperSentArgs e) { - Debug.Log(sender.ToString()); - Debug.Log(e.Receiver); + UnityEngine.Debug.Log(sender.ToString()); + UnityEngine.Debug.Log(e.Receiver); } private void ClientOnJoinedChannel(object sender, OnJoinedChannelArgs e) { - joinedChannel = new JoinedChannel(channel_name); - botChannel = new JoinedChannel(bot_name); + JoinedChannel = new JoinedChannel(ChannelName); + BotChannel = new JoinedChannel(BotName); //client.SendMessage(joinedChannel, "SimpaGameBotConnected"); } private void MyCommandReceivedFunction(object sender, OnChatCommandReceivedArgs e) { Arrrgs chatArgs = new Arrrgs(); - chatArgs.message = e.Command.ChatMessage.Message; - chatArgs.userID = e.Command.ChatMessage.UserId; - chatArgs.displayName = e.Command.ChatMessage.DisplayName; - chatArgs.commandText = e.Command.CommandText.ToLower(); - chatArgs.multiCommand = e.Command.ArgumentsAsList; + chatArgs.Message = e.Command.ChatMessage.Message; + chatArgs.UserID = e.Command.ChatMessage.UserId; + chatArgs.DisplayName = e.Command.ChatMessage.DisplayName; + chatArgs.CommandText = e.Command.CommandText.ToLower(); + chatArgs.MultiCommand = e.Command.ArgumentsAsList; for (int index = 0; index < e.Command.ArgumentsAsList.Count; index++) { - chatArgs.commandArgs += e.Command.ArgumentsAsList[index].ToLower(); + chatArgs.CommandArgs += e.Command.ArgumentsAsList[index].ToLower(); } - commandQueue.FirstCommandBuckets(chatArgs); //e - debug.text = (e.Command.ChatMessage.Username); + CommandQueue.FirstCommandBuckets(chatArgs); //e + Debug.text = (e.Command.ChatMessage.Username); } private void MyMessageReceivedFunction(object sender, TwitchLib.Client.Events.OnMessageReceivedArgs e) { - Debug.Log(e.ChatMessage.UserId); + UnityEngine.Debug.Log(e.ChatMessage.UserId); } private void Client_OnWhisperReceived(object sender, OnWhisperReceivedArgs e) { Arrrgs chatArgs = new Arrrgs(); - chatArgs.message = e.WhisperMessage.Message; - chatArgs.userID = e.WhisperMessage.UserId; - chatArgs.displayName = e.WhisperMessage.DisplayName; - chatArgs.commandText = ConvertWhisperToCommand(e.WhisperMessage.Message); - chatArgs.commandArgs = ConvertWhisperToArguments(e.WhisperMessage.Message); - commandQueue.FirstCommandBuckets(chatArgs); + chatArgs.Message = e.WhisperMessage.Message; + chatArgs.UserID = e.WhisperMessage.UserId; + chatArgs.DisplayName = e.WhisperMessage.DisplayName; + chatArgs.CommandText = ConvertWhisperToCommand(e.WhisperMessage.Message); + chatArgs.CommandArgs = ConvertWhisperToArguments(e.WhisperMessage.Message); + CommandQueue.FirstCommandBuckets(chatArgs); } private string ConvertWhisperToCommand(string whisper) { @@ -120,7 +120,7 @@ private string ConvertWhisperToArguments(string whisper) whisper = whisper.Substring(1); string[] commandArray = whisper.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); - Debug.Log(commandArray[0]); + UnityEngine.Debug.Log(commandArray[0]); if (commandArray.Length > 1) { for (int i = 1; i < commandArray.Length; i++) @@ -143,8 +143,8 @@ private List ParseCommand(string command) } for (int i = 0; i < commandArray.Length; i++) { - Debug.Log(commandArray.Length + " : this is command Array Length"); - Debug.Log(commandArray[i] + " : this is command Array"); + UnityEngine.Debug.Log(commandArray.Length + " : this is command Array Length"); + UnityEngine.Debug.Log(commandArray[i] + " : this is command Array"); } return null; } From 24eba72c06b4be67946b19333280afdd33971a32 Mon Sep 17 00:00:00 2001 From: HelpfulStranger999 Date: Fri, 8 Jan 2021 00:16:29 -0600 Subject: [PATCH 08/13] Renames Arrrgs to a more standard name of CommandEventArgs --- .../{Arrrgs.cs => CommandEventArgs.cs} | 2 +- Assets/Scripts/CommandQueue.cs | 10 ++--- Assets/Scripts/Commands.cs | 38 +++++++++---------- Assets/Scripts/GameData.cs | 4 +- Assets/Scripts/JumpManager.cs | 4 +- Assets/Scripts/TwitchClient.cs | 4 +- 6 files changed, 31 insertions(+), 31 deletions(-) rename Assets/Scripts/{Arrrgs.cs => CommandEventArgs.cs} (93%) diff --git a/Assets/Scripts/Arrrgs.cs b/Assets/Scripts/CommandEventArgs.cs similarity index 93% rename from Assets/Scripts/Arrrgs.cs rename to Assets/Scripts/CommandEventArgs.cs index de91c4c..5a5ebee 100644 --- a/Assets/Scripts/Arrrgs.cs +++ b/Assets/Scripts/CommandEventArgs.cs @@ -2,7 +2,7 @@ using System.Collections.Generic; using UnityEngine; -public class Arrrgs +public class CommandEventArgs { //These are the chat arguments that we care about //Stores data for both whispers and chat messeges diff --git a/Assets/Scripts/CommandQueue.cs b/Assets/Scripts/CommandQueue.cs index 1705231..c7cd76b 100644 --- a/Assets/Scripts/CommandQueue.cs +++ b/Assets/Scripts/CommandQueue.cs @@ -7,22 +7,22 @@ public class CommandQueue : MonoBehaviour //Queue's store and handle messege sending so the BOT does not break Twitch Dev Guidlines //100 chat messeges per min //200 whispers per min - Queue CommandQueueChat = new Queue(); - Queue CommandQueueWhisper = new Queue(); + Queue CommandQueueChat = new Queue(); + Queue CommandQueueWhisper = new Queue(); [SerializeField] Commands Commands; private void Start() { //commands = FindObjectOfType(); StartCoroutine(RemoveFromChatQueue()); } - public void AddToChatQueue(Arrrgs arg) + public void AddToChatQueue(CommandEventArgs arg) { CommandQueueChat.Enqueue(arg); Debug.Log("Command in queue"); Debug.Log("There are " + CommandQueueChat.Count + " in the queue"); } - private void AddToWhisperQueue(Arrrgs arg) + private void AddToWhisperQueue(CommandEventArgs arg) { CommandQueueWhisper.Enqueue(arg); } @@ -59,7 +59,7 @@ IEnumerator RemoveFromChatQueue() //This Seperates the different commands into buckets - public void FirstCommandBuckets(Arrrgs e) + public void FirstCommandBuckets(CommandEventArgs e) { string firstCommand = e.CommandText; //Command.CommandText.ToLower(); //These commands will provide player confirmation/Response in CHAT diff --git a/Assets/Scripts/Commands.cs b/Assets/Scripts/Commands.cs index 132c68e..b96a339 100644 --- a/Assets/Scripts/Commands.cs +++ b/Assets/Scripts/Commands.cs @@ -62,7 +62,7 @@ public void Setup() } //Help - provids a list of commands - public void Help(Arrrgs e) + public void Help(CommandEventArgs e) { if (ChatClient == null) { @@ -76,13 +76,13 @@ public void Help(Arrrgs e) } } - private void AttemptToHelp(Arrrgs e) + private void AttemptToHelp(CommandEventArgs e) { ChatClient.SendMessage(ChatJoinedChannel, help); } //Join - check if player data exists - if not create empty player data entry - public void Join(Arrrgs e) + public void Join(CommandEventArgs e) { if (ChatClient == null) { @@ -94,7 +94,7 @@ public void Join(Arrrgs e) AttemptToJoin(e); } } - private void AttemptToJoin(Arrrgs e) + private void AttemptToJoin(CommandEventArgs e) { if (GameDataScript.CheckIfPlayerExists(e.UserID)) { @@ -109,7 +109,7 @@ private void AttemptToJoin(Arrrgs e) //Money - checks if player data exists - if so returns how much money they have in chat - public void money(Arrrgs e) + public void money(CommandEventArgs e) { if (ChatClient == null) { @@ -121,7 +121,7 @@ public void money(Arrrgs e) AttemptToCheckMoney(e); } } - private void AttemptToCheckMoney(Arrrgs e) + private void AttemptToCheckMoney(CommandEventArgs e) { string playerID = e.UserID; string userName = e.DisplayName; @@ -138,7 +138,7 @@ private void AttemptToCheckMoney(Arrrgs e) //Buy - checks if player data exists - if so checks if has enough money - if so then unlock skin - public void Buy(Arrrgs e) + public void Buy(CommandEventArgs e) { if (ChatClient == null) { @@ -150,7 +150,7 @@ public void Buy(Arrrgs e) AttemptToBuy(e); } } - public void AttemptToBuy(Arrrgs e) + public void AttemptToBuy(CommandEventArgs e) { string commonName = ""; string playerID = e.UserID; //Command.ChatMessage.UserId; @@ -209,7 +209,7 @@ public void AttemptToBuy(Arrrgs e) //Equip - checks if player data exists - checks if they own that skin - equips the skin - public void Equip(Arrrgs e) + public void Equip(CommandEventArgs e) { if (ChatClient == null) { @@ -221,7 +221,7 @@ public void Equip(Arrrgs e) AttemptToEquip(e); } } - private void AttemptToEquip(Arrrgs e) + private void AttemptToEquip(CommandEventArgs e) { string commonName = ""; string playerID = e.UserID; @@ -262,7 +262,7 @@ private void AttemptToEquip(Arrrgs e) //Equipted - checks if player data exists - checks what skin they have equipped - tells them what skin that is - public void InUse(Arrrgs e) + public void InUse(CommandEventArgs e) { if (ChatClient == null) { @@ -274,7 +274,7 @@ public void InUse(Arrrgs e) AttemptToInUse(e); } } - private void AttemptToInUse(Arrrgs e) + private void AttemptToInUse(CommandEventArgs e) { string playerID = e.UserID; string playerUserName = e.DisplayName; @@ -291,7 +291,7 @@ private void AttemptToInUse(Arrrgs e) } } - public void Play(Arrrgs e) + public void Play(CommandEventArgs e) { if (ChatClient == null) { @@ -304,7 +304,7 @@ public void Play(Arrrgs e) } } - private void AttemptToPlay(Arrrgs e) + private void AttemptToPlay(CommandEventArgs e) { string userID = e.UserID; string displayName = e.DisplayName; @@ -368,7 +368,7 @@ public void AcceptWhispers(OnChatCommandReceivedArgs e) } } */ - public void Skins(Arrrgs e) + public void Skins(CommandEventArgs e) { if (ChatClient == null) { @@ -380,7 +380,7 @@ public void Skins(Arrrgs e) AttemptToSkins(e); } } - public void AttemptToSkins(Arrrgs e) + public void AttemptToSkins(CommandEventArgs e) { string userID = e.UserID; string displayName = e.DisplayName; @@ -406,14 +406,14 @@ public void AkaiEasterEgg(string name) ChatClient.SendMessage(ChatJoinedChannel, name + secretMsg); } - public void Rotate(Arrrgs e) //Temporary command!!! TODO REMOVE + public void Rotate(CommandEventArgs e) //Temporary command!!! TODO REMOVE { if (e.UserID == "73184979") { FindObjectOfType().ResetShop(); } } - public void Give(Arrrgs e) + public void Give(CommandEventArgs e) { if (ChatClient == null) { @@ -425,7 +425,7 @@ public void Give(Arrrgs e) AttemptToGive(e); } } - public void AttemptToGive(Arrrgs e) + public void AttemptToGive(CommandEventArgs e) { if (e.MultiCommand != null) { diff --git a/Assets/Scripts/GameData.cs b/Assets/Scripts/GameData.cs index aff6d70..556e2a9 100644 --- a/Assets/Scripts/GameData.cs +++ b/Assets/Scripts/GameData.cs @@ -55,7 +55,7 @@ public bool CheckIfPlayerExists(string playerID) return false; } } - public void CreateNewPlayerEntry(Arrrgs e) + public void CreateNewPlayerEntry(CommandEventArgs e) { PlayerData tempData = new PlayerData(); tempData.Money = 0; @@ -121,7 +121,7 @@ public bool CheckIfPlayerSubscribedToWhispers(string playerID) //Returns true if player subscribed } - public string CheckSkins(Arrrgs e) + public string CheckSkins(CommandEventArgs e) { string playerID = e.UserID; string playerName = e.DisplayName; diff --git a/Assets/Scripts/JumpManager.cs b/Assets/Scripts/JumpManager.cs index ecc43a2..65192e4 100644 --- a/Assets/Scripts/JumpManager.cs +++ b/Assets/Scripts/JumpManager.cs @@ -38,7 +38,7 @@ public void ResetHighJumpedPlayers() HighJumpedPlayers = new List(); } - public void CreateMarbleAndJump(Arrrgs e) + public void CreateMarbleAndJump(CommandEventArgs e) { string userID = e.UserID; string displayName = e.DisplayName; @@ -78,7 +78,7 @@ public void CreateMarbleAndJump(Arrrgs e) } } - public void CreateMarbleAndHighJump(Arrrgs e) + public void CreateMarbleAndHighJump(CommandEventArgs e) { string userID = e.UserID; string displayName = e.DisplayName; diff --git a/Assets/Scripts/TwitchClient.cs b/Assets/Scripts/TwitchClient.cs index d2b09c6..e66e57b 100644 --- a/Assets/Scripts/TwitchClient.cs +++ b/Assets/Scripts/TwitchClient.cs @@ -61,7 +61,7 @@ private void ClientOnJoinedChannel(object sender, OnJoinedChannelArgs e) private void MyCommandReceivedFunction(object sender, OnChatCommandReceivedArgs e) { - Arrrgs chatArgs = new Arrrgs(); + CommandEventArgs chatArgs = new CommandEventArgs(); chatArgs.Message = e.Command.ChatMessage.Message; chatArgs.UserID = e.Command.ChatMessage.UserId; chatArgs.DisplayName = e.Command.ChatMessage.DisplayName; @@ -84,7 +84,7 @@ private void MyMessageReceivedFunction(object sender, } private void Client_OnWhisperReceived(object sender, OnWhisperReceivedArgs e) { - Arrrgs chatArgs = new Arrrgs(); + CommandEventArgs chatArgs = new CommandEventArgs(); chatArgs.Message = e.WhisperMessage.Message; chatArgs.UserID = e.WhisperMessage.UserId; chatArgs.DisplayName = e.WhisperMessage.DisplayName; From aecbe459bb42670a7b2f2a608ad62d68dbb44468 Mon Sep 17 00:00:00 2001 From: HelpfulStranger999 Date: Fri, 8 Jan 2021 13:01:04 -0600 Subject: [PATCH 09/13] Renaming didn't work properly for whichever reason --- ...rrrgs.cs.meta => CommandEventArgs.cs.meta} | 2 +- Assets/Scripts/Commands.cs | 44 +++++++++---------- 2 files changed, 23 insertions(+), 23 deletions(-) rename Assets/Scripts/{Arrrgs.cs.meta => CommandEventArgs.cs.meta} (83%) diff --git a/Assets/Scripts/Arrrgs.cs.meta b/Assets/Scripts/CommandEventArgs.cs.meta similarity index 83% rename from Assets/Scripts/Arrrgs.cs.meta rename to Assets/Scripts/CommandEventArgs.cs.meta index 94afe53..13b2137 100644 --- a/Assets/Scripts/Arrrgs.cs.meta +++ b/Assets/Scripts/CommandEventArgs.cs.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 6fdb9ba6061a24d43b5507259151dfc9 +guid: bcd52ee8fb9eb954ab6902f5838dc4f1 MonoImporter: externalObjects: {} serializedVersion: 2 diff --git a/Assets/Scripts/Commands.cs b/Assets/Scripts/Commands.cs index b96a339..e6e7d55 100644 --- a/Assets/Scripts/Commands.cs +++ b/Assets/Scripts/Commands.cs @@ -28,7 +28,7 @@ public class Commands : MonoBehaviour [SerializeField] JumpManager JumpManager; [SerializeField] Shop Shop; const string SecretMsg = " is hacking"; - const string Help = "!join-join the game | !play-play the game when it is GAMETIME | play to earn money" + + const string HelpMessage = "!join-join the game | !play-play the game when it is GAMETIME | play to earn money" + " | save money to buy and equip new marbles"; const string PlayerAlreadyExists = " your user entry already exists, no need to join"; const string NoPlayerEntryExists = ", Please type '!join' to play"; @@ -78,7 +78,7 @@ public void Help(CommandEventArgs e) private void AttemptToHelp(CommandEventArgs e) { - ChatClient.SendMessage(ChatJoinedChannel, help); + ChatClient.SendMessage(ChatJoinedChannel, HelpMessage); } //Join - check if player data exists - if not create empty player data entry @@ -98,12 +98,12 @@ private void AttemptToJoin(CommandEventArgs e) { if (GameDataScript.CheckIfPlayerExists(e.UserID)) { - ChatClient.SendMessage(ChatJoinedChannel, e.DisplayName + playerAlreadyExists); + ChatClient.SendMessage(ChatJoinedChannel, e.DisplayName + PlayerAlreadyExists); } else { GameDataScript.CreateNewPlayerEntry(e); - ChatClient.SendMessage(ChatJoinedChannel, e.DisplayName + playerEntryAdded); + ChatClient.SendMessage(ChatJoinedChannel, e.DisplayName + PlayerEntryAdded); } } @@ -132,7 +132,7 @@ private void AttemptToCheckMoney(CommandEventArgs e) } else { - ChatClient.SendMessage(ChatJoinedChannel, userName + noPlayerEntryExists); + ChatClient.SendMessage(ChatJoinedChannel, userName + NoPlayerEntryExists); } } @@ -173,7 +173,7 @@ public void AttemptToBuy(CommandEventArgs e) int marbleCode = MarbleList.GetMarbleCodeFromCommonName(commonName); if (GameDataScript.IsSkinUnlocked(playerID, marbleCode)) { - ChatClient.SendMessage(ChatJoinedChannel, playerUserName + skinAlreadyUnlocked1 + commonName + skinAlreadyUnlocked2); + ChatClient.SendMessage(ChatJoinedChannel, playerUserName + SkinAlreadyUnlocked1 + commonName + SkinAlreadyUnlocked2); } else { @@ -182,28 +182,28 @@ public void AttemptToBuy(CommandEventArgs e) GameDataScript.SubtractMoneyFromPlayerID(marbleCost, playerID); GameDataScript.UnlockSkinForPlayer(playerID, marbleCode); int currentMoney = GameDataScript.CheckPlayerMoney(playerID); - ChatClient.SendMessage(ChatJoinedChannel, playerUserName + unlockedMarble1 + - commonName + unlockedMarble2 + commonName + unlockedMarble3 + unlockedMarble4 + currentMoney); + ChatClient.SendMessage(ChatJoinedChannel, playerUserName + UnlockedMarble1 + + commonName + UnlockedMarble2 + commonName + UnlockedMarble3 + UnlockedMarble4 + currentMoney); } else { - ChatClient.SendMessage(ChatJoinedChannel, playerUserName + notEnoughMoney + commonName); + ChatClient.SendMessage(ChatJoinedChannel, playerUserName + NotEnoughMoney + commonName); } } } else { - ChatClient.SendMessage(ChatJoinedChannel, commonName + marbleNotInShop); + ChatClient.SendMessage(ChatJoinedChannel, commonName + MarbleNotInShop); } } else { - ChatClient.SendMessage(ChatJoinedChannel, playerUserName + noMarbleWithNameExists); + ChatClient.SendMessage(ChatJoinedChannel, playerUserName + NoMarbleWithNameExists); } } else { - ChatClient.SendMessage(ChatJoinedChannel, playerUserName + noPlayerEntryExists); + ChatClient.SendMessage(ChatJoinedChannel, playerUserName + NoPlayerEntryExists); } } @@ -246,17 +246,17 @@ private void AttemptToEquip(CommandEventArgs e) } else { - ChatClient.SendMessage(ChatJoinedChannel, playerUserName + dontOwnThatSkin); + ChatClient.SendMessage(ChatJoinedChannel, playerUserName + DontOwnThatSkin); } } else { - ChatClient.SendMessage(ChatJoinedChannel, playerUserName + noMarbleWithNameExists); + ChatClient.SendMessage(ChatJoinedChannel, playerUserName + NoMarbleWithNameExists); } } else { - ChatClient.SendMessage(ChatJoinedChannel, playerUserName + noPlayerEntryExists); + ChatClient.SendMessage(ChatJoinedChannel, playerUserName + NoPlayerEntryExists); } } @@ -287,7 +287,7 @@ private void AttemptToInUse(CommandEventArgs e) } else { - ChatClient.SendMessage(ChatJoinedChannel, playerUserName + noPlayerEntryExists); + ChatClient.SendMessage(ChatJoinedChannel, playerUserName + NoPlayerEntryExists); } } @@ -333,7 +333,7 @@ private void AttemptToPlay(CommandEventArgs e) } else { - ChatClient.SendMessage(ChatJoinedChannel, displayName + noPlayerEntryExists); + ChatClient.SendMessage(ChatJoinedChannel, displayName + NoPlayerEntryExists); } } //AcceptWhispers @@ -393,7 +393,7 @@ public void AttemptToSkins(CommandEventArgs e) } else { - ChatClient.SendMessage(ChatJoinedChannel, displayName + noPlayerEntryExists); + ChatClient.SendMessage(ChatJoinedChannel, displayName + NoPlayerEntryExists); } } IEnumerator SkinsMessege(string skinsList) @@ -403,7 +403,7 @@ IEnumerator SkinsMessege(string skinsList) } public void AkaiEasterEgg(string name) { - ChatClient.SendMessage(ChatJoinedChannel, name + secretMsg); + ChatClient.SendMessage(ChatJoinedChannel, name + SecretMsg); } public void Rotate(CommandEventArgs e) //Temporary command!!! TODO REMOVE @@ -439,7 +439,7 @@ public void AttemptToGive(CommandEventArgs e) string PersonGettingMoney = GameDataScript.ConvertCommonNameToUserID(otherPlayerDisplayName); if (String.IsNullOrEmpty(PersonGettingMoney)) { - ChatClient.SendMessage(ChatJoinedChannel, cantGiveMoneyToPlayer1 + otherPlayerDisplayName + cantGiveMoneyToPlayer2); + ChatClient.SendMessage(ChatJoinedChannel, CantGiveMoneyToPlayer1 + otherPlayerDisplayName + CantGiveMoneyToPlayer2); } else { @@ -472,7 +472,7 @@ public void AttemptToGive(CommandEventArgs e) } else { - ChatClient.SendMessage(ChatJoinedChannel, cantGiveMoneyToPlayer1 + e.MultiCommand[0] + cantGiveMoneyToPlayer2); + ChatClient.SendMessage(ChatJoinedChannel, CantGiveMoneyToPlayer1 + e.MultiCommand[0] + CantGiveMoneyToPlayer2); } } } @@ -483,7 +483,7 @@ public void AttemptToGive(CommandEventArgs e) } else { - ChatClient.SendMessage(ChatJoinedChannel, displayName + noPlayerEntryExists); + ChatClient.SendMessage(ChatJoinedChannel, displayName + NoPlayerEntryExists); } } } From a974d5224ace5b73e190dbf02d61844027d57bbb Mon Sep 17 00:00:00 2001 From: HelpfulStranger999 Date: Fri, 8 Jan 2021 14:22:31 -0600 Subject: [PATCH 10/13] Fixes gitignore and removes .meta files for ignored files as well --- .gitignore | 2 ++ Assets/Marbles/MarbleData.meta | 8 -------- Assets/Marbles/MarbleSkins.meta | 8 -------- 3 files changed, 2 insertions(+), 16 deletions(-) delete mode 100644 Assets/Marbles/MarbleData.meta delete mode 100644 Assets/Marbles/MarbleSkins.meta diff --git a/.gitignore b/.gitignore index b2b9d62..71aaab1 100644 --- a/.gitignore +++ b/.gitignore @@ -57,6 +57,8 @@ sysinfo.txt Builds Assets/Marbles/MarbleSkins Assets/Marbles/MarbleData/*.prefab* +Assets/Marbles/MarbleData.meta +Assets/Marbles/MarbleSkins.meta # Crashlytics generated file crashlytics-build.properties diff --git a/Assets/Marbles/MarbleData.meta b/Assets/Marbles/MarbleData.meta deleted file mode 100644 index aa6e07d..0000000 --- a/Assets/Marbles/MarbleData.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 3675c5d2b96ffed47b96b49d17c4f7aa -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Marbles/MarbleSkins.meta b/Assets/Marbles/MarbleSkins.meta deleted file mode 100644 index ad2b3b9..0000000 --- a/Assets/Marbles/MarbleSkins.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: afcddd465659e4445b696c17a9fc7e77 -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: From 61408e40eb44cca64879cfc0ae4ebedfa469d8b9 Mon Sep 17 00:00:00 2001 From: HelpfulStranger999 Date: Fri, 8 Jan 2021 16:15:25 -0600 Subject: [PATCH 11/13] Removes empty script --- Assets/Scripts/MarbleAssigner.cs | 18 ------------------ Assets/Scripts/MarbleAssigner.cs.meta | 11 ----------- 2 files changed, 29 deletions(-) delete mode 100644 Assets/Scripts/MarbleAssigner.cs delete mode 100644 Assets/Scripts/MarbleAssigner.cs.meta diff --git a/Assets/Scripts/MarbleAssigner.cs b/Assets/Scripts/MarbleAssigner.cs deleted file mode 100644 index 22befab..0000000 --- a/Assets/Scripts/MarbleAssigner.cs +++ /dev/null @@ -1,18 +0,0 @@ -using System.Collections; -using System.Collections.Generic; -using UnityEngine; - -public class MarbleAssigner : MonoBehaviour -{ - // Start is called before the first frame update - void Start() - { - - } - - // Update is called once per frame - void Update() - { - - } -} diff --git a/Assets/Scripts/MarbleAssigner.cs.meta b/Assets/Scripts/MarbleAssigner.cs.meta deleted file mode 100644 index 7c3b48f..0000000 --- a/Assets/Scripts/MarbleAssigner.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: f5a0e1c13febfa7499d7e8e31645cba6 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: From 7bb4af989b414b1d78f5d440ca64e4394710f232 Mon Sep 17 00:00:00 2001 From: HelpfulStranger999 Date: Mon, 11 Jan 2021 13:33:46 -0600 Subject: [PATCH 12/13] Cleanup methods and names a little more --- Assets/Scripts/CommandQueue.cs | 2 +- Assets/Scripts/Commands.cs | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/Assets/Scripts/CommandQueue.cs b/Assets/Scripts/CommandQueue.cs index c7cd76b..0ed8797 100644 --- a/Assets/Scripts/CommandQueue.cs +++ b/Assets/Scripts/CommandQueue.cs @@ -39,7 +39,7 @@ IEnumerator RemoveFromChatQueue() if (firstCommand == "buy") { Commands.Buy(e); } else if (firstCommand == "join") { Commands.Join(e); } else if (firstCommand == "equip") { Commands.Equip(e); } - else if (firstCommand == "money") { Commands.money(e); } + else if (firstCommand == "money") { Commands.CheckMoney(e); } else if (firstCommand == "inuse") { Commands.InUse(e); } else if (firstCommand == "help") { Commands.Help(e); } else if (firstCommand == "skins") { Commands.Skins(e); } diff --git a/Assets/Scripts/Commands.cs b/Assets/Scripts/Commands.cs index e6e7d55..f447aca 100644 --- a/Assets/Scripts/Commands.cs +++ b/Assets/Scripts/Commands.cs @@ -109,7 +109,7 @@ private void AttemptToJoin(CommandEventArgs e) //Money - checks if player data exists - if so returns how much money they have in chat - public void money(CommandEventArgs e) + public void CheckMoney(CommandEventArgs e) { if (ChatClient == null) { @@ -152,12 +152,11 @@ public void Buy(CommandEventArgs e) } public void AttemptToBuy(CommandEventArgs e) { - string commonName = ""; string playerID = e.UserID; //Command.ChatMessage.UserId; string playerUserName = e.DisplayName; //Command.ChatMessage.Username; if (GameDataScript.CheckIfPlayerExists(playerID)) { - commonName = e.CommandArgs; + string commonName = e.CommandArgs; /* for (int index = 0; index < e.Command.ArgumentsAsList.Count; index++) { From 8fc90e9c1b657199dc88524a2a7e82c5a23b57b3 Mon Sep 17 00:00:00 2001 From: HelpfulStranger999 Date: Mon, 11 Jan 2021 13:36:26 -0600 Subject: [PATCH 13/13] Extract the GameMode and GameState enums into their own file --- Assets/Scripts/Commands.cs | 8 ++++---- Assets/Scripts/GameController.cs | 28 +++++++++++++--------------- Assets/Scripts/GameMode.cs | 10 ++++++++++ Assets/Scripts/GameMode.cs.meta | 11 +++++++++++ Assets/Scripts/GameState.cs | 10 ++++++++++ Assets/Scripts/GameState.cs.meta | 11 +++++++++++ 6 files changed, 59 insertions(+), 19 deletions(-) create mode 100644 Assets/Scripts/GameMode.cs create mode 100644 Assets/Scripts/GameMode.cs.meta create mode 100644 Assets/Scripts/GameState.cs create mode 100644 Assets/Scripts/GameState.cs.meta diff --git a/Assets/Scripts/Commands.cs b/Assets/Scripts/Commands.cs index f447aca..88f82cd 100644 --- a/Assets/Scripts/Commands.cs +++ b/Assets/Scripts/Commands.cs @@ -310,17 +310,17 @@ private void AttemptToPlay(CommandEventArgs e) if (GameDataScript.CheckIfPlayerExists(userID)) { - if (GameController.CurrentState == gameState.gametime) + if (GameController.CurrentState == GameState.GameTime) { - if (GameController.CurrentGameMode == gameMode.longjump) + if (GameController.CurrentGameMode == GameMode.LongJump) { JumpManager.CreateMarbleAndJump(e); } - else if (GameController.CurrentGameMode == gameMode.highjump) + else if (GameController.CurrentGameMode == GameMode.HighJump) { JumpManager.CreateMarbleAndHighJump(e); } - else if (GameController.CurrentGameMode == gameMode.race) + else if (GameController.CurrentGameMode == GameMode.Race) { } diff --git a/Assets/Scripts/GameController.cs b/Assets/Scripts/GameController.cs index 663b3b2..4f78baf 100644 --- a/Assets/Scripts/GameController.cs +++ b/Assets/Scripts/GameController.cs @@ -4,13 +4,11 @@ using TMPro; using UnityEngine; -public enum gameState { downtime, cutscene, gametime }; -public enum gameMode { longjump, highjump, race }; public class GameController : MonoBehaviour { public DataManager DataManager; - public gameState CurrentState; - public gameMode CurrentGameMode; + public GameState CurrentState; + public GameMode CurrentGameMode; [SerializeField] TextMeshPro GameStateText; JumpManager JumpManager; public Shop GameShop; @@ -23,8 +21,8 @@ public class GameController : MonoBehaviour void Start() { - CurrentGameMode = gameMode.longjump; - CurrentState = gameState.downtime; + CurrentGameMode = GameMode.LongJump; + CurrentState = GameState.DownTime; JumpManager = FindObjectOfType(); UpdateGameStateText(); } @@ -34,13 +32,13 @@ private void UpdateGameStateText() Debug.Log(CurrentState); switch (CurrentState) { - case gameState.downtime: + case GameState.DownTime: GameStateText.text = "Down Time"; break; - case gameState.cutscene: + case GameState.Cutscene: GameStateText.text = "Cut Scene"; break; - case gameState.gametime: + case GameState.GameTime: GameStateText.text = "Game Time"; break; default: @@ -58,21 +56,21 @@ void Update() public void TriggerCutscene() { - CurrentState = gameState.cutscene; + CurrentState = GameState.Cutscene; GameShop.gameObject.SetActive(false); NullCharacter.NullStartCutScene(); UpdateGameStateText(); } public void TriggerGame() { - CurrentState = gameState.gametime; + CurrentState = GameState.GameTime; UpdateGameStateText(); Timer.ResetGameTimer(); } public void TriggerDowntime() { Shop.ResetShop(); - CurrentState = gameState.downtime; + CurrentState = GameState.DownTime; UpdateGameStateText(); Timer.ResetDowntimeTimer(); StartCoroutine(JumpManager.DestroyMarbles()); @@ -84,12 +82,12 @@ public string FindGameState() Debug.Log(CurrentGameMode); switch (CurrentGameMode) { - case gameMode.longjump: + case GameMode.LongJump: return "Long Jump"; - case gameMode.highjump: + case GameMode.HighJump: Debug.Log("Launching High Jump"); return "High Jump"; - case gameMode.race: + case GameMode.Race: return "Race"; default: return "YOUR MOM"; diff --git a/Assets/Scripts/GameMode.cs b/Assets/Scripts/GameMode.cs new file mode 100644 index 0000000..ab14290 --- /dev/null +++ b/Assets/Scripts/GameMode.cs @@ -0,0 +1,10 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public enum GameMode +{ + LongJump, + HighJump, + Race +}; diff --git a/Assets/Scripts/GameMode.cs.meta b/Assets/Scripts/GameMode.cs.meta new file mode 100644 index 0000000..1a849a3 --- /dev/null +++ b/Assets/Scripts/GameMode.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 0fb60972b02d5d74e885aa9dbdcb08a5 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/GameState.cs b/Assets/Scripts/GameState.cs new file mode 100644 index 0000000..c93e5d5 --- /dev/null +++ b/Assets/Scripts/GameState.cs @@ -0,0 +1,10 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public enum GameState +{ + DownTime, + Cutscene, + GameTime +}; diff --git a/Assets/Scripts/GameState.cs.meta b/Assets/Scripts/GameState.cs.meta new file mode 100644 index 0000000..030aafa --- /dev/null +++ b/Assets/Scripts/GameState.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 72cac14c2cdf27d46af513eea0789c30 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: