From e13fd4cf1fc0ad9eff857295fd5abc15ab01462c Mon Sep 17 00:00:00 2001 From: Jakob Stendahl Date: Fri, 6 Oct 2017 16:04:38 +0200 Subject: Startet på tårn, fiksa dev-mode, laga stats UI MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- td/Assets/Scripts/player.cs | 48 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 td/Assets/Scripts/player.cs (limited to 'td/Assets/Scripts/player.cs') diff --git a/td/Assets/Scripts/player.cs b/td/Assets/Scripts/player.cs new file mode 100644 index 0000000..b972477 --- /dev/null +++ b/td/Assets/Scripts/player.cs @@ -0,0 +1,48 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class player : MonoBehaviour { + + public int startingMoney; + + GameObject[] towers; + + int playerMoney; + int playerScore; + + bool placingTower; + + void Awake() { + playerMoney = startingMoney; + } + + #region stats + public int score() { + return playerScore; + } + + public void score(int points) { + playerScore += points; + } + + public int money() { + return playerMoney; + } + + public void moneyAdd(int sum) { + playerMoney += sum; + } + + public void moneySubtract(int sum) { + playerMoney -= sum; + } + #endregion + + public void spawnTower(GameObject towerType) { + GameObject tower = Instantiate (towerType, new Vector3 (0, 0, 0), Quaternion.identity, transform.Find ("towers").transform); + tower script = tower.GetComponent (); + script.player = this; + } + +} -- cgit v1.2.3