Пример #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);
            }
        }
Пример #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);
            }
        }