-
Notifications
You must be signed in to change notification settings - Fork 0
/
ItemBehaviour.cs
122 lines (74 loc) · 2.82 KB
/
ItemBehaviour.cs
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
using UnityEngine;
public class ItemBehaviour : MonoBehaviour
{
[SerializeField] private LayerMask whatIsGround;
[SerializeField] private Transform groundCheck;
[SerializeField] private LayerMask ignoreCollision;
public GameObject stone;
public GameObject dirt;
public GameObject grass;
//private const float itemWidth = (RectTransform)this.gameObject.transform.rect.width;
// Class needs to be in charge of creating/rendering items when they are destroyed
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
}
void FixedUpdate()
{
//Collider2D collider = Physics2D.OverlapBoxAll(groundCheck.position, new Vector2(this.transform., whatIsGround);
if (GetComponent<Collider>())
{
// Item is touching ground
}
}
// Called when dropped item needs to be rendered on floor
public void dropItem(Vector3 pos, int itemType)
{
//Debug.Log("test");
switch(itemType)
{
// Destroy stone
case 1:
//Instantiate(stonePrefab, position, Quaternion.identity).transform.parent = this.transform; ;
GameObject stoneItem = GameObject.Instantiate(stone);
stoneItem.transform.position = pos;
//stoneItem.transform.position.z = 0;
stoneItem.transform.parent = this.transform;
//creature.gameObject.transform.parent = this.transform;
break;
// Destroy dirt
case 2:
Instantiate(dirt, pos, Quaternion.identity).transform.parent = this.transform; ;
break;
// Destroy grass
case 3:
Instantiate(grass, pos, Quaternion.identity).transform.parent = this.transform;
break;
// Destroy coal
case 4:
//Instantiate(myPrefab, position, Quaternion.identity);
break;
// Destroy iron
case 5:
//Instantiate(myPrefab, position, Quaternion.identity);
break;
// Destroy tree
case 11:
//Instantiate(myPrefab, position, Quaternion.identity);
break;
}
/*
Vector3 centralPosition = player.transform.position;
GameObject creature = GameObject.Instantiate(hostileCreature);
creature.gameObject.transform.parent = this.transform;
float randPosition = Random.Range(-300, 300);
creature.transform.position = new Vector3(centralPosition.x + randPosition, 800);
creature.SetActive(true);
*/
//Instantiate(myPrefab, position, Quaternion.identity);
}
}