Properties are now working

This commit is contained in:
Anthony Berg
2020-07-15 16:25:00 +01:00
parent 091784c015
commit 0853a4d4f0
47 changed files with 13037 additions and 22 deletions

View File

@@ -11,6 +11,7 @@ public class Waypoints : MonoBehaviour
float rotSpeed;
public float speed;
double WPradius = 0.001;
private properties properties;
public void UpdateRoll(int passedRoll)
{
@@ -19,9 +20,14 @@ public class Waypoints : MonoBehaviour
{
roll -= 40;
}
properties.currentProperty(roll);
}
void Update()
void Awake()
{
properties = GameObject.FindObjectOfType<properties>();
}
void Update()
{
if ((Vector3.Distance(waypoints[position].transform.position, transform.position) < WPradius) && position != roll)
{

View File

@@ -1,14 +1,26 @@
using UnityEngine;
using System.Collections;
using UnityEngine.Networking;
using System;
public static class Domain
{
static string domain = "https://monopoly.smyalygames.com/"; //The domain used to access the website.
public static string subDomain(string subDirectory)
{
return (domain + subDirectory); //Adds the subdomain to the website URL
}
}
public class WebTest : MonoBehaviour {
void Start() {
StartCoroutine(GetText());
}
IEnumerator GetText() {
UnityWebRequest www = UnityWebRequest.Get("https://monopoly.smyalygames.com/test.php");
UnityWebRequest www = UnityWebRequest.Get(Domain.subDomain("test.php"));
yield return www.SendWebRequest();
if(www.isNetworkError || www.isHttpError) {
@@ -17,9 +29,6 @@ public class WebTest : MonoBehaviour {
else {
// Show results as text
Debug.Log(www.downloadHandler.text);
// Or retrieve results as binary data
byte[] results = www.downloadHandler.data;
}
}
}

View File

@@ -28,8 +28,8 @@ public class board : MonoBehaviour
// Start is called before the first frame update
void Start()
{
Property cards = new Property("cunt cunt cunt", "test", 200, 400);
Debug.Log(cards.ToString());
//Property cards = new Property("cunt cunt cunt", "test", 200, 400);
//Debug.Log(cards.ToString());
}
// Update is called once per frame

View File

@@ -1,4 +1,5 @@
using System.Collections;
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
@@ -45,7 +46,7 @@ public class player : MonoBehaviour
// Start is called before the first frame update
void Start()
{
Debug.Log(Domain.subDomain("Yes"));
}
// Update is called once per frame

View File

@@ -1,17 +1,34 @@
using System.Collections;
using JetBrains.Annotations;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Networking;
using Newtonsoft.Json;
public class Property
{
/*
public string title; //The name of the property.
public string group; //The colour, station or utility.
public int value; //How much it costs to buy.
public int houseCost; //How much it costs to buy a house on that property.
*/
public int property_id;
public string property_name;
public string property_group;
public int? property_value;
public int? property_cost;
public int? property_rent;
public int? property_house1;
public int? property_house2;
public int? property_house3;
public int? property_house4;
public int? property_hotel;
public int houses = 0; //How many houses it has. (Can have up to 4)
public bool hotel = false; //Whether it has a hotel or not. (Can only have 1)
public bool mortgage = false; //Whether the property has been mortgaged.
/*
public Property(string name, string importGroup, int importValue, int house) //For houses.
{
//Initialising all the variables.
@@ -28,6 +45,7 @@ public class Property
group = importGroup;
value = importValue;
}
*/
public void addHouse() //Used to add a house.
{
@@ -81,24 +99,52 @@ public class Property
}
public string printTitle() {
return title;
return property_name;
}
}
public class properties : MonoBehaviour
{
public List<Property> data;
int test;
// Start is called before the first frame update
void Start()
{
StartCoroutine(GetProperties());
}
// Update is called once per frame
void Update()
{
if (data != null && test == 0)
{
Debug.Log(data[1].printTitle());
test++;
}
}
IEnumerator GetProperties()
{
UnityWebRequest www = UnityWebRequest.Get(Domain.subDomain("includes/get-properties.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;
data = JsonConvert.DeserializeObject<List<Property>>(json);
}
}
public void currentProperty(int propertyNum)
{
Debug.Log(data[propertyNum].printTitle());
}
}