Inheritance: AndroidGameView, Android.Views.View.IOnTouchListener
Esempio n. 1
0
 public MonoGameAndroidGameView(Context context, AndroidGameWindow androidGameWindow, Game game)
     : base(context)
 {
     _gameWindow   = androidGameWindow;
     _game         = game;
     _touchManager = new AndroidTouchEventManager(androidGameWindow);
 }
        public MonoGameAndroidGameView(Context context, AndroidGameWindow androidGameWindow, Game game)
            : base(context)
        {
            _gameWindow = androidGameWindow;
			_game = game;
            _touchManager = new AndroidTouchEventManager(androidGameWindow);
        }
Esempio n. 3
0
        public AndroidGamePlatform(Game game)
            : base(game)
        {
            System.Diagnostics.Debug.Assert(Game.Activity != null, "Must set Game.Activity before creating the Game instance");
            AndroidGameActivity.Game     = game;
            AndroidGameActivity.Paused  += Activity_Paused;
            AndroidGameActivity.Resumed += Activity_Resumed;

            Window = new AndroidGameWindow(Game.Activity, game);
        }
Esempio n. 4
0
        public AndroidGamePlatform(Game game)
            : base(game)
        {
            System.Diagnostics.Debug.Assert(Game.Activity != null, "Must set Game.Activity before creating the Game instance");
            Game.Activity.Game = Game;
            AndroidGameActivity.Paused += Activity_Paused;
            AndroidGameActivity.Resumed += Activity_Resumed;

            _gameWindow = new AndroidGameWindow(Game.Activity, game);
            Window = _gameWindow;
        }
Esempio n. 5
0
        public override void OnOrientationChanged(int orientation)
        {
            if (orientation == OrientationEventListener.OrientationUnknown)
            {
                return;
            }

            // Avoid changing orientation whilst the screen is locked
            if (ScreenReceiver.ScreenLocked)
            {
                return;
            }

            if (_naturalOrientation.Value == Orientation.Landscape)
            {
                orientation += 270;
            }

            // Round orientation into one of 4 positions, either 0, 90, 180, 270.
            int ort = ((orientation + 45) / 90 * 90) % 360;

            var disporientation = DisplayOrientation.Unknown;

            switch (ort)
            {
            case 90: disporientation = AndroidCompatibility.FlipLandscape ? DisplayOrientation.LandscapeLeft : DisplayOrientation.LandscapeRight;
                break;

            case 270: disporientation = AndroidCompatibility.FlipLandscape ? DisplayOrientation.LandscapeRight : DisplayOrientation.LandscapeLeft;
                break;

            case 0: disporientation = DisplayOrientation.Portrait;
                break;

            case 180: disporientation = DisplayOrientation.PortraitDown;
                break;

            default:
                disporientation = DisplayOrientation.LandscapeLeft;
                break;
            }

            // Only auto-rotate if target orientation is supported and not current
            AndroidGameWindow gameWindow = (AndroidGameWindow)Game.Instance.Window;

            if ((gameWindow.GetEffectiveSupportedOrientations() & disporientation) != 0 &&
                disporientation != gameWindow.CurrentOrientation)
            {
                gameWindow.SetOrientation(disporientation, true);
            }
        }
Esempio n. 6
0
        public Game(Activity context)
        {
            contextInstance = context;

            // Initialize collections
            _services = new GameServiceContainer();
            _gameComponentCollection = new GameComponentCollection();

            view      = new AndroidGameWindow(context);
            view.game = this;
            // Initialize GameTime
            _updateGameTime = new GameTime();
            _drawGameTime   = new GameTime();
        }
Esempio n. 7
0
        public Game()
        {
            System.Diagnostics.Debug.Assert(contextInstance != null, "Must set Game.Activity before creating the Game instance");
            contextInstance.Game = this;

            // Initialize collections
            _services = new GameServiceContainer();
            _gameComponentCollection = new GameComponentCollection();

            _content = new ContentManager(_services);

            view      = new AndroidGameWindow(contextInstance);
            view.game = this;
            // Initialize GameTime
            _updateGameTime = new GameTime();
            _drawGameTime   = new GameTime();
        }
Esempio n. 8
0
        public AndroidGamePlatform(Game game)
            : base(game)
        {
            System.Diagnostics.Debug.Assert(Game.Activity != null, "Must set Game.Activity before creating the Game instance");
            Game.Activity.Game = Game;
            AndroidGameActivity.Paused += Activity_Paused;
            AndroidGameActivity.Resumed += Activity_Resumed;

            _gameWindow = new AndroidGameWindow(Game.Activity, game);
            Window = _gameWindow;

            MediaLibrary.Context = Game.Activity;
            try
            {
                soundControllerInstance = OpenALSoundController.GetInstance;
            }
            catch (DllNotFoundException ex)
            {
                throw (new NoAudioHardwareException("Failed to init OpenALSoundController", ex));
            }
        }
Esempio n. 9
0
        public AndroidGamePlatform(Game game)
            : base(game)
        {
            System.Diagnostics.Debug.Assert(Game.Activity != null, "Must set Game.Activity before creating the Game instance");
            Game.Activity.Game           = Game;
            AndroidGameActivity.Paused  += Activity_Paused;
            AndroidGameActivity.Resumed += Activity_Resumed;

            _gameWindow = new AndroidGameWindow(Game.Activity, game);
            Window      = _gameWindow;

            MediaLibrary.Context = Game.Activity;
            try
            {
                OpenALSoundController soundControllerInstance = OpenALSoundController.GetInstance;
            }
            catch (DllNotFoundException ex)
            {
                throw (new NoAudioHardwareException("Failed to init OpenALSoundController", ex));
            }
        }
Esempio n. 10
0
        public override void OnOrientationChanged(int orientation)
        {
            if (orientation == OrientationEventListener.OrientationUnknown)
            {
                return;
            }

            // Avoid changing orientation whilst the screen is locked
            if (ScreenReceiver.ScreenLocked)
            {
                return;
            }

            // Check if screen orientation is locked by user: if it's locked, do not change orientation.
            try
            {
                if (Settings.System.GetInt(Application.Context.ContentResolver, "accelerometer_rotation") == 0)
                {
                    return;
                }
            }
            catch (Settings.SettingNotFoundException)
            {
                // Do nothing (or log warning?). In case android API or Xamarin do not support this Android system property.
            }

            var disporientation = AndroidCompatibility.GetAbsoluteOrientation(orientation);

            // Only auto-rotate if target orientation is supported and not current
            AndroidGameWindow gameWindow = (AndroidGameWindow)Game.Instance.Window;

            if ((gameWindow.GetEffectiveSupportedOrientations() & disporientation) != 0 &&
                disporientation != gameWindow.CurrentOrientation)
            {
                gameWindow.SetOrientation(disporientation, true);
            }
        }
Esempio n. 11
0
        public override void OnOrientationChanged(int orientation)
        {
            if (orientation == OrientationEventListener.OrientationUnknown)
            {
                return;
            }

            // Avoid changing orientation whilst the screen is locked
            if (ScreenReceiver.ScreenLocked)
            {
                return;
            }

            var disporientation = AndroidCompatibility.GetAbsoluteOrientation(orientation);

            // Only auto-rotate if target orientation is supported and not current
            AndroidGameWindow gameWindow = (AndroidGameWindow)Game.Instance.Window;

            if ((gameWindow.GetEffectiveSupportedOrientations() & disporientation) != 0 &&
                disporientation != gameWindow.CurrentOrientation)
            {
                gameWindow.SetOrientation(disporientation, true);
            }
        }
Esempio n. 12
0
 public XnaGameWindowImpl(Activity context, Game game)
 {
     nativeWindow = new AndroidGameWindow(context, game);
 }
Esempio n. 13
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Protogame.Platform.AndroidGameWindow"/> class.
 /// </summary>
 /// <param name="gameWindow">The underlying Android game window to wrap.</param>
 public AndroidGameWindow(AndroidMonoGameWindow gameWindow)
 {
     this.m_GameWindow = gameWindow;
 }
Esempio n. 14
0
        public Game(Activity context)
        {
            contextInstance = context;

            // Initialize collections
            _services = new GameServiceContainer();
            _gameComponentCollection = new GameComponentCollection();

            view = new AndroidGameWindow(context);
            view.game = this;
            // Initialize GameTime
            _updateGameTime = new GameTime();
            _drawGameTime = new GameTime();
        }
 public XnaGameWindowImpl(Activity context, Game game)
 {
     nativeWindow      = new AndroidGameWindow(context);
     nativeWindow.game = game;
 }
Esempio n. 16
0
        public Game()
        {
            _instance = this;

            System.Diagnostics.Debug.Assert(contextInstance != null, "Must set Game.Activity before creating the Game instance");
            contextInstance.Game = this;

            // Initialize collections
            _services = new GameServiceContainer();
            _gameComponentCollection = new GameComponentCollection();

            _content = new ContentManager(_services);

            view = new AndroidGameWindow(contextInstance);
            view.game = this;
            // Initialize GameTime
            _updateGameTime = new GameTime();
            _drawGameTime = new GameTime();
        }
Esempio n. 17
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Protogame.Platform.AndroidGameWindow"/> class.
 /// </summary>
 /// <param name="gameWindow">The underlying Android game window to wrap.</param>
 public AndroidGameWindow(AndroidMonoGameWindow gameWindow)
 {
     this.m_GameWindow = gameWindow;
 }