From 00759d32f857b9edc3a6c47f7fe63df89f726817 Mon Sep 17 00:00:00 2001 From: smyalygames Date: Thu, 5 Mar 2020 10:48:13 +0000 Subject: [PATCH] Started a player class --- Assets/player.cs | 56 +++++++++++++++++++++++++++++++++++++++++++ Assets/player.cs.meta | 11 +++++++++ Assets/properties.cs | 2 +- 3 files changed, 68 insertions(+), 1 deletion(-) create mode 100644 Assets/player.cs create mode 100644 Assets/player.cs.meta diff --git a/Assets/player.cs b/Assets/player.cs new file mode 100644 index 0000000..98af6df --- /dev/null +++ b/Assets/player.cs @@ -0,0 +1,56 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class player : MonoBehaviour +{ + + public class Player + { + + public int money; //Initializes the variable for money. + public int position = 0; //Positions vary from 0-39 (40 squares on the board) (Go is 0) + + public Player() + { + + } + + public Move(int length) //This moves the player a certain length (what they got from rolling the dice). + { + if (position + length < 40) //Checks if the player will not pass go. + { + position += length; //Adds the length that the player needs to move. + } + else //If they pass go. + { + position = length - (39 - position); //Makes it so that the position is + money += 200; //Collect money as they pass go. + + } + } + + public goToJail() //If the player needs to go to jail. + { + position = 40; //Special position for jail. + } + + public getOutOfJail(int length) //If the player is going out of jail. + { + position = 10; //Moves the player out of jail. + Move(length); //Then moves the player. + } + } + + // Start is called before the first frame update + void Start() + { + + } + + // Update is called once per frame + void Update() + { + + } +} diff --git a/Assets/player.cs.meta b/Assets/player.cs.meta new file mode 100644 index 0000000..f53b80f --- /dev/null +++ b/Assets/player.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 74cd34bd689e47d48862579cdb566e89 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/properties.cs b/Assets/properties.cs index ddc0136..9091ce2 100644 --- a/Assets/properties.cs +++ b/Assets/properties.cs @@ -2,7 +2,7 @@ using System.Collections.Generic; using UnityEngine; -public class NewBehaviourScript : MonoBehaviour +public class properties : MonoBehaviour { public class Property