This commit is contained in:
Anthony 2020-11-24 12:52:22 +00:00
commit 0112c5ceff
18 changed files with 3227 additions and 184 deletions

View File

@ -3,7 +3,6 @@
<component name="ContentModelUserStore">
<attachedFolders />
<explicitIncludes>
<Path>Assets</Path>
<Path>Library/PackageCache/com.unity.collab-proxy@1.3.9</Path>
<Path>Library/PackageCache/com.unity.ext.nunit@1.0.0</Path>
<Path>Library/PackageCache/com.unity.ide.rider@1.2.1</Path>

View File

@ -1,36 +0,0 @@
CREATE TABLE properties (
property_id int(2) AUTO_INCREMENT PRIMARY KEY NOT NULL, #Easy way to identify with code
property_name TINYTEXT NOT NULL, #The name of the property
property_group TINYTEXT NOT NULL, #The group that the property is
property_value int(3), #How much it costs to buy the property
property_cost int(3), #How much it is to buy a house/hotel
property_rent int(2), #How much it costs to rent
property_house1 int(3), #How much it costs with 1 house
property_house2 int(3), #How much it costs with 2 houses
property_house3 int(4), #How much it costs with 3 houses
property_house4 int(4), #How much it costs with 4 houses
property_hotel int(4) #How much it costs with a hotel
);
property_name,property_group,property_value,property_cost,property_rent,property_house1,property_house2,property_house3,property_house4,property_hotel
CREATE TABLE users (
user_id int(11) AUTO_INCREMENT PRIMARY KEY NOT NULL, #This is a uniquie ID for the user
user_uid TINYTEXT NOT NULL, #This is the username for the user
user_email TINYTEXT NOT NULL, #This is the email for the user
user_pwd LONGTEXT NOT NULL #This is where the hashed password would be stored
);
CREATE TABLE pwdreset (
pwd_id int(11) PRIMARY KEY AUTO_INCREMENT NOT NULL, #This is a unique identifier
pwd_email TEXT NOT NULL, #The email used to change the password for
pwd_selector TEXT NOT NULL, #Where the selector is stored in plaintext
pwd_token LONGTEXT NOT NULL, #Where the hashed token is stored
pwd_expires TEXT NOT NULL #When the token expires
);
CREATE TABLE money_spent(
user_id int(11) PRIMARY KEY NOT NULL,
user_spent int(11) NOT NULL,
FOREIGN KEY (user_id) REFERENCES users(user_id)
);

View File

@ -2060,7 +2060,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 76c392e42b5098c458856cdf6ecaaaa1, type: 3}
m_Name:
m_EditorClassIdentifier:
m_FirstSelected: {fileID: 0}
m_FirstSelected: {fileID: 1444966873}
m_sendNavigationEvents: 1
m_DragThreshold: 10
--- !u!4 &765233206
@ -3878,9 +3878,9 @@ MonoBehaviour:
m_Name:
m_EditorClassIdentifier:
m_Navigation:
m_Mode: 3
m_Mode: -1
m_SelectOnUp: {fileID: 0}
m_SelectOnDown: {fileID: 0}
m_SelectOnDown: {fileID: 1616246420}
m_SelectOnLeft: {fileID: 0}
m_SelectOnRight: {fileID: 0}
m_Transition: 1
@ -4498,6 +4498,8 @@ MonoBehaviour:
username: {fileID: 1444966875}
password: {fileID: 1616246420}
login: {fileID: 570354252}
errors: {fileID: 1922298507}
errorsText: {fileID: 1922298509}
--- !u!114 &1549879027
MonoBehaviour:
m_ObjectHideFlags: 0
@ -5890,6 +5892,7 @@ RectTransform:
- {fileID: 570354255}
- {fileID: 876748453}
- {fileID: 1171125062}
- {fileID: 1922298508}
m_Father: {fileID: 1549879024}
m_RootOrder: 3
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
@ -5898,6 +5901,140 @@ RectTransform:
m_AnchoredPosition: {x: 0, y: 0.25}
m_SizeDelta: {x: 0, y: -0.5}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!1 &1922298507
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1922298508}
- component: {fileID: 1922298510}
- component: {fileID: 1922298509}
m_Layer: 5
m_Name: Error Text
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 0
--- !u!224 &1922298508
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1922298507}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 1922023088}
m_RootOrder: 7
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 1}
m_AnchorMax: {x: 1, y: 1}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 0, y: 66.54178}
m_Pivot: {x: 0.5, y: 1}
--- !u!114 &1922298509
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1922298507}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: f4688fdb7df04437aeb418b961361dc5, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_RaycastTarget: 1
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
m_Maskable: 1
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_text: 'Error:'
m_isRightToLeft: 0
m_fontAsset: {fileID: 11400000, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2}
m_sharedMaterial: {fileID: 2180264, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2}
m_fontSharedMaterials: []
m_fontMaterial: {fileID: 0}
m_fontMaterials: []
m_fontColor32:
serializedVersion: 2
rgba: 4278190335
m_fontColor: {r: 1, g: 0, b: 0, a: 1}
m_enableVertexGradient: 0
m_colorMode: 3
m_fontColorGradient:
topLeft: {r: 1, g: 1, b: 1, a: 1}
topRight: {r: 1, g: 1, b: 1, a: 1}
bottomLeft: {r: 1, g: 1, b: 1, a: 1}
bottomRight: {r: 1, g: 1, b: 1, a: 1}
m_fontColorGradientPreset: {fileID: 0}
m_spriteAsset: {fileID: 0}
m_tintAllSprites: 0
m_StyleSheet: {fileID: 0}
m_TextStyleHashCode: -1183493901
m_overrideHtmlColors: 0
m_faceColor:
serializedVersion: 2
rgba: 4294967295
m_fontSize: 36
m_fontSizeBase: 36
m_fontWeight: 400
m_enableAutoSizing: 0
m_fontSizeMin: 18
m_fontSizeMax: 72
m_fontStyle: 0
m_HorizontalAlignment: 2
m_VerticalAlignment: 256
m_textAlignment: 65535
m_characterSpacing: 0
m_wordSpacing: 0
m_lineSpacing: 0
m_lineSpacingMax: 0
m_paragraphSpacing: 0
m_charWidthMaxAdj: 0
m_enableWordWrapping: 1
m_wordWrappingRatios: 0.4
m_overflowMode: 0
m_linkedTextComponent: {fileID: 0}
parentLinkedComponent: {fileID: 0}
m_enableKerning: 1
m_enableExtraPadding: 0
checkPaddingRequired: 0
m_isRichText: 1
m_parseCtrlCharacters: 1
m_isOrthographic: 1
m_isCullingEnabled: 0
m_horizontalMapping: 0
m_verticalMapping: 0
m_uvLineOffset: 0
m_geometrySortingOrder: 0
m_IsTextObjectScaleStatic: 0
m_VertexBufferAutoSizeReduction: 1
m_useMaxVisibleDescender: 1
m_pageToDisplay: 1
m_margin: {x: 0, y: 0, z: 0, w: 0}
m_isUsingLegacyAnimationComponent: 0
m_isVolumetricText: 0
m_hasFontAssetChanged: 1
m_baseMaterial: {fileID: 0}
m_maskOffset: {x: 0, y: 0, z: 0, w: 0}
--- !u!222 &1922298510
CanvasRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1922298507}
m_CullTransparentMesh: 0
--- !u!1 &1922521208
GameObject:
m_ObjectHideFlags: 0

File diff suppressed because it is too large Load Diff

View File

@ -21,6 +21,8 @@ public class Login : MonoBehaviour
public TMP_InputField username; //This is for the username text input.
public TMP_InputField password; //This is for the password text input.
public Button login; //This is the button used to log in.
public GameObject errors;
public TextMeshProUGUI errorsText;
private bool CheckIsEmpty() //This checks if the strings are empty.
{
@ -85,8 +87,17 @@ public class Login : MonoBehaviour
else
{
string status = www.downloadHandler.text; //This downloads the data from the server.
LoginInformation information = JsonConvert.DeserializeObject<LoginInformation>(status); //This deserializes the JSON string to a class.
Debug.Log(status);
var settings = new JsonSerializerSettings
{
NullValueHandling = NullValueHandling.Ignore
};
LoginInformation information = JsonConvert.DeserializeObject<LoginInformation>(status, settings); //This deserializes the JSON string to a class.
if (information.errors != null)
{
errors.SetActive(true);
errorsText.text = information.errors;
}
if (information.success) //If the user has successfully logged in.
{

View File

@ -0,0 +1,66 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.Networking;
using TMPro;
using Newtonsoft.Json;
class LeaderboardInformation
{
public string user_username;
public int user_plays;
}
public class LeaderboardHandler : MonoBehaviour
{
public TextMeshProUGUI Leaderboard;
public Button LeaderboardMenuButton;
private List<LeaderboardInformation> players;
// Start is called before the first frame update
void Start()
{
LeaderboardMenuButton.onClick.AddListener(delegate
{
StartCoroutine(GetLeaderboard());
});
}
private void ParseLeaderboardInformation()
{
string parsedString = "";
for (int i = 0; i < players.Count; i++)
{
if (players[i].user_plays == 1) //This removes the plural in how many times the player has played the game.
{
parsedString += $"{i+1}. {players[i].user_username} played {players[i].user_plays} time\n";
break;
}
parsedString += $"{i+1}. {players[i].user_username} played {players[i].user_plays} times\n";
}
Leaderboard.text = parsedString;
}
IEnumerator GetLeaderboard()
{
UnityWebRequest www = UnityWebRequest.Get(Domain.subDomain("includes/get-leaderboard.inc.php"));
yield return www.SendWebRequest();
if (www.isNetworkError || www.isHttpError)
{
Debug.Log(www.error);
}
else
{
// Show results as text
string json = www.downloadHandler.text;
players = JsonConvert.DeserializeObject<List<LeaderboardInformation>>(json);
ParseLeaderboardInformation();
}
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 69ea8de79eecb2641833a267c141affe
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,6 +1,8 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
using UnityEngine.Networking;
using UnityEngine.UI;
public class LevelLoader : MonoBehaviour
@ -11,12 +13,33 @@ public class LevelLoader : MonoBehaviour
public void LoadLevel (string sceneName)
{
StartCoroutine(LoadAsynchronously(sceneName)); //Starts the LoadAsynchronously function
StartCoroutine(UpdateTable()); //Starts the LoadAsynchronously function
StartCoroutine(LoadAsynchronously(sceneName)); //Starts the LoadAsynchronously function
}
IEnumerator UpdateTable()
{
List<IMultipartFormSection> formData = new List<IMultipartFormSection>();
//POST Data
formData.Add(new MultipartFormDataSection("id", UserManager.userID.ToString())); //For the username.
UnityWebRequest www = UnityWebRequest.Post(Domain.subDomain("includes/updateplays.inc.php"), formData); //This initiates the post request.
yield return www.SendWebRequest(); //This sends the post request.
if (www.isNetworkError || www.isHttpError) //This checks for an error with the server.
{
Debug.Log(www.error); //This prints the error.
}
else
{
Debug.Log(www.downloadHandler.text); //This sends the error code or if it worked on the server side.
}
}
IEnumerator LoadAsynchronously (string sceneName)
{
AsyncOperation operation = SceneManager.LoadSceneAsync(sceneName); //Loads the monopoly board.
AsyncOperation operation = SceneManager.LoadSceneAsync(sceneName); //Loads the monopoly board.
loadingScreen.SetActive(true); //Shows the loading screen.

View File

@ -1,9 +1,6 @@
using Newtonsoft.Json;
using System.Collections;
using System.Collections.Generic;
using System.Collections;
using UnityEngine;
using UnityEngine.Networking;
using TMPro;
using UnityEngine.UI;
public class MainMenu : MonoBehaviour
@ -54,7 +51,7 @@ public class MainMenu : MonoBehaviour
Debug.Log("QUIT!");
Application.Quit();
}
IEnumerator GetProperties()
{
UnityWebRequest www = UnityWebRequest.Get(Domain.subDomain("includes/get-properties.inc.php"));

View File

@ -2,7 +2,6 @@
using System.Collections.Generic;
using UnityEngine;
using Newtonsoft.Json;
using UnityEditor;
public class Property
@ -779,7 +778,7 @@ public class Player
{
money -= Convert.ToInt32(fee); //This deducts the money from the user's balance.
}
public bool Mortgage(int currentProperty) //This is used for mortgaging a property.
{
if (currentProperty == 50) //Checks if there was an error - 50 is an error code.

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -9,7 +9,7 @@ Material:
m_PrefabAsset: {fileID: 0}
m_Name: LiberationSans SDF Material
m_Shader: {fileID: 4800000, guid: fe393ace9b354375a9cb14cdbbc28be4, type: 3}
m_ShaderKeywords: OUTLINE_ON
m_ShaderKeywords:
m_LightmapFlags: 1
m_EnableInstancingVariants: 0
m_DoubleSidedGI: 0
@ -30,7 +30,7 @@ Material:
- _MaskSoftnessX: 0
- _MaskSoftnessY: 0
- _OutlineSoftness: 0
- _OutlineWidth: 0.074
- _OutlineWidth: 0.152
- _PerspectiveFilter: 0.875
- _ScaleRatioA: 0.9
- _ScaleRatioB: 1
@ -56,7 +56,7 @@ Material:
- _WeightNormal: 0
m_Colors:
- _ClipRect: {r: -32767, g: -32767, b: 32767, a: 32767}
- _FaceColor: {r: 1, g: 1, b: 1, a: 1}
- _FaceColor: {r: 0, g: 0, b: 0, a: 1}
- _OutlineColor: {r: 0, g: 0, b: 0, a: 1}
- _UnderlayColor: {r: 0, g: 0, b: 0, a: 0.5}
m_BuildTextureStacks: []

52
Assets/sql.sql Normal file
View File

@ -0,0 +1,52 @@
CREATE TABLE properties (
property_id int(2) AUTO_INCREMENT PRIMARY KEY NOT NULL, #Easy way to identify with code
property_name TINYTEXT NOT NULL, #The name of the property
property_group TINYTEXT NOT NULL, #The group that the property is
property_value int(3), #How much it costs to buy the property
property_cost int(3), #How much it is to buy a house/hotel
property_rent int(2), #How much it costs to rent
property_house1 int(3), #How much it costs with 1 house
property_house2 int(3), #How much it costs with 2 houses
property_house3 int(4), #How much it costs with 3 houses
property_house4 int(4), #How much it costs with 4 houses
property_hotel int(4) #How much it costs with a hotel
);
CREATE TABLE cards (
card_id int(11) AUTO_INCREMENT PRIMARY KEY NOT NULL,
card_group int(1) NOT NULL,
card_text TEXT,
card_function int(11) NOT NULL,
extra int(11)
);
CREATE TABLE users (
user_id int(11) AUTO_INCREMENT PRIMARY KEY NOT NULL, #This is a uniquie ID for the user
user_uid TINYTEXT NOT NULL, #This is the username for the user
user_email TINYTEXT NOT NULL, #This is the email for the user
user_pwd LONGTEXT NOT NULL #This is where the hashed password would be stored
);
CREATE TABLE password (
user_id int(11) PRIMARY KEY NOT NULL, #The unique identifier and email used to change the password
pwd_selector TEXT NOT NULL, #Where the selector is stored in plaintext
pwd_token LONGTEXT NOT NULL, #Where the hashed token is stored
pwd_expires INT NOT NULL, #When the token expires
FOREIGN KEY (user_id) REFERENCES users(user_id) #This links the user_id to the users table
);
CREATE TABLE plays (
user_id int(11) PRIMARY KEY NOT NULL, #This is the unique player
user_plays int(11) NOT NULL, #This is how many times the player has played the game
FOREIGN KEY (user_id) REFERENCES users(user_id) #This links the user_id to the users table
);
#Not in use
property_name,property_group,property_value,property_cost,property_rent,property_house1,property_house2,property_house3,property_house4,property_hotel
CREATE TABLE money_spent(
user_id int(11) PRIMARY KEY NOT NULL,
user_spent int(11) NOT NULL,
FOREIGN KEY (user_id) REFERENCES users(user_id)
);

View File

@ -1,6 +1,6 @@
fileFormatVersion: 2
guid: 4e2ec0654b6aa5c4990ff0ee457f2409
TextScriptImporter:
guid: 0910983ed86451f43af20cee848bb834
DefaultImporter:
externalObjects: {}
userData:
assetBundleName: