//------------------------------------------------------------------------------ // Method: Activate // Author: Neil Holmes // Summary: test function to make the achievement display //------------------------------------------------------------------------------ public void OnAchievementUnlocked(int userId, ICELandaLib.CoAchievement achievement) { int width; int heightPixels; achievement.Image.GetDimensions(out width, out heightPixels); Byte[] pixelData = (Byte[])achievement.Image.PixelData; Texture2D icon = new Texture2D(graphicsDevice, width, heightPixels, false, SurfaceFormat.Color); icon.SetData<Byte>(pixelData); achievement unlockedAchievement = new achievement(); unlockedAchievement.icon = icon; // testIcon; // testAchievements[0].icon; unlockedAchievement.name = String.Copy(achievement.Title); unlockedAchievement.description = String.Copy(achievement.Description); unlockedAchievement.value = (int)achievement.TrueValue; unlockedAchievement.unlocked = false; unlockedAchievements.Enqueue(unlockedAchievement); }
//------------------------------------------------------------------------------ // Constructor: ICAchievementList // Author: Neil Holmes // Summary: Constructor - prepares the achievement list system //------------------------------------------------------------------------------ public ICAchievementList(Game game, GraphicsDeviceManager graphicsDeviceManager, ICELandaLib.CoAchievementGroup achievementGroup, ICAchievementScale scale) : base(game, graphicsDeviceManager, achievementGroup, ICAchievementPosition.listMode, scale) { // by default we want to display the list from the first achievement onwards achievementDisplayIndex = 0; // the number of achievements that were previously displayed achievementsDisplayed = 0; }
//------------------------------------------------------------------------------ // Constructor: ICAchievementSystem // Author: Neil Holmes // Summary: main constructor for the achievement display system //------------------------------------------------------------------------------ public ICAchievementSystem(Game game, GraphicsDeviceManager graphicsDeviceManager, ICELandaLib.CoAchievementGroup achievementGroup, ICAchievementPosition positionMode, ICAchievementScale scale) { // create a content manager to handle loading the textures we need ContentManager content = new ContentManager(game.Services); // store the graphics device for future reference this.graphicsDevice = game.GraphicsDevice; // store the achievement group this.achievementGroup = achievementGroup; // store the position mode that we are using this.positionMode = positionMode; // store the scale we are using if (scale == ICAchievementScale.normal) displayScale = 1.0f; else displayScale = 0.5f; // create a sprite batch for rendering spriteBatch = new SpriteBatch(graphicsDevice); // defulat display to false display = false; // load the achievement display textures badgeTexture = content.Load<Texture2D>(@"Content\ICAchievements\Badge"); bannerTexture = content.Load<Texture2D>(@"Content\ICAchievements\Shadow"); padlockTexture = content.Load<Texture2D>(@"Content\ICAchievements\Padlock"); // load the achievement font if (scale == ICAchievementScale.normal) { messageFont = content.Load<SpriteFont>(@"Content\ICAchievements\MessageFont"); valueFont = content.Load<SpriteFont>(@"Content\ICAchievements\ValueFont"); } else { messageFont = content.Load<SpriteFont>(@"Content\ICAchievements\MessageFontSmall"); valueFont = content.Load<SpriteFont>(@"Content\ICAchievements\ValueFontSmall"); } // calculate some constants for the display system badgeRect.Width = badgeRect.Height = (int)(badgeTexture.Width * displayScale); halfBadgeSize = badgeRect.Width / 2; }
public ICLeaderboardsBrowser(Game game, GraphicsDeviceManager graphicsDeviceManager, ICELandaLib.CoLeaderboardManager leaderboardManager, ICLeaderboardScale scale, int[] leaderboardUIDlist) { // create a content manager to handle loading the textures we need ContentManager content = new ContentManager(game.Services); // store the graphics device for future reference this.graphicsDevice = game.GraphicsDevice; // store a handle to the leaderboard manager this.leaderboardManager = leaderboardManager; // store the scale we are using if (scale == ICLeaderboardScale.normal) displayScale = 1.0f; else displayScale = 0.5f; // store the ordered list of leaderboard UID values this.leaderboardUIDlist = leaderboardUIDlist; // create a sprite batch for rendering spriteBatch = new SpriteBatch(graphicsDevice); // load the leaderboard display textures bannerTexture = content.Load<Texture2D>(@"Content\ICLeaderboards\Shadow"); // load the leaderboard fonts if (scale == ICLeaderboardScale.normal) { nameFont = content.Load<SpriteFont>(@"Content\ICLeaderboards\NameFont"); valueFont = content.Load<SpriteFont>(@"Content\ICLeaderboards\ValueFont"); } else { nameFont = content.Load<SpriteFont>(@"Content\ICLeaderboards\NameFontSmall"); valueFont = content.Load<SpriteFont>(@"Content\ICLeaderboards\ValueFontSmall"); } // by default we want to display the first leaderbaord in the list currentLeaderboardIndex = 0; // by default we want to display the leaderboard from the first entry onwards entryDisplayIndex = 0; // the number of leaderboard entries that were previously displayed entriesDisplayed = 0; // ensure leaderboard entries recieved, currentLeaderboard and requestedPage are all reset numEntriesReceived = 0; noMoreEntries = false; currentLeaderboard = null; requestedPage = null; lastRequestedPage = null; entries = new List<leaderboardEntry>(); }