コード例 #1
0
        protected override void LoadContent()
        {
            _taps = new List <Vector2>();
            // Create a new SpriteBatch, which can be used to draw textures.
            SpriteBatch = new SpriteBatch(GraphicsDevice);
            GameData    = new GamePersistance <GameData>(this);
            Pixel       = new Texture2D(GraphicsDevice, 1, 1, false, SurfaceFormat.Color);
            Pixel.SetData(new[] { Color.White });
            Textures.LoadContent(Content);
            Fonts.LoadContent(Content);

            ParticleSystem = new ParticleEngine();
            ParticleColor  = Color.Black;
            MouseInput     = new MouseInput();
            TouchInput     = new TouchInput();
            UnifiedInput   = new UnifiedInput(this);
            KeyboardInput  = new KeyboardInput(this);


            UnifiedInput.MoveListeners.Add((v) =>
            {
                ParticleSystem.Add(new Emitter(v, new TimeSpan(0, 0, 0, 1),
                                               e => ParticleFactory.GenerateParticle(e, Textures.ParticleStar,
                                                                                     ParticleColor), 5, 20));
            });
            UnifiedInput.TapListeners.Add(OnTap);
            UnifiedInput.DraggedListeners.Add(OnDragged);

            //Branding.BackgroundColor = Color.Red;

            IsMouseVisible = false;
            BackGroundTune = Game.Audio.Play(Cues.Background, AudioChannels.Music, true);
        }
コード例 #2
0
ファイル: BaseGame.cs プロジェクト: pixelwhipped/SquareGrid
        protected override void LoadContent()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            SpriteBatch = new SpriteBatch(GraphicsDevice);
            GameData    = new GamePersistance <GameData>(this);
            Pixel       = new Texture2D(GraphicsDevice, 1, 1, false, SurfaceFormat.Color);
            Pixel.SetData(new[] { Color.White });
            Textures.LoadContent(Content);
            Font = new FontTexture(Content.Load <Texture2D>(@"Images\EditSysLarge.png"), 58, 8, -10, new[]
            {
                26, 22, 36, 36, 50, 47, 40, 21, 28, 28, 29, 33, 26, 40, 22, 47,
                47, 33, 47, 47, 47, 47, 47, 47, 47, 47, 26, 26, 51, 40, 46, 47,
                47, 47, 47, 47, 47, 47, 47, 47, 47, 26, 47, 47, 47, 47, 47, 47,
                47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 29, 47, 29, 33, 47,
                26, 31, 33, 30, 33, 32, 28, 33, 31, 22, 26, 32, 21, 40, 31, 24,
                33, 33, 27, 29, 28, 31, 33, 40, 32, 33, 31, 33, 21, 33, 33, 31
            });
            Mouse          = new MouseInput();
            IsMouseVisible = false;

            Touch         = new TouchInput();
            UnifiedInput  = new UnifiedInput(this);
            KeyboardInput = new KeyboardInput(this);
            UnifiedInput.TapListeners.Add(Tap);
            Branding.BackgroundColor = Color.Black;
            Audio.Play(Cues.Music01, AudioChannels.Music, true);
            _currentComponent = new Intro(this, null);
        }
コード例 #3
0
 void Start()
 {
     cameraRigidBody = GetComponent <Rigidbody2D>();
     inputManager    = GameObject.Find("Director").GetComponent <UnifiedInput>();
     inputManager.OnBackgroundDown += OnBackgroundDown;
     inputManager.OnBackgroundMove += OnBackgroundMove;
     inputManager.OnBackgroundUp   += OnBackgroundUp;
 }
コード例 #4
0
ファイル: PinchZoom.cs プロジェクト: rickbatka/birds
 void Start()
 {
     inputManager = GameObject.Find("Director").GetComponent <UnifiedInput>();
     inputManager.OnBackgroundDown       += OnMainFingerAdded;
     inputManager.OnBackgroundMove       += OnMainFingerMoved;
     inputManager.OnBackgroundUp         += OnMainFingerRemoved;
     inputManager.OnBackgroundSecondDown += OnSecondFingerAdded;
     inputManager.OnBackgroundSecondMove += OnSecondFingerMoved;
     inputManager.OnBackgroundSecondUp   += OnSecondFingerRemoved;
 }
コード例 #5
0
        /// <summary>
        /// Allows the game to run logic such as updating the world,
        /// checking for collisions, gathering input, and playing audio.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Update(GameTime gameTime)
        {
            SideBar.Update();
            //  Clouds.Update(gameTime);
            TouchInput.Update(gameTime);
            MouseInput.Update(gameTime);
            UnifiedInput.Update(gameTime);
            KeyboardInput.Update(gameTime);

            UpdateFaders(gameTime);
            MenuMap.Update(gameTime);
            Arena.Update(gameTime);
            Sprites.Update(gameTime);
            Sounds.Update();
            base.Update(gameTime);
        }
コード例 #6
0
ファイル: Arkanoid.cs プロジェクト: pixelwhipped/ArkanoidDX
 /// <summary>
 ///     Allows the game to run logic such as updating the world,
 ///     checking for collisions, gathering input, and playing audio.
 /// </summary>
 /// <param name="gameTime">Provides a snapshot of timing values.</param>
 protected override void Update(GameTime gameTime)
 {
     if (IsPaused)
     {
         PauseArena.Update(gameTime);
         return;
     }
     Starfield.Update(gameTime);
     if (!ApplicationView.GetForCurrentView().IsFullScreenMode)
     {
         ApplicationView.GetForCurrentView().TryEnterFullScreenMode();
     }
     TouchInput.Update(gameTime);
     MouseInput.Update(gameTime);
     UnifiedInput.Update(gameTime);
     KeyboardInput.Update(gameTime);
     Arena.Update(gameTime);
     Sprites.Update(gameTime);
     base.Update(gameTime);
 }
コード例 #7
0
ファイル: Arkanoid.cs プロジェクト: pixelwhipped/ArkanoidDX
        /// <summary>
        ///     LoadContent will be called once per game and is the place to load
        ///     all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            Settings    = new GameSettings(this);
            SpriteBatch = new SpriteBatch(GraphicsDevice);
            Sounds.LoadContent();
            Pixel = new Texture2D(GraphicsDevice, 1, 1, false, SurfaceFormat.Color);
            Pixel.SetData(new[] { Color.White });

            MouseInput    = new MouseInput();
            TouchInput    = new TouchInput();
            UnifiedInput  = new UnifiedInput(this);
            KeyboardInput = new KeyboardInput(this);
            UnifiedInput.TapListeners.Add(t => Arena?.OnTap(t));

            Levels.Levels.LoadContent(Content);
            Fonts.LoadContent(Content);
            Textures.LoadContent(Content);
            Sprites.LoadContent(this, Content);
            Starfield  = new Starfield(100, ArenaArea);
            PauseArena = new PauseArena(this);
            Arena      = new MenuArena(this);
            Arena.Initialise();
        }
コード例 #8
0
        /// <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);
            Pixel       = new Texture2D(GraphicsDevice, 1, 1, false, SurfaceFormat.Color);
            Pixel.SetData(new[] { Color.White });
            Logo    = new TitleLogo(this);
            SideBar = new SideBar(this);

            MouseInput    = new MouseInput();
            TouchInput    = new TouchInput();
            UnifiedInput  = new UnifiedInput(this);
            KeyboardInput = new KeyboardInput(this);
            UnifiedInput.TapListeners.Add(t => Arena?.OnTap(t));

            Textures.LoadContent(Content);
            Sprites.LoadContent(this, Content);
            Fonts.LoadContent(Content);
            Sounds = new Sounds(this);

            TileSet01 = new TileSet(Strings.Park, new Color(37f / 255f, 92f / 255f, 64f / 255f), Textures.TileSetJungle01, Textures.TileSetShadows, Textures.TileSetBridges);
            TileSet02 = new TileSet(Strings.Jungle, new Color(13f / 255f, 69f / 255f, 17f / 255f), Textures.TileSetJungle02, Textures.TileSetShadows, Textures.TileSetBridges);
            TileSet03 = new TileSet(Strings.RoadBlock, new Color(101f / 255f, 97f / 255f, 96f / 255f), Textures.TileSetRoad01, Textures.TileSetShadows, Textures.TileSetBridgesRoad);
            TileSet04 = new TileSet(Strings.Geiger, new Color(39f / 255f, 37f / 255f, 92f / 255f), Textures.TileSetGeiger01, Textures.TileSetShadows, Textures.TileSetBridgesGeiger);


            TileSets = new TileSet[] { TileSet01, TileSet02, TileSet03, TileSet04 };
            TileSet  = TileSets[GameSettings.TileSet];

            MenuMap.Initialize();

            MenuArena  = new MenuArena(this);
            PauseArena = new PauseArena(this, MenuArena);

            _arena = MenuArena;
            _arena.Initialise();
        }
コード例 #9
0
ファイル: aimcannon.cs プロジェクト: rickbatka/birds
 // Use this for initialization
 void Start()
 {
     cannonCollider = this.GetComponent <CircleCollider2D>();
     aimingLine     = GetComponent <AimingLine>();
     inputManager   = GameObject.Find("Director").GetComponent <UnifiedInput>();
 }
コード例 #10
0
ファイル: BaseGame.cs プロジェクト: pixelwhipped/SquareGrid
        protected async override void Update(GameTime gameTime)
        {
            if (IsPaused)
            {
                return;
            }
            Touch.Update(gameTime);
            Mouse.Update(gameTime);
            UnifiedInput.Update(gameTime);
            KeyboardInput.Update(gameTime);
            //TODO Update Code

            foreach (var backgroundParticle in _backgroundParticles)
            {
                backgroundParticle.Update(gameTime);
            }


            if (_fade1Xin)
            {
                FadeX1 += 0.025f;
                if (FadeX1 >= 1f)
                {
                    _fade1Xin = false;
                }
            }
            else
            {
                FadeX1 -= 0.025f;
                if (FadeX1 <= .5f)
                {
                    _fade1Xin = true;
                }
            }
            if (_fade2Xin)
            {
                FadeX2 += 0.05f;
                if (FadeX2 >= 1f)
                {
                    _fade2Xin = false;
                }
            }
            else
            {
                FadeX2 -= 0.05f;
                if (FadeX2 <= 0.5f)
                {
                    _fade2Xin = true;
                }
            }

            if ((_currentComponent ?? this).Transition >= 1f)
            {
                NextComponent = (_currentComponent ?? this).Update(gameTime, this);
            }

            if (_currentComponent != null)
            {
                _currentComponent.Transition += 0.05f;
                if (_currentComponent.HasPrevious && _taps.Any(t => new Rectangle((int)Width - 64, 0, 64, 64).Contains(t)))
                {
                    Audio.Play(Cues.Fail);
                    _currentComponent.Back();
                }


                if (_currentComponent.HasPrevious && KeyboardInput.TypedKey(Keys.Escape))
                {
                    Audio.Play(Cues.Fail);
                    _currentComponent.Back();
                }
            }
            if (_previousComponent != null)
            {
                _previousComponent.Transition -= 0.05f;
            }

            if (NextComponent != null && NextComponent != _currentComponent)
            {
                GameData.Save();
                _previousComponent = _currentComponent;
                _currentComponent  = NextComponent;
            }

            _taps.Clear();
            base.Update(gameTime);
        }
コード例 #11
0
        protected async override void Update(GameTime gameTime)
        {
            if (IsPaused)
            {
                return;
            }
            if (NextComponent == null)
            {
                NextComponent = new MainMenu(this, null, Color.White);
            }
            if (_currentComponent.Transition >= 1)
            {
                TouchInput.Update(gameTime);
                MouseInput.Update(gameTime);
                UnifiedInput.Update(gameTime);
                KeyboardInput.Update(gameTime);
            }

            if (_fade1Xin)
            {
                FadeX1 += 0.025f;
                if (FadeX1 >= 1f)
                {
                    _fade1Xin = false;
                }
            }
            else
            {
                FadeX1 -= 0.025f;
                if (FadeX1 <= .5f)
                {
                    _fade1Xin = true;
                }
            }
            if (_fade2Xin)
            {
                FadeX2 += 0.05f;
                if (FadeX2 >= 1f)
                {
                    _fade2Xin = false;
                }
            }
            else
            {
                FadeX2 -= 0.05f;
                if (FadeX2 <= 0.5f)
                {
                    _fade2Xin = true;
                }
            }

            if ((_currentComponent ?? this).Transition >= 1f)
            {
                NextComponent = (_currentComponent ?? this).Update(gameTime, this);
            }

            if (_currentComponent != null)
            {
                _currentComponent.Transition += 0.05f;
                if (EnableGoBack)
                {
                    if (_currentComponent.HasPrevious &&
                        _taps.Any(t => new Rectangle((int)Width - 64, 0, 64, 64).Contains(t)))
                    {
                        //Audio.Play(Cues.Fail);
                        _currentComponent.Back();
                    }


                    if (_currentComponent.HasPrevious && KeyboardInput.TypedKey(Keys.Escape))
                    {
                        //Audio.Play(Cues.Fail);
                        _currentComponent.Back();
                    }
                }
            }
            if (_previousComponent != null)
            {
                _previousComponent.Transition -= 0.05f;
            }

            if (NextComponent != null && NextComponent != _currentComponent)
            {
                GameData.Save();
                _previousComponent = _currentComponent;
                _currentComponent  = NextComponent;
            }

            _taps.Clear();
            base.Update(gameTime);
        }