Пример #1
0
        public BoatComponent(BaseBoat boat, Point3D offset, int[,] directionalItemIDs)
            : base()
        {
            m_Boat  = boat;
            Offset  = offset;
            Movable = false;
            if (directionalItemIDs != null) // it is null for ship cannons
            {
                m_DirectionalItemIDs = directionalItemIDs;
            }
            if (m_Boat != null)
            {
                Point3D loc = m_Boat.GetRotatedLocation(offset.X, offset.Y);
                loc.Z = m_Boat.Z + offset.Z;
                MoveToWorld(loc, m_Boat.Map);
                SetFacing(m_Boat.Direction);
            }
            m_ComponentType = GetBoatComponentType();
            if (m_ComponentType == BoatComponentType.SteeringWheel)
            {
                Name = "ship's wheel";
            }
            else if (m_ComponentType == BoatComponentType.CannonSpot)
            {
                Name = "cannon holder";
            }
            else if (m_ComponentType == BoatComponentType.Rope)
            {
                // don't need to change the name
            }

            /*
             * else if (m_ComponentType == BoatComponentType.Mast)
             * {
             *  Name = "a mast";
             *  if (UberScriptFileName != null)
             *  {
             *      XmlScript script = new XmlScript(UberScriptFileName);
             *      script.Name = "cannon";
             *      XmlAttach.AttachTo(this, script);
             *  }
             * }*/
            else if (m_ComponentType == BoatComponentType.Hold)
            {
                Name = "hold";
            }
        }
Пример #2
0
        public static void PlaceShipCannon(BaseBoat boat, Point3D point, CannonType cannonType, CannonPosition cannonPosition)
        {
            if (boat == null)
            {
                return;
            }

            ShipCannon shipCannon = new ShipCannon();

            shipCannon.Visible = false;

            shipCannon.m_Boat           = boat;
            shipCannon.m_CannonType     = cannonType;
            shipCannon.m_CannonPosition = cannonPosition;
            shipCannon.m_xOffset        = point.X;
            shipCannon.m_yOffset        = point.Y;
            shipCannon.m_zOffset        = point.Z;

            Point3D cannonLocation = boat.GetRotatedLocation(point.X, point.Y, 0);

            shipCannon.MoveToWorld(new Point3D(boat.Location.X + cannonLocation.X, boat.Location.Y + cannonLocation.Y, boat.Location.Z + cannonLocation.Z), boat.Map);
            shipCannon.BoatFacingChange(boat.Facing);
            shipCannon.Z = boat.Location.Z + cannonLocation.Z + shipCannon.GetAdjustedCannonZOffset();

            shipCannon.Hue = boat.CannonHue;

            if (boat.MobileControlType != MobileControlType.Player)
            {
                shipCannon.Ammunition = shipCannon.GetMaxAmmunition();
            }

            shipCannon.Visible = true;

            boat.m_Cannons.Add(shipCannon);

            switch (cannonPosition)
            {
            case CannonPosition.Left: boat.m_LeftCannons.Add(shipCannon); break;

            case CannonPosition.Right: boat.m_RightCannons.Add(shipCannon); break;

            case CannonPosition.Front: boat.m_FrontCannons.Add(shipCannon); break;

            case CannonPosition.Rear: boat.m_RearCannons.Add(shipCannon); break;
            }
        }