public CCSpriteSheet AddSpriteSheet(PlistDictionary dictionary, CCTexture2D texture, string name) { CCSpriteSheet result; if (!_spriteSheets.TryGetValue(name, out result)) { result = new CCSpriteSheet(name, texture); _spriteSheets.Add(name, result); } return result; }
public CCSpriteSheet AddSpriteSheet(string fileName, CCTexture2D texture) { CCSpriteSheet result; if (!_spriteSheets.TryGetValue(fileName, out result)) { result = new CCSpriteSheet(fileName, texture); _spriteSheets.Add(fileName, result); } return result; }
public void Remove(CCSpriteSheet spriteSheet) { if (spriteSheet == null) { return; } string key = null; foreach (var pair in _spriteSheets) { if (pair.Value == spriteSheet) { key = pair.Key; break; } } if (key != null) { _spriteSheets.Remove(key); } }
public NewGameLayer(List <Level> gameLevels, Player player) : base(CCColor4B.Black) { uiSpriteSheet = new CCSpriteSheet("ui.plist"); levels = gameLevels; activePlayer = player; }
/// <summary> /// /// </summary> /// <param name="key"></param> /// <param name="plistFile"></param> /// <returns></returns> public CCSpriteSheet AddSpriteSheet(string key, string plistFile) { return(m_spriteSheets[key] = new CCSpriteSheet(plistFile)); }
//--------------------------------------------------------------------------------------------------------- // SetupUI //--------------------------------------------------------------------------------------------------------- // Sets up the game UI //--------------------------------------------------------------------------------------------------------- void SetupUI(CCRect bounds) { uiSpriteSheet = new CCSpriteSheet("ui.plist"); s01StdSprite = new CCSprite(uiSpriteSheet.Frames.Find(x => x.TextureFilename.Equals("s01-linear.png"))); s01SelSprite = new CCSprite(uiSpriteSheet.Frames.Find(x => x.TextureFilename.Equals("s01-linear-g.png"))); s01DisSprite = new CCSprite(uiSpriteSheet.Frames.Find(x => x.TextureFilename.Equals("s01-linear.png"))); s02StdSprite = new CCSprite(uiSpriteSheet.Frames.Find(x => x.TextureFilename.Equals("s02-even.png"))); s02SelSprite = new CCSprite(uiSpriteSheet.Frames.Find(x => x.TextureFilename.Equals("s02-even-g.png"))); s02DisSprite = new CCSprite(uiSpriteSheet.Frames.Find(x => x.TextureFilename.Equals("s02-even.png"))); s03StdSprite = new CCSprite(uiSpriteSheet.Frames.Find(x => x.TextureFilename.Equals("s03-odd.png"))); s03SelSprite = new CCSprite(uiSpriteSheet.Frames.Find(x => x.TextureFilename.Equals("s03-odd-g.png"))); s03DisSprite = new CCSprite(uiSpriteSheet.Frames.Find(x => x.TextureFilename.Equals("s03-odd.png"))); s04StdSprite = new CCSprite(uiSpriteSheet.Frames.Find(x => x.TextureFilename.Equals("s04-triangular.png"))); s04SelSprite = new CCSprite(uiSpriteSheet.Frames.Find(x => x.TextureFilename.Equals("s04-triangular-g.png"))); s04DisSprite = new CCSprite(uiSpriteSheet.Frames.Find(x => x.TextureFilename.Equals("s04-triangular.png"))); s05StdSprite = new CCSprite(uiSpriteSheet.Frames.Find(x => x.TextureFilename.Equals("s05-square.png"))); s05SelSprite = new CCSprite(uiSpriteSheet.Frames.Find(x => x.TextureFilename.Equals("s05-square-g.png"))); s05DisSprite = new CCSprite(uiSpriteSheet.Frames.Find(x => x.TextureFilename.Equals("s05-square.png"))); s06StdSprite = new CCSprite(uiSpriteSheet.Frames.Find(x => x.TextureFilename.Equals("s06-lazy.png"))); s06SelSprite = new CCSprite(uiSpriteSheet.Frames.Find(x => x.TextureFilename.Equals("s06-lazy-g.png"))); s06DisSprite = new CCSprite(uiSpriteSheet.Frames.Find(x => x.TextureFilename.Equals("s06-lazy.png"))); s07StdSprite = new CCSprite(uiSpriteSheet.Frames.Find(x => x.TextureFilename.Equals("s07-fibonacci.png"))); s07SelSprite = new CCSprite(uiSpriteSheet.Frames.Find(x => x.TextureFilename.Equals("s07-fibonacci-g.png"))); s07DisSprite = new CCSprite(uiSpriteSheet.Frames.Find(x => x.TextureFilename.Equals("s07-fibonacci.png"))); s08StdSprite = new CCSprite(uiSpriteSheet.Frames.Find(x => x.TextureFilename.Equals("s08-prime.png"))); s08SelSprite = new CCSprite(uiSpriteSheet.Frames.Find(x => x.TextureFilename.Equals("s08-prime-g.png"))); s08DisSprite = new CCSprite(uiSpriteSheet.Frames.Find(x => x.TextureFilename.Equals("s08-prime.png"))); s09StdSprite = new CCSprite(uiSpriteSheet.Frames.Find(x => x.TextureFilename.Equals("s09-double.png"))); s09SelSprite = new CCSprite(uiSpriteSheet.Frames.Find(x => x.TextureFilename.Equals("s09-double-g.png"))); s09DisSprite = new CCSprite(uiSpriteSheet.Frames.Find(x => x.TextureFilename.Equals("s09-double.png"))); s10StdSprite = new CCSprite(uiSpriteSheet.Frames.Find(x => x.TextureFilename.Equals("s10-triple.png"))); s10SelSprite = new CCSprite(uiSpriteSheet.Frames.Find(x => x.TextureFilename.Equals("s10-triple-g.png"))); s10DisSprite = new CCSprite(uiSpriteSheet.Frames.Find(x => x.TextureFilename.Equals("s10-triple.png"))); s11StdSprite = new CCSprite(uiSpriteSheet.Frames.Find(x => x.TextureFilename.Equals("s11-pi.png"))); s11SelSprite = new CCSprite(uiSpriteSheet.Frames.Find(x => x.TextureFilename.Equals("s11-pi-g.png"))); s11DisSprite = new CCSprite(uiSpriteSheet.Frames.Find(x => x.TextureFilename.Equals("s11-pi.png"))); s12StdSprite = new CCSprite(uiSpriteSheet.Frames.Find(x => x.TextureFilename.Equals("s12-recaman.png"))); s12SelSprite = new CCSprite(uiSpriteSheet.Frames.Find(x => x.TextureFilename.Equals("s12-recaman-g.png"))); s12DisSprite = new CCSprite(uiSpriteSheet.Frames.Find(x => x.TextureFilename.Equals("s12-recaman.png"))); var s01MenuItem = new CCMenuItemImage(s01StdSprite, s01SelSprite, s01DisSprite, ChallengeMenuCallback) { UserData = "Linear", Scale = 2, ZoomBehaviorOnTouch = false, }; var s02MenuItem = new CCMenuItemImage(s02StdSprite, s02SelSprite, s02DisSprite, ChallengeMenuCallback) { UserData = "Even", Scale = 2, ZoomBehaviorOnTouch = false, }; var s03MenuItem = new CCMenuItemImage(s03StdSprite, s03SelSprite, s03DisSprite, ChallengeMenuCallback) { UserData = "Odd", Scale = 2, ZoomBehaviorOnTouch = false, }; var s04MenuItem = new CCMenuItemImage(s04StdSprite, s04SelSprite, s04DisSprite, ChallengeMenuCallback) { UserData = "Triangular", Scale = 2, ZoomBehaviorOnTouch = false, }; var s05MenuItem = new CCMenuItemImage(s05StdSprite, s05SelSprite, s05DisSprite, ChallengeMenuCallback) { UserData = "Square", Scale = 2, ZoomBehaviorOnTouch = false, }; var s06MenuItem = new CCMenuItemImage(s06StdSprite, s06SelSprite, s06DisSprite, ChallengeMenuCallback) { UserData = "Lazy", Scale = 2, ZoomBehaviorOnTouch = false, }; var s07MenuItem = new CCMenuItemImage(s07StdSprite, s07SelSprite, s07DisSprite, ChallengeMenuCallback) { UserData = "Fibonacci", Scale = 2, ZoomBehaviorOnTouch = false, }; var s08MenuItem = new CCMenuItemImage(s08StdSprite, s08SelSprite, s08DisSprite, ChallengeMenuCallback) { UserData = "Prime", Scale = 2, ZoomBehaviorOnTouch = false, }; var s09MenuItem = new CCMenuItemImage(s09StdSprite, s09SelSprite, s09DisSprite, ChallengeMenuCallback) { UserData = "Double", Scale = 2, ZoomBehaviorOnTouch = false, }; var s10MenuItem = new CCMenuItemImage(s10StdSprite, s10SelSprite, s10DisSprite, ChallengeMenuCallback) { UserData = "Triple", Scale = 2, ZoomBehaviorOnTouch = false, }; var s11MenuItem = new CCMenuItemImage(s11StdSprite, s11SelSprite, s11DisSprite, ChallengeMenuCallback) { UserData = "Pi", Scale = 2, ZoomBehaviorOnTouch = false, }; var s12MenuItem = new CCMenuItemImage(s12StdSprite, s12SelSprite, s12DisSprite, ChallengeMenuCallback) { UserData = "Recaman", Scale = 2, ZoomBehaviorOnTouch = false, }; challengeMenuItems = new List <CCMenuItemImage> (); challengeMenuItems.Add(s01MenuItem); challengeMenuItems.Add(s02MenuItem); challengeMenuItems.Add(s03MenuItem); challengeMenuItems.Add(s04MenuItem); challengeMenuItems.Add(s05MenuItem); challengeMenuItems.Add(s06MenuItem); challengeMenuItems.Add(s07MenuItem); challengeMenuItems.Add(s08MenuItem); challengeMenuItems.Add(s09MenuItem); challengeMenuItems.Add(s10MenuItem); challengeMenuItems.Add(s11MenuItem); challengeMenuItems.Add(s12MenuItem); sequenceChallengesLeft = new CCMenu(s01MenuItem, s02MenuItem, s03MenuItem, s04MenuItem, s05MenuItem, s06MenuItem); sequenceChallengesLeft.AlignItemsVertically(50); sequenceChallengesLeft.AnchorPoint = CCPoint.AnchorMiddle; sequenceChallengesLeft.PositionX = bounds.MidX - 350; sequenceChallengesLeft.PositionY = bounds.MidY + 70; AddChild(sequenceChallengesLeft); sequenceChallengesRight = new CCMenu(s07MenuItem, s08MenuItem, s09MenuItem, s10MenuItem, s11MenuItem, s12MenuItem); sequenceChallengesRight.AlignItemsVertically(50); sequenceChallengesRight.AnchorPoint = CCPoint.AnchorMiddle; sequenceChallengesRight.PositionX = bounds.MidX + 200; sequenceChallengesRight.PositionY = bounds.MidY + 70; AddChild(sequenceChallengesRight); var infoStdSprite = new CCSprite(uiSpriteSheet.Frames.Find(x => x.TextureFilename.Equals("info_std.png"))); var infoSelSprite = new CCSprite(uiSpriteSheet.Frames.Find(x => x.TextureFilename.Equals("info_sel.png"))); var infoDisSprite = new CCSprite(uiSpriteSheet.Frames.Find(x => x.TextureFilename.Equals("info_std.png"))); var i01MenuItem = new CCMenuItemImage(infoStdSprite, infoSelSprite, infoDisSprite, InfoMenuCallback) { UserData = "Linear", Scale = 1.3f, ZoomBehaviorOnTouch = false, }; var i02MenuItem = new CCMenuItemImage(infoStdSprite, infoSelSprite, infoDisSprite, InfoMenuCallback) { UserData = "Even", Scale = 1.3f, ZoomBehaviorOnTouch = false, }; var i03MenuItem = new CCMenuItemImage(infoStdSprite, infoSelSprite, infoDisSprite, InfoMenuCallback) { UserData = "Odd", Scale = 1.3f, ZoomBehaviorOnTouch = false, }; var i04MenuItem = new CCMenuItemImage(infoStdSprite, infoSelSprite, infoDisSprite, InfoMenuCallback) { UserData = "Triangular", Scale = 1.3f, ZoomBehaviorOnTouch = false, }; var i05MenuItem = new CCMenuItemImage(infoStdSprite, infoSelSprite, infoDisSprite, InfoMenuCallback) { UserData = "Square", Scale = 1.3f, ZoomBehaviorOnTouch = false, }; var i06MenuItem = new CCMenuItemImage(infoStdSprite, infoSelSprite, infoDisSprite, InfoMenuCallback) { UserData = "Lazy", Scale = 1.3f, ZoomBehaviorOnTouch = false, }; var i07MenuItem = new CCMenuItemImage(infoStdSprite, infoSelSprite, infoDisSprite, InfoMenuCallback) { UserData = "Fibonacci", Scale = 1.3f, ZoomBehaviorOnTouch = false, }; var i08MenuItem = new CCMenuItemImage(infoStdSprite, infoSelSprite, infoDisSprite, InfoMenuCallback) { UserData = "Prime", Scale = 1.3f, ZoomBehaviorOnTouch = false, }; var i09MenuItem = new CCMenuItemImage(infoStdSprite, infoSelSprite, infoDisSprite, InfoMenuCallback) { UserData = "Double", Scale = 1.3f, ZoomBehaviorOnTouch = false, }; var i10MenuItem = new CCMenuItemImage(infoStdSprite, infoSelSprite, infoDisSprite, InfoMenuCallback) { UserData = "Triple", Scale = 1.3f, ZoomBehaviorOnTouch = false, }; var i11MenuItem = new CCMenuItemImage(infoStdSprite, infoSelSprite, infoDisSprite, InfoMenuCallback) { UserData = "Pi", Scale = 1.3f, ZoomBehaviorOnTouch = false, }; var i12MenuItem = new CCMenuItemImage(infoStdSprite, infoSelSprite, infoDisSprite, InfoMenuCallback) { UserData = "Recaman", Scale = 1.3f, ZoomBehaviorOnTouch = false, }; infoMenuItems = new List <CCMenuItemImage> (); infoMenuItems.Add(i01MenuItem); infoMenuItems.Add(i02MenuItem); infoMenuItems.Add(i03MenuItem); infoMenuItems.Add(i04MenuItem); infoMenuItems.Add(i05MenuItem); infoMenuItems.Add(i06MenuItem); infoMenuItems.Add(i07MenuItem); infoMenuItems.Add(i08MenuItem); infoMenuItems.Add(i09MenuItem); infoMenuItems.Add(i10MenuItem); infoMenuItems.Add(i11MenuItem); infoMenuItems.Add(i12MenuItem); challengeInfoLeft = new CCMenu(i01MenuItem, i02MenuItem, i03MenuItem, i04MenuItem, i05MenuItem, i06MenuItem); challengeInfoLeft.AlignItemsVertically(50); challengeInfoLeft.AnchorPoint = CCPoint.AnchorMiddle; challengeInfoLeft.PositionX = bounds.MidX - 200; challengeInfoLeft.PositionY = bounds.MidY + 70; AddChild(challengeInfoLeft); challengeInfoRight = new CCMenu(i07MenuItem, i08MenuItem, i09MenuItem, i10MenuItem, i11MenuItem, i12MenuItem); challengeInfoRight.AlignItemsVertically(50); challengeInfoRight.AnchorPoint = CCPoint.AnchorMiddle; challengeInfoRight.PositionX = bounds.MidX + 350; challengeInfoRight.PositionY = bounds.MidY + 70; AddChild(challengeInfoRight); // disable any challenge and info menu items for those that aren't unlocked for (int i = 1; i < 13; i++) { challengeMenuItems [i - 1].Enabled = !currentPlayer.BranchProgression [i].IsLocked; infoMenuItems [i - 1].Enabled = !currentPlayer.BranchProgression [i].IsLocked; if (!challengeMenuItems [i - 1].Enabled) { challengeMenuItems [i - 1].Color = CCColor3B.DarkGray; infoMenuItems [i - 1].Color = CCColor3B.DarkGray; } } // disable any challenge modes that are marked as completed for (int i = 1; i < 13; i++) { if (challengeMenuItems [i - 1].Enabled) { if (Equals(currentPlayer.BranchProgression [i].BranchState, CompletionState.completed)) //TODO: When a branch is completed, set the completion state to completed { challengeMenuItems [i - 1].Enabled = false; } if (currentPlayer.BranchProgression [i].LastLevelCompleted > 19) { challengeMenuItems [i - 1].Enabled = false; //TODO: remove this when the completion state is properly set infoMenuItems [i - 1].Enabled = false; } } if (!challengeMenuItems [i - 1].Enabled) { challengeMenuItems [i - 1].Color = CCColor3B.DarkGray; infoMenuItems [i - 1].Color = CCColor3B.DarkGray; } } var titleLabel = new CCLabel("Select Challenge", GOTHIC_56_WHITE_HD_FNT) { AnchorPoint = CCPoint.AnchorMiddle, Scale = 1.5f, PositionX = bounds.Center.X, PositionY = bounds.MaxY - 130, }; AddChild(titleLabel); backLabel = new CCLabel("Back", GOTHIC_44_HD_FNT) { AnchorPoint = CCPoint.AnchorMiddle, Scale = 1.5f, }; var backItem = new CCMenuItemLabel(backLabel, BackToGameSelect); var backMenu = new CCMenu(backItem); backMenu.AnchorPoint = CCPoint.AnchorMiddleBottom; backMenu.Position = new CCPoint(bounds.Size.Width / 2, 220f); AddChild(backMenu); }