aboutsummaryrefslogtreecommitdiff
path: root/td/Assets/Scripts/player.cs
blob: 30ad07f8e8f9cbcd531244f45b64c595db1a890c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Player : MonoBehaviour {

	public int InitialHealth;
    public int StartingMoney;

	private GameObject[] _towers;
    private int _playerMoney;
    private int _playerScore;
	private int _playerHealth;

    void Awake() {
	    /* This method initializes the player class */
        _playerMoney = StartingMoney;
		_playerHealth = InitialHealth;
    }

	#region stats
    public int Score() {
        return _playerScore;
    }

    public void ScoreAdd(int points) {
        _playerScore += points;
    }

    public int Money() {
        return _playerMoney;
    }

    public void MoneyAdd(int sum) {
        _playerMoney += sum;
    }

    public void MoneySubtract(int sum) {
        _playerMoney -= sum;
    }

	public int Health() {
		return _playerHealth;
	}

	public void DecreaseHealth(int hp) {
		_playerHealth -= hp;
	}
	#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 <Tower>();
		script.Player = this;
	}

}