using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Input.Touch;
using Android.Content.Res;
using Android.Content;
namespace Penguloon
{
///
/// This is the main type for your game.
///
public class Main : Game
{
private GraphicsDeviceManager _graphics;
private SpriteBatch _spriteBatch;
private Resources _resources;
public GraphicsDeviceManager Graphics
{
get => _graphics;
set => _graphics = value;
}
public SpriteBatch SpriteBatch
{
get => _spriteBatch;
set => _spriteBatch = value;
}
public Resources Resources
{
get => _resources;
set => _resources = value;
}
public Context Context { get; set; }
public Context Activity_ { get; set; }
public Activity Activity__ { get; set; }
public Main(Resources resources, Activity context)
{
Context = context.ApplicationContext;
Activity_ = context;
Activity__ = context;
Resources = resources;
Graphics = new GraphicsDeviceManager(this);
Content.RootDirectory = "Content";
Graphics.IsFullScreen = true;
Graphics.SupportedOrientations = DisplayOrientation.LandscapeLeft | DisplayOrientation.LandscapeRight;
}
///
/// Allows the game to perform any initialization it needs to before starting to run.
/// This is where it can query for any required services and load any non-graphic
/// related content. Calling base.Initialize will enumerate through any components
/// and initialize them as well.
///
protected override void Initialize()
{
SceneManager.Initialize(this);
StaticUIValues.Initialize(this);
base.Initialize();
}
///
/// LoadContent will be called once per game and is the place to load
/// all of your content.
///
protected override void LoadContent()
{
// Create a new SpriteBatch, which can be used to draw textures.
SpriteBatch = new SpriteBatch(GraphicsDevice);
ContentManager.LoadContent(this);
UserdataManager.ReadData(Context);
// TODO: use this.Content to load your game content here
}
///
/// UnloadContent will be called once per game and is the place to unload
/// game-specific content.
///
protected override void UnloadContent()
{
// TODO: Unload any non ContentManager content here
ContentManager.DisposeContent();
}
///
/// Allows the game to run logic such as updating the world,
/// checking for collisions, gathering input, and playing audio.
///
/// Provides a snapshot of timing values.
protected override void Update(GameTime gameTime)
{
// bug free code XDDDDDDdd
try
{
var delta = (float)gameTime.ElapsedGameTime.TotalSeconds;
TouchLocation[] touchLocations = TouchPanel.GetState().ToArray();
SceneManager.Update(delta, touchLocations);
}
catch { }
base.Update(gameTime);
}
///
/// This is called when the game should draw itself.
///
/// Provides a snapshot of timing values.
protected override void Draw(GameTime gameTime)
{
var delta = (float)gameTime.ElapsedGameTime.TotalSeconds;
GraphicsDevice.Clear(Color.Black);
SpriteBatch.Begin();
SceneManager.Draw(delta);
SpriteBatch.End();
base.Draw(gameTime);
}
}
}