public BodyBigBomberShiny() : base("bodyBigBomberShiny.png") { SetHealthAndMaxHealth(80); NormalAnchorPoint = CCPoint.AnchorMiddle; // set your types Types = new Type[] { Type.BODY }; // NEW: add mount points for two single wings var wingMount1 = new PartMount(this, new CCPoint((ContentSize.Width * 0.62f), (ContentSize.Height / 2) + 4), Type.SINGLE_WING); var wingMount2 = new PartMount(this, new CCPoint((ContentSize.Width * 0.62f), (ContentSize.Height / 2) - 4), Type.SINGLE_WING); // add mount points for two rudders var rudderMount1 = new PartMount(this, new CCPoint(11f, (ContentSize.Height / 2) + 2), Type.RUDDER); var rudderMount2 = new PartMount(this, new CCPoint(11f, (ContentSize.Height / 2) - 2), Type.RUDDER); // add a mount for a weapon var gunMount = new PartMount(this, new CCPoint(31, ContentSize.Height / 2), Type.GUN); gunMount.MaxTurningAngle = 180f; PartMounts = new PartMount[] { wingMount1, wingMount2, rudderMount1, rudderMount2, gunMount }; // specify the collision polygon CollisionType = Collisions.CreateDiamondCollisionPolygon(this); // specify the mass points MassPoints = CreateDiamondMassPoints(160); }
public TestWings() : base("testWings.png") { // set your types Types = new Type[] { Type.WINGS }; NormalAnchorPoint = CCPoint.AnchorMiddle; // add a mount point for two engines at the center of each wing var engineMount1 = new PartMount(this, new CCPoint(ContentSize.Width / 2, (ContentSize.Height / 2) + (ContentSize.Height / 4)), Type.ENGINE); var engineMount2 = new PartMount(this, new CCPoint(ContentSize.Width / 2, (ContentSize.Height / 2) - (ContentSize.Height / 4)), Type.ENGINE); // add mount points for two guns a bit further out var gunMount1 = new PartMount(this, new CCPoint(ContentSize.Width / 2, (ContentSize.Height - (ContentSize.Height / 6))), Type.GUN); var gunMount2 = new PartMount(this, new CCPoint(ContentSize.Width / 2, ContentSize.Height / 6), Type.GUN); gunMount1.NullRotation = -20f; gunMount1.Dz = 1; gunMount2.NullRotation = 20f; gunMount2.Dz = 1; PartMounts = new PartMount[] { engineMount1, engineMount2, gunMount1, gunMount2 }; // specify the collision polygon CollisionType = Collisions.CreateDiamondCollisionPolygon(this); // specify the mass points MassPoints = new MassPoint[] { new MassPoint((ContentSize.Width / 2) - 1, ContentSize.Height, 30), new MassPoint((ContentSize.Width / 2), (ContentSize.Height / 2) + (ContentSize.Height / 6), 50), new MassPoint((ContentSize.Width / 2), (ContentSize.Height / 2) - (ContentSize.Height / 6), 50), new MassPoint((ContentSize.Width / 2) - 1, 0, 30) }; }
public BodyFighterShiny() : base("bodyFighterShiny.png") { SetHealthAndMaxHealth(30); NormalAnchorPoint = CCPoint.AnchorMiddle; // set your types Types = new Type[] { Type.BODY }; // add mount points for two single wings var wingMount1 = new PartMount(this, new CCPoint(ContentSize.Width * 0.65f, (ContentSize.Height / 2) + 3), Type.SINGLE_WING); var wingMount2 = new PartMount(this, new CCPoint(ContentSize.Width * 0.65f, (ContentSize.Height / 2) - 3), Type.SINGLE_WING); var doubleWingMount = new PartMount(this, new CCPoint((ContentSize.Width * 0.65f), ContentSize.Height / 2), Type.WINGS); doubleWingMount.PossiblyBlockingPartMounts.Add(wingMount1); doubleWingMount.PossiblyBlockingPartMounts.Add(wingMount2); wingMount1.PossiblyBlockingPartMounts.Add(doubleWingMount); wingMount2.PossiblyBlockingPartMounts.Add(doubleWingMount); // add mount points for two rudders var rudderMount1 = new PartMount(this, new CCPoint(4.5f, (ContentSize.Height / 2) + 1), Type.RUDDER); var rudderMount2 = new PartMount(this, new CCPoint(4.5f, (ContentSize.Height / 2) - 1), Type.RUDDER); // add a mount for a rotor var rotorMount = new PartMount(this, new CCPoint(ContentSize.Width - 1, ContentSize.Height / 2), Type.ROTOR); PartMounts = new PartMount[] { wingMount1, wingMount2, doubleWingMount, rudderMount1, rudderMount2, rotorMount }; // specify the collision polygon CollisionType = Collisions.CreateDiamondCollisionPolygon(this); // specify the mass points MassPoints = CreateDiamondMassPoints(55); }
public BodyJet() : base("bodyJet.png") { SetHealthAndMaxHealth(40); NormalAnchorPoint = CCPoint.AnchorMiddle; // set your types Types = new Type[] { Type.BODY }; // add mount points for two single wings var wingMount1 = new PartMount(this, new CCPoint(ContentSize.Width * 0.4f, (ContentSize.Height / 2) + 5), Type.SINGLE_WING); var wingMount2 = new PartMount(this, new CCPoint(ContentSize.Width * 0.4f, (ContentSize.Height / 2) - 5), Type.SINGLE_WING); // add mount points for two rudders var rudderMount1 = new PartMount(this, new CCPoint(6f, (ContentSize.Height / 2) + 2), Type.RUDDER); var rudderMount2 = new PartMount(this, new CCPoint(6f, (ContentSize.Height / 2) - 2), Type.RUDDER); PartMounts = new PartMount[] { wingMount1, wingMount2, rudderMount1, rudderMount2 }; // specify the collision polygon CollisionType = Collisions.CreateDiamondCollisionPolygon(this); // specify the mass points MassPoints = CreateDiamondMassPoints(80); // add a special maneuver ability! (jet propulsion :) ) ManeuverAbility = new ManeuverAbility((float)Math.Pow(10, 5) * 2.75f, (float)Math.Pow(10, 5) * 35.0f); ManeuverAbility.CloudTailNode.ReferenceSize *= 2f; }
public BodyPotatoShiny() : base("bodyPotatoShiny.png") { SetHealthAndMaxHealth(18); NormalAnchorPoint = CCPoint.AnchorMiddle; // set your types Types = new Type[] { Type.BODY }; // add mount points for two single wings (and a rivaling double wing mount) var wingMount1 = new PartMount(this, new CCPoint((ContentSize.Width * 0.75f), (ContentSize.Height / 2) + 5), Type.SINGLE_WING); var wingMount2 = new PartMount(this, new CCPoint((ContentSize.Width * 0.75f), (ContentSize.Height / 2) - 5), Type.SINGLE_WING); var doubleWingMount = new PartMount(this, new CCPoint((ContentSize.Width * 0.65f), ContentSize.Height / 2), Type.WINGS); doubleWingMount.Dz = 2; doubleWingMount.PossiblyBlockingPartMounts.Add(wingMount1); doubleWingMount.PossiblyBlockingPartMounts.Add(wingMount2); wingMount1.PossiblyBlockingPartMounts.Add(doubleWingMount); wingMount2.PossiblyBlockingPartMounts.Add(doubleWingMount); // add mount points for two rudders var rudderMount1 = new PartMount(this, new CCPoint(2f, (ContentSize.Height / 2) + 1), Type.RUDDER); var rudderMount2 = new PartMount(this, new CCPoint(2f, (ContentSize.Height / 2) - 1), Type.RUDDER); // add a mount for a rotor or weapon var rotorMount = new PartMount(this, new CCPoint(ContentSize.Width - 3, ContentSize.Height / 2), Type.ROTOR, Type.GUN); rotorMount.MaxTurningAngle = 40f; PartMounts = new PartMount[] { wingMount1, wingMount2, doubleWingMount, rudderMount1, rudderMount2, rotorMount }; // specify the collision polygon CollisionType = Collisions.CreateDiamondCollisionPolygon(this); // specify the mass points MassPoints = CreateDiamondMassPoints(35); }
public BodyBalloonShiny() : base("bodyBalloonShiny.png") { SetHealthAndMaxHealth(40); NormalAnchorPoint = CCPoint.AnchorMiddle; // set your types Types = new Type[] { Type.BODY }; // add a central mount point for a weapon var weaponMount = new PartMount(this, (CCPoint)ContentSize / 2, Type.GUN); weaponMount.MaxTurningAngle = 115f; weaponMount.Dz = -1; // add mount points for two rotors var rotorMount1 = new PartMount(this, new CCPoint(ContentSize.Width / 2, 4), Type.ROTOR); var rotorMount2 = new PartMount(this, new CCPoint(ContentSize.Width / 2, ContentSize.Height - 4), Type.ROTOR); rotorMount1.Dz = 1; rotorMount2.Dz = 1; PartMounts = new PartMount[] { weaponMount, rotorMount1, rotorMount2 }; // specify the collision polygon CollisionType = Collisions.CreateDiamondCollisionPolygon(this); // specify the mass points MassPoints = CreateDiamondMassPoints(400); }
public TestBodyShiny() : base("bodyTestShiny.png") { SetHealthAndMaxHealth(18); NormalAnchorPoint = CCPoint.AnchorMiddle; //Position = new CCPoint((ContentSize.Width / 2), (ContentSize.Height / 2)); // set your types Types = new Type[] { Type.BODY }; // NEW: add mount points for two single wings var wingMount1 = new PartMount(this, new CCPoint((ContentSize.Width / 2) + 3f, (ContentSize.Height / 2) + 4), Type.SINGLE_WING); var wingMount2 = new PartMount(this, new CCPoint((ContentSize.Width / 2) + 3f, (ContentSize.Height / 2) - 4), Type.SINGLE_WING); var doubleWingMount = new PartMount(this, new CCPoint((ContentSize.Width / 2) + 3.5f, (ContentSize.Height / 2)), Type.WINGS); doubleWingMount.PossiblyBlockingPartMounts.Add(wingMount1); doubleWingMount.PossiblyBlockingPartMounts.Add(wingMount2); wingMount1.PossiblyBlockingPartMounts.Add(doubleWingMount); wingMount2.PossiblyBlockingPartMounts.Add(doubleWingMount); // add mount points for two rudders var rudderMount1 = new PartMount(this, new CCPoint(5, (ContentSize.Height / 2) + 1), Type.RUDDER); var rudderMount2 = new PartMount(this, new CCPoint(5, (ContentSize.Height / 2) - 1), Type.RUDDER); // add a mount for a rotor var rotorMount = new PartMount(this, new CCPoint(ContentSize.Width - 5, ContentSize.Height / 2), Type.ROTOR); PartMounts = new PartMount[] { wingMount1, wingMount2, doubleWingMount, rudderMount1, rudderMount2, rotorMount }; // specify the collision polygon CollisionType = Collisions.CreateDiamondCollisionPolygon(this); // specify the mass points MassPoints = CreateDiamondMassPoints(55); //new MassPoint[] { new MassPoint(ContentSize.Width / 5, ContentSize.Height / 2, 100), new MassPoint(ContentSize.Width - (ContentSize.Width / 5), ContentSize.Height / 2, 90) }; }
/// <summary> /// tries to mount a given part on a PartMount of this Part /// </summary> /// <param name="partMount"></param> /// <param name="part"></param> /// <param name="dz">the difference in ZOrder between the mounted part and this part</param> /// <returns>whether it was successfully mounted</returns> internal bool MountPart(PartMount partMount, Part part) { // check whether the PartMount is actually one of yours and proceed if true for (int i = 0; i < PartMounts.Length; i++) { if (PartMounts[i].Equals(partMount)) { return(MountPart(i, part)); } } return(false); }
public WingFighterShiny() : base("wingFighterShiny.png") { SetHealthAndMaxHealth(25); // set your types Types = new Type[] { Type.SINGLE_WING }; NormalAnchorPoint = new CCPoint(0.5f, 1 / ContentSize.Height); // add a mount point for a gun var gunMount = new PartMount(this, new CCPoint(ContentSize.Width / 2, ContentSize.Height / 2), Type.GUN); gunMount.Dz = -1; PartMounts = new PartMount[] { gunMount }; // specify the collision polygon CollisionType = Collisions.CreateDiamondCollisionPolygon(this); // specify the mass points MassPoints = CreateDiamondMassPoints(18f); }
public WingBigBomber() : base("wingBigBomber.png") { SetHealthAndMaxHealth(40); // set your types Types = new Type[] { Type.SINGLE_WING }; NormalAnchorPoint = new CCPoint(0.5f, 0); // add mount points for 2 rotors var rotorMount1 = new PartMount(this, new CCPoint(ContentSize.Width - 3f, 8.5f), Type.ROTOR); var rotorMount2 = new PartMount(this, new CCPoint(ContentSize.Width - 3f, 21.5f), Type.ROTOR); PartMounts = new PartMount[] { rotorMount1, rotorMount2 }; // specify the collision polygon CollisionType = Collisions.CreateDiamondCollisionPolygon(this); // specify the mass points MassPoints = CreateDiamondMassPoints(120f); }
public TestWing() : base("testWing.png") { // set your types Types = new Type[] { Type.SINGLE_WING }; NormalAnchorPoint = CCPoint.AnchorMiddleBottom; // add a mount point for two engines at the center of the wing var engineMount = new PartMount(this, new CCPoint(ContentSize.Width / 2, (ContentSize.Height / 2)), Type.ENGINE); // add a mount points for a gun a bit further out var gunMount = new PartMount(this, new CCPoint(ContentSize.Width / 2, (ContentSize.Height - (ContentSize.Height / 4))), Type.GUN); gunMount.NullRotation = -20f; gunMount.Dz = 1; PartMounts = new PartMount[] { engineMount, gunMount }; // specify the collision polygon CollisionType = Collisions.CreateDiamondCollisionPolygon(this); // specify the mass points MassPoints = new MassPoint[] { new MassPoint((ContentSize.Width / 2) - 1, ContentSize.Height, 30), new MassPoint((ContentSize.Width / 2), (ContentSize.Height / 2) + (ContentSize.Height / 6), 50), new MassPoint((ContentSize.Width / 2), (ContentSize.Height / 2) - (ContentSize.Height / 6), 50), new MassPoint((ContentSize.Width / 2) - 1, 0, 30) }; }
public TestDoubleWingShiny() : base("doubleWingsTestShiny.png") { SetHealthAndMaxHealth(17); // set your types Types = new Type[] { Type.WINGS }; NormalAnchorPoint = CCPoint.AnchorMiddle; // add mounts points for guns var gunMount1 = new PartMount(this, new CCPoint(ContentSize.Width / 2, (ContentSize.Height - (ContentSize.Height / 4))), Type.GUN); var gunMount2 = new PartMount(this, new CCPoint(ContentSize.Width / 2, (ContentSize.Height / 4)), Type.GUN); gunMount1.Dz = -1; gunMount2.Dz = -1; PartMounts = new PartMount[] { gunMount1, gunMount2 }; // specify the collision polygon CollisionType = Collisions.CreateDiamondCollisionPolygon(this); // specify the mass points MassPoints = CreateDiamondMassPoints(28); }
public BodyScrap() : base("bodyScrap.png") { SetHealthAndMaxHealth(14); NormalAnchorPoint = CCPoint.AnchorMiddle; //Position = new CCPoint((ContentSize.Width / 2), (ContentSize.Height / 2)); // set your types Types = new Type[] { Type.BODY }; // OLD: add a mount point for wings at your center // NEW: add mount points for two single wings var wingMount1 = new PartMount(this, new CCPoint((ContentSize.Width / 2) + 4.5f, (ContentSize.Height / 2) + 4), Type.SINGLE_WING); var wingMount2 = new PartMount(this, new CCPoint((ContentSize.Width / 2) + 4.5f, (ContentSize.Height / 2) - 4), Type.SINGLE_WING); var doubleWingMount = new PartMount(this, new CCPoint((ContentSize.Width / 2) + 5f, (ContentSize.Height / 2)), Type.WINGS); doubleWingMount.Dz = 2; doubleWingMount.PossiblyBlockingPartMounts.Add(wingMount1); doubleWingMount.PossiblyBlockingPartMounts.Add(wingMount2); wingMount1.PossiblyBlockingPartMounts.Add(doubleWingMount); wingMount2.PossiblyBlockingPartMounts.Add(doubleWingMount); // add mount points for two rudders var rudderMount1 = new PartMount(this, new CCPoint(5, (ContentSize.Height / 2) + 1), Type.RUDDER); var rudderMount2 = new PartMount(this, new CCPoint(5, (ContentSize.Height / 2) - 1), Type.RUDDER); // add a mount for a rotor var rotorMount = new PartMount(this, new CCPoint(ContentSize.Width - 4, ContentSize.Height / 2), Type.ROTOR); // add a mount for a weapon aiming backwards var weaponMount = new PartMount(this, new CCPoint(15f, ContentSize.Height / 2), Type.GUN); weaponMount.NullRotation = 180f; weaponMount.MaxTurningAngle = 75f; PartMounts = new PartMount[] { wingMount1, wingMount2, doubleWingMount, rudderMount1, rudderMount2, rotorMount, weaponMount }; // specify the collision polygon CollisionType = Collisions.CreateDiamondCollisionPolygon(this); // specify the mass points MassPoints = CreateDiamondMassPoints(60); //new MassPoint[] { new MassPoint(ContentSize.Width / 5, ContentSize.Height / 2, 100), new MassPoint(ContentSize.Width - (ContentSize.Width / 5), ContentSize.Height / 2, 90) }; }
public WingPotatoShiny() : base("wingPotatoShiny.png") { SetHealthAndMaxHealth(3); // set your types Types = new Type[] { Type.SINGLE_WING }; NormalAnchorPoint = new CCPoint(0.6f, 2 / ContentSize.Height); // SHINY: add a mount point for a weapons var weaponMount = new PartMount(this, new CCPoint(ContentSize.Width - 6, ContentSize.Height - 7), Type.GUN); weaponMount.MaxTurningAngle = 90f; PartMounts = new PartMount[] { weaponMount }; // specify the collision polygon CollisionType = Collisions.CreateDiamondCollisionPolygon(this); // specify the mass points MassPoints = CreateDiamondMassPoints(15f); // give it a maneuver ability! ManeuverAbility = new ManeuverAbility((float)Math.Pow(10, 5) * 0.95f, (float)Math.Pow(10, 5) * 3.0f, (float)Math.Pow(10, 5) * 0.45f, (float)Math.Pow(10, 5) * 0.75f); ManeuverAbility.CloudTailNode = null; }
new private protected void OnTouchesEnded(List <CCTouch> touches, CCEvent touchEvent) { base.OnTouchesEnded(touches, touchEvent); switch (touches.Count) { case 1: { var touch = touches[0]; if (DragAndDropObject != null) { touchEvent.StopPropogation(); switch (HangarLayer.State) { case HangarLayer.HangarState.HANGAR: var selectedAircraft = DragAndDropObject as Aircraft; DragAndDropObject = null; if (selectedAircraft != null) { // if an aircraft is dragged upon the takeoff node add it to the collection if (!(TakeoffNode.BoundingBoxTransformedToParent.ContainsPoint(touch.Location) && TakeoffCollectionNode.AddToCollection(selectedAircraft))) { // if not, then place it back into the hangar HangarLayer.AddAircraftChild(selectedAircraft); selectedAircraft.Scale = Constants.STANDARD_SCALE; HangarLayer.PlaceAircraft(selectedAircraft, HangarLayer.GUICoordinatesToHangar(selectedAircraft.Position)); } if (TakeoffCollectionNode.Collection.Any()) { GOButton.AddAction(HangarLayer.AddGOButton); TakeoffCollectionLabel.Visible = false; } else if (!PopUp.TriggeredPlayLayer) { TakeoffCollectionLabel.Visible = true; } } break; case HangarLayer.HangarState.MODIFY_AIRCRAFT: { bool mounted = false; HangarLayer.UpdateClosestMount(); // the object is a part var part = (Part)DragAndDropObject; DragAndDropObject = null; // if it is a body and the aircraft currently has none (which means no parts at all) if (HangarLayer.ModifiedAircraft.Body == null && part.Types.Contains(Part.Type.BODY) && CCPoint.IsNear(HangarLayer.GUICoordinatesToHangar(part.PositionWorldspace), HangarLayer.ModifiedAircraft.PositionWorldspace, MOUNT_DISTANCE)) { // set it as the aircraft body HangarLayer.ModifiedAircraft.InWorkshopConfiguration = false; part.Scale = 1; HangarLayer.ModifiedAircraft.Body = part; HangarLayer.ModifiedAircraft.InWorkshopConfiguration = true; HangarLayer.CalcBoundaries(); // the aircraft has changed size, so update the boundaries HangarLayer.DrawInModifyAircraftState(); mounted = true; } // check if the part is currently at a mount point where it can be mounted else if (!mounted) { var possibleMounts = new List <PartMount>(); foreach (var modPart in HangarLayer.ModifiedAircraft.TotalParts) { foreach (var mountPoint in modPart.PartMounts) { if (mountPoint.Available && mountPoint.CanMount(part)) { if (CCPoint.IsNear(HangarLayer.GUICoordinatesToHangar(part.PositionWorldspace), mountPoint.PositionModifyAircraft, MOUNT_DISTANCE)) { possibleMounts.Add(mountPoint); } } } } // mount at the closest possible mount point float minDistance = float.PositiveInfinity; PartMount closestMount = null; foreach (var mountPoint in possibleMounts) { float distance = CCPoint.Distance(HangarLayer.GUICoordinatesToHangar(part.PositionWorldspace), mountPoint.PositionModifyAircraft); if (distance < minDistance) { minDistance = distance; closestMount = mountPoint; } } if (closestMount != null) { // better mount in non-workshop configuration HangarLayer.ModifiedAircraft.InWorkshopConfiguration = false; part.Scale = 1; closestMount.MyPart.MountPart(closestMount, part); HangarLayer.ModifiedAircraft.InWorkshopConfiguration = true; HangarLayer.CalcBoundaries(); // the aircraft has probably changed size, so update the boundaries HangarLayer.DrawInModifyAircraftState(); mounted = true; } } // if the part has not been mounted the part is just dropped and added to the collection if (!mounted) { // first disassemble it though // and flip it if it is flipped var totalParts = part.TotalParts; part.Disassemble(); foreach (var singlePart in totalParts) { if (singlePart.Flipped) { singlePart.Flip(); } HangarLayer.AddPart(singlePart); } } } break; } DragAndDropObject = null; } } break; default: break; } }