/// <summary> /// Create a DrawableAd with desired properties. /// </summary> private void CreateAd() { // Create a banner ad for the game. int width = 480; int height = 80; int x = 0; int y = 0; bannerAd = AdGameComponent.Current.CreateAd(AdUnitId, new Rectangle(x, y, width, height), true); AdGameComponent.Current.UpdateOrder = 0; // Add handlers for events (optional). bannerAd.ErrorOccurred += new EventHandler <Microsoft.Advertising.AdErrorEventArgs>(bannerAd_ErrorOccurred); bannerAd.AdRefreshed += new EventHandler(bannerAd_AdRefreshed); // bannerAd.Visible = true; // Set some visual properties (optional). bannerAd.BorderEnabled = true; // default is true // bannerAd.BorderColor = Color.White; // default is White bannerAd.DropShadowEnabled = false; // default is true AdGameComponent.Current.Enabled = true; AdGameComponent.Current.Visible = true; Debug.WriteLine("Ad created"); }
public DrawableAd InitializeAd(string adUnitId) { if (!this.Initialized) { throw new InvalidOperationException("Ad provider must be initialized before creating the ad"); } if (_currentAd != null) { _currentAd.ErrorOccurred -= this.OnErrorOccured; _currentAd.AdRefreshed -= this.OnAdAvailable; _adComponent.RemoveAd(_currentAd); } _currentAd = _adComponent.CreateAd(adUnitId, base.DisplayArea, true); _currentAd.ErrorOccurred += this.OnErrorOccured; _currentAd.AdRefreshed += this.OnAdAvailable; // Disable border and shadow to reduce drawing. Fill rate is a big bottle neck on 1st gen WP devices _currentAd.BorderEnabled = false; _currentAd.DropShadowEnabled = false; return _currentAd; }
public Advertisement(Rectangle adUnitRect, string applicationId, string adUnitId) { this.bannerAd = AdGameComponent.Current.CreateAd(adUnitId, adUnitRect, true); this.bannerAd.Visible = false; // Initially ad will not visible. Call AdvertisementObj.setVisible(bool) to show the ad. // Set some visual properties (optional). this.bannerAd.BorderEnabled = true; this.bannerAd.BorderColor = Color.Black; this.bannerAd.DropShadowEnabled = true; // Add handlers for events (optional). bannerAd.ErrorOccurred += new EventHandler <Microsoft.Advertising.AdErrorEventArgs>(bannerAd_ErrorOccurred); bannerAd.AdRefreshed += new EventHandler(bannerAd_AdRefreshed); bannerAd.VisibleChanged += new EventHandler(bannerAd_VisibleChanged); bannerAd.EngagedChanged += new EventHandler(bannerAd_EngagedChanged); // Provide the location to the ad for better targeting (optional). // This is done by starting a GeoCoordinateWatcher and waiting for the location to be available. // The callback will set the location into the ad. // Note: The location may not be available in time for the first ad request. AdGameComponent.Current.Enabled = false; this.gcw = new GeoCoordinateWatcher(); this.gcw.PositionChanged += new EventHandler <GeoPositionChangedEventArgs <GeoCoordinate> >(gcw_PositionChanged); this.gcw.StatusChanged += new EventHandler <GeoPositionStatusChangedEventArgs>(gcw_StatusChanged); this.gcw.Start(); }
/// <summary> /// 创建广告 /// </summary> private void CreateAd(Game game) { // 创建指定大小的广告组件 int width = 480; int height = 80; // 定位到屏幕中央上方 int x = (game.GraphicsDevice.Viewport.Bounds.Width - width) / 2; int y = 5; bannerAd = AdGameComponent.Current.CreateAd(AdUnitId, new Rectangle(x, y, width, height), true); // 添加广告事件监听 bannerAd.ErrorOccurred += new EventHandler <Microsoft.Advertising.AdErrorEventArgs>(bannerAd_ErrorOccurred); bannerAd.AdRefreshed += new EventHandler(bannerAd_AdRefreshed); // 并不是立即激活广告(在GPS定位成功后才激活) AdGameComponent.Current.Enabled = false; // 构建定位器 this.gcw = new GeoCoordinateWatcher(); // 监听定位器活动 this.gcw.PositionChanged += new EventHandler <GeoPositionChangedEventArgs <GeoCoordinate> >(gcw_PositionChanged); this.gcw.StatusChanged += new EventHandler <GeoPositionStatusChangedEventArgs>(gcw_StatusChanged); this.gcw.Start(); }
private void CreateAd() { int width = 480; int height = 80; int x = (GraphicsDevice.Viewport.Bounds.Width - width) / 2; // centered on the display int y = 720; bannerAd = AdGameComponent.Current.CreateAd(AdUnitId, new Rectangle(x, y, width, height), true); }
private void CreateAd() { // Create a banner ad for the game. int width = 480; int height = 80; int x = (GraphicsDevice.Viewport.Bounds.Width - width) / 2; // centered on the display int y = 0; advertisement = AdGameComponent.Current.CreateAd(adUnit, new Rectangle(x, y, width, height), true); }
public void InitializeAds(string applicationId, string unitId, Rectangle location) { #if WINDOWS_PHONE AdGameComponent.Initialize(this, applicationId); this.Components.Add(AdGameComponent.Current); _ad = AdGameComponent.Current.CreateAd(unitId, location); _ad.ErrorOccurred += ad_ErrorOccurred; _ad.Visible = false; #endif }
public AdManager(DrawableAd ad) { XnaAd = ad; ad.ErrorOccurred += new EventHandler<Microsoft.Advertising.AdErrorEventArgs>(ad_ErrorOccurred); }
private void CreateAd() { // Create a banner ad for the game. int width = 480; int height = 80; int x = (800 - width) / 2; int y = 0; bannerAd = AdGameComponent.Current.CreateAd("Image" + width + "_" + height, new Rectangle(x, y, width, height), true); }
/// <summary> /// Create a DrawableAd with desired properties. /// </summary> private void CreateAd() { // Create a banner ad for the game. int width = 320; int height = 50; int x = (GraphicsDevice.Viewport.Bounds.Width - width) / 2; // centered on the display int y = 0; advertisement = AdGameComponent.Current.CreateAd(adUnit, new Rectangle(x, y, width, height), true); }
protected override void OnNavigatedTo(NavigationEventArgs e) { SharedGraphicsDeviceManager.Current.GraphicsDevice.SetSharingMode(true); spriteBatch = new SpriteBatch(SharedGraphicsDeviceManager.Current.GraphicsDevice); /** * DebugShapeRenderer.Initialize(SharedGraphicsDeviceManager.Current.GraphicsDevice); */ //LA VITA DEVE CAMBIARE A SECONDA DEL LIVELLO DI DIFFICOLTA' maxLife = Constants.MAX_EASY_LIFE; //SE NON ESISTE UN MATCH CARICATO LO CREO. MA SOLO ALLORA. if (((App)App.Current).NewMatch) { ((App)App.Current).match = new SavedMatch(); ((App)App.Current).match.cameraPos = new Vector3(0, 3.5f, 0); ((App)App.Current).match.cameraLook = new Vector3(0, 3.5f, -1); ((App)App.Current).match.cameraShake = Vector2.Zero; ((App)App.Current).match.shakeMagnitude = 0; ((App)App.Current).match.playerBox = new BoundingBox(new Vector3(((App)App.Current).match.cameraPos.X, ((App)App.Current).match.cameraPos.Y, ((App)App.Current).match.cameraPos.Z - 1), ((App)App.Current).match.cameraPos); ((App)App.Current).match.life = Utilities.Constants.MAX_EASY_LIFE; ((App)App.Current).match.lifepositions = new float[maxLife]; for (int counter = 0; counter < ((App)App.Current).match.lifepositions.Length; counter++) { ((App)App.Current).match.lifepositions[counter] = 0; } ((App)App.Current).match.matchTime = new TimeSpan(); ((App)App.Current).match.gameState = GamePageState.PLAY; //Add sections ((App)App.Current).match.sections = new List <Section>(); ((App)App.Current).match.sections.Add(new Section(0, 0, 0)); ((App)App.Current).match.sections.Add(new Section(0, 0, ((App)App.Current).match.sections[((App)App.Current).match.sections.Count - 1].zPosition - 50)); ((App)App.Current).match.sections.Add(new Section(0, 0, ((App)App.Current).match.sections[((App)App.Current).match.sections.Count - 1].zPosition - 50)); ((App)App.Current).match.speedTime = 0.1f; ((App)App.Current).match.flashCounter = 0; ((App)App.Current).match.fadeIndex = 0; } else { ((App)App.Current).NewMatch = true; } match = ((App)App.Current).match; //Pubblicità AdComponent.Initialize("00000000-0000-0000-0000-000000000000"); drawableAd = AdComponent.Current.CreateAd("00000000", new Rectangle(168, 0, 480, 80), true); drawableAd.AdRefreshed += new EventHandler(drawableAd_AdRefreshed); drawableAd.ErrorOccurred += new EventHandler <AdErrorEventArgs>(drawableAd_ErrorOccurred); //Textures timeBack = contentManager.Load <Texture2D>("TimeBack"); barraBack = contentManager.Load <Texture2D>("BarraBack"); barra = contentManager.Load <Texture2D>("Barra"); heart = contentManager.Load <Texture2D>("Heart"); //Models models = new Model[8]; models[0] = contentManager.Load <Model>("planeModel"); models[1] = contentManager.Load <Model>("fenceModel"); models[2] = contentManager.Load <Model>("treeModel"); models[3] = contentManager.Load <Model>("dogModel"); models[4] = contentManager.Load <Model>("shadowModel"); models[5] = contentManager.Load <Model>("boostModel"); models[6] = contentManager.Load <Model>("heartModel"); models[7] = contentManager.Load <Model>("boxesModel"); //Suoni bark = contentManager.Load <SoundEffect>("bark"); hit = contentManager.Load <SoundEffect>("hit"); //Font font = contentManager.Load <SpriteFont>("font"); /* * debug = false; */ //Speed - abbastanza definitivo. speedCurve = new Curve(); firstKey = new CurveKey(0, 0); speedCurve.Keys.Add(firstKey); speedCurve.Keys.Add(new CurveKey(Constants.SPRINT_DURATION, Constants.MAX_SPEED)); speedCurve.Keys.Add(new CurveKey(Constants.SPRINT_DURATION + Constants.MAX_SPEED_DURATION, Constants.MAX_SPEED)); speedCurve.Keys.Add(new CurveKey(Constants.SPRINT_DURATION + Constants.MAX_SPEED_DURATION + Constants.SLOWDOWN_DURATION, 0)); //Flash boost boostFlashCurve = new Curve(); boostFlashCurve.Keys.Add(new CurveKey(0, 128)); boostFlashCurve.Keys.Add(new CurveKey(Constants.FLASH_DURATION - Constants.FLASH_DURATION / 5, Constants.FLASH_STRENGTH)); boostFlashCurve.Keys.Add(new CurveKey(Constants.FLASH_DURATION, 128)); inputManager = new InputManager(true); //FLASH PICKUP BOOST whiteTexture = new Texture2D(SharedGraphicsDeviceManager.Current.GraphicsDevice, 1, 1); whiteTexture.SetData <Color>(new Color[] { Color.White }); brightness = 255; brightnessBlend = new BlendState(); brightnessBlend.ColorSourceBlend = brightnessBlend.AlphaSourceBlend = Blend.Zero; brightnessBlend.ColorDestinationBlend = brightnessBlend.AlphaDestinationBlend = Blend.SourceColor; contrastBlend = new BlendState(); contrastBlend.ColorSourceBlend = contrastBlend.AlphaSourceBlend = Blend.DestinationColor; contrastBlend.ColorDestinationBlend = contrastBlend.AlphaDestinationBlend = Blend.SourceColor; //BLACK FADE blackTexture = new Texture2D(SharedGraphicsDeviceManager.Current.GraphicsDevice, 1, 1); blackTexture.SetData <Color>(new Color[] { Color.Black }); IsolatedStorageSettings settings = IsolatedStorageSettings.ApplicationSettings; soundEffectsVolume = (float)settings["SoundsVolume"]; vibration = (bool)settings["Vibration"]; timer.Start(); PhoneApplicationService.Current.UserIdleDetectionMode = IdleDetectionMode.Disabled; base.OnNavigatedTo(e); }
/// <summary> /// LoadContent will be called once per game and is the place to load /// all of your content. /// </summary> protected override void LoadContent() { // Create a new SpriteBatch, which can be used to draw textures. spriteBatch = new SpriteBatch(GraphicsDevice); #if DEBUG bannerAd = adGameComponent.CreateAd("Image480_80", new Rectangle(0, 0, 480, 80), true); #else bannerAd = adGameComponent.CreateAd("81067", new Rectangle(0, 0, 480, 80), true); #endif bannerAd.ErrorOccurred += new EventHandler<Microsoft.Advertising.AdErrorEventArgs>(bannerAd_ErrorOccurred); bannerAd.AdRefreshed += new EventHandler(bannerAd_AdRefreshed); adDuplex = new AdManager(this, "8831"); #if DEBUG adDuplex.IsTest = true; #endif adDuplex.LoadContent(); backgroundTexture = Content.Load<Texture2D>("background"); logoTexture = Content.Load<Texture2D>("logo"); instructionsTexture1 = Content.Load<Texture2D>("Instructions1"); instructionsTexture2 = Content.Load<Texture2D>("instructions2"); pixelTexture = Content.Load<Texture2D>("pixel"); spriteFont = Content.Load<SpriteFont>("SpriteFont"); menuFont = Content.Load<SpriteFont>("MenuFont"); tapScreen = new TextAnimation(); string text = "Tap the screen to continue"; Vector2 position = new Vector2( (GraphicsDevice.Viewport.Width / 2) - (spriteFont.MeasureString(text).X / 2), GraphicsDevice.Viewport.Height - (spriteFont.MeasureString(text).Y * 4) ); tapScreen.Initialize(spriteFont, text, position, Color.White); wallTexture = Content.Load<Texture2D>("wall"); pathTexture = Content.Load<Texture2D>("path"); solutionTexture = Content.Load<Texture2D>("solution"); foodTexture = Content.Load<Texture2D>("food"); swordTexture = Content.Load<Texture2D>("sword"); prisonerTexture = Content.Load<Texture2D>("prisonerAnimation"); startTexture = Content.Load<Texture2D>("startAnimation"); treasureTexture = Content.Load<Texture2D>("treasureAnimation"); playerAnimation = new Animation(); playerTexture = Content.Load<Texture2D>("playerAnimation"); playerAnimation.Initialize(playerTexture, Vector2.Zero, 48, 48, 2, 167, Color.White, 1f, true); fightAnimation = new Animation(); fightTexture = Content.Load<Texture2D>("fightAnimation"); fightAnimation.Initialize(fightTexture, Vector2.Zero, 48, 48, 6, 300, Color.White, 1f, true); winAnimation = new Animation(); winTexture = Content.Load<Texture2D>("winAnimation"); winAnimation.Initialize(winTexture, Vector2.Zero, 48, 48, 2, 300, Color.White, 1f, true); loseAnimation = new Animation(); loseTexture = Content.Load<Texture2D>("loseAnimation"); loseAnimation.Initialize(loseTexture, Vector2.Zero, 48, 48, 2, 300, Color.White, 1f, true); enemyTexture = Content.Load<Texture2D>("enemyAnimation"); energyBarTexture = Content.Load<Texture2D>("energyBar"); overlayTexture = Content.Load<Texture2D>("overlay"); playerStep = Content.Load<SoundEffect>("sound/playerStep"); enemyStep = Content.Load<SoundEffect>("sound/enemyStep"); playerFight = Content.Load<SoundEffect>("sound/playerFight"); swordDraw = Content.Load<SoundEffect>("sound/swordDraw"); foodEating = Content.Load<SoundEffect>("sound/foodEat"); pickupTreasure = Content.Load<SoundEffect>("sound/treasure"); releasePrisoner = Content.Load<SoundEffect>("sound/prisoner"); }
private void CreateAd() { bannerAd = AdGameComponent.Current.CreateAd(AdUnitId, new Rectangle(0, 720, 480,80), true); bannerAd.ErrorOccurred += new EventHandler<Microsoft.Advertising.AdErrorEventArgs>(bannerAd_ErrorOccurred); bannerAd.AdRefreshed += new EventHandler(bannerAd_AdRefreshed); AdGameComponent.Current.Enabled = false; this.gcw = new GeoCoordinateWatcher(); this.gcw.PositionChanged += new EventHandler<GeoPositionChangedEventArgs<GeoCoordinate>>(gcw_PositionChanged); this.gcw.StatusChanged += new EventHandler<GeoPositionStatusChangedEventArgs>(gcw_StatusChanged); this.gcw.Start(); }
private void CreateAd() { // Create a banner ad for the game. int width = 480; int height = 80; int x = (ScreenManager.Game.GraphicsDevice.Viewport.Bounds.Width - width) / 2; // centered on the display int y = 5; bannerAd = AdGameComponent.Current.CreateAd(AdUnitId, new Rectangle(x, y, width, height), true); }
private void ContinueLoad(GameTime gameTime) { loadingStarted = true; ForceDraw(gameTime); // Create a banner ad for the game. bannerAd = adGameComponent.CreateAd("83468", new Rectangle(0, 400, GraphicsDevice.Viewport.Bounds.Width, 80)); bannerAd.Keywords = "math, mathematics, divide, game, prime number, even number, numbers, the human calculator, count"; bannerAd.Visible = false; font = Content.Load<SpriteFont>("font"); mediumFont = Content.Load<SpriteFont>("mediumFont"); bigFont = Content.Load<SpriteFont>("bigFont"); smallFont = Content.Load<SpriteFont>("smallFont"); BG = Content.Load<Texture2D>("BG"); menuBg = Content.Load<Texture2D>("menuBg"); tutorialImage1 = Content.Load<Texture2D>("tutorialImage1"); tutorialImage2 = Content.Load<Texture2D>("tutorialImage2"); tutorialImage3 = Content.Load<Texture2D>("tutorialImage3"); tutorialImage4 = Content.Load<Texture2D>("tutorialImage4"); tutorialImage5 = Content.Load<Texture2D>("tutorialImage5"); gameOverImage = Content.Load<Texture2D>("gameOverImage"); creditsImage = Content.Load<Texture2D>("creditsImage"); highscoresImage = Content.Load<Texture2D>("highscoresImage"); soundOn = Content.Load<Texture2D>("soundOn"); soundOff = Content.Load<Texture2D>("soundOff"); resume = Content.Load<Texture2D>("resume"); //to avoid lag when the first number and first explosion is initialized Content.Load<Texture2D>("Twirls"); Content.Load<Texture2D>("HitSprite2000"); field2.LoadContent(); field3.LoadContent(); field5.LoadContent(); field7.LoadContent(); otherField.LoadContent(); redField.LoadContent(); backgroundTop.LoadContent("TrailTop"); backgroundMid.LoadContent("TrailMid"); backgroundBot.LoadContent("TrailBot"); music = Content.Load<Song>("sound/music"); acceptedNumber = Content.Load<SoundEffect>("sound/accepted_number"); lose = Content.Load<SoundEffect>("sound/lose"); menuSelect = Content.Load<SoundEffect>("sound/menu_select"); specialAbility = Content.Load<SoundEffect>("sound/special_ability"); playMusic(false); loadingComplete = true; }
protected override void OnNavigatedTo(NavigationEventArgs e) { App.InitializeGamePageGraphics(gameContext); InitializeScene(); base.OnNavigatedTo(e); timer.Start(); // Initialize audio var settings = ServiceLocator.Get<GameContext>().Settings; var audioHandler = gameContext.AudioHandler; audioHandler.StopSong(); if (settings.MusicVolume > 0.0d) { audioHandler.PlaySong("BGM2", true); } audioHandler.MusicVolume = (float)settings.MusicVolume; audioHandler.SoundVolume = (float)settings.SoundVolume; #if DEBUG AdComponent.Initialize("test_client"); drawableAd = AdComponent.Current.CreateAd("Image480_80", new Rectangle(0, (int)RenderSize.Height - 80, 480, 80), true); #else AdComponent.Initialize("41af360b-5268-4cee-ac68-5825d51962c0"); drawableAd = AdComponent.Current.CreateAd("90977", new Rectangle(0, 0, 480, 80), true); #endif drawableAd.AdRefreshed += DrawableAdOnAdRefreshed; drawableAd.ErrorOccurred += DrawableAdOnErrorOccurred; }
/// <summary> /// Create a DrawableAd with desired properties. /// </summary> private void CreateAd() { // Create a banner ad for the game. int width = 800; int height = 100; int x = (GraphicsDevice.Viewport.Bounds.Width - width) / 2; // centered on the display int y = 5; bannerAd = AdGameComponent.Current.CreateAd(AdUnitId, new Rectangle(x, y, width, height), true); // Add handlers for events (optional). bannerAd.ErrorOccurred += new EventHandler<Microsoft.Advertising.AdErrorEventArgs>(bannerAd_ErrorOccurred); bannerAd.AdRefreshed += new EventHandler(bannerAd_AdRefreshed); // Set some visual properties (optional). //bannerAd.BorderEnabled = true; // default is true //bannerAd.BorderColor = Color.White; // default is White //bannerAd.DropShadowEnabled = true; // default is true // Provide the location to the ad for better targeting (optional). // This is done by starting a GeoCoordinateWatcher and waiting for the location to be available. // The callback will set the location into the ad. // Note: The location may not be available in time for the first ad request. AdGameComponent.Current.Enabled = false; this.gcw = new GeoCoordinateWatcher(); this.gcw.PositionChanged += new EventHandler<GeoPositionChangedEventArgs<GeoCoordinate>>(gcw_PositionChanged); this.gcw.StatusChanged += new EventHandler<GeoPositionStatusChangedEventArgs>(gcw_StatusChanged); this.gcw.Start(); }
private void RetryAdCreation(GameTime gameTime) { if (retryAdCreation == true) { if (adTimeout >= 120000) { bannerAd = adGameComponent.CreateAd("81067", new Rectangle(0, 0, 480, 80), true); bannerAd.ErrorOccurred += new EventHandler<Microsoft.Advertising.AdErrorEventArgs>(bannerAd_ErrorOccurred); bannerAd.AdRefreshed += new EventHandler(bannerAd_AdRefreshed); adTimeout = 0; } adTimeout += (int)gameTime.ElapsedGameTime.TotalMilliseconds; } else { return; } }