Created front end for the login and register page

This commit is contained in:
Anthony Berg 2020-09-07 19:06:33 +01:00
parent 8f4595b0ba
commit f856f17cfb
13 changed files with 5305 additions and 32 deletions

5062
Assets/Scenes/login.unity Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 06bc121b9edc6ff4ab13df4566207bbf
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -501,14 +501,14 @@ MonoBehaviour:
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_Color: {r: 0.83921576, g: 0.83921576, b: 0.83921576, 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_Sprite: {fileID: 10907, guid: 0000000000000000f000000000000000, type: 0}
m_Sprite: {fileID: 0}
m_Type: 1
m_PreserveAspect: 0
m_FillCenter: 1

View File

@ -1216,7 +1216,6 @@ RectTransform:
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 0, y: 0, z: 0}
m_Children:
- {fileID: 769744150}
- {fileID: 1029953937}
- {fileID: 1111531777}
- {fileID: 1871971151}
@ -3110,7 +3109,7 @@ RectTransform:
m_Children:
- {fileID: 1977242781}
m_Father: {fileID: 310476697}
m_RootOrder: 5
m_RootOrder: 4
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 1, y: 1}
@ -4157,11 +4156,11 @@ Transform:
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 769744147}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: -543, y: -303, z: 0}
m_LocalPosition: {x: 11, y: -1.5, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 310476697}
m_RootOrder: 0
m_Father: {fileID: 0}
m_RootOrder: 8
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &810784022
GameObject:
@ -4690,7 +4689,7 @@ RectTransform:
m_Children:
- {fileID: 1110544714}
m_Father: {fileID: 310476697}
m_RootOrder: 4
m_RootOrder: 3
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 1, y: 1}
@ -5862,7 +5861,7 @@ RectTransform:
m_Children:
- {fileID: 985089323}
m_Father: {fileID: 310476697}
m_RootOrder: 1
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 1, y: 0.5}
m_AnchorMax: {x: 1, y: 0.5}
@ -6508,7 +6507,7 @@ RectTransform:
- {fileID: 398680387}
- {fileID: 609172439}
m_Father: {fileID: 310476697}
m_RootOrder: 2
m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 1, y: 1}
@ -9644,7 +9643,7 @@ RectTransform:
- {fileID: 323029380}
- {fileID: 1759702751}
m_Father: {fileID: 310476697}
m_RootOrder: 3
m_RootOrder: 2
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 1, y: 1}

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: da669fc6ce289d84892ff69bf89d1224
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,44 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using TMPro;
public class Login : MonoBehaviour
{
public TextMeshProUGUI username; //This is for the username text input.
public TextMeshProUGUI password; //This is for the password text input.
public Button login; //This is the button used to register.
private bool CheckIsEmpty() //This checks if the strings are empty.
{
var strings = new List<string> {username.text, password.text}; //This puts all of the text boxes into an array.
string check = ""; //This is used for the check, the ZWSP is TMP's way of identifying nothing as null.
if (strings.Contains(check)) //If any of the inputs are null.
{
return true;
}
return false;
}
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
if (CheckIsEmpty())
{
login.interactable = false;
}
else
{
login.interactable = true;
}
}
}

View File

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

View File

@ -0,0 +1,52 @@
using System;
using System.Collections.Generic;
using System.Xml.Schema;
using TMPro;
using UnityEngine;
using UnityEngine.UI;
public class Register : MonoBehaviour
{
public TextMeshProUGUI username; //This is for the username text input.
public TextMeshProUGUI email; //This is for the email text input.
public TextMeshProUGUI password; //This is for the password text input.
public TextMeshProUGUI repeatPassword; //This is for the password that has been repeated in the text input.
public Button register; //This is the button used to register.
private bool CheckIsEmpty() //This checks if the strings are empty.
{
var strings = new List<string> {username.text, email.text, password.text, repeatPassword.text}; //This puts all of the text boxes into an array.
string check = ""; //This is used for the check, the ZWSP is TMP's way of identifying nothing as null.
if (strings.Contains(check)) //If any of the inputs are null.
{
return true;
}
return false;
}
void Awake()
{
}
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
if (CheckIsEmpty()) //This checks if all of the inputs are empty.
{
register.interactable = false; //If they are empty, disable the register button.
}
else
{
register.interactable = true; //If all of them are filled, then allow the user to register.
}
}
}

View File

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

View File

@ -191,10 +191,12 @@ public class Board //Creating the class for the board mechanics.
communityPointer = 0;
}
public void MovePlayer(int roll) //This moves the player
public void MovePlayer(int roll1, int roll2) //This moves the player
{
players[currentPlayer].Move(roll); //This is telling the player to move in the local player class.
textHandler.UpdateRoll(roll); //This is updating the text on the screen for the roll
int totalRoll = roll1 + roll2;
players[currentPlayer].Move(roll1, roll2); //This is telling the player to move in the local player class.
textHandler.UpdateRoll(totalRoll); //This is updating the text on the screen for the roll
//Money UI
int money = players[currentPlayer].money; //Gets the money the player has
@ -498,14 +500,16 @@ public class Board //Creating the class for the board mechanics.
{
case 0: //This is for Chance.
card = SelectCard(group); //This selects a card from the deck.
textHandler.ShowCard(group, chance[0].card_text); //This displays the card details on the UI.
textHandler.ShowCard(group, card.card_text); //This displays the card details on the UI.
break;
case 1: //This is for Community Chest.
card = SelectCard(group); //This selects a card from the deck.
textHandler.ShowCard(group, communityChest[0].card_text); //This displays the card details on the UI.
textHandler.ShowCard(group, card.card_text); //This displays the card details on the UI.
break;
}
card = chance[11];
(int, int) properties; //This is initialised to count the properties.
int houses; //This is initialised to calculate the total cost of each house.
int hotels; //This is initialised to calculate the total cost of each hotel.
@ -516,7 +520,7 @@ public class Board //Creating the class for the board mechanics.
{
case 1:
//1 - move | extra - move to x (position)
//TODO
players[currentPlayer].CardMove(1, Convert.ToInt32(card.extra));
break;
case 2:
//2 - bank gives money | extra - give x money (money)
@ -532,6 +536,7 @@ public class Board //Creating the class for the board mechanics.
case 4:
//4 - advance to the nearest station - requires calculation pay the owner 2x the rent
//TODO
players[currentPlayer].CardMove(4, Convert.ToInt32(card.extra));
break;
case 5:
//5 - advance to the nearest utility - make player roll dice, then pay owner 10x entitled pay.
@ -559,6 +564,7 @@ public class Board //Creating the class for the board mechanics.
case 8:
//8 - go back 3 steps.
//TODO
players[currentPlayer].CardMove(8, 3);
break;
case 9:
//9 - get out of jail free card
@ -649,13 +655,13 @@ public class Player
textHandler = GameObject.FindObjectOfType<TextHandler>(); //Finds the text handler script
}
public void Move(int roll) //This moves the player a certain length (what they got from rolling the dice).
public void Move(int roll1, int roll2) //This moves the player a certain length (what they got from rolling the dice).
{
diceRoll = roll;
diceRoll = roll1 + roll2;
int previousPosition = position; //This saves the previous position the player was at
position += roll; //Add the position with what was rolled.
position += diceRoll; //Add the position with what was rolled.
if (position >= 40) //If the player has reached or passed go then...
{
@ -668,6 +674,28 @@ public class Player
//return position; //Returns where the player needs to move to on the board
}
private void MoveToPosition(int position)
{
int previousPosition = this.position;
this.position = position;
movement.Move(previousPosition, this.position, playerNumber);
}
private void MoveBack(int roll)
{
int previousPosition = position; //This saves the previous position the player was at
position -= roll; //Subtracts the position with what was rolled.
if (position < 0) //If the player has reached or passed go then...
{
position += 40; //As the player has gone round the board once, it removes the fact that it has gone around the board once.
}
movement.MoveBack(previousPosition, position, playerNumber);
}
public void GoToJail() //If the player needs to go to jail. TODO
{
int previousPosition = position;
@ -677,11 +705,11 @@ public class Player
movement.Move(previousPosition,position, playerNumber); //Moves the player to jail.
}
public void GetOutOfJail(int roll) //If the player is going out of jail. TODO
public void GetOutOfJail(int roll1, int roll2) //If the player is going out of jail. TODO
{
position = 10; //Moves the player out of jail.
inJail = false; //Disables the inJail functions for the player.
Move(roll); //Then moves the player.
Move(roll1, roll2); //Then moves the player.
}
public void BuyProperty(Property property) //This function allows the player to own a property.
@ -802,6 +830,22 @@ public class Player
return (houses, hotels);
}
public void CardMove(int function, int position)
{
switch (function)
{
case 1:
MoveToPosition(position);
break;
case 4:
break;
case 8:
MoveBack(position);
break;
}
}
}
public class Main : MonoBehaviour

View File

@ -12,14 +12,25 @@ public class Movement : MonoBehaviour
public float speed;
double WPradius = 0.001;
private Main main;
private bool forward;
public void Move(int previousPosition, int _roll, int playerNumber)
{
position = previousPosition;
roll = _roll;
movement = true;
forward = true;
currentPlayer = playerNumber;
movement = true;
}
public void MoveBack(int previousPosition, int back, int playerNumber)
{
forward = false;
position = previousPosition;
roll = back;
currentPlayer = playerNumber;
movement = true;
}
void Awake()
@ -31,7 +42,31 @@ public class Movement : MonoBehaviour
{
if (!movement) return;
if ((Vector3.Distance(waypoints[position].transform.position, players[currentPlayer].transform.position) < WPradius) && roll == 40) //This checks if the player has to go to jail
if (!forward)
{
Debug.Log("yes");
if ((Vector3.Distance(waypoints[position].transform.position, players[currentPlayer].transform.position) < WPradius) && position != roll)
{
position--;
if (position < 0)
{
position = 39;
}
} else if ((Vector3.Distance(waypoints[position].transform.position, players[currentPlayer].transform.position) < WPradius) && position == roll)
{
movement = false;
if (position == 30) //This checks if the player has landed on go to jail.
{
main.board.players[currentPlayer].GoToJail();
return;
}
if (!main.board.CheckProperty(roll))
{
main.board.CheckFees();
}
}
} else if ((Vector3.Distance(waypoints[position].transform.position, players[currentPlayer].transform.position) < WPradius) && roll == 40) //This checks if the player has to go to jail
{
position = 40;
}

View File

@ -44,12 +44,12 @@ public class RollDice : MonoBehaviour
else
{
Debug.Log($"You got out of jail with {dice1} and {dice2}!");
main.board.players[current].GetOutOfJail(totalRoll);
main.board.players[current].GetOutOfJail(dice1, dice2);
return;
}
}
main.board.MovePlayer(1);
main.board.MovePlayer(1, 1);
}
}

View File

@ -1,12 +1,12 @@
1 - move | extra - move to x (position)
1 - move | extra - move to x (position) TODO
2 - bank gives money | extra - give x money (money)
3 - make repairs 25 per house and 100 per hotel.
4 - advance to the nearest station - requires calculation pay the owner 2x the rent
5 - advance to the nearest utility - make player roll dice, then pay owner 10x entitled pay.
4 - advance to the nearest station - requires calculation pay the owner 2x the rent TODO
5 - advance to the nearest utility - make player roll dice, then pay owner 10x entitled pay. TODO
6 - pay each player a sum of money | extra - money x
7 - pay bank | extra - money x
8 - go back 3 steps.
9 - get out of jail free card
8 - go back 3 steps. TODO
9 - get out of jail free card (TODO)
10 - street repairs, 40 per house and 115 per hotel.
11 - collect money from every player | extra - money x