-
Notifications
You must be signed in to change notification settings - Fork 0
/
SandBagArea.cs
55 lines (52 loc) · 1.24 KB
/
SandBagArea.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
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class SandBagArea : MonoBehaviour {
public bool m_Full;
public SandBag m_InSandBag;
public SandBagHealth m_SandBagHealth;
private void Update()
{
if (m_Full == true && m_InSandBag.m_PickedUp == false && m_InSandBag.m_PlacedDown == false)
{
m_InSandBag.gameObject.transform.position = transform.position;
m_InSandBag.m_PlacedDown = true;
}
if (m_Full)
{
if (m_SandBagHealth.WhatsMyHealth() <= 0)
{
Destroy(m_InSandBag.gameObject);
m_InSandBag = null;
m_Full = false;
}
}
}
private void OnTriggerStay(Collider collision)
{
if (collision.gameObject.CompareTag("SandBag"))
{
if(m_Full == false) {
m_InSandBag = collision.gameObject.GetComponent<SandBag>();
m_SandBagHealth = collision.gameObject.GetComponent<SandBagHealth>();
if (m_InSandBag.m_PickedUp == false)
{
m_Full = true;
}
}
}
}
private void OnTriggerExit(Collider collision)
{
if (collision.gameObject.CompareTag("SandBag"))
{
if (m_Full == true)
{
m_InSandBag.m_PlacedDown = false;
m_InSandBag = null;
m_SandBagHealth = null;
m_Full = false;
}
}
}
}