private void OnTriggerExit(Collider other)
 {
     if (m_SandBagIThrew != null)
     {
         if (other.gameObject == m_SandBagIThrew.gameObject)
         {
             m_SandBagIThrew = null;
         }
     }
 }
Exemplo n.º 2
0
 public SandBag TakeFromCrate(Transform playerTransform)
 {
     if (m_SandBagsInCrate > 0)
     {
         m_SandBagsInCrate--;
         SandBag sandBag = Instantiate(m_SandBag, playerTransform).GetComponent <SandBag>();
         return(sandBag);
     }
     return(null);
 }
    private void OnTriggerStay(Collider collision)
    {
        if (Input.GetKeyDown(m_Interact))
        {
            if (collision.gameObject.CompareTag("SandBag"))
            {
                m_SandBagHolding = collision.gameObject.GetComponent <SandBag>();

                if (m_SandBagHolding.m_PickedUp == false && m_CurrentlyHolding == false)
                {
                    PickUp();
                }
                else if (m_SandBagHolding != null)
                {
                    if (m_SandBagHolding.m_PickedUp == true && m_CurrentlyHolding == true)
                    {
                        LetGo();
                    }
                }
            }
        }
        else if (m_CurrentlyHolding == false && collision.gameObject.CompareTag("SandBag") && collision.GetComponent <SandBag>().m_BeingThrown == true)
        {
            m_SandBagHolding = collision.gameObject.GetComponent <SandBag>();
            if (m_SandBagHolding != m_SandBagIThrew)
            {
                PickUp();
            }
            else
            {
                m_SandBagHolding = null;
            }
        }
        else if (Input.GetKeyDown(m_ThrowKey) && m_SandBagHolding != null)
        {
            m_Rigidbody.velocity        = Vector3.zero;
            m_Rigidbody.angularVelocity = Vector3.zero;
            m_Rigidbody.AddForce(transform.forward * m_ForwardForce, ForceMode.Impulse);
            m_Rigidbody.AddForce(transform.up * m_UpWardForce, ForceMode.Impulse);
            m_SandBagHolding.m_BeingThrown = true;
            m_SandBagIThrew = m_SandBagHolding;
            LetGo();
        }
        if (collision.gameObject.CompareTag("SpawnerCrate") && m_SandBagHolding == null)
        {
            SpawnerBlock sandBagSpawner = collision.gameObject.GetComponent <SpawnerBlock>();

            if (m_CurrentlyHolding == false && sandBagSpawner.m_SandBagsInCrate > 0)
            {
                m_SandBagHolding = sandBagSpawner.TakeFromCrate(transform);
                PickUp();
            }
        }
    }
 private void LetGo()
 {
     m_CurrentlyHolding          = false;
     m_SandBagHolding.m_PickedUp = false;
     m_SandBagCollider.isTrigger = false;
     m_Rigidbody.useGravity      = true;
     m_SandBagPosition.parent    = null;
     m_SandBagPosition           = null;
     m_SandBagCollider           = null;
     m_SandBagHolding            = null;
     m_Rigidbody = null;
 }
Exemplo n.º 5
0
 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;
         }
     }
 }
Exemplo n.º 6
0
 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;
             }
         }
     }
 }
Exemplo n.º 7
0
 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;
         }
     }
 }