Esempio n. 1
0
        public void GrabAmmo(Grabber grabber)
        {
            if (GetAmmo() != null)
            {
                GameObject ammo = Instantiate(GetAmmo(), grabber.transform.position, grabber.transform.rotation) as GameObject;
                Grabbable  g    = ammo.GetComponent <Grabbable>();

                // Disable rings for performance
                GrabbableRingHelper grh = ammo.GetComponentInChildren <GrabbableRingHelper>();
                if (grh)
                {
                    Destroy(grh);
                    RingHelper r = ammo.GetComponentInChildren <RingHelper>();
                    Destroy(r.gameObject);
                }


                // Offset to hand
                ammo.transform.parent        = grabber.transform;
                ammo.transform.localPosition = -g.GrabPositionOffset;
                ammo.transform.parent        = null;

                grabber.GrabGrabbable(g);
            }
        }
Esempio n. 2
0
        public void GrabAmmo(Grabber grabber)
        {
            if (demoClips == null)
            {
                demoClips = new List <Grabbable>();
            }

            if (demoClips.Count > 0 && demoClips[0] == null)
            {
                demoClips.RemoveAt(0);
            }

            if (AmmoObject != null)
            {
                // Make room for new clip. This ensures the demo doesn't ge bogged down
                if (demoClips.Count > 4 && demoClips[0] != null && demoClips[0].transform.parent == null)
                {
                    GameObject.Destroy(demoClips[0].gameObject);
                }

                GameObject ammo = Instantiate(AmmoObject, grabber.transform.position, grabber.transform.rotation) as GameObject;
                Grabbable  g    = ammo.GetComponent <Grabbable>();

                // Disable rings for performance
                GrabbableRingHelper grh = ammo.GetComponentInChildren <GrabbableRingHelper>();
                Destroy(grh);
                RingHelper r = ammo.GetComponentInChildren <RingHelper>();
                Destroy(r.gameObject);

                // Offset to hand
                ammo.transform.parent        = grabber.transform;
                ammo.transform.localPosition = -g.GrabPositionOffset;
                ammo.transform.parent        = null;

                if (g != null)
                {
                    demoClips.Add(g);
                }

                grabber.GrabGrabbable(g);
            }
        }
Esempio n. 3
0
        void Start()
        {
            // Set up Ring
            if (RingOnValidPickup)
            {
                RingHelper rh = GetComponentInChildren <RingHelper>();
                if (rh == null)
                {
                    GameObject go = Instantiate(Resources.Load("RingHelper", typeof(GameObject))) as GameObject;
                    go.transform.SetParent(this.transform, false);
                    go.transform.name          = "Ring Helper";
                    go.transform.localPosition = grab.GrabPositionOffset;

                    // Use GrabPoint if set
                    if (grab.GrabPoints != null && grab.GrabPoints.Count > 0)
                    {
                        go.transform.localPosition = grab.GrabPoints.FirstOrDefault().localPosition;
                    }

                    RectTransform rt = go.GetComponent <RectTransform>();
                    rt.localScale = new Vector3(RingHelperScale, RingHelperScale, RingHelperScale);
                }
            }
        }