/// <summary> /// Creates a new EntityModel. /// </summary> /// <param name="entity">Entity to attach the graphical representation to.</param> /// <param name="model">Graphical representation to use for the entity.</param> /// <param name="transform">Base transformation to apply to the model before moving to the entity.</param> /// <param name="game">Game to which this component will belong.</param> public SceneObject(String name, Entity entity, Model model, Matrix transform, #if WPF MonoGameControl. #else Microsoft.Xna.Framework. #endif Game game, ICamera camera) : base(game, camera, entity) { this.Name = name; this.model = model; this.Transform = transform; this.Collide = true; //Collect any bone transformations in the model itself. //The default cube model doesn't have any, but this allows the EntityModel to work with more complicated shapes. boneTransforms = new Matrix[model.Bones.Count]; foreach (ModelMesh mesh in model.Meshes) { foreach (BasicEffect effect in mesh.Effects) { effect.EnableDefaultLighting(); } } }
public ElementFactory(int initCount, ContentRepository repo, #if WPF MonoGameControl. #else Microsoft.Xna.Framework. #endif Game game, ICamera camera, Func <ContentRepository, #if WPF MonoGameControl. #else Microsoft.Xna.Framework. #endif Game, ICamera, T> creator, ElementManager manager) { _freeObjects = new Queue <T>(); _usedObjects = new List <T>(); _creator = creator; _repo = repo; _game = game; _camera = camera; _manager = manager; for (int i = 0; i < initCount; i++) { T obj = creator(repo, game, camera); obj.Visible = false; _freeObjects.Enqueue(obj); } }
public ElementManager(ContentRepository repo, SceneInterface si, #if WPF MonoGameControl. #else Microsoft.Xna.Framework. #endif Game game, ICamera camera, Tunnel tunnel, Player player, MusicPlayer music) { ExplosionParticles = new ParticleSystem(game, game.Content, GetExplosionSettings()); ExplosionParticles.Initialize(); FireParticles = new ParticleSystem(game, game.Content, GetFireSettings()); FireParticles.Initialize(); SmokeParticles = new ParticleSystem(game, game.Content, GetSmokeSettings()); SmokeParticles.Initialize(); StarsParticles = new ParticleSystem(game, game.Content, GetStarsSettings()); StarsParticles.Initialize(); BombFactory = new ElementFactory <Bomb>(50, repo, game, camera, (ContentRepository r, #if WPF MonoGameControl. #else Microsoft.Xna.Framework. #endif Game g, ICamera c) => new Bomb(r, g, c), this); StarFactory = new ElementFactory <Star>(50, repo, game, camera, (ContentRepository r, #if WPF MonoGameControl. #else Microsoft.Xna.Framework. #endif Game g, ICamera c) => new Star(r, g, c), this); Music = music; Scene = new Scene(); Scene.Submit(player); _sceneInterface = si; _sceneInterface.Submit(Scene); _repo = repo; _game = game; _camera = camera; _tunnel = tunnel; _player = player; _tunnel.TunnelSectionCreated += TunnelSectionCreated; _tunnel.TunnelSectionSetZCalled += TunnelSectionSetZCalled; StarFactory.ObjectRemoved += (o, i) => { var data = LoopGame.Instance.GameObjects.GetValue("Objects"); LoopGame.Instance.GameObjects.TryUpdate("Objects", new Vector3(i.Angle, data.Y, data.Z)); }; BombFactory.ObjectRemoved += (o, i) => { var data = LoopGame.Instance.GameObjects.GetValue("Objects"); LoopGame.Instance.GameObjects.TryUpdate("Objects", new Vector3(data.X, i.Angle, data.Z)); }; }
public ContentRepository( #if WPF MonoGameControl. #else Microsoft.Xna.Framework. #endif Game game) { _allModels = new Dictionary <string, Model>(); _game = game; }
public TunnelObject(String name, Entity entity, Model model, Matrix transform, #if WPF MonoGameControl. #else Microsoft.Xna.Framework. #endif Game game, ICamera camera) : base(name, entity, model, transform, game, camera) { zInitialized = false; _world = World; }
public PrefabObjectGenerator( #if WPF MonoGameControl. #else Microsoft.Xna.Framework. #endif Game game, Camera camera, Model template) { _template = template; _game = game; _camera = camera; }
public ElementManager(ContentRepository repo, SceneInterface si, #if WPF MonoGameControl. #else Microsoft.Xna.Framework. #endif Game game, ICamera camera, Tunnel tunnel, Player player, MusicPlayer music) { ExplosionParticles = new ParticleSystem(game, game.Content, GetExplosionSettings()); ExplosionParticles.Initialize(); FireParticles = new ParticleSystem(game, game.Content, GetFireSettings()); FireParticles.Initialize(); SmokeParticles = new ParticleSystem(game, game.Content, GetSmokeSettings()); SmokeParticles.Initialize(); StarsParticles = new ParticleSystem(game, game.Content, GetStarsSettings()); StarsParticles.Initialize(); BombFactory = new ElementFactory <Bomb>(50, repo, game, camera, (ContentRepository r, #if WPF MonoGameControl. #else Microsoft.Xna.Framework. #endif Game g, ICamera c) => new Bomb(r, g, c), this); StarFactory = new ElementFactory <Star>(50, repo, game, camera, (ContentRepository r, #if WPF MonoGameControl. #else Microsoft.Xna.Framework. #endif Game g, ICamera c) => new Star(r, g, c), this); Music = music; Scene = new Scene(); Scene.Submit(player); _sceneInterface = si; _sceneInterface.Submit(Scene); _repo = repo; _game = game; _camera = camera; _tunnel = tunnel; _player = player; _tunnel.TunnelSectionCreated += TunnelSectionCreated; _tunnel.TunnelSectionSetZCalled += TunnelSectionSetZCalled; }
public SceneEntity( #if WPF MonoGameControl. #else Microsoft.Xna.Framework. #endif Game game, ICamera camera, Entity entity) : base(game) { this.entity = entity; this.Camera = camera; ShowBoundingBox = false; _components = new List <BaseComponent>(); }
public Bomb(ContentRepository repo, #if WPF MonoGameControl. #else Microsoft.Xna.Framework. #endif Game game, ICamera camera) : base( "Bomb", new Sphere(MathConverter.Convert(Vector3.Zero), 2f, 0.2f), repo.LoadModel("Models/Bomb"), Matrix.CreateScale(0.4f) * Matrix.CreateTranslation(new Vector3(0, -2, 0)) * Matrix.CreateRotationZ((float)Math.PI), game, camera) { }
public Star(ContentRepository repo, #if WPF MonoGameControl. #else Microsoft.Xna.Framework. #endif Game game, ICamera camera) : base( "Star", new Sphere(MathConverter.Convert(Vector3.Zero), 2f, 0.2f), repo.LoadModel("Models/Star"), Matrix.CreateScale(0.04f) * Matrix.CreateTranslation(new Vector3(0, 0, 0)) * Matrix.CreateRotationZ((float)Math.PI), game, camera) { //ShowBoundingBox = true; //this.Visible = false; }
public Player(ContentRepository repo, #if WPF MonoGameControl. #else Microsoft.Xna.Framework. #endif Game game, Camera camera, Tunnel tunnel) : base( "Player", new Box(MathConverter.Convert(new Vector3(0, 0, 20)), 4f, 1f, 2.5f), repo.LoadModel("Models/Ship2"), Matrix.CreateScale(0.0025f) * Matrix.CreateRotationX((float)Math.PI), game, camera) { _world = World; _tunnel = tunnel; Angle = 0f; _distanceFromCenter = 7.8f; _zDistance = 6f; _tiltRotation = 0f; }
public Engine(SceneInterface si, ContentRepository repo, #if WPF MonoGameControl. #else Microsoft.Xna.Framework. #endif Game game, Screen screen ) { _sceneInterface = si; _game = game; _music = new MusicPlayer(); ContentRepository = repo; farClip = 400.0f; Vector3 up = new Vector3(0.0f, 1.0f, 0.0f); Vector3 forward = new Vector3(0.0f, 0.0f, 1.0f); world = Matrix.CreateWorld(Vector3.Zero, forward, up); Matrix projection = new Matrix(); Matrix.CreatePerspectiveFieldOfView((float)Math.PI / 4.0f, game.GraphicsDevice.Viewport.AspectRatio, 0.01f, farClip, out projection); _camera = new LoopLib.World.Camera(Matrix.CreateLookAt(Vector3.Zero, forward, up), projection); _screen = screen; _inactiveBackground = new Texture2D(game.GraphicsDevice, 1, 1); _inactiveBackground.SetData <Color>(new Color[] { Color.Black }); IsRunning = false; _generator = new LevelGenerator(); Globals.Lives = 0; Globals.IsFinnished = false; //ContentRepository.Game.Components.Add(_explosionParticles); }