//--------------------------------------------------------------------------------------------------------- // SetupUI //--------------------------------------------------------------------------------------------------------- // Sets up the game UI //--------------------------------------------------------------------------------------------------------- void SetupUI(CCRect screenBounds) { slot1NewGameLabel = new CCLabel("New Game", GOTHIC_56_WHITE_HD_FNT); slot2NewGameLabel = new CCLabel("New Game", GOTHIC_56_WHITE_HD_FNT); slot3NewGameLabel = new CCLabel("New Game", GOTHIC_56_WHITE_HD_FNT); slot1NameLabel = new CCLabel(player1.Name, GOTHIC_56_WHITE_FNT) { HorizontalAlignment = CCTextAlignment.Left }; slot2NameLabel = new CCLabel(player2.Name, GOTHIC_56_WHITE_FNT) { HorizontalAlignment = CCTextAlignment.Left }; slot3NameLabel = new CCLabel(player3.Name, GOTHIC_56_WHITE_FNT) { HorizontalAlignment = CCTextAlignment.Left }; slot1CoinsLabel = new CCLabel("Coins: " + player1.Coins, GOTHIC_56_WHITE_FNT); slot2CoinsLabel = new CCLabel("Coins: " + player2.Coins, GOTHIC_56_WHITE_FNT); slot3CoinsLabel = new CCLabel("Coins: " + player3.Coins, GOTHIC_56_WHITE_FNT); slotStdSprite = new CCSprite(uiSpriteSheet.Frames.Find(x => x.TextureFilename.Equals("slot_std.png"))); slotSelSprite = new CCSprite(uiSpriteSheet.Frames.Find(x => x.TextureFilename.Equals("slot_sel.png"))); // Setup Slot 1 slot1MenuItem = new CCMenuItemImage(slotStdSprite, slotSelSprite, PlayerSelect) { UserData = "Slot1", ZoomBehaviorOnTouch = false, AnchorPoint = CCPoint.AnchorMiddle, }; if (player1.HasStarted) { slot1MenuItem.AddChild(slot1NameLabel); slot1MenuItem.AddChild(slot1CoinsLabel); slot1NameLabel.PositionX = slot1NameLabel.Parent.AnchorPointInPoints.X - 200; slot1NameLabel.PositionY = slot1NameLabel.Parent.AnchorPointInPoints.Y; slot1CoinsLabel.PositionX = slot1CoinsLabel.Parent.AnchorPointInPoints.X + 200; slot1CoinsLabel.PositionY = slot1CoinsLabel.Parent.AnchorPointInPoints.Y; } else { slot1MenuItem.AddChild(slot1NewGameLabel); slot1NewGameLabel.Position = slot1NewGameLabel.Parent.AnchorPointInPoints; } // Setup Slot 2 slot2MenuItem = new CCMenuItemImage(slotStdSprite, slotSelSprite, PlayerSelect) { UserData = "Slot2", ZoomBehaviorOnTouch = false, }; if (player2.HasStarted) { slot2MenuItem.AddChild(slot2NameLabel); slot2MenuItem.AddChild(slot2CoinsLabel); slot2NameLabel.PositionX = slot2NameLabel.Parent.AnchorPointInPoints.X - 200; slot2NameLabel.PositionY = slot2NameLabel.Parent.AnchorPointInPoints.Y; slot2CoinsLabel.PositionX = slot2CoinsLabel.Parent.AnchorPointInPoints.X + 200; slot2CoinsLabel.PositionY = slot2CoinsLabel.Parent.AnchorPointInPoints.Y; } else { slot2MenuItem.AddChild(slot2NewGameLabel); slot2NewGameLabel.Position = slot2NewGameLabel.Parent.AnchorPointInPoints; } // Setup Slot 3 slot3MenuItem = new CCMenuItemImage(slotStdSprite, slotSelSprite, PlayerSelect) { UserData = "Slot3", ZoomBehaviorOnTouch = false, }; if (player3.HasStarted) { slot3MenuItem.AddChild(slot3NameLabel); slot3MenuItem.AddChild(slot3CoinsLabel); slot3NameLabel.PositionX = slot3NameLabel.Parent.AnchorPointInPoints.X - 200; slot3NameLabel.PositionY = slot3NameLabel.Parent.AnchorPointInPoints.Y; slot3CoinsLabel.PositionX = slot3CoinsLabel.Parent.AnchorPointInPoints.X + 200; slot3CoinsLabel.PositionY = slot3CoinsLabel.Parent.AnchorPointInPoints.Y; } else { slot3MenuItem.AddChild(slot3NewGameLabel); slot3NewGameLabel.Position = slot3NewGameLabel.Parent.AnchorPointInPoints; } playerSlotItems = new List <CCMenuItemImage> (); playerSlotItems.Add(slot1MenuItem); playerSlotItems.Add(slot2MenuItem); playerSlotItems.Add(slot3MenuItem); playerSlotsMenu = new CCMenu(slot1MenuItem, slot2MenuItem, slot3MenuItem) { AnchorPoint = CCPoint.AnchorMiddleTop, PositionX = screenBounds.Size.Width / 2, PositionY = (screenBounds.Size.Height / 5) * 2.7f, }; playerSlotsMenu.AlignItemsVertically(150); AddChild(playerSlotsMenu); playerDeleteStdSprite = new CCSprite(uiSpriteSheet.Frames.Find(x => x.TextureFilename.Equals("red_x_std.png"))); playerDeleteSelSprite = new CCSprite(uiSpriteSheet.Frames.Find(x => x.TextureFilename.Equals("red_x_sel.png"))); playerInfoStdSprite = new CCSprite(uiSpriteSheet.Frames.Find(x => x.TextureFilename.Equals("info_std.png"))); playerInfoSelSprite = new CCSprite(uiSpriteSheet.Frames.Find(x => x.TextureFilename.Equals("info_sel.png"))); player1DeleteMenuItem = new CCMenuItemImage(playerDeleteStdSprite, playerDeleteSelSprite, PlayerDelete) { UserData = "Slot1", ZoomBehaviorOnTouch = false, }; player2DeleteMenuItem = new CCMenuItemImage(playerDeleteStdSprite, playerDeleteSelSprite, PlayerDelete) { UserData = "Slot2", ZoomBehaviorOnTouch = false, }; player3DeleteMenuItem = new CCMenuItemImage(playerDeleteStdSprite, playerDeleteSelSprite, PlayerDelete) { UserData = "Slot3", ZoomBehaviorOnTouch = false, }; player1InfoMenuItem = new CCMenuItemImage(playerInfoStdSprite, playerInfoSelSprite, PlayerInfo) { UserData = "Slot1", ZoomBehaviorOnTouch = false, }; player2InfoMenuItem = new CCMenuItemImage(playerInfoStdSprite, playerInfoSelSprite, PlayerInfo) { UserData = "Slot2", ZoomBehaviorOnTouch = false, }; player3InfoMenuItem = new CCMenuItemImage(playerInfoStdSprite, playerInfoSelSprite, PlayerInfo) { UserData = "Slot3", ZoomBehaviorOnTouch = false, }; if (player1.HasStarted) { playerSlot1SubMenu = new CCMenu(player1InfoMenuItem, player1DeleteMenuItem) { AnchorPoint = CCPoint.AnchorMiddleTop, PositionX = playerSlotsMenu.Children [0].PositionWorldspace.X, PositionY = playerSlotsMenu.Children [0].PositionWorldspace.Y - 205, }; playerSlot1SubMenu.AlignItemsHorizontally(400); AddChild(playerSlot1SubMenu); } if (player2.HasStarted) { playerSlot2SubMenu = new CCMenu(player2InfoMenuItem, player2DeleteMenuItem) { AnchorPoint = CCPoint.AnchorMiddleTop, PositionX = playerSlotsMenu.Children [1].PositionWorldspace.X, PositionY = playerSlotsMenu.Children [1].PositionWorldspace.Y - 205, }; playerSlot2SubMenu.AlignItemsHorizontally(400); AddChild(playerSlot2SubMenu); } if (player3.HasStarted) { playerSlot3SubMenu = new CCMenu(player3InfoMenuItem, player3DeleteMenuItem) { AnchorPoint = CCPoint.AnchorMiddleTop, PositionX = playerSlotsMenu.Children [2].PositionWorldspace.X, PositionY = playerSlotsMenu.Children [2].PositionWorldspace.Y - 205, }; playerSlot3SubMenu.AlignItemsHorizontally(400); AddChild(playerSlot3SubMenu); } backLabel = new CCLabel("Back", GOTHIC_44_HD_FNT) { AnchorPoint = CCPoint.AnchorMiddle, Scale = 1.5f, }; var backItem = new CCMenuItemLabel(backLabel, BackToMain); var backMenu = new CCMenu(backItem); backMenu.AnchorPoint = CCPoint.AnchorMiddleBottom; backMenu.Position = new CCPoint(screenBounds.Size.Width / 2, 220f); AddChild(backMenu); }