예제 #1
0
        public GamePage()
        {
            InitializeComponent();

            // Get the application's ContentManager
            content = (Application.Current as App).Content;

            timer = new GameTimer { UpdateInterval = TimeSpan.FromTicks(333333) };
            timer.Update += OnUpdate;
            timer.Draw += OnDraw;

            dispatcherTimer = new DispatcherTimer { Interval = TimeSpan.FromMilliseconds(50) };
            dispatcherTimer.Tick += (sender, e1) => Detect();

            if (GameState.getInstance(false) != null)
            {
                GameState.getInstance().resetTurn();
            }

            //setup microphone and configure delegates that handle events
            microphone.BufferDuration = TimeSpan.FromSeconds(1);
            microphoneBuffer = new byte[microphone.GetSampleSizeInBytes(microphone.BufferDuration)];

            BasicHttpBinding binding = new BasicHttpBinding() { MaxReceivedMessageSize = int.MaxValue, MaxBufferSize = int.MaxValue };
            EndpointAddress address = new EndpointAddress(voiceRecognitionServerIP);
            speechRecognitionClient = new ARVRClient(binding, address);

            microphone.BufferReady += delegate
            {
                microphone.GetData(microphoneBuffer);
                microphoneMemoryStream.Write(microphoneBuffer, 0, microphoneBuffer.Length);
            };
            speechRecognitionClient.RecognizeSpeechCompleted += new EventHandler<RecognizeSpeechCompletedEventArgs>(_client_RecognizeSpeechCompleted);
        }
예제 #2
0
        public void Animate(GameTimer timer, Player player)
        {
            if (player.IsAlive)
                this.Position += direction * velocity * (float)timer.UpdateInterval.TotalSeconds;

            if (this.assetName != "bomb")
            {
                if (currentFrame < animate.Length)
                {
                    Source = sources[animate[currentFrame]];
                    currentFrame++;
                }
                else
                    currentFrame = 0;
            }
            else
            {
                if (this.Scale < 0.75f && smallest)
                    this.Scale += 0.6f * (float)timer.UpdateInterval.TotalSeconds;
                else
                {
                    smallest = false;
                    biggest = true;
                }
                if (this.Scale > 0.4f && biggest)
                    this.Scale -= 0.6f * (float)timer.UpdateInterval.TotalSeconds;
                else
                {
                    smallest = true;
                    biggest = false;
                }
            }
        }
예제 #3
0
파일: Bomb.cs 프로젝트: kulhajs/wp_planes
        public void Update(GameTimer timer)
        {
            this.Position += gravity * velocity * (float)timer.UpdateInterval.TotalSeconds;

            if (this.Rotation < wRotation)
                this.Rotation += 0.02f;
        }
예제 #4
0
        public GamePage()
        {
            InitializeComponent();

            // Obtenir le gestionnaire de contenu de l’application
            contentManager = (Application.Current as App).Content;

            // Créer un minuteur pour cette page
            timer = new GameTimer();
            timer.UpdateInterval = TimeSpan.FromTicks(333333);
            timer.Update += OnUpdate;
            timer.Draw += OnDraw;

            this.map = new Map(this);
            server = new Network();
            this.plist = new List<Player>();
            this.elist = new List<Egg>();
            this.tlist = new List<string>();
            this.lbc = new Queue<string>();
            this.screen = new Microsoft.Xna.Framework.Rectangle(0, 0, 800, 480);
            this.inventory_details = null;
            this.inventory_timer = TimeSpan.Zero;
            this.dot = new Vector2(640, 360);
            this.end = false;
            this.winner = "toto";
        }
        public GameOverPage()
        {
            InitializeComponent();

            App app = Application.Current as App;
            Score.Text = "Score: " + app.Score.ToString("#,#");
            app.Leaderboard.AddEntry(app.Score);

            //for(int e = 0; e < app.Leaderboard.Entries.Count; e++)
            //{
            //    Leaderboard.Text += app.Leaderboard.Entries[e].Rank + ". " + app.Leaderboard.Entries[e].Date + " " + app.Leaderboard.Entries[e].Score + "\n";
            //}

            graphicsDevice = SharedGraphicsDeviceManager.Current.GraphicsDevice;

            // Get the content manager from the application
            contentManager = (Application.Current as App).Content;

            // Create a timer for this page
            timer = new GameTimer();
            timer.UpdateInterval = TimeSpan.FromTicks(333333);
            timer.Update += OnUpdate;
            timer.Draw += OnDraw;

            LayoutUpdated += new EventHandler(GameOverPage_LayoutUpdated);
        }
예제 #6
0
        public void Update(GameTimer timer, ContentManager theContentManager, PowerupHandler pu, Player player, bool soundMuted)
        {
            enemiesInLevel = (background.Period + 1) * 3;

            elapsedTime += (float)timer.UpdateInterval.TotalSeconds;
            if (elapsedTime > 45f / enemiesInLevel && readyEnemies.Count > 0) //45f = time to 4000px to pass (current background width = 2000px)
            {
                elapsedTime = 0;
                readyEnemies[0].Position = new Vector2(player.Position.X + random.Next(760, 810), random.Next(110, 450));
                visibleEnemies.Add(readyEnemies[0]);
                readyEnemies.Remove(readyEnemies[0]);
            }

            foreach (Enemy e in visibleEnemies)
            {
                if (e.Position.X < player.Position.X - 100)
                {
                    if (e.IsAlive && player.IsAlive)
                        player.score.AddPoints(-5);
                    e.IsAlive = true;
                    e.Hitpoints = maxHealth;
                    e.ExplosionCreated = false;
                    e.explosionHandler.explosions.Clear();
                    readyEnemies.Add(e);
                    visibleEnemies.Remove(e);
                    break;
                }
                e.Update(timer, pu, theContentManager, player, soundMuted);
            }
        }
예제 #7
0
        public GamePage()
        {
            InitializeComponent();

            // Get the content manager from the application
            contentManager = (Application.Current as App).Content;

            // Create a timer for this page
            timer = new GameTimer();
            //timer.UpdateInterval = TimeSpan.FromTicks(333333);

            // Using TimeSpan.Zero causes the update to happen
            // at the actual framerate of the device. This makes
            // animation much smoother. However, this will cause
            // the speed of the app to vary from device to device
            // where a fixed UpdateInterval will not.
            timer.UpdateInterval = TimeSpan.Zero;
            timer.Update += OnUpdate;
            timer.Draw += OnDraw;

            // Use the LayoutUpdate event to know when the page layout
            // has completed so we can create the UIElementRenderer
            LayoutUpdated += new EventHandler(GamePage_LayoutUpdated);
            LayoutUpdated += new EventHandler(GamePage_LayoutUpdated);
        }
예제 #8
0
        Random rand; //random number generator

        #endregion Fields

        #region Constructors

        //must pass lanewidth from Game1 object
        public GameBoard( int displayWidth )
        {
            int laneWidth = displayWidth / ( laneCount );
            //set up random numbers
            this.rand = new Random();

            this.Lanes = new int[7];
            for( int i = 0; i < laneCount; i++ ) {
                this.Lanes[i] = i * laneWidth;
            }

            this.currentNutList = new List<Nut>();
            this.removeNutList = new List<Nut>();
            //this.currentPineCones = new List<PineCone>();
            //this.removePineCones = new List<PineCone>();

            //sets up event, to affect frequency of nuts, adjust update interval...perhaps add randomness?
            this.nutsFalling = new GameTimer();
            nutsFalling.UpdateInterval = TimeSpan.FromSeconds(nutFrequency);
            nutsFalling.Update += new EventHandler<GameTimerEventArgs>(generateNuts);
            nutsFalling.Start();

            //sets up level up timer
            this.levelTimer = new GameTimer();
            levelTimer.UpdateInterval = TimeSpan.FromSeconds(levelFrequency);
            levelTimer.Update += new EventHandler<GameTimerEventArgs>(levelUp);
            levelTimer.Start();
        }
예제 #9
0
        private void GamePage_Loaded(object sender, RoutedEventArgs e)
        {
            if (!pageLoaded)
            {
                manager = SharedGraphicsDeviceManager.Current;
                manager.PreferredBackBufferWidth = (int)this.ActualWidth;
                manager.PreferredBackBufferHeight = (int)this.ActualHeight;
                manager.SwapChainPanel = this;
                manager.ApplyChanges();

                gameTimer = new GameTimer();
                gameTimer.UpdateInterval = TimeSpan.FromTicks(166666);
                gameTimer.Update += Update;
                gameTimer.Draw += Draw;

                this.SizeChanged += GamePage_SizeChanged;

                // Le contenu est chargé une fois
                LoadContent();

                pageLoaded = true;
            }

            // L'initialisation doit se faire à chaque rechargement
            Initialize();
        }
예제 #10
0
        public Menu()
        {
            InitializeComponent();
            timer = new GameTimer();
            timer.UpdateInterval = TimeSpan.FromTicks(333333);
            timer.Update += OnUpdate;

            this.image_PlayGame.Tap += new EventHandler<GestureEventArgs>(image_PlayGame_Tap);
        }
예제 #11
0
 public void Update(GameTimer timer, bool move, bool soundMuted)
 {
     foreach (Explosion e in explosions)
     {
         e.Explode(soundMuted);
         if (move)
             e.Position += direction * velocity * (float)timer.UpdateInterval.TotalSeconds;
     }
 }
예제 #12
0
        /// <summary>
        /// Creates a new map game page view using the given content manager.
        /// </summary>
        /// <param name="contentManager"></param>
        public MapGamePageView(ContentManager contentManager)
        {
            // Get the content manager from the application
            _contentManager = contentManager;

            // Create a timer for this page
            _timer = new GameTimer();
            _timer.UpdateInterval = TimeSpan.FromTicks(333333);
            _timer.Update += OnUpdate;
            _timer.Draw += OnDraw;
        }
예제 #13
0
        public void initializeGameTimer()
        {
            Microsoft.Xna.Framework.GameTimer gameTimer = new Microsoft.Xna.Framework.GameTimer();
            gameTimer.UpdateInterval = TimeSpan.FromMilliseconds(33);

            gameTimer.Update += delegate { try { FrameworkDispatcher.Update(); } catch { } };

            gameTimer.Start();

            FrameworkDispatcher.Update();
        }
예제 #14
0
        public PlayLevel()
        {
            InitializeComponent();
            goalReached = false;
            gameTime = new GameTimer();
            gameTime.UpdateInterval = TimeSpan.FromSeconds(0.03);
            gameTime.Update += new EventHandler<GameTimerEventArgs>(gameTime_Update);
            levelName = "levelname";

            GObjs = new List<GameObject>();
            //deserializeJsonAsync();
            
            // Load Level to the canvas
            /*
            EnemyTemp = new Enemy();
            enemyNoGravity = false;
            Enemies = new List<Enemy>();
            Enemies.Add(new Enemy(10,10,10,10,10,1,1000,true,false));
            Enemies.Add(new Enemy(10,100,10,10,10,1,1000,false,true));
            foreach (Enemy e in Enemies)
            {
                Canvas.SetLeft(e.hitbox, e.Left);
                Canvas.SetTop(e.hitbox, e.Top);
                canvasWorld.Children.Add(e.hitbox);

            }
            */

            kbLeft = false;
            kbRight = false;
            topTemp = 0;
            jump = 0;
            doubleJumpAvaivable = true;

            /*
            //GObjs.Add(new GameObject(10,10,100,10));
            GObjs.Add(new GameObject(100, 10, 100, 10));
            GObjs.Add(new GameObject(150, 110, 100, 10));
            GObjs.Add(new GameObject(200, 210, 100, 10));
            GObjs.Add(new GameObject(250, 310, 100, 10));

            foreach (GameObject go in GObjs)
            {
                Canvas.SetLeft(go.hitbox, go.Left);
                Canvas.SetTop(go.hitbox, go.Top);
                canvasWorld.Children.Add(go.hitbox);
                
            }
            */

            //MessageBox.Show("Start Game");
            //gameTime.Start();

        }
예제 #15
0
 public void Animate(GameTimer timer, Player player)
 {
     foreach (Powerup pu in powerups)
     {
         pu.Animate(timer, player);
         if (pu.X < -16)
         {
             powerups.Remove(pu);
             break;
         }
     }
 }
예제 #16
0
        public GamePage()
        {
            InitializeComponent();

            // Get the content manager from the application
            contentManager = (Application.Current as App).Content;

            // Create a timer for this page
            timer = new GameTimer();
            timer.UpdateInterval = TimeSpan.FromTicks(333333);
            timer.Update += OnUpdate;
            timer.Draw += OnDraw;
        }
예제 #17
0
        public Couteau()
        {
            InitializeComponent();

            // Obtenir le gestionnaire de contenu à partir de l'application
            contentManager = (Application.Current as App).Content;

            // Créez une minuterie pour cette page
            timer = new GameTimer();
            timer.UpdateInterval = TimeSpan.FromTicks(333333);
            timer.Update += OnUpdate;
            timer.Draw += OnDraw;
        }
        public BuilderPage()
        {
            InitializeComponent();

            // Obtenga el administrador de contenido de la aplicación
            contentManager = (Application.Current as App).Content;
            LayoutUpdated += new EventHandler(XNARendering_LayoutUpdated);
            // Crear un temporizador para esta página
            timer = new GameTimer();
            timer.UpdateInterval = TimeSpan.FromTicks(333333);
            timer.Update += OnUpdate;
            timer.Draw += OnDraw;
        }
예제 #19
0
        /// <summary>
        /// Initialize all components and timers
        /// </summary>
        public GamePage()
        {
            InitializeComponent();

            // Inhalts-Manager aus der Anwendung abrufen
            contentManager = (Application.Current as App).Content;

            // Timer für diese Seite erstellen
            timer = new GameTimer();
            timer.UpdateInterval = TimeSpan.FromTicks(333333);
            timer.Update += OnUpdate;
            timer.Draw += OnDraw;
        }
        public MainPage()
        {
            this.InitializeComponent();
            this.Loaded += this.OnLoad;

            this.gameTimer = new GameTimer();
            this.gameTimer.Draw += this.OnDraw;
            this.gameTimer.Update += this.OnUpdate;
            this.gameTimer.UpdateInterval = TimeSpan.Zero;

            var services = new AppServiceProvider();
            services.AddService(typeof(IGraphicsDeviceService), SharedGraphicsDeviceManager.Current);
        }
예제 #21
0
        public GamePage()
        {
            InitializeComponent();

            // Get the content manager from the application
            _contentManager = ((App) Application.Current).Content;

            // Create a timer for this page
            _timer = new GameTimer {UpdateInterval = TimeSpan.FromTicks(333333)};
            _timer.Update += OnUpdate;
            _timer.Draw += OnDraw;
            _screenHeight = SharedGraphicsDeviceManager.Current.GraphicsDevice.Viewport.Height - 162;
            _screenWidth = SharedGraphicsDeviceManager.Current.GraphicsDevice.Viewport.Width;
        }
예제 #22
0
파일: Clouds.cs 프로젝트: kulhajs/wp_planes
        public void Scroll(GameTimer timer, Player p)
        {
            if (p.IsAlive)
                this.X += direction * velocity * (float)timer.UpdateInterval.TotalSeconds;

            #region END_OF_TEXTURE_CHECK
            if (this.X % clouds.Width < 0 && this.X % clouds.Width > -5f && !textureChanged)
            {
                period += 1;
                textureChanged = true;
            }
            if (this.X % clouds.Width < -5f && textureChanged)
                textureChanged = false;
            #endregion
        }
        public GamePage()
        {
            InitializeComponent();

            // Get the application's ContentManager
            content = (Application.Current as App).Content;

            // Create a timer for this page
            timer = new GameTimer();
            timer.UpdateInterval = TimeSpan.FromTicks(333333);
            timer.Update += OnUpdate;
            timer.Draw += OnDraw;

            scoreboardRenderer = new UIElementRenderer(scoreboard, 456, 60);
        }
예제 #24
0
        public GamePage()
        {
            InitializeComponent();

            // Get the content manager from the application
            contentManager = (Application.Current as App).Content;

            // Create a timer for this page
            timer = new GameTimer();
            timer.UpdateInterval = TimeSpan.FromTicks(333333);
            timer.Update += OnUpdate;
            timer.Draw += OnDraw;

            ThreadPool.QueueUserWorkItem(new WaitCallback(LoadMedia));
        }
예제 #25
0
        public GamePage()
        {
            InitializeComponent();
          // Get the application's ContentManager
            content = (Application.Current as App).Content;
            

            // Create a timer for this page
            timer = new GameTimer();
            timer.UpdateInterval = TimeSpan.FromTicks(333333);
            timer.Update += OnUpdate;
            timer.Draw += OnDraw;

            LayoutUpdated += new EventHandler(GamePage_LayoutUpdated);
        }
예제 #26
0
        public GamePage()
        {
            InitializeComponent();

            // Get the content manager from the application
            contentManager = (Application.Current as App).Content;

            TouchPanel.EnabledGestures = GestureType.Flick;// | GestureType.DragComplete;

            // Create a timer for this page
            timer = new GameTimer();
            timer.UpdateInterval = TimeSpan.FromTicks(333333);
            timer.Update += OnUpdate;
            timer.Draw += OnDraw;
        }
예제 #27
0
        public LevelSelectPage()
        {
            InitializeComponent();

            gameContext = ServiceLocator.Get<GameContext>();

            // Create a timer for this page running at 30 fps
            timer = new GameTimer();
            timer.UpdateInterval = TimeSpan.FromTicks(33333);
            timer.Update += OnUpdate;
            timer.Draw += OnDraw;

            InitializeAudio();

            TouchPanel.EnabledGestures = GestureType.Flick | GestureType.Tap;
        }
예제 #28
0
        public GamePage()
        {
            InitializeComponent();

            // Get the content manager from the application
            _contentManager = (Application.Current as App).Content;

            // Create a timer for this page
            _timer = new GameTimer {UpdateInterval = TimeSpan.FromTicks(333333)};
            _timer.Update += OnUpdate;
            _timer.Draw += OnDraw;

            TouchPanel.EnabledGestures = GestureType.Tap;

            Ships = new List<Ship>();
        }
예제 #29
0
        public GamePlay1()
        {
            InitializeComponent();

            // Get the content manager from the application
            contentManager = (Application.Current as App).Content;

            // Create a timer for this page
            timer = new GameTimer();
            timer.UpdateInterval = TimeSpan.FromTicks(333333);
            timer.Update += OnUpdate;
            timer.Draw += OnDraw;

            // Event binding for XNA Rendering //
            LayoutUpdated += XNARendering;
        }
예제 #30
0
        public GamePage()
        {
            InitializeComponent();

            // Get the content manager from the application
            contentManager = (Application.Current as App).Content;

            // Create a timer for this page
            timer = new GameTimer();
			timer.UpdateInterval = TimeSpan.FromTicks(166667);
			timer.Update += OnUpdate;
#if USE_THREAD_LOCKED_VERSION
			timer.FrameAction += PreDraw;
#else
#endif
        }