Ejemplo n.º 1
0
 public void GiveObj(InteractableWorldObject obj)
 {
     if (data.RightControllerStuff.PreviousState == ControllerState.Empty)
     {
         Instantiate(obj).Grab(data.RightControllerStuff, data.rightControllerAttach);
     }
 }
Ejemplo n.º 2
0
    private void OnTriggerExit(Collider collider)
    {
        InteractableWorldObject interactable = collider.gameObject.GetComponent <InteractableWorldObject>();

        if (interactable && interactable.joint == null)
        {
            Destroy(collider.gameObject, 5f);
        }
    }
Ejemplo n.º 3
0
    private void PickUp(Controller123 stuff, Rigidbody rb, Controller123 other)
    {
        if (stuff.State != ControllerState.Empty)
        {
            return;
        }

        Collider[] hits = new Collider[godConfig.MaxHitsPickUpSphere];

        int count = Physics.OverlapSphereNonAlloc(rb.position, godData.RayCastSphereRadius, hits, godConfig.LayerMaskPickUp);

        if (count < 1)
        {
            return;
        }

        int nearest = 0;

        for (int i = 1; i < count; i++)
        {
            if (Vector3.Distance(rb.position, hits[nearest].transform.position) < Vector3.Distance(rb.position, hits[i].transform.position))
            {
                continue;
            }

            if (other.Obj)
            {
                if (hits[nearest].transform == other.Obj.transform)
                {
                    continue;
                }
            }

            nearest = i;
        }

        if (nearest == 0)
        {
            if (other.Obj)
            {
                if (hits[nearest].transform == other.Obj.transform)
                {
                    return;
                }
            }
        }

        InteractableWorldObject obj = hits[nearest].transform.GetComponent <InteractableWorldObject>();

        if (!obj)
        {
            UnityEngine.Debug.LogWarning("INTERACTABLEWORLDOBJECT PLS");
            return;
        }

        obj.Grab(stuff, rb);
    }
Ejemplo n.º 4
0
    public void ClearHand(InteractableWorldObject obj)
    {
        if (godData.LeftControllerStuff.Obj == obj)
        {
            godData.RightControllerStuff.Obj  = null;
            godData.LeftControllerStuff.State = ControllerState.Empty;
        }

        if (godData.RightControllerStuff.Obj == obj)
        {
            godData.RightControllerStuff.Obj  = null;
            godData.LeftControllerStuff.State = ControllerState.Empty;
        }
    }
Ejemplo n.º 5
0
    protected override void OnCollisionEnter(Collision collision)
    {
        if (collision.gameObject.layer == 8) //Terrain
        {
            var rotation = transform.rotation;

            RaycastHit hitInfo;
            LayerMask  mask = LayerMask.GetMask("Terrain");
            Physics.Raycast(transform.position + Vector3.up, Vector3.down, out hitInfo, 100.0f, mask);

            var vfx = Object2.Instantiate <GameObject>(VFX_Place, transform.position, Quaternion.identity);
            Destroy(vfx, 1.1f);

            rigi.isKinematic = true;

            transform.position = hitInfo.point;
            var localYRotation = rotation.eulerAngles.y;
            rotation.eulerAngles = (new Vector3(0.0f, localYRotation, 0.0f));
            transform.rotation   = rotation;
        }

        if (collision.collider.name == "Tree_05_Downscaled_LOD")
        {
            if (resourceCurrent < resourceRequired)
            {
                InteractableWorldObject worldObject = collision.gameObject.GetComponent <InteractableWorldObject>();
                if (worldObject)
                {
                    if (worldObject.joint)
                    {
                        worldObject.Drop();
                    }
                }

                Destroy(collision.gameObject);
                IncreaseBuildingProgression();
            }
        }
    }
Ejemplo n.º 6
0
 public void ClearHand(InteractableWorldObject obj)
 {
     controller.ClearHand(obj);
 }
Ejemplo n.º 7
0
 public void ClearHand(InteractableWorldObject obj)
 {
 }
Ejemplo n.º 8
0
 public void GiveObj(InteractableWorldObject obj)
 {
 }