/// <summary>
        /// Unmounts a shape from this shape.  The unmounted shape is in an unregistered state.
        /// </summary>
        /// <param name="mountee">The shape which was previously mounted to this shape.</param>
        /// <returns>True if the shape was found and unmounted.</returns>
        public bool UnmountShape(T2DShape3D mountee)
        {
            if (mountee._mount != this)
                return false;

            mountee._mount = null;
            mountee._mountIndex = -1;
            _mounted.Remove(mountee);

            return true;
        }
Пример #2
0
        ///<summary>
        ///deploy/carry/mount/hold weapon
        ///</summary>
        ///<param name="weapon">weapon to hold</param>
        public void HoldWeapon(Weapon weapon)
        {
            if (null == weapon && null != _currentWeapon)
            {
                UnmountShape(_currentWeapon);
                _currentWeapon = null;
            }
            else if (weapon != null)
            {
                //TODO: need more weapon models
                switch (weapon.WeaponType)
                {
                    case WeaponTypes.Railgun:
                        if (null == _gl)
                        {
                            _gl = new GrenadeLauncher();
                        }
                        _currentWeapon = _gl;
                        break;

                    case WeaponTypes.RocketLauncher:
                        if (null == _gl)
                        {
                            _gl = new GrenadeLauncher();
                        }
                        _currentWeapon = _gl;
                        break;

                    case WeaponTypes.Shotgun:
                        if (null == _rifle)
                        {
                            _rifle = new Rifle();
                        }
                        _currentWeapon = _rifle;
                        break;

                        //case WeaponTypes.Blaster:
                    default:
                        if (null == _rifle)
                        {
                            _rifle = new Rifle();
                        }
                        _currentWeapon = _rifle;
                        break;
                }
                MountShape(_currentWeapon, "Mount0");
            }
        }
        /// <summary>
        /// Mounts another shape object on to this shape at a node.  The mountee
        /// will be unregistered to remove it from the scene graph.
        /// </summary>
        /// <param name="mountee">The shape to mount.</param>
        /// <param name="node">The case sensitive node name at which to mount the shape.</param>
        /// <returns>Returns true if the shape was mounted.</returns>
        public bool MountShape(T2DShape3D mountee, String node)
        {
            // Check some basic issues... we should be initialized.  We should get
            // a mountee and a node.  Make sure the mountee isn't already mounted to
            // something... unmount first!
            if (_shapeInstance == null || mountee == null || node == null ||
                mountee._mount != null)
                return false;

            // Find the node to mount to!
            Shape shape = _shapeInstance.GetShape();
            int index = shape.FindNode(node);
            if (index == -1)
                return false;

            // Setup the mountee... notice we unregister the object
            // here because we no longer want it to appear in the scene
            // graph... we take over rendering ourselves.
            mountee._mount = this;
            mountee._mountIndex = index;
            if (mountee.IsRegistered)
                TorqueObjectDatabase.Instance.Unregister(mountee);

            // Add it to our list of mounted shapes.
            _mounted.Add(mountee);

            return true;
        }