-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathFarmer.cs
More file actions
50 lines (44 loc) · 1.21 KB
/
Farmer.cs
File metadata and controls
50 lines (44 loc) · 1.21 KB
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
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using TMPro;
public class Farmer : MonoBehaviour
{
private GameObject TaskM;
public bool inRange;
public int TreesPlanted;
public GameObject FarmerFin;
private GameObject Player;
private void Start()
{
TreesPlanted = 0;
TaskM = GameObject.Find("TaskManager");
Player = GameObject.Find("Player");
}
private void Update()
{
if(inRange == true && Input.GetKeyDown(KeyCode.Space))
{
Player.GetComponent<PlayerScript>().hasSeed = true;
Debug.Log("BOOL IS ACTIVE");
}
if (TreesPlanted == 3)
{
TaskM.GetComponent<Tasks_GameManager>().isFarmerFinished = true;
Instantiate(FarmerFin, transform.position, Quaternion.identity);
Destroy(gameObject);
}
}
private void OnTriggerEnter2D(Collider2D collision)
{
if(collision.gameObject.tag == "Player")
{
inRange = true;
}
}
private void OnTriggerExit2D(Collider2D collision)
{
inRange = false;
}
}