public DataManager(Game game) : base(game) { _switches = new SwitchCollection(); _variables = new VariableCollection(); _switches["Achievement Test"] = new Switch() { Name = "Achievement Test" }; _switches["switch_ponies"] = new Switch() { Name = "Multi Switch Check Test" }; _playerParty = new BattleDataCollection(); _playerCharacters = new BattleDataCollection(); _enemyCollection = new BattleDataCollection(); _switches["Achievement Test"].TurnOn(); PlayerName = new Variable("Pinkie Pie"); PlayerGold = new Variable(1000); PlayerSteps = new Variable(0); PlayerName.Value = "Pinkie Pie"; _variables["{steps_taken}"] = PlayerSteps; _variables["{profilename}"] = PlayerName; _variables["{gold}"] = PlayerGold; }
public HierarchicalProfilerSample(Microsoft.Xna.Framework.Game game) : base(game) { GraphicsScreen.ClearBackground = true; GraphicsScreen.UseFixedWidthFont = true; // Start profiling. _profiler.Reset(); // This loop simulates the main-loop of a game. for (int i = 0; i < 20; i++) { // NewFrame() must be called when a new frame begins (= start of game loop). _profiler.NewFrame(); Update(); Draw(); } // Print the profiler data. We start at the root node and include up to 5 child levels. var debugRenderer = GraphicsScreen.DebugRenderer2D; debugRenderer.DrawText("\n"); debugRenderer.DrawText(_profiler.Dump(_profiler.Root, 5)); }
public static object CreateInstance(Type type, Microsoft.Xna.Framework.Game game) { if (type == null) { throw new ArgumentNullException("Manager Type"); } ConstructorInfo info = type.GetConstructor(new Type[] { typeof(Microsoft.Xna.Framework.Game) }); if (info == null) { return(null); } object instance; try { instance = info.Invoke(new object[] { game }); } catch (Exception ex) { if (ex is SystemException) { throw; } instance = null; } return(instance); }
protected BasicSample(Microsoft.Xna.Framework.Game game) : base(game) { // Create a graphics screen for rendering basic stuff. GraphicsScreen = new SampleGraphicsScreen(Services) { ClearBackground = true, }; // The order of the graphics screens is back-to-front. Add the screen at index 0, // i.e. behind all other screens. The screen should be rendered first and all other // screens (menu, GUI, help, ...) should be on top. GraphicsService.Screens.Insert(0, GraphicsScreen); // GameObjects that need to render stuff will retrieve the DebugRenderers or // Scene through the service provider. Services.Register(typeof(DebugRenderer), null, GraphicsScreen.DebugRenderer); Services.Register(typeof(DebugRenderer), "DebugRenderer2D", GraphicsScreen.DebugRenderer2D); Services.Register(typeof(IScene), null, GraphicsScreen.Scene); // Add a default light setup (ambient light + 3 directional lights). var defaultLightsObject = new DefaultLightsObject(Services); GameObjectService.Objects.Add(defaultLightsObject); }
public DataManager(Game game) : base(game) { _switches = new SwitchCollection(); _variables = new VariableCollection(); _switches["Achievement Test"] = new Switch() { Name = "Achievement Test" }; _switches["switch_ponies"] = new Switch() { Name = "Multi Switch Check Test" }; _playerParty = new BattleDataCollection(); _playerCharacters = new BattleDataCollection(); _enemyCollection = new BattleDataCollection(); _switches["Achievement Test"].TurnOn(); PlayerName = new Variable("Pinkie Pie"); PlayerGold = new Variable(1000); PlayerSteps = new Variable(0); PlayerName.Value = "Pinkie Pie"; _variables["{steps_taken}"] = PlayerSteps; _variables["{profilename}"] = PlayerName; _variables["{gold}"] = PlayerGold; }
/// <summary> /// Binds the game into the kernel. /// </summary> /// <param name="game">The game.</param> /// <param name="kernel">The kernel to bind into.</param> /// <param name="bindGraphicsDevice">if set to <c>true</c> binds game.GraphicsDevice.</param> /// <param name="bindContentManager">if set to <c>true</c> binds game.Content.</param> /// <param name="bindServiceContainer">if set to <c>true</c> binds game.Services.</param> /// <param name="bindComponentCollection"></param> public static void BindGame(Game game, IKernel kernel, bool bindGraphicsDevice = true, bool bindContentManager = true, bool bindServiceContainer = true, bool bindComponentCollection = true) { // bind the game to a singleton instance var thisType = game.GetType(); kernel.Bind(thisType).ToConstant(game); kernel.Bind<Game>().ToConstant(game); // bind the graphics device if (bindGraphicsDevice) kernel.Bind<GraphicsDevice>().ToMethod(c => game.GraphicsDevice); // bind the content manager if (bindContentManager) kernel.Bind<ContentManager>().ToMethod(c => game.Content); // bind services if (bindServiceContainer) { kernel.Bind<GameServiceContainer>().ToMethod(c => game.Services); kernel.Bind<IServiceProvider>().ToMethod(c => game.Services); } if (bindComponentCollection) { kernel.Bind<GameComponentCollection>().ToMethod(c => game.Components); } }
public SoundCenter(Microsoft.Xna.Framework.Game game) { HitCannon = game.Content.Load <SoundEffect>("hitcannon"); HitTerrain = game.Content.Load <SoundEffect>("hitterrain"); Launch = game.Content.Load <SoundEffect>("launch"); HitBird = game.Content.Load <SoundEffect>("explosion-05"); }
public DataManager(Game game) : base(game) { _switches = new SwitchCollection(); _variables = new VariableCollection(); _achievementsToCreate = new Stack<Achievement>(); _switches["Achievement Test"] = new Switch() { Name = "Achievement Test" }; _switches["switch_ponies"] = new Switch() { Name = "Multi Switch Check Test" }; _switches["Achievement Test"].TurnOn(); PlayerName = new Variable("Pinkie Pie"); PlayerGold = new Variable(1000); PlayerSteps = new Variable(0); PlayerName.Value = "Pinkie Pie"; _variables["{steps_taken}"] = PlayerSteps; _variables["{profilename}"] = PlayerName; _variables["{gold}"] = PlayerGold; }
public Form1() { InitializeComponent(); game = new Microsoft.Xna.Framework.Game(); IM = new GuitarInput(game); skin = new InputSkin(game, IM); }
public DataManager(Game game) : base(game) { _switches = new SwitchCollection(); _variables = new VariableCollection(); _achievementsToCreate = new Stack <Achievement>(); _switches["Achievement Test"] = new Switch() { Name = "Achievement Test" }; _switches["switch_ponies"] = new Switch() { Name = "Multi Switch Check Test" }; _switches["Achievement Test"].TurnOn(); PlayerName = new Variable("Pinkie Pie"); PlayerGold = new Variable(1000); PlayerSteps = new Variable(0); PlayerName.Value = "Pinkie Pie"; _variables["{steps_taken}"] = PlayerSteps; _variables["{profilename}"] = PlayerName; _variables["{gold}"] = PlayerGold; }
public ConvexHullSample(Microsoft.Xna.Framework.Game game) : base(game) { // Add basic force effects. Simulation.ForceEffects.Add(new Gravity()); Simulation.ForceEffects.Add(new Damping()); // Add a ground plane. RigidBody groundPlane = new RigidBody(new PlaneShape(Vector3F.UnitY, 0)) { Name = "GroundPlane", // Names are not required but helpful for debugging. MotionType = MotionType.Static, }; Simulation.RigidBodies.Add(groundPlane); // Load model and add it to the graphics scene. _saucerModelNode = ContentManager.Load <ModelNode>("Saucer2/saucer").Clone(); GraphicsScreen.Scene.Children.Add(_saucerModelNode); // Create rigid body for this model. // The tag contains the collision shape (created in the content processor). Shape saucerShape = (Shape)_saucerModelNode.UserData; _saucerBody = new RigidBody(saucerShape) { Pose = new Pose(new Vector3F(0, 2, 0), RandomHelper.Random.NextQuaternionF()) }; Simulation.RigidBodies.Add(_saucerBody); }
public FxaaSample(Microsoft.Xna.Framework.Game game) : base(game) { var fxaaFilter = new FxaaFilter(GraphicsService); GraphicsScreen.PostProcessors.Add(fxaaFilter); }
public TimeService(Game game) { Contract.Requires(game != null); _game = game; UpdateOrder = int.MaxValue; }
public CustomRenderer(Microsoft.Xna.Framework.Game game) : base(game) { // Disable final draw from the core game component (used by SadConsole.Game.SadConsoleGameComponent) Settings.DoFinalDraw = false; // Draw after SadConsole.Game.SadConsoleGameComponent DrawOrder = 6; // Load the effect (This is OK to do here in the case of SadConsole) spriteEffect = SadConsole.Game.Instance.Content.Load <Effect>("CRT"); spriteEffect.Parameters["hardScan"]?.SetValue(-20.0f); spriteEffect.Parameters["hardPix"]?.SetValue(-10.0f); spriteEffect.Parameters["warpX"]?.SetValue(0.011f); // 0.031 spriteEffect.Parameters["warpY"]?.SetValue(0.0f); // 0.041 spriteEffect.Parameters["maskDark"]?.SetValue(1f); spriteEffect.Parameters["maskLight"]?.SetValue(1f); spriteEffect.Parameters["scaleInLinearGamma"]?.SetValue(1.0f); spriteEffect.Parameters["shadowMask"]?.SetValue(3.0f); spriteEffect.Parameters["brightboost"]?.SetValue(2.0f); spriteEffect.Parameters["hardBloomScan"]?.SetValue(-10.0f); spriteEffect.Parameters["hardBloomPix"]?.SetValue(-2.0f); spriteEffect.Parameters["bloomAmount"]?.SetValue(0.8f); spriteEffect.Parameters["shape"]?.SetValue(1.0f); }
public TextBox(Control parent, Game game, SpriteFont font, string title, string description) : base(parent) { _textString = string.Empty; _text = new StringBuilder(); _textString = ""; _typing = false; _title = title; _description = description; _drawBuffer = new StringBuilder(); _font = font; _colour = Color.White; _drawStartIndex = 0; _drawEndIndex = 0; _blink = new Pulser(PulserType.SquareWave, TimeSpan.FromSeconds(0.5)); _keyRepeat = new Pulser(PulserType.Simple, TimeSpan.FromSeconds(0.1), TimeSpan.FromSeconds(0.5)); _selectionStartIndex = 0; _selectionEndIndex = 0; _measurementBuffer = new StringBuilder(); _blank = new Texture2D(game.GraphicsDevice, 1, 1); _blank.SetData(new Color[] { Color.White }); IgnoredCharacters = new List<char>(); SetSize(100, font.LineSpacing); Gestures.Bind((g, t, i) => { i.Owner.Focus(this); BeginTyping(i.Owner.ID < 4 ? (PlayerIndex)i.Owner.ID : PlayerIndex.One); }, new ButtonPressed(Buttons.A), new MousePressed(MouseButtons.Left)); Gestures.Bind((g, t, i) => { var keyboard = (KeyboardDevice)i; foreach (var character in keyboard.Characters) Write(character.ToString(CultureInfo.InvariantCulture)); }, new CharactersEntered()); Gestures.Bind((g, t, i) => Copy(), new KeyCombinationPressed(Keys.C, Keys.LeftControl), new KeyCombinationPressed(Keys.C, Keys.RightControl)); Gestures.Bind((g, t, i) => Cut(), new KeyCombinationPressed(Keys.X, Keys.LeftControl), new KeyCombinationPressed(Keys.X, Keys.RightControl)); Gestures.Bind((g, t, i) => Paste(), new KeyCombinationPressed(Keys.V, Keys.LeftControl), new KeyCombinationPressed(Keys.V, Keys.RightControl)); FocusedChanged += control => { if (!IsFocused) _typing = false; }; }
public UnitComponent(string unitName, string imageName, Microsoft.Xna.Framework.Game game) : base(game) { _unitName = unitName; _imageName = imageName; Width = 100; Height = 100; }
public AssetManager(Microsoft.Xna.Framework.Game game) { _game = game ?? throw new ArgumentNullException(nameof(game)); _textures = new Dictionary <string, Texture2D>(); _fonts = new Dictionary <string, SpriteFont>(); _songs = new Dictionary <string, Song>(); _soundEffects = new Dictionary <string, SoundEffect>(); }
public LockRotationSample(Microsoft.Xna.Framework.Game game) : base(game) { // Add basic force effects. Simulation.ForceEffects.Add(new Gravity()); Simulation.ForceEffects.Add(new Damping()); // Add a ground plane. RigidBody groundPlane = new RigidBody(new PlaneShape(Vector3F.UnitY, 0)) { Name = "GroundPlane", // Names are not required but helpful for debugging. MotionType = MotionType.Static, }; Simulation.RigidBodies.Add(groundPlane); // Next, we add boxes and capsules in random positions and orientations. // For all bodies the flags LockRotationX/Y/Z are set. This will prevent all // rotation that would be caused by forces. (It is still allowed to manually // change the rotation or to set an angular velocity.) BoxShape boxShape = new BoxShape(0.5f, 0.8f, 1.2f); for (int i = 0; i < 10; i++) { Vector3F position = RandomHelper.Random.NextVector3F(-10, 10); position.Y = 5; QuaternionF orientation = RandomHelper.Random.NextQuaternionF(); RigidBody body = new RigidBody(boxShape) { Pose = new Pose(position, orientation), LockRotationX = true, LockRotationY = true, LockRotationZ = true, }; Simulation.RigidBodies.Add(body); } CapsuleShape capsuleShape = new CapsuleShape(0.3f, 1.2f); for (int i = 0; i < 10; i++) { Vector3F randomPosition = RandomHelper.Random.NextVector3F(-10, 10); randomPosition.Y = 5; QuaternionF randomOrientation = RandomHelper.Random.NextQuaternionF(); RigidBody body = new RigidBody(capsuleShape) { Pose = new Pose(randomPosition, randomOrientation), LockRotationX = true, LockRotationY = true, LockRotationZ = true, }; Simulation.RigidBodies.Add(body); } }
public ContentPipelineHeightFieldSample(Microsoft.Xna.Framework.Game game) : base(game) { // Add basic force effects. Simulation.ForceEffects.Add(new Gravity()); Simulation.ForceEffects.Add(new Damping()); // Load height field model and add it to the graphics scene. _heightFieldModelNode = ContentManager.Load <ModelNode>("HeightField/TerrainHeights").Clone(); GraphicsScreen.Scene.Children.Add(_heightFieldModelNode); // The UserData contains the collision shape of type HeightField. HeightField heightField = (HeightField)_heightFieldModelNode.UserData; _heightFieldModelNode.PoseWorld = new Pose(new Vector3F(-heightField.WidthX / 2, 0, -heightField.WidthZ / 2)); // Create rigid body. _heightFieldBody = new RigidBody(heightField, null, null) { MotionType = MotionType.Static, Pose = _heightFieldModelNode.PoseWorld, // The PhysicsSample class should not draw the height field. UserData = "NoDraw", }; Simulation.RigidBodies.Add(_heightFieldBody); // Distribute a few spheres and boxes across the landscape. SphereShape sphereShape = new SphereShape(0.5f); for (int i = 0; i < 30; i++) { Vector3F position = RandomHelper.Random.NextVector3F(-30, 30); position.Y = 20; RigidBody body = new RigidBody(sphereShape) { Pose = new Pose(position) }; Simulation.RigidBodies.Add(body); } BoxShape boxShape = new BoxShape(1, 1, 1); for (int i = 0; i < 30; i++) { Vector3F position = RandomHelper.Random.NextVector3F(-30, 30); position.Y = 20; RigidBody body = new RigidBody(boxShape) { Pose = new Pose(position) }; Simulation.RigidBodies.Add(body); } }
public ResponseFilterSample(Microsoft.Xna.Framework.Game game) : base(game) { // Add basic force effects. Simulation.ForceEffects.Add(new Gravity()); Simulation.ForceEffects.Add(new Damping()); // Only disable collision response if you need collision detection info but no collision // response. If you can disable collision detection too, use // Simulation.CollisionDomain.CollisionDetection.CollisionFilter // instead - this is more efficient! // (In this sample, a custom filter implementation is used. DigitalRune.Physics provides // a standard filter implementation: DigitalRune.Physics.CollisionResponseFilter.) Simulation.ResponseFilter = new MyCollisionResponseFilter(); // Add a ground plane. RigidBody groundPlane = new RigidBody(new PlaneShape(Vector3F.UnitY, 0)) { Name = "GroundPlane", // Names are not required but helpful for debugging. MotionType = MotionType.Static, }; Simulation.RigidBodies.Add(groundPlane); // ----- Add boxes at random poses. BoxShape boxShape = new BoxShape(0.5f, 0.8f, 1.2f); for (int i = 0; i < 20; i++) { Vector3F position = RandomHelper.Random.NextVector3F(-3, 3); position.Y = 5; QuaternionF orientation = RandomHelper.Random.NextQuaternionF(); RigidBody body = new RigidBody(boxShape) { Pose = new Pose(position, orientation), }; Simulation.RigidBodies.Add(body); } // ----- Add capsules at random poses. CapsuleShape capsuleShape = new CapsuleShape(0.3f, 1.2f); for (int i = 0; i < 20; i++) { Vector3F position = RandomHelper.Random.NextVector3F(-3, 3); position.Y = 5; QuaternionF orientation = RandomHelper.Random.NextQuaternionF(); RigidBody body = new RigidBody(capsuleShape) { Pose = new Pose(position, orientation), }; Simulation.RigidBodies.Add(body); } }
public static void Register(Microsoft.Xna.Framework.Game game) { var builder = new ContainerBuilder(); game.Content.RootDirectory = "Content"; builder.RegisterInstance(new SpriteBatch(game.GraphicsDevice)).AsSelf(); builder.RegisterInstance(game.Content).AsSelf(); builder.RegisterInstance(game.GraphicsDevice).AsSelf(); // Third Party Registrations builder.RegisterType <Texture2D>(); builder.RegisterType <EntityWorld>().SingleInstance(); builder.RegisterType <FileSystem>().As <IFileSystem>(); // Managers builder.RegisterType <GraphicsManager>().As <IGraphicsManager>().SingleInstance(); builder.RegisterType <GameManager>().As <IGameManager>().SingleInstance(); builder.RegisterType <ScreenManager>().As <IScreenManager>().SingleInstance(); builder.RegisterType <DataManager>().As <IDataManager>().SingleInstance(); builder.RegisterType <InputManager>().As <IInputManager>().SingleInstance(); builder.RegisterType <CameraManager>().As <ICameraManager>().SingleInstance(); builder.RegisterType <ScriptManager>().As <IScriptManager>().SingleInstance(); builder.RegisterType <ContentManagerWrapper>().As <IContentManager>().SingleInstance(); // Factories builder.RegisterType <EntityFactory>().As <IEntityFactory>().SingleInstance(); builder.RegisterType <ComponentFactory>().As <IComponentFactory>().SingleInstance(); builder.RegisterType <ScreenFactory>().As <IScreenFactory>().SingleInstance(); builder.RegisterType <PlayerStateFactory>().As <IPlayerStateFactory>().SingleInstance(); // Loaders builder.RegisterType <GameLevelLoader>().As <ILevelLoader>(); builder.RegisterType <GameSystemLoader>().As <ISystemLoader>(); // Script Methods builder.RegisterType <AudioMethods>().As <IAudioMethods>(); builder.RegisterType <EntityMethods>().As <IEntityMethods>(); builder.RegisterType <LevelMethods>().As <ILevelMethods>(); builder.RegisterType <LocalDataMethods>().As <ILocalDataMethods>(); builder.RegisterType <MiscellaneousMethods>().As <IMiscellaneousMethods>(); builder.RegisterType <PhysicsMethods>().As <IPhysicsMethods>(); builder.RegisterType <PlayerMethods>().As <IPlayerMethods>(); builder.RegisterType <SpriteMethods>().As <ISpriteMethods>(); var loadAssemblyCall = new Projectile(); // At the moment the Entities assembly isn't loaded when this is called, so the next set of instructions don't pick up anything. var loadAssemblyCall2 = new PhysicsSystem(); // These statements are a workaround for the time being to ensure the assembly is loaded before we register components. IOCContainerHelper.RegisterGameEntities(builder); IOCContainerHelper.RegisterComponents(builder); IOCContainerHelper.RegisterPlayerStates(builder); IOCContainerHelper.RegisterSystems(builder); IOCContainerHelper.RegisterScreens(builder); _container = builder.Build(); }
/// <summary> /// Constructor of GraphicsEngineService class /// </summary> /// <param name="game">Instance of Game class</param> public GraphicsEngineService(XnaGame game) { if (game == null) throw new ArgumentNullException("game"); if (game.Services.GetService(typeof(IGraphicsEngineService)) != null) throw new ArgumentException("GraphicsEngineService already present"); game.Services.AddService(typeof(IGraphicsEngineService), this); _engine = new GraphicsEngine(game.Services); }
/// <summary> /// Constructor of InputService class /// </summary> /// <param name="game">Game instance</param> public InputService(XnaGame game) { if (game == null) throw new ArgumentNullException("game", "Cannot be null"); if (game.Services.GetService(typeof(IInputService)) != null) throw new ArgumentException("InputManager already present"); game.Services.AddService(typeof(IInputService), this); _input = new InputManager(); }
public TilingSample(Microsoft.Xna.Framework.Game game) : base(game) { // Disable mouse centering and show the mouse cursor. EnableMouseCentering = false; // Add a DelegateGraphicsScreen as the first graphics screen to the graphics // service. This lets us do the rendering in the Render method of this class. _graphicsScreen = new DelegateGraphicsScreen(GraphicsService) { RenderCallback = Render, }; GraphicsService.Screens.Insert(0, _graphicsScreen); // Load a UI theme, which defines the appearance and default values of UI controls. _uiContentManager = new ContentManager(Services, "TilingSampleTheme"); Theme theme = _uiContentManager.Load <Theme>("Theme"); // Create a UI renderer, which uses the theme info to renderer UI controls. UIRenderer renderer = new UIRenderer(Game, theme); // Create a UIScreen and add it to the UI service. The screen is the root of the // tree of UI controls. Each screen can have its own renderer. _uiScreen = new UIScreen("SampleUIScreen", renderer); UIService.Screens.Add(_uiScreen); // Create a window using the default style "Window". var stretchedWindow = new Window { X = 100, Y = 100, Width = 480, Height = 320, CanResize = true, }; _uiScreen.Children.Add(stretchedWindow); // Create a window using the style "TiledWindow". var tiledWindow = new Window { X = 200, Y = 200, Width = 480, Height = 320, CanResize = true, Style = "TiledWindow", }; _uiScreen.Children.Add(tiledWindow); // Check file TilingSampleContent/Theme.xml to see how the styles are defined. }
public ContinuousCollisionDetectionSample(Microsoft.Xna.Framework.Game game) : base(game) { // Add basic force effects. Simulation.ForceEffects.Add(new Gravity()); Simulation.ForceEffects.Add(new Damping()); // Add a ground plane. RigidBody groundPlane = new RigidBody(new PlaneShape(Vector3.UnitY, 0)) { Name = "GroundPlane", // Names are not required but helpful for debugging. MotionType = MotionType.Static, }; Simulation.RigidBodies.Add(groundPlane); // Add a thin wall. RigidBody body = new RigidBody(new BoxShape(10, 10, 0.1f)) { MotionType = MotionType.Static, Pose = new Pose(new Vector3(0, 5, -5)) }; Simulation.RigidBodies.Add(body); // ----- Add two fast bodies that move to the wall. // The first object does not use CCD. (Per default, RigidBody.CcdEnabled is false.) // The second object uses CCD. SphereShape bulletShape = new SphereShape(0.2f); body = new RigidBody(bulletShape) { Pose = new Pose(new Vector3(-2, 5, 5.5f)), LinearVelocity = new Vector3(0, 0, -100), }; Simulation.RigidBodies.Add(body); body = new RigidBody(bulletShape) { Pose = new Pose(new Vector3(2, 5, 5.5f)), LinearVelocity = new Vector3(0, 0, -100), // Enable CCD for this body. CcdEnabled = true, }; Simulation.RigidBodies.Add(body); // Note: // Global CCD settings can be changed in Simulation.Settings.Motion. // CCD can be globally enabled or disabled. // Per default, Simulation.Settings.Motion.CcdEnabled is true. But RigidBody.CcdEnabled // is false. RigidBody.CcdEnabled should be set for critical game objects. }
public CompositeMaterial2Sample(Microsoft.Xna.Framework.Game game) : base(game) { // Add basic force effects. Simulation.ForceEffects.Add(new Gravity()); Simulation.ForceEffects.Add(new Damping()); // Add a ground plane. RigidBody groundPlane = new RigidBody(new PlaneShape(new Vector3(0, 1, 0.25f).Normalized, 0)) { Name = "GroundPlane", // Names are not required but helpful for debugging. MotionType = MotionType.Static, }; // Adjust the coefficients of friction of the ground plane. ((UniformMaterial)groundPlane.Material).DynamicFriction = 0.5f; ((UniformMaterial)groundPlane.Material).StaticFriction = 0.5f; Simulation.RigidBodies.Add(groundPlane); // Prepare two materials: a slippery material and a rough material. UniformMaterial slipperyMaterial = new UniformMaterial { DynamicFriction = 0.001f, StaticFriction = 0.001f, }; UniformMaterial roughMaterial = new UniformMaterial { DynamicFriction = 1, StaticFriction = 1, }; // Create a rigid body that consists of multiple shapes: Two boxes and a cylinder between them. CompositeShape compositeShape = new CompositeShape(); compositeShape.Children.Add(new GeometricObject(new BoxShape(1f, 1f, 1f), new Pose(new Vector3(1.5f, 0f, 0f)))); compositeShape.Children.Add(new GeometricObject(new BoxShape(1f, 1, 1f), new Pose(new Vector3(-1.5f, 0f, 0f)))); compositeShape.Children.Add(new GeometricObject(new CylinderShape(0.1f, 2), new Pose(Matrix.CreateRotationZ(ConstantsF.PiOver2)))); // A CompositeMaterial is used to assign a different material to each shape. CompositeMaterial compositeMaterial = new CompositeMaterial(); compositeMaterial.Materials.Add(roughMaterial); // Assign the rough material to the first box. compositeMaterial.Materials.Add(slipperyMaterial); // Assign the slippery material to the second box. compositeMaterial.Materials.Add(null); // Use whatever is default for the handle between the boxes. RigidBody body = new RigidBody(compositeShape, null, compositeMaterial) { Pose = new Pose(new Vector3(0, 2.2f, -5)), }; Simulation.RigidBodies.Add(body); }
public static void Initialize(Microsoft.Xna.Framework.Game game) { #if !MONOGAME m_SelectCursor = CreateCursor((Bitmap)Bitmap.FromFile($"{cursorDirectory}{selectCursorFileName}")); m_MoveCursor = CreateCursor((Bitmap)Bitmap.FromFile($"{cursorDirectory}{moveCursorFileName}")); m_AttackCursor = CreateCursor((Bitmap)Bitmap.FromFile($"{cursorDirectory}{attackCursorFileName}")); m_TargetCursor = CreateCursor((Bitmap)Bitmap.FromFile($"{cursorDirectory}{targetCursorFileName}")); m_GameAsForm = (System.Windows.Forms.Form)System.Windows.Forms.Control.FromHandle(game.Window.Handle); CurrentCursorState = CursorState.Select; #endif }
private void browser_NavigationFailed(object sender, System.Windows.Navigation.NavigationFailedEventArgs e) { var g = new Microsoft.Xna.Framework.Game(); var title = "Ups!"; var message = "Algo salió mal.\r\n¿Estás seguro tienes conexión a Internet?"; var ans = MessageBox.Show(message, title, MessageBoxButton.OKCancel); if (ans == MessageBoxResult.OK) { title = "¿Quieres instalar el certificado en tu teléfono?"; message = "El SIDING tiene problemas con el certificado de seguridad.\r\n" + "Si no has seguido las instrucciones, pon Ok para que te expliquemos qué debes hacer.\r\n\r\n" + "Si ya hiciste el trámite pon cancelar e intenta más tarde. Saldrás de la app."; ans = MessageBox.Show(message, title, MessageBoxButton.OKCancel); if (ans != MessageBoxResult.OK) { g.Exit(); } else { title = "Instrucciones 1/2"; message = "1. Desde un computador baja el archivo http://bit.ly/dsCertf\r\n" + "2. Adjunta el archivo y envíalo por email a la cuenta que tienes configurada en la app Mail de tu equipo Windows Phone.\r\n\r\n" + "Cuando estes listo pon Ok para seguir con los pasos."; ans = MessageBox.Show(message, title, MessageBoxButton.OK); if (ans != MessageBoxResult.OK) { g.Exit(); } title = "Instrucciones 2/2"; message = "1. Desde tu smartphone ve a la app Mail y revisa el correo que te acabas de enviar.\r\n" + "2. Descarga el archivo adjunto .pem haciendo tap en el nombre.\r\n" + "3. Abre el archivo adjunto. Si todo va bien debe aparecer un \"escudo\" de ícono.\r\n" + "4. Acepta instalar el certificado de seguridad.\r\n\r\n" + "Una vez hecho todo esto, reinicia directSiding. Tap Ok para salir."; MessageBox.Show(message, title, MessageBoxButton.OK); g.Exit(); } } else { title = "¡Conéctate a Internet antes!"; message = "Es necesario que actives tu conexión de datos o Wi-Fi para continuar.\r\n" + "Tap Ok para salir"; MessageBox.Show(message, title, MessageBoxButton.OK); g.Exit(); } }
public WallSample(Microsoft.Xna.Framework.Game game) : base(game) { // Add basic force effects. Simulation.ForceEffects.Add(new Gravity()); Simulation.ForceEffects.Add(new Damping()); // Add a ground plane. RigidBody groundPlane = new RigidBody(new PlaneShape(Vector3.UnitY, 0)) { Name = "GroundPlane", // Names are not required but helpful for debugging. MotionType = MotionType.Static, }; Simulation.RigidBodies.Add(groundPlane); // ----- Create a wall of boxes. const int wallHeight = 10; const int wallWidth = 10; const float boxWidth = 1.0f; const float boxDepth = 0.5f; const float boxHeight = 0.5f; BoxShape boxShape = new BoxShape(boxWidth, boxHeight, boxDepth); // Optional: Use a small overlap between boxes to improve the stability. float overlap = Simulation.Settings.Constraints.AllowedPenetration * 0.5f; float x; float y = boxHeight / 2 - overlap; float z = -5; for (int i = 0; i < wallHeight; i++) { for (int j = 0; j < wallWidth; j++) { // Tip: Leave a small gap between neighbor bricks. If the neighbors on the same // row do not touch, the simulation has less work to do! x = -boxWidth * wallWidth / 2 + j * (boxWidth + 0.02f) + (i % 2) * boxWidth / 2; RigidBody brick = new RigidBody(boxShape) { Name = "Brick" + i, Pose = new Pose(new Vector3(x, y, z)), }; Simulation.RigidBodies.Add(brick); } y += boxHeight - overlap; } }
public BasicMathSample(Microsoft.Xna.Framework.Game game) : base(game) { GraphicsScreen.ClearBackground = true; var debugRenderer = GraphicsScreen.DebugRenderer2D; debugRenderer.DrawText("\n\n"); CompareFloats(); RotateVector(); CompareVectors(); SolveLinearSystems(); FindRoot(); }
public CopyFilterSample(Microsoft.Xna.Framework.Game game) : base(game) { // A filter that copies the current image to a low resolution render target. var copyFilterA = new CopyFilter(GraphicsService) { DefaultTargetFormat = new RenderTargetFormat(320, 240, false, SurfaceFormat.Color, DepthFormat.None), }; GraphicsScreen.PostProcessors.Add(copyFilterA); // A filter that copies the result of the first filter to the back buffer. var copyFilterB = new CopyFilter(GraphicsService); GraphicsScreen.PostProcessors.Add(copyFilterB); }
/// <summary> /// Initializes a new instance of the <see cref="UIManager"/> class. /// </summary> /// <param name="game">The XNA game instance.</param> /// <param name="inputService">The input service.</param> /// <exception cref="ArgumentNullException"> /// <paramref name="game"/> or <paramref name="inputService"/> is <see langword="null"/>. /// </exception> public UIManager(Microsoft.Xna.Framework.Game game, IInputService inputService) { if (game == null) throw new ArgumentNullException("game"); if (inputService == null) throw new ArgumentNullException("inputService"); _sortedScreens = new List<UIScreen>(); GameForm = PlatformHelper.GetForm(game.Window.Handle); game.Window.OrientationChanged += OnGameWindowOrientationChanged; InputService = inputService; KeyMap = KeyMap.AutoKeyMap; Screens = new UIScreenCollection(this); }
//Constructor private SceneManager(Microsoft.Xna.Framework.Game game) { this._game = game; _last = State.LOADING; _current = State.MENU; _dao = new DAO(); if (_dao.setup(_connectionString, _databaseString, _collectionString)) { Console.WriteLine("Connected to " + _databaseString + " using the " + _collectionString + " collection on " + _connectionString); } else { Console.WriteLine("Connection to " + _databaseString + " failed"); } }
public CustomGravitySample(Microsoft.Xna.Framework.Game game) : base(game) { // Add basic force effects. Simulation.ForceEffects.Add(new CustomGravity()); Simulation.ForceEffects.Add(new Damping()); // Add a static sphere that represents the planet. RigidBody planet = new RigidBody(new SphereShape(5)) { MotionType = MotionType.Static, }; Simulation.RigidBodies.Add(planet); // ----- Add a few cylinder and sphere bodies at random positions above the planet. Shape cylinderShape = new CylinderShape(0.3f, 1); for (int i = 0; i < 10; i++) { // A random position 10 m above the planet center. Vector3 randomPosition = RandomHelper.Random.NextVector3(-1, 1); randomPosition.Length = 10; RigidBody body = new RigidBody(cylinderShape) { Pose = new Pose(randomPosition), }; Simulation.RigidBodies.Add(body); } Shape sphereShape = new SphereShape(0.5f); for (int i = 0; i < 10; i++) { Vector3 randomPosition = RandomHelper.Random.NextVector3(-1, 1); randomPosition.Length = 10; RigidBody body = new RigidBody(sphereShape) { Pose = new Pose(randomPosition), }; Simulation.RigidBodies.Add(body); } }
public void Compose(string seed, bool testMode) // 1st { InitialSeed = seed; try { game = CreateGameInstance(); // 2nd } catch (Exception ex) { Logger.Fatal("Exception terminated construction", ex); return; } SourceMe.Build(new Size(gameWidth, gameHeight)); // 3rd Logger = SourceMe.The <ILog>(); Basis.ConnectIDGenerator(); }
// Token: 0x06000004 RID: 4 RVA: 0x00008E18 File Offset: 0x00007018 public static Dictionary <string, T> LoadXmlFiles <T>(Microsoft.Xna.Framework.Game p_game, string directory, string extension = ".xml") { directory = p_game.Content.RootDirectory + "/" + directory; DirectoryInfo directoryInfo = new DirectoryInfo(directory); if (!directoryInfo.Exists) { throw new DirectoryNotFoundException(); } Dictionary <string, T> dictionary = new Dictionary <string, T>(); foreach (FileInfo fileInfo in directoryInfo.GetFiles("*" + extension)) { string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(fileInfo.Name); dictionary[fileNameWithoutExtension] = XmlSerializerHelper.Deserialize <T>(directory + "/" + fileInfo.Name); } return(dictionary); }
/// <summary> /// initialize verything /// required to run this /// </summary> /// <param name="contentManager">the XNA content Manager</param> /// <param name="graphicDeviceManager">the XNA graphic manager</param> /// /// <param name="displayModes">possible display modes</param> public void Run(Microsoft.Xna.Framework.Content.ContentManager contentManager, Microsoft.Xna.Framework.GraphicsDeviceManager graphicDeviceManager, Microsoft.Xna.Framework.GameWindow window, Microsoft.Xna.Framework.Game game) { this.Properties = new GameProperties(contentManager, graphicDeviceManager, window); // load bare media to initialize loadingscreen // Cursor textures FenrirGame.Instance.Properties.ContentManager.AddTextureToLibrary(DataIdentifier.textureCursorRegular, "Texture/Cursor/Default"); FenrirGame.Instance.Properties.ContentManager.AddTextureToLibrary(DataIdentifier.textureCursorCamera, "Texture/Cursor/Camera"); this.game = game; this.renderer = new Renderer(); this.cursor = new Cursor(); this.menuLoader = new LoadingScreen.LoadMenu(); this.gameLoader = new LoadingScreen.LoadGame(); }
public static void LoadSounds(Microsoft.Xna.Framework.Game game) { BackgroundMusic = game.Content.Load <Song>("music"); JumpSound = game.Content.Load <SoundEffect>("smb_jump"); MarioDeath = game.Content.Load <SoundEffect>("smb_mariodeath"); GameOver = game.Content.Load <SoundEffect>("smb_gameover"); StageClear = game.Content.Load <SoundEffect>("smb_stage_clear"); OneUp = game.Content.Load <SoundEffect>("sound_1up"); BrickSmash = game.Content.Load <SoundEffect>("sound_breakblock"); Bump = game.Content.Load <SoundEffect>("smb_bump"); Coin = game.Content.Load <SoundEffect>("smb_coin"); DownTheFlagpole = game.Content.Load <SoundEffect>("smb_flagpole"); Fireball = game.Content.Load <SoundEffect>("smb_fireball"); Pause = game.Content.Load <SoundEffect>("smb_pause"); PowerDown = game.Content.Load <SoundEffect>("smb_pipe"); PowerUp = game.Content.Load <SoundEffect>("smb_powerup"); PowerUpAppears = game.Content.Load <SoundEffect>("smb_powerup_appears"); Stomp = game.Content.Load <SoundEffect>("smb_stomp"); }
public TelemetryProxy(Microsoft.Xna.Framework.Game game, String serverURL) { this.game = game; this.serverURL = serverURL; }
/// <summary> /// Binds the game into the kernel. /// </summary> /// <param name="game">The game.</param> /// <param name="bindGraphicsDevice">if set to <c>true</c> binds game.GraphicsDevice.</param> /// <param name="bindContentManager">if set to <c>true</c> binds game.Content.</param> /// <param name="bindServiceContainer">if set to <c>true</c> binds game.Services.</param> public static void BindGame(Game game, bool bindGraphicsDevice = true, bool bindContentManager = true, bool bindServiceContainer = true) { BindGame(game, Instance, bindGraphicsDevice, bindContentManager, bindServiceContainer); }
/// <summary> /// initialize verything /// required to run this /// </summary> /// <param name="contentManager">the XNA content Manager</param> /// <param name="graphicDeviceManager">the XNA graphic manager</param> /// /// <param name="displayModes">possible display modes</param> public void Run(Microsoft.Xna.Framework.Content.ContentManager contentManager, Microsoft.Xna.Framework.GraphicsDeviceManager graphicDeviceManager, Microsoft.Xna.Framework.GameWindow window, Microsoft.Xna.Framework.Game game) { this.Properties = new GameProperties(contentManager, graphicDeviceManager, window); // load bare media to initialize loadingscreen // Cursor textures FenrirGame.Instance.Properties.ContentManager.AddTextureToLibrary(DataIdentifier.textureCursorRegular, "Texture/Cursor/Default"); FenrirGame.Instance.Properties.ContentManager.AddTextureToLibrary(DataIdentifier.textureCursorCamera, "Texture/Cursor/Camera"); this.game = game; this.renderer = new Renderer(); this.cursor = new Cursor(); this.menuLoader = new LoadingScreen.LoadMenu(); this.gameLoader = new LoadingScreen.LoadGame(); }
/// <summary> /// Initializes a new instance of the <see cref="CommandConsole"/> class. /// </summary> /// <param name="game">The game.</param> /// <param name="font"></param> /// <param name="assemblies">The assemblies containing commands and options to add to this <see cref="CommandConsole"/> instance.</param> public CommandConsole(Game game, SpriteFont font, params Assembly[] assemblies) : this(game, font, CreateUserInterface(game), assemblies) { }
protected SceneBase(Microsoft.Xna.Framework.Game game) { _game = game; }
public TestScene(IKernel kernel, Game game, ContentManager content, GraphicsDevice device, [Optional]SceneConfiguration config) { config = config ?? new SceneConfiguration(); _scene = new Scene(kernel); _game = game; _cameraPosition = new Vector3(100, 50, 0); _camera = new Camera(); _camera.NearClip = 1; _camera.FarClip = 700; _camera.View = Matrix4x4.CreateLookAt(_cameraPosition, new Vector3(0, 50, 0), Vector3.UnitY); _camera.Projection = Matrix4x4.CreatePerspectiveFieldOfView(MathHelper.ToRadians(60), 16f / 9f, _camera.NearClip, _camera.FarClip); if (config.View) { var cameraDesc = kernel.Get<EntityDescription>(); cameraDesc.AddProperty(new TypedName<Camera>("camera")); cameraDesc.AddProperty(new TypedName<Viewport>("viewport")); cameraDesc.AddBehaviour<View>(); var cameraEntity = cameraDesc.Create(); cameraEntity.GetProperty(new TypedName<Camera>("camera")).Value = _camera; cameraEntity.GetProperty(new TypedName<Viewport>("viewport")).Value = new Viewport() {Width = device.PresentationParameters.BackBufferWidth, Height = device.PresentationParameters.BackBufferHeight}; _scene.Add(cameraEntity); } if (config.Skybox) { var skyboxDesc = kernel.Get<EntityDescription>(); skyboxDesc.AddBehaviour<Skybox>(); var skybox = skyboxDesc.Create(); skybox.GetProperty(new TypedName<TextureCube>("texture")).Value = content.Load<TextureCube>("StormCubeMap"); skybox.GetProperty(new TypedName<float>("brightness")).Value = 0.5f; skybox.GetProperty(new TypedName<bool>("gamma_correct")).Value = false; _scene.Add(skybox); } var pointLight = kernel.Get<EntityDescription>(); pointLight.AddProperty(new TypedName<Vector3>("position")); pointLight.AddProperty(new TypedName<Vector3>("colour")); pointLight.AddProperty(new TypedName<float>("range")); pointLight.AddBehaviour<PointLight>(); //scene.Add(pointLight.Create()); _lights = new List<PointLight>(); var rng = new Random(); for (int i = 0; i < config.RandomPointLights; i++) { var entity = pointLight.Create(); _scene.Add(entity); entity.GetProperty(new TypedName<Vector3>("position")).Value = new Vector3(0, 10, 0); entity.GetProperty(new TypedName<Vector3>("colour")).Value = new Vector3(0, 5, 0); entity.GetProperty(new TypedName<float>("range")).Value = 200; var light = entity.GetBehaviour<PointLight>(null); light.Colour = Vector3.Normalize(new Vector3(0.1f + (float)rng.NextDouble(), 0.1f + (float)rng.NextDouble(), 0.1f + (float)rng.NextDouble())) * 10; _lights.Add(light); } if (config.Spotlight) { var spotLight = kernel.Get<EntityDescription>(); spotLight.AddProperty(new TypedName<Vector3>("position")); spotLight.AddProperty(new TypedName<Vector3>("colour")); spotLight.AddProperty(new TypedName<Vector3>("direction")); spotLight.AddProperty(new TypedName<float>("angle")); spotLight.AddProperty(new TypedName<float>("range")); spotLight.AddProperty(new TypedName<Texture2D>("mask")); spotLight.AddProperty(new TypedName<int>("shadow_resolution")); spotLight.AddBehaviour<SpotLight>(); var spotLightEntity = spotLight.Create(); spotLightEntity.GetProperty(new TypedName<Vector3>("position")).Value = new Vector3(-180, 250, 0); spotLightEntity.GetProperty(new TypedName<Vector3>("colour")).Value = new Vector3(10); spotLightEntity.GetProperty(new TypedName<Vector3>("direction")).Value = new Vector3(0, -1, 0); spotLightEntity.GetProperty(new TypedName<float>("angle")).Value = MathHelper.PiOver2; spotLightEntity.GetProperty(new TypedName<float>("range")).Value = 500; spotLightEntity.GetProperty(new TypedName<Texture2D>("mask")).Value = content.Load<Texture2D>("Chrysanthemum"); spotLightEntity.GetProperty(new TypedName<int>("shadow_resolution")).Value = 1024; _spotLight = spotLightEntity.GetBehaviour<SpotLight>(null); _scene.Add(spotLightEntity); } if (config.AmbientLight) { var ambientLight = kernel.Get<EntityDescription>(); ambientLight.AddProperty(new TypedName<Vector3>("sky_colour")); ambientLight.AddProperty(new TypedName<Vector3>("ground_colour")); ambientLight.AddProperty(new TypedName<Vector3>("up")); ambientLight.AddBehaviour<AmbientLight>(); var ambientLightEntity = ambientLight.Create(); ambientLightEntity.GetProperty(new TypedName<Vector3>("sky_colour")).Value = new Vector3(0.04f); ambientLightEntity.GetProperty(new TypedName<Vector3>("ground_colour")).Value = new Vector3(0.04f, 0.05f, 0.04f); ambientLightEntity.GetProperty(new TypedName<Vector3>("up")).Value = Vector3.UnitY; _scene.Add(ambientLightEntity); } if (config.SunLight) { var sunlight = kernel.Get<EntityDescription>(); sunlight.AddBehaviour<SunLight>(); var sunlightEntity = sunlight.Create(); sunlightEntity.GetProperty(new TypedName<Vector3>("colour")).Value = new Vector3(1, 0.75f, 0.6f); sunlightEntity.GetProperty(new TypedName<Vector3>("direction")).Value = -Vector3.UnitY; sunlightEntity.GetProperty(new TypedName<int>("shadow_resolution")).Value = 1024; _scene.Add(sunlightEntity); //var sunEntity = kernel.Get<EntityDescription>(); //sunEntity.AddProperty(SunLight.DirectionName, Vector3.Normalize(new Vector3(-.2f, -1f, .3f))); //sunEntity.AddProperty(SunLight.ColourName, new Vector3(1, 0.3f, 0.01f) * 5); //sunEntity.AddProperty(SunLight.ShadowResolutionName, 4096); //sunEntity.AddProperty(SunLight.ActiveName, true); //sunEntity.AddBehaviour<SunLight>(); //Entity sun = sunEntity.Create(); //_scene.Add(sun); //var sun2 = sunEntity.Create(); //sun2.GetProperty<Vector3>("direction").Value = Vector3.Normalize(new Vector3(1, -1, 0)); //sun2.GetProperty<Vector3>("colour").Value = new Vector3(1, 0, 0); //scene.Add(sun2); } //var floor = content.Load<ModelData>(@"Models\Ground"); //var floorEntity = kernel.Get<EntityDescription>(); //floorEntity.AddProperty<ModelData>("model", floor); //floorEntity.AddProperty<Matrix>("transform", Matrix.CreateScale(2)); //floorEntity.AddProperty<bool>("isstatic", true); //floorEntity.AddBehaviour<ModelInstance>(); //scene.Add(floorEntity.Create()); //var ship1 = content.Load<ModelData>(@"Models\Ship1"); //var ship1Entity = kernel.Get<EntityDescription>(); //ship1Entity.AddProperty<ModelData>("model", ship1); //ship1Entity.AddProperty<Matrix>("transform", Matrix.CreateTranslation(30, 0, 0)); //ship1Entity.AddProperty<bool>("is_static", true); //ship1Entity.AddBehaviour<ModelInstance>(); //scene.Add(ship1Entity.Create()); //var hebeModel = content.Load<ModelData>(@"Models\Hebe2"); //var hebe = kernel.Get<EntityDescription>(); //hebe.AddProperty(new TypedName<ModelData>("model")); //hebe.AddProperty(new TypedName<Matrix4x4>("transform")); //hebe.AddProperty(new TypedName<bool>("is_static")); //hebe.AddBehaviour<ModelInstance>(); //var hebeEntity = hebe.Create(); //hebeEntity.GetProperty(new TypedName<ModelData>("model")).Value = hebeModel; //hebeEntity.GetProperty(new TypedName<Matrix4x4>("transform")).Value = Matrix4x4.CreateScale(25 / hebeModel.Meshes.First().BoundingSphere.Radius) // * Matrix4x4.CreateRotationY(MathHelper.PiOver2) // * Matrix4x4.CreateTranslation(-150, 20, 0); //hebeEntity.GetProperty(new TypedName<bool>("is_static")).Value = true; //hebeEntity.GetProperty(ModelInstance.OpacityName).Value = 0.5f; //_scene.Add(hebeEntity); var sphereModel = content.Load<ModelData>(@"Models\sphere"); var sphere = kernel.Get<EntityDescription>(); sphere.AddProperty(new TypedName<ModelData>("model")); sphere.AddProperty(new TypedName<Matrix4x4>("transform")); sphere.AddProperty(new TypedName<bool>("is_static")); sphere.AddBehaviour<ModelInstance>(); var sphereEntity = sphere.Create(); sphereEntity.GetProperty(new TypedName<ModelData>("model")).Value = sphereModel; sphereEntity.GetProperty(new TypedName<Matrix4x4>("transform")).Value = Matrix4x4.CreateScale(5 / sphereModel.Meshes.First().BoundingSphere.Radius) * Matrix4x4.CreateRotationY(MathHelper.PiOver2) * Matrix4x4.CreateTranslation(-150, 20, 0); sphereEntity.GetProperty(new TypedName<bool>("is_static")).Value = true; _scene.Add(sphereEntity); var smodel = sphereEntity.GetBehaviour<ModelInstance>(null); smodel.Opacity = 0.5f; smodel.SubSurfaceScattering = 0.5f; smodel.Attenuation = 0.3f; //var dudeModel = content.Load<ModelData>(@"dude"); //var dude = kernel.Get<EntityDescription>(); //dude.AddProperty<ModelData>("model", dudeModel); //dude.AddProperty<Matrix>("transform", Matrix.CreateScale(0.75f) * Matrix.CreateTranslation(-50, 0, 0)); //dude.AddProperty<bool>("is_static", true); //dude.AddBehaviour<ModelInstance>(); //dude.AddBehaviour<Animated>(); //var dudeEntity = dude.Create(); //scene.Add(dudeEntity); var sponzaModel = content.Load<ModelData>(@"Sponza"); var sponza = kernel.Get<EntityDescription>(); sponza.AddProperty(new TypedName<ModelData>("model")); sponza.AddProperty(new TypedName<Matrix4x4>("transform")); sponza.AddProperty(new TypedName<bool>("is_static")); sponza.AddBehaviour<ModelInstance>(); var sponzaEntity = sponza.Create(); sponzaEntity.GetProperty(new TypedName<ModelData>("model")).Value = sponzaModel; sponzaEntity.GetProperty(new TypedName<Matrix4x4>("transform")).Value = Matrix4x4.Identity * Matrix4x4.CreateScale(1); sponzaEntity.GetProperty(new TypedName<bool>("is_static")).Value = true; _scene.Add(sponzaEntity); var renderer = _scene.GetService<Renderer>(); _resolution = renderer.Data.Get<Vector2>("resolution"); var console = kernel.Get<CommandConsole>(); renderer.Settings.BindCommandEngine(console.Engine); if (config.Fire) { //var fire1 = Fire.Create(kernel, content, new Vector3(123.5f, 30f, -55f)); //var fire2 = Fire.Create(kernel, content, new Vector3(123.5f, 30f, 35f)); //var fire3 = Fire.Create(kernel, content, new Vector3(-157f, 30f, 35f)); //var fire4 = Fire.Create(kernel, content, new Vector3(-157f, 30f, -55f)); //scene.Add(fire1); //scene.Add(fire2); //scene.Add(fire3); //scene.Add(fire4); } _cameraScript = new CameraScript(_camera); _cameraScript.AddWaypoint(0, new Vector3(218, 160, 104), new Vector3(0, 150, 0)); _cameraScript.AddWaypoint(10, new Vector3(-195, 160, 104), new Vector3(-150, 150, 0)); _cameraScript.AddWaypoint(12, new Vector3(-270, 160, 96), new Vector3(-150, 150, 0)); _cameraScript.AddWaypoint(14, new Vector3(-302, 160, 45), new Vector3(-150, 150, 0)); _cameraScript.AddWaypoint(16, new Vector3(-286, 160, 22), new Vector3(-150, 150, 0)); _cameraScript.AddWaypoint(18, new Vector3(-276, 160, 22), new Vector3(-150, 100, 0)); _cameraScript.AddWaypoint(20, new Vector3(-158, 42, 19), new Vector3(-150, 40, 0)); _cameraScript.AddWaypoint(21, new Vector3(-105, 24, -7), new Vector3(-150, 40, 0)); _cameraScript.AddWaypoint(23, new Vector3(-105, 44, -7), new Vector3(-150, 40, 0)); _cameraScript.AddWaypoint(27, new Vector3(-105, 50, -7), new Vector3(-80, 50, -100)); _cameraScript.AddWaypoint(32, new Vector3(100, 50, -7), new Vector3(150, 40, 0)); _cameraScript.AddWaypoint(34, new Vector3(100, 50, -7), new Vector3(150, 40, 100)); _cameraScript.AddWaypoint(36, new Vector3(100, 50, -7), new Vector3(0, 60, 0)); //cameraScript.AddWaypoint(1000, new Vector3(100, 50, -7), new Vector3(0, 60, 0)); _cameraScript.Initialise(); }
private static Control CreateUserInterface(Game game) { UserInterface ui = new UserInterface(game.GraphicsDevice) { DrawOrder = int.MaxValue }; game.Components.Add(ui); var player = new InputActor(1) { new KeyboardDevice(PlayerIndex.One) }; game.Components.Add(player); ui.Actors.Add(player); return ui.Root; }
/// <summary> /// Initializes a new instance of the <see cref="CommandConsole"/> class. /// </summary> /// <param name="font"></param> /// <param name="parent"></param> /// <param name="game"></param> public CommandConsole(Game game, SpriteFont font, Control parent) : this(game, font, parent, Assembly.GetCallingAssembly()) { }
/// <summary> /// Initializes a new instance of the <see cref="CommandConsole"/> class. /// </summary> /// <param name="font"></param> /// <param name="parent">The parent.</param> /// <param name="assemblies">The assemblies containing commands and options to add to this <see cref="CommandConsole"/> instance.</param> /// <param name="game"></param> public CommandConsole(Game game, SpriteFont font, Control parent, params Assembly[] assemblies) : base(parent) { _engine = new CommandEngine(assemblies); _writer = new ConsoleWriter(this); PresentationParameters pp = game.GraphicsDevice.PresentationParameters; SetSize(0, pp.BackBufferHeight / 3); SetPoint(Points.Top, 0, 5); SetPoint(Points.Left, 5, 0); SetPoint(Points.Right, -5, 0); Strata = new ControlStrata() { Layer = Layer.Overlay, Offset = 100 }; FocusPriority = int.MaxValue; LikesHavingFocus = false; IsVisible = false; RespectSafeArea = true; ToggleKey = Keys.Oem8; //var font = Content.Load<SpriteFont>(game, "Consolas"); //skin = Content.Load<Skin>(game, "Console"); //skin.BackgroundColour = new Color(1f, 1f, 1f, 0.8f); _background = new Texture2D(game.GraphicsDevice, 1, 1); _background.SetData(new Color[] { Color.Black }); _textBox = new TextBox(this, game, font, "Command Console", "Enter your command"); _textBox.SetPoint(Points.Bottom, 0, -3); _textBox.SetPoint(Points.Left, 3, 0); _textBox.SetPoint(Points.Right, -3, 0); _textBox.FocusPriority = 1; _textBox.FocusedChanged += c => { if (c.IsFocused) _textBox.BeginTyping(PlayerIndex.One); }; _textBox.IgnoredCharacters.Add('`'); _log = new TextLog(this, font, (int)(3 * Area.Height / (float)font.LineSpacing)); _log.SetPoint(Points.TopLeft, 3, 3); _log.SetPoint(Points.TopRight, -3, 3); _log.SetPoint(Points.Bottom, 0, 0, _textBox, Points.Top); _log.WriteLine("Hello world"); _tabCompletion = new Label(this, font); _tabCompletion.SetSize(300, 0); _tabCompletion.SetPoint(Points.TopLeft, 3, 6, this, Points.BottomLeft); _infoBox = new Label(this, font); _infoBox.SetPoint(Points.TopRight, -3, 6, this, Points.BottomRight); AreaChanged += c => _infoBox.SetSize(Math.Max(0, c.Area.Width - 311), 0); _commandStack = new CommandStack(_textBox, Gestures); BindGestures(); Gestures.BlockedDevices.Add(typeof(KeyboardDevice)); }
public TimeService(Game game) { _game = game; UpdateOrder = int.MaxValue; }
private void PhoneApplicationPage_BackKeyPress(object sender, System.ComponentModel.CancelEventArgs e) { base.OnBackKeyPress(e); Microsoft.Xna.Framework.Game game = new Microsoft.Xna.Framework.Game(); game.Exit(); }
public override void FinishedLaunching(UIApplication app) { // Fun begins.. game = new Game1(); game.Run(); }
private void exitButton_Click(object sender, EventArgs e) { Microsoft.Xna.Framework.Game game = new Microsoft.Xna.Framework.Game(); game.Exit(); }
internal static void RunGame() { game = new HaumeaGame(); game.Run(); }