internal PartCarouselNode(Part.Type partType) { PartType = partType; Scale = 1f; BGNode = new PartCollectionBG(); BGNode.ScaleY = 6f; AddChild(BGNode, -1); var box = BGNode.BoundingBoxTransformedToParent; ContentSize = box.Size; BGNode.Position = (CCPoint)ContentSize / 2; PartCollectionNode = new ScrollableCollectionNode(new CCSize(box.Size.Width, box.Size.Height * 0.7f)); PartCollectionNode.MaxScale = Constants.STANDARD_SCALE * 2; PartCollectionNode.Rows = 1; PartCollectionNode.Columns = 4000; PartCollectionNode.BoxSize = new CCSize(PartCollectionNode.ContentSize.Height, PartCollectionNode.ContentSize.Height); PartCollectionNode.AnchorPoint = CCPoint.AnchorMiddle; PartCollectionNode.Position = (CCPoint)ContentSize / 2; AddChild(PartCollectionNode, 1); }
protected override void AddedToScene() { base.AddedToScene(); // DEBUG: test out the PopUp //PopUp.ShowPopUp(this, "This is a test."); var bounds = VisibleBoundsWorldspace; // move the part carousel away as the hangar does not start there PartCarousel.PositionY += PartCarousel.ContentSize.Height * 1.5f; HangarOptionHangar = new HangarOptionHangar(); HangarOptionWorkshop = new HangarOptionWorkshop(); HangarOptionScrapyard = new HangarOptionScrapyard(); HangarOptionCarousel = new Carousel(new CCSize(bounds.Size.Width, HangarOptionHangar.BoundingBoxTransformedToWorld.Size.Height)); HangarOptionCarousel.NodeAnchor = CCPoint.AnchorMiddleTop; AddChild(HangarOptionCarousel); HangarOptionCarousel.AnchorPoint = CCPoint.AnchorUpperLeft; HangarOptionCarousel.Position = new CCPoint(0, bounds.MaxY); HangarOptionCarousel.AddToCollection(HangarOptionHangar); HangarOptionCarousel.AddToCollection(HangarOptionWorkshop); HangarOptionCarousel.AddToCollection(HangarOptionScrapyard); TakeoffCollectionNode = new ScrollableCollectionNode(new CCSize(bounds.Size.Width, bounds.Size.Height / 7)); float borderToCollection = 15f; TakeoffNode.Position = CCPoint.Zero; TakeoffNode.AnchorPoint = CCPoint.AnchorLowerLeft; TakeoffNode.AddChild(TakeoffCollectionNode); TakeoffCollectionNode.PositionY = borderToCollection; TakeoffCollectionNode.Columns = HangarLayer.UnlockedPlaneSlots; // start off with only one plane slot unlocked TakeoffCollectionNode.Rows = 1; TakeoffCollectionNode.BoxSize = new CCSize(TakeoffCollectionNode.ContentSize.Height, TakeoffCollectionNode.ContentSize.Height); AddChild(TakeoffNode, zOrder: 1); TakeoffNode.ContentSize = new CCSize(TakeoffCollectionNode.ContentSize.Width, TakeoffCollectionNode.ContentSize.Height + 2 * borderToCollection); var drawNode = new CCDrawNode(); TakeoffNode.AddChild(drawNode, zOrder: -1); drawNode.DrawRect(TakeoffNode.BoundingBoxTransformedToWorld, CCColor4B.Black); drawNode.DrawLine(new CCPoint(0, TakeoffNode.BoundingBoxTransformedToWorld.UpperRight.Y), TakeoffNode.BoundingBoxTransformedToWorld.UpperRight, 8f, CCColor4B.White); drawNode.DrawLine(CCPoint.Zero, new CCPoint(TakeoffNode.BoundingBoxTransformedToWorld.MaxX, 0), 8f, CCColor4B.White); TakeoffNode.ContentSize = new CCSize(TakeoffNode.ContentSize.Width, TakeoffNode.ContentSize.Height + 2 * 4f); TakeoffNode.PositionY += 8f; TakeoffNode.AddChild(TakeoffCollectionLabel); TakeoffCollectionLabel.VerticalAlignment = CCVerticalTextAlignment.Center; TakeoffCollectionLabel.HorizontalAlignment = CCTextAlignment.Center; TakeoffCollectionLabel.Color = CCColor3B.White; TakeoffCollectionLabel.Scale = 2.5f; if (PopUp.TriggeredPlayLayer) { TakeoffCollectionLabel.Visible = false; } TakeoffCollectionLabel.AnchorPoint = CCPoint.AnchorMiddle; TakeoffCollectionLabel.Position = (CCPoint)TakeoffNode.ContentSize / 2; GOButton = new GOButton(); AddChild(GOButton); // place the go button a bit higher than the rest (in ZOrder) GOButton.Visible = false; GOButton.Position = GOButtonOutPosition; // let the hangar listen to the TakeoffCollectionNode TakeoffCollectionNode.CollectionRemovalEvent += HangarLayer.ReceiveAircraftFromCollection; // let the hangar listen to the Carousel for a change of the middle node HangarOptionCarousel.MiddleChangedEvent += HangarLayer.MiddleNodeChanged; // listen to the part carousel for a change of the middle node PartCarousel.MiddleChangedEvent += (sender, args) => { if (HangarLayer.State == HangarLayer.HangarState.MODIFY_AIRCRAFT) { HangarLayer.DrawInModifyAircraftState(); } }; // also listen to each part carousel node's collectionNode foreach (var node in PartCarousel.CollectionNode.Children) { PartCarouselNode pNode = (PartCarouselNode)node; pNode.PartCollectionNode.CollectionRemovalEvent += HangarLayer.ReceivePartFromCollection; } }