示例#1
0
        //TODO: debugview in eiegene componente auslagern

        public WorldManager()
        {
            this.WorldStep = 30f;

            this.IsEnabled       = true;
            this.EntitiesInRange = new List <Entity>();
            this.World           = new World(Vector2.Zero);


#if DEBUG
            debug = new DebugViewXNA(this.World);
            debug.DefaultShapeColor  = Color.White;
            debug.SleepingShapeColor = Color.LightGray;


            //    debug.AppendFlags(DebugViewFlags.PerformanceGraph);

            //    debug.AppendFlags(DebugViewFlags.DebugPanel);

            debug.AppendFlags(DebugViewFlags.ContactPoints);
            //     debug.AppendFlags(DebugViewFlags.ContactNormals);


            //      debug.AppendFlags(DebugViewFlags.PolygonPoints);


            debug.AppendFlags(DebugViewFlags.Controllers);
            debug.AppendFlags(DebugViewFlags.CenterOfMass);
            debug.AppendFlags(DebugViewFlags.AABB);

            debug.RemoveFlags(DebugViewFlags.Joint);
#endif
        }
        public void InitializePhysics(GraphicsDevice graphics, ContentManager Content)
        {
            // Catching Viewport dimensions
            ViewportWidth  = graphics.Viewport.Width;
            ViewportHeight = graphics.Viewport.Height;

            if (Penumbra == null)
            {
                Penumbra = new PenumbraComponent(graphics, Content);
            }

            // Our world for the physics body
            _World = new World(Vector2.Zero);

            // Unit conversion rule to get the right position data between simulation space and display space
            ConvertUnits.SetDisplayUnitToSimUnitRatio(MeterInPixels);

            // Initialize the physics debug view
            PhysicsDebugView = new DebugViewXNA(_World);
            PhysicsDebugView.LoadContent(graphics, Content);
            PhysicsDebugView.RemoveFlags(DebugViewFlags.Controllers);
            PhysicsDebugView.RemoveFlags(DebugViewFlags.Joint);
            PhysicsDebugView.RemoveFlags(DebugViewFlags.Shape);
            PhysicsDebugView.DefaultShapeColor = new Color(255, 255, 0);
        }
示例#3
0
        public override void OnEnter()
        {
            SceneManager.Instance.UseDof = true;
            LoadLevel();
            GameWorldManager.Instance.SaveState();
            Platform.Instance.PhysicsWorld.Gravity = new Vector2(0f, 9.82f);

            FrameUpdateManager.Instance.Register(HintManager.Instance);

            _actionReset           = false;
            _debugViewState        = false;
            _actionToggleDebugView = false;


            _debugView = new DebugViewXNA(Platform.Instance.PhysicsWorld);

            _debugView.LoadContent(Platform.Instance.Device, Platform.Instance.Content);
            //_debugView.RemoveFlags( DebugViewFlags.Joint );
            //_debugView.AppendFlags( DebugViewFlags.PerformanceGraph );

            _debugView.TextColor = Color.Black;

            _view = Matrix.Identity;

            Song song = _contentManager.Load <Song>("music/Beluga_-_Lost_In_Outer_Space");

            Platform.Instance.SoundManager.PlayMusic(song);
            FrameUpdateManager.Instance.Register(SceneManager.Instance);

            SceneManager.Instance.SortByLayer();
        }
示例#4
0
        public Physics(Engine engine)
            : base(engine)
        {
            // this should probably never change
            PixelsPerMeter = Global.Configuration.GetFloatConfig("Physics", "PixelsPerMeter");

            World = new World(new Vector2(0.0f, 9.8f));

            DebugView = new DebugViewXNA(World);
            DebugView.LoadContent(Global.Game.GraphicsDevice, Engine.Content);
            uint flags = 0;

            flags          += (uint)DebugViewFlags.AABB;
            flags          += (uint)DebugViewFlags.CenterOfMass;
            flags          += (uint)DebugViewFlags.ContactNormals;
            flags          += (uint)DebugViewFlags.ContactPoints;
            flags          += (uint)DebugViewFlags.DebugPanel;
            flags          += (uint)DebugViewFlags.Joint;
            flags          += (uint)DebugViewFlags.Pair;
            flags          += (uint)DebugViewFlags.PolygonPoints;
            flags          += (uint)DebugViewFlags.Shape;
            DebugView.Flags = (DebugViewFlags)flags;

            DrawOrder = int.MaxValue;
        }
示例#5
0
        public FarseerManager(bool main, KinectRagdollGame game)
        {
            //world.ContactManager = new ContactManager();

            world = new World(new Vector2(0, -20));



            debugview       = new DebugViewXNA(world);
            debugview.Flags = FarseerPhysics.DebugViewFlags.TexturedShape | FarseerPhysics.DebugViewFlags.RagdollCustom;

            //World loaded = Serializer.readFromDataContract("graph.xml");
            //world.JointList.AddRange(loaded.JointList);
            //world.BodyList.AddRange(loaded.BodyList);



            this.game = game;
            //world = new World(new Vector2(0, 0));



            rand = new Random();

            if (main)
            {
                Main = this;
            }
        }
示例#6
0
        /// <summary>
        /// Call this in LoadContent after all the level is set up
        /// </summary>
        public void ExtablishDebugView(GraphicsDevice graphicsDevice, ContentManager content)
        {
            //Give your world to debugView
            DebugView = new DebugViewXNA(LevelWorld);
            //DebugView have many Property you can add
            DebugView.RemoveFlags(DebugViewFlags.Shape);
            DebugView.RemoveFlags(DebugViewFlags.Joint);
            DebugView.DefaultShapeColor  = Color.LightPink;
            DebugView.SleepingShapeColor = Color.MediumPurple;
            //add your GraphicsDevice & your ContentManager

            DebugView.AppendFlags(DebugViewFlags.CenterOfMass);
            DebugView.AppendFlags(DebugViewFlags.PerformanceGraph);
            DebugView.AppendFlags(DebugViewFlags.Shape);
            DebugView.AppendFlags(DebugViewFlags.ContactPoints);
            DebugView.AppendFlags(DebugViewFlags.PolygonPoints);
            DebugView.AppendFlags(DebugViewFlags.ContactNormals);

            DebugView.DefaultShapeColor  = Color.White;
            DebugView.SleepingShapeColor = Color.LightGray;

            DebugView.DebugPanelPosition     = Vector2.Zero;
            DebugView.PerformancePanelBounds = graphicsDevice.ScissorRectangle;

            DebugView.LoadContent(graphicsDevice, content);
        }
示例#7
0
 public override void LoadContent()
 {
     _debug = new DebugViewXNA(_world);
     _debug.LoadContent(ScreenManager.GraphicsDevice, ScreenManager.Content);
     _debug.AppendFlags(FarseerPhysics.DebugViewFlags.Shape);
     _debug.AppendFlags(FarseerPhysics.DebugViewFlags.PolygonPoints);
 }
示例#8
0
        public ControllerViewManager(GraphicsDevice graphicsDevice, ContentManager content)
        {
            controllers = new List <Controller>();
            views       = new List <IView>();

            this.content         = content;
            this.graphicsDevice  = graphicsDevice;
            this.batch           = new SpriteBatch(graphicsDevice);
            this.world           = new World(new Vector2(0, Constants.GamePlayGravity));
            this.controllerQueue = new ConcurrentQueue <Tuple <Controller, QueueState> >();
            this.viewQueue       = new ConcurrentQueue <Tuple <IView, QueueState> >();

            if (Constants.DebugMode && debugView == null)
            {
                debugView = new DebugViewXNA(world);
                debugView.AppendFlags(DebugViewFlags.DebugPanel);
                debugView.DefaultShapeColor  = Color.Red;
                debugView.SleepingShapeColor = Color.Green;
                debugView.LoadContent(graphicsDevice, content);
            }

            if (camera == null)
            {
                Viewport v = graphicsDevice.Viewport;
                camera          = new Camera2D(graphicsDevice);
                camera.Position = new Vector2(v.Width / 2, v.Height / 2);
            }
            else
            {
                camera.ResetCamera();
            }
        }
        public override void LoadContent()
        {
            base.LoadContent();
            if (World == null)
            {
                return;
            }

            DebugView = new DebugViewXNA(World);
            DebugView.AppendFlags(DebugViewFlags.TexturedShape);
            DebugView.RemoveFlags(DebugViewFlags.Shape);
            DebugView.RemoveFlags(DebugViewFlags.Joint);

            DebugView.DefaultShapeColor  = Color.White;
            DebugView.SleepingShapeColor = Color.LightGray;

            DebugView.LoadContent(ScreenManager.GraphicsDevice, ScreenManager.ContentManager);
            Vector2 gameWorld =
                Camera2D.ConvertScreenToWorld(new Vector2(ScreenManager.Camera.ScreenWidth,
                                                          ScreenManager.Camera.ScreenHeight));

            _border = new Border(World, gameWorld.X, gameWorld.Y, 1f);

            ScreenManager.Camera.ProjectionUpdated += UpdateScreen;

            // Loading may take a while... so prevent the game from "catching up" once we finished loading
            ScreenManager.Game.ResetElapsedTime();
        }
示例#10
0
        /// <summary>
        /// LoadContent is called once per instance of screen and is used to
        /// load all of the graphical content
        /// </summary>
        public override bool LoadContent()
        {
            bool success = base.LoadContent();

            if (success)
            {
                this.world = new World(new Vector2(0f, 9.81f * this.gravityScalar));

                this.map = MapLoader.Initialize(this.maps[0], this);
                if (this.map == null || !MapLoader.LoadCurrentMap())
                {
                    System.Console.WriteLine(string.Format(CultureInfo.CurrentCulture, "Loading of Map: {0} has failed!", this.maps[0]));
                    success = false;
                }
                else
                {
                    this.debugView = new DebugViewXNA(this.world);
                    this.debugView.DefaultShapeColor  = Color.White;
                    this.debugView.SleepingShapeColor = Color.LightGray;
                    this.debugView.LoadContent(this.GraphicsDevice, MainGame.ContentManager);
                    this.debugViewMatrix = Matrix.CreateOrthographicOffCenter(0f, ConvertUnits.ToSimUnits(this.map.Width), ConvertUnits.ToSimUnits(this.map.Height), 0f, 0f, .01f);
                }

                if (this.map.Players.Count() > 0)
                {
                    this.Camera.Following    = this.map.Players.ElementAt(0);
                    SoundController.Map      = this.map;
                    SoundController.Listener = this.map.Players.ElementAt(0).Listener;
                }
            }

            return(success);
        }
示例#11
0
        public FarseerManager(bool main, KinectRagdollGame game)
        {
            
            //world.ContactManager = new ContactManager();

            world = new World(new Vector2(0, -20));

            

            debugview = new DebugViewXNA(world);
            debugview.Flags = FarseerPhysics.DebugViewFlags.TexturedShape | FarseerPhysics.DebugViewFlags.RagdollCustom;

            //World loaded = Serializer.readFromDataContract("graph.xml");
            //world.JointList.AddRange(loaded.JointList);
            //world.BodyList.AddRange(loaded.BodyList);

            


            this.game = game;
            //world = new World(new Vector2(0, 0));
            
            




            rand = new Random();

            if (main)
            {
                Main = this;
            }

        }
示例#12
0
        private void TryInitPhysDbg()
        {
            if (Physics.World == null)
            {
                dbgv_?.Dispose();
                return;
            }

            if (dbgv_ != null)
            {
                return;
            }

            dbgv_ = new DebugViewXNA(Physics.World);
            dbgv_.LoadContent(Graphics.Device, Content.Manager);
            dbgv_.RemoveFlags((DebugViewFlags)Int32.MaxValue);
            //        dbgv_.AppendFlags(DebugViewFlags.AABB);
            dbgv_.AppendFlags(DebugViewFlags.CenterOfMass);
            //        dbgv_.AppendFlags(DebugViewFlags.ContactNormals);
            dbgv_.AppendFlags(DebugViewFlags.ContactPoints);
            //        dbgv_.AppendFlags(DebugViewFlags.Controllers);
            //        dbgv.AppendFlags(DebugViewFlags.DebugPanel);
            dbgv_.AppendFlags(DebugViewFlags.Joint);
            //        dbgv.AppendFlags(DebugViewFlags.PerformanceGraph);
            dbgv_.AppendFlags(DebugViewFlags.PolygonPoints);
            dbgv_.AppendFlags(DebugViewFlags.Shape);
        }
示例#13
0
 public override void LoadContent()
 {
     _debug = new DebugViewXNA(_world);
     _debug.LoadContent(ScreenManager.GraphicsDevice, ScreenManager.Content);
     _debug.AppendFlags(FarseerPhysics.DebugViewFlags.Shape);
     _debug.AppendFlags(FarseerPhysics.DebugViewFlags.PolygonPoints);
 }
示例#14
0
        private void OnLevelSelected()
        {
            _level = PrefabRepository.Instance.GetLevelPrefab(@"Content\Levels\" + _levelName + ".eql");
            GameWorldManager.Instance.SetState(_level._savedState);
            GameWorldManager.Instance.LoadLastState();

            LoadLevel();
            Platform.Instance.PhysicsWorld.Gravity = Vector2.UnitY * Platform.Instance.PhysicsWorld.Gravity.Length();

            _debugViewState        = false;
            _actionToggleDebugView = false;

            _debugView = new DebugViewXNA(Platform.Instance.PhysicsWorld);

            _debugView.LoadContent(Platform.Instance.Device, Platform.Instance.Content);
            //_debugView.RemoveFlags( DebugViewFlags.Joint );
            //_debugView.AppendFlags( DebugViewFlags.PerformanceGraph );

            _debugView.TextColor = Color.Black;

            _view = Matrix.Identity;

            //Song song = _contentManager.Load<Song>( "music/Beluga_-_Lost_In_Outer_Space" );
            //Platform.Instance.SoundManager.PlayMusic( song );

            FrameUpdateManager.Instance.Register(HintManager.Instance);
            FrameUpdateManager.Instance.Register(SceneManager.Instance);

            _levelLoaded = true;
        }
示例#15
0
 public static void Draw(DebugViewXNA debug)
 {
     for (int i = 0; i < currentCount - 1; i++)
     {
         debug.DrawSegment(currentPath[i].Position, currentPath[i + 1].Position, Color.Green, 0.04f);
     }
 }
示例#16
0
 /// <summary>
 /// Ends the drawing of text for this frame.
 /// </summary>
 public static void EndPanelText(DebugViewXNA debugView)
 {
     for (var i = 0; i < _panelText.Count; i++)
     {
         debugView.DrawString((TextPanelTopLeftCorner + FontLineSpacing * i), _panelText[i]);
     }
 }
        public override void LoadContent()
        {
            base.LoadContent();
            if (World == null)
                return;

            DebugView = new DebugViewXNA(World);
            DebugView.AppendFlags(DebugViewFlags.TexturedShape);
            DebugView.RemoveFlags(DebugViewFlags.Shape);
            DebugView.RemoveFlags(DebugViewFlags.Joint);

            DebugView.DefaultShapeColor = Color.White;
            DebugView.SleepingShapeColor = Color.LightGray;

            DebugView.LoadContent(ScreenManager.GraphicsDevice, ScreenManager.ContentManager);
            Vector2 gameWorld =
                Camera2D.ConvertScreenToWorld(new Vector2(ScreenManager.Camera.ScreenWidth,
                                                          ScreenManager.Camera.ScreenHeight));
            _border = new Border(World, gameWorld.X, gameWorld.Y, 1f);

            ScreenManager.Camera.ProjectionUpdated += UpdateScreen;

            // Loading may take a while... so prevent the game from "catching up" once we finished loading
            ScreenManager.Game.ResetElapsedTime();
        }
示例#18
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);

            if (world == null)
            {
                world = new World(new Vector2(0, 9.82f));
            }
            else
            {
                world.Clear();
            }

            this.IsMouseVisible = true;

            lvlBuilder = new LevelBuilder(Content, world);
            lvlBuilder.readLevel("level1.txt");

            backgroundTexture = Content.Load <Texture2D>("cornflowerback");

            objectList = lvlBuilder.getLevelObjects();

            //FarseerPhysics.Collision
            font = Content.Load <SpriteFont>("font");

            debugView = new DebugViewXNA(world);
            debugView.LoadContent(this.GraphicsDevice, this.Content);
            debugView.AppendFlags(FarseerPhysics.DebugViewFlags.Shape);
            debugView.AppendFlags(FarseerPhysics.DebugViewFlags.PolygonPoints);
            //debugView.AppendFlags(FarseerPhysics.DebugViewFlags.DebugPanel);
            debugView.AppendFlags(FarseerPhysics.DebugViewFlags.CenterOfMass);
            // TODO: use this.Content to load your game content here
        }
 public Actor()
 {
     theMaster = Master.theMaster;
     theRenderman = theMaster.Renderer;
     if (moveSpeed == 0)
     moveSpeed = radius = density = width = height = 10f;
 }
示例#20
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);

            font   = Content.Load <SpriteFont>("font");
            cursor = new SpriteSheet("cursor");
            cursor.LoadTexture(Content, 1, 1);
            cursor.SetScale(2f);
            cursor.SetCurrentSprite(0, 0);

            movePointer = new SpriteAnimation("movepointer", Content, 8, 1);
            movePointer.SetScale(1f);
            for (int i = 0; i < 8; i++)
            {
                movePointer.AddFrame(i, 0, 50);
            }

            if (DebugView == null)
            {
                DebugView = new DebugViewXNA(Physics.World);
                DebugView.AppendFlags(DebugViewFlags.DebugPanel);
                DebugView.AppendFlags(DebugViewFlags.PerformanceGraph);
                DebugView.DefaultShapeColor  = Color.White;
                DebugView.SleepingShapeColor = Color.Red;
                DebugView.LoadContent(GraphicsDevice, Content);
            }
        }
示例#21
0
        public void Initialize(bool editor, ContentManager content)
        {
            this.spriteBatch = new SpriteBatch(GameLoop.gameInstance.GraphicsDevice);
            _flipFlop        = new RenderTargetFlipFlop(ref spriteBatch);
            _flipFlop.Initialise();
            _Gravitation = new Vector2(0.0f, 9.8f);
            Physics      = new World(_Gravitation);
            debugView    = new DebugViewXNA(Level.Physics);
            Camera.initialize(GameSettings.Default.resolutionWidth, GameSettings.Default.resolutionHeight);
            Camera.Position = new Vector2(GameSettings.Default.resolutionWidth / 2, GameSettings.Default.resolutionHeight / 2);
            Camera.Scale    = GameSettings.Default.gameCamScale;
            if (editor)
            {
                ParticleManager.initializeInEditor(content);
            }
            else
            {
                ParticleManager.initialize();
            }

            this.GraphicsEnabled  = true;
            this.DebugViewEnabled = false;

            this._contentPath = Path.Combine(Directory.GetCurrentDirectory(), "Content");

            foreach (Layer l in layerList)
            {
                l.initializeLayer();
            }
        }
示例#22
0
        public override void LoadContent()
        {
            if (World == null)
            {
                World = new World(Vector2.Zero);
            }
            else
            {
                World.Clear();
            }

            if (DebugView == null)
            {
                DebugView = new DebugViewXNA(World);
                DebugView.DefaultShapeColor  = Color.White;
                DebugView.SleepingShapeColor = Color.LightGray;
                DebugView.LoadContent(Framework.GraphicsDevice, Framework.Content);
            }

            DebugView.Flags = _flags;
            _flagsChanged   = false;

            if (Camera == null)
            {
                Camera = new Camera2D(Framework.GraphicsDevice);
            }
            else
            {
                Camera.ResetCamera();
            }

            base.LoadContent();
        }
示例#23
0
 public static void Draw(DebugViewXNA debug)
 {
     for (int i = 0; i < currentCount - 1; i++)
     {
         debug.DrawSegment(currentPath[i].Position, currentPath[i + 1].Position, Color.Green, 0.04f);
     }
 }
示例#24
0
        public Engine(Game game)
        {
            this.Game = game;
            this.World = new World(Vector2.Zero);
            this.PerspectiveManager = new PerspectiveManager();
            this.UISpriteBatch = new SpriteBatch(this.Game.GraphicsDevice);

            this.worldView = new DebugViewXNA(this.World);

            var now = DateTime.Now;

            this.InputScheduler = new HistoricalScheduler(now);
            this.UpdateScheduler = new HistoricalScheduler(now);
            this.PrePhysicsScheduler = new HistoricalScheduler(now);
            this.PostPhysicsScheduler = new HistoricalScheduler(now);
            this.PostDrawScheduler = new HistoricalScheduler(now);

            this.Keyboard = new ReactiveKeyboard(this.InputScheduler);
            this.Mouse = new ReactiveMouse(this);

            this.Logger = new DebugLogger(this);
            this.Logger.Initialize().Attach();

            this.worldView.LoadContent(this.Game.GraphicsDevice, this.Game.Content);
        }
示例#25
0
        public void Initialize()
        {
            renderTargets    = new RenderTarget2D[5];
            renderTargets[1] = new RenderTarget2D(GameLoop.gameInstance.GraphicsDevice, GameSettings.Default.resolutionWidth, GameSettings.Default.resolutionHeight);
            renderTargets[2] = new RenderTarget2D(GameLoop.gameInstance.GraphicsDevice, GameSettings.Default.resolutionWidth, GameSettings.Default.resolutionHeight);
            renderTargets[3] = new RenderTarget2D(GameLoop.gameInstance.GraphicsDevice, GameSettings.Default.resolutionWidth, GameSettings.Default.resolutionHeight);
            renderTargets[4] = new RenderTarget2D(GameLoop.gameInstance.GraphicsDevice, GameSettings.Default.resolutionWidth, GameSettings.Default.resolutionHeight);

            this.spriteBatch = new SpriteBatch(GameLoop.gameInstance.GraphicsDevice);
            _Gravitation     = new Vector2(0.0f, 9.8f);
            Physics          = new World(_Gravitation);
            debugView        = new DebugViewXNA(Level.Physics);
            Camera.initialize(GameSettings.Default.resolutionWidth, GameSettings.Default.resolutionHeight);
            Camera.Position = new Vector2(GameSettings.Default.resolutionWidth / 2, GameSettings.Default.resolutionHeight / 2);
            Camera.Scale    = 0.4f;
            ParticleManager.initialize();

            this.GraphicsEnabled  = true;
            this.DebugViewEnabled = false;

            this._contentPath = Path.Combine(Directory.GetCurrentDirectory(), "Content");

            foreach (Layer l in layerList)
            {
                l.initializeLayer();
            }
        }
示例#26
0
        protected override void LoadContent()
        {
            spriteBatch = new SpriteBatch(GraphicsDevice);
            background  = Content.Load <Texture2D>("sky");
            foreground  = Content.Load <Texture2D>("nearback");
            world       = new World(new Vector2(0, 1f));

            debugView       = new DebugViewXNA(world);
            camera          = new Camera(this);
            camera.Position = new Vector2(22, 20);
            debugView.LoadContent(GraphicsDevice, Content);

            playerController.LoadContent();
            badger = new ScrapBadger(this, new Vector2(23, 4));

            badger.Rotate(20f * 0.0174532925f);


            crate = new Crate(this, new Vector2(26, 2));
            //XmlLoader loader = new XmlLoader();
            //loader.LoadLevel(ref entityList);


            terrain.LoadContent();
            terrain.CreateGround(world);

            //Init();
        }
        protected PhysicsGameScreen()
        {
            HasCursor = false;
            World = null;
            Camera = null;
            DebugView = null;
			EnabledGestures = GestureType.None;
        }
示例#28
0
文件: Map.cs 项目: njdom24/Microgames
        public Map(GraphicsDevice pDevice, ContentManager content, int pTileWidth, int pTileHeight, int pWidth, int pHeight)
        {
            ConvertUnits.SetDisplayUnitToSimUnitRatio(100);
            entityList = new List<MapEntity>();
            verticesList = new List<Vector2>();
            //light = content.Load<Texture2D>("lightmask");
            effect = content.Load<Effect>("File");
            //effect.Parameters["lightMask"].SetValue(light);
            prevState = Keyboard.GetState();
            hud = new Hud(new string[] { "Undertale is bad,\nand so am I." }, content);
            speaking = false;
            blocks = new List<Body>();
            tileWidth = pTileWidth;
            tileHeight = pTileHeight;
            width = pWidth;
            height = pHeight;
            g = pDevice;
            cont = content;

            menu = new Menu(content, null);

            camera = new Camera2D(pDevice);
            debug = content.Load<Texture2D>("overworld_gutter");

            tMap = content.Load<TiledMap>("Map/Tazmily/Tazmily");
            mapRenderer = new TiledMapRenderer(pDevice);

            world = new World(Vector2.Zero);
            //world.ContactManager.OnBroadphaseCollision += BroadphaseHandler;
            //world.ContactManager.EndContact += EndContactHandler;
            debugView = new DebugViewXNA(world);
            debugView.LoadContent(pDevice, content);
            //debugView.AppendFlags(DebugViewFlags.DebugPanel);
            //debugView.AppendFlags(DebugViewFlags.PolygonPoints);
            //debugView.AppendFlags(DebugViewFlags.ContactPoints);
            //debugView.AppendFlags(DebugViewFlags.AABB);
            debugView.AppendFlags(DebugViewFlags.Shape);
            debugView.DefaultShapeColor = Color.Green;

            //camera.Position = player.body.Position;
            //Console.WriteLine("Scunt: " + tMap.ObjectLayers.Count);
            player = new Player(world, content, 16, 23);
            //npc = new NPC(world, content, colArray, 2, false, 16, 14, new string[] {"Weebs are worse\nthan fortnite\ngamers.", "Where's the lie?" });

            //Body b1 = BodyFactory.CreateRectangle(world, 3, 3, 1);

            blockDims = new List<Vector2>();
            MakeCollisionBodies();

            npcs = new NPC[] {
                //new NPC(world, content, player, 1, false, 12, 15, prevState, new string[] { "@You wanna see the special?\n@It's a detective story. Some kind of <Columbo>\n  knock-off.\n@Well, ya interested or not?", "@Get outta here." }),
                new NPC(world, content, player, 1, false, 12, 15, prevState, new string[] { "@Your name Steve Foley? Of course it is.\n  You are great. Fantastic.\n@Good job Steve.", "@Get outta here." }),
                //new NewNPC(world, content, player, 0, true, 18, 18, new string[] {"help"}, 4, 1)
            };
            entityList.Add(player);
            foreach (NPC n in npcs)
                entityList.Add(n);
        }
示例#29
0
 void LoadCreateDebugView(World world)
 {
     //create and configure the debug view
     _debugView = new DebugViewXNA(world);
     _debugView.AppendFlags(DebugViewFlags.DebugPanel | DebugViewFlags.AABB | DebugViewFlags.PerformanceGraph | DebugViewFlags.ContactPoints | DebugViewFlags.Controllers);
     _debugView.DefaultShapeColor  = Color.Blue;
     _debugView.SleepingShapeColor = Color.LightGray;
     _debugView.LoadContent(screenManager.GraphicsDevice, _content);
 }
示例#30
0
 private void InitDebug()
 {
     _debugView = new DebugViewXNA(World);
     _debugView.RemoveFlags(DebugViewFlags.Shape);
     _debugView.RemoveFlags(DebugViewFlags.Joint);
     _debugView.DefaultShapeColor  = Color.White;
     _debugView.SleepingShapeColor = Color.LightGray;
     _debugView.LoadContent(GraphicsDevice, Game1.contentManager);
 }
示例#31
0
 public Scene(SpriteBatch sb, GraphicsDeviceManager graphicsDeviceManager, GraphicsDevice gd, GameWindow window,
              ContentManager content, int FOVWidth, int FOVHeight, IDrawSystem system = null)
 {
     buffer                 = new RenderTarget2D(gd, graphicsDeviceManager.PreferredBackBufferWidth, graphicsDeviceManager.PreferredBackBufferHeight);
     GraphicsDevice         = gd;
     SpriteBatch            = sb;
     _graphicsDeviceManager = graphicsDeviceManager;
     Content                = content;
     GameWindow             = window;
     Camera                 = new Camera(this, gd.Viewport)
     {
         FOV = new Vector2(FOVWidth, FOVHeight)
     };
     Input.Instance              = new Input(this);
     GameObjects                 = new GameObjectManager(this);
     TiledPrefabs                = new Dictionary <string, Type>();
     World                       = new World(Vector2.Zero);
     Settings.AllowSleep         = true;
     Settings.VelocityIterations = 2;
     Settings.ContinuousPhysics  = true;
     DebugView                   = new DebugViewXNA(World);
     DebugView.RemoveFlags(DebugViewFlags.Shape);
     DebugView.RemoveFlags(DebugViewFlags.Joint);
     DebugView.DefaultShapeColor  = Color.LightPink;
     DebugView.SleepingShapeColor = Color.MediumPurple;
     DebugView.LoadContent(GraphicsDevice, content);
     DebugView.AppendFlags(DebugViewFlags.DebugPanel);
     DebugView.AppendFlags(DebugViewFlags.PerformanceGraph);
     Debug = true;
     LoadedTiledPrefabs = new List <TiledPrefab>();
     Pipeline           = new CludoContentPipeline(gd);
     Vector             = Pipeline.LoadContent <Texture2D>("Vector", content, true);
     Line = new Texture2D(GraphicsDevice, 1, 1);
     Line.SetData(new[] { Color.White });
     GameWindow.ClientSizeChanged +=
         (sender, args) => {
         VirtualResolutionScaler = new VirtualResolutionScaler(this,
                                                               graphicsDeviceManager.PreferredBackBufferWidth, graphicsDeviceManager.PreferredBackBufferHeight,
                                                               gd, true);
     };
     VirtualResolutionScaler = new VirtualResolutionScaler(this,
                                                           graphicsDeviceManager.PreferredBackBufferWidth, graphicsDeviceManager.PreferredBackBufferHeight,
                                                           gd, true);
     Pipeline.LoadContent <SpriteFont>("Font", Content, true);
     if (system == null)
     {
         SetDrawSystem(new NormalDrawSystem(GraphicsDevice, this,
                                            new Vector2(graphicsDeviceManager.PreferredBackBufferWidth,
                                                        graphicsDeviceManager.PreferredBackBufferHeight)));
     }
     else
     {
         SetDrawSystem(system);
     }
     StartScene();
 }
示例#32
0
        /// <summary>
        /// Loads debug view resources.
        /// </summary>
        public void LoadDebugView()
        {
            if (_game == null)
            {
                throw new Exception("Must pass 'Game' into constructor to use debug view.");
            }

            _debugViewXna = new DebugViewXNA(World);
            _debugViewXna.LoadContent(_game.GraphicsDevice, _game.Content, @"Fonts\VerdanaFont");
        }
示例#33
0
        public override void LoadContent(ContentManager content)
        {
            this.Content    = content;
            player1.texture = content.Load <Texture2D>("dad_sat");
            player2.texture = content.Load <Texture2D>("mom_sat");
            table.texture   = content.Load <Texture2D>("table");
            ending          = content.Load <Song>("co");


            font = content.Load <SpriteFont>("SpriteFont1");
            for (int i = 0; i < N; i++)
            {
                ball[i].texture = content.Load <Texture2D>("ball");
            }
            ball[0].texture = content.Load <Texture2D>("ttukbaegi");
            ball[1].texture = content.Load <Texture2D>("rice_1");
            ball[2].texture = content.Load <Texture2D>("kimchi");
            ball[3].texture = content.Load <Texture2D>("kimchi");
            ball[4].texture = content.Load <Texture2D>("ttukbaegi");
            ball[5].texture = content.Load <Texture2D>("rice_1");
            ball[6].texture = content.Load <Texture2D>("rice_2");
            ball[7].texture = content.Load <Texture2D>("kimchi");
            ball[8].texture = content.Load <Texture2D>("ttukbaegi");
            ball[9].texture = content.Load <Texture2D>("kimchi");

            baby.texture = this.Content.Load <Texture2D>("baby");

            background = this.Content.Load <Texture2D>("background");



            view = new DebugViewXNA(world);
            view.AppendFlags(DebugViewFlags.Shape);
            view.RemoveFlags(DebugViewFlags.Joint);
            view.DefaultShapeColor  = Color.White;
            view.SleepingShapeColor = Color.LightGray;
            view.LoadContent(game.GraphicsDevice, Content);
            if (Camera == null)
            {
                Camera = new Camera2D(game.GraphicsDevice);
            }
            else
            {
                Camera.ResetCamera();
            }
            glass_sfx = content.Load <SoundEffect>("glass");

            hit1_sfx = content.Load <SoundEffect>("hit1");
            hit2_sfx = content.Load <SoundEffect>("hit2");
            bgm      = content.Load <Song>("bgm");
            MediaPlayer.Play(bgm);
            MediaPlayer.IsRepeating = true;

            help_font = content.Load <SpriteFont>("SpriteFont2");
        }
示例#34
0
        public override void Startup()
        {
            ConvertUnits.SetDisplayUnitToSimUnitRatio(1.0f / Scale);

            m_world = new World(new Vector2(0, 0));
            m_world.FixtureAdded = OnFixtureAdded;

            m_debugView = new DebugViewXNA(m_world);

            Engine.AssetManager.RegisterAssetType <CollisionDefinition>(new CollisionDefinitionLoader());
        }
示例#35
0
        public WorldScreen(Game Game)
            : base(Game, GeneralManager.ScreenX, GeneralManager.ScreenY)
        {
            GeneralManager.LoadAnimation("TestAnim", Vector2.One * 64, 6, 80);
            GeneralManager.LoadAnimation("PlayerIdle", Vector2.One * 64, 1, 10000);

            DebugWindow.Visible = false;
            DebugWindow.AddGUI(FarseerDebugCheck, DebugWindow);
            AddGUI(DebugWindow);

            LE = new LightingEngine();
            Color a = new Color(ambient, ambient, ambient);

            LE.SetAmbient(a, a);
            //LE.SetAmbient(Color.Gray, Color.Gray);
            Renderer.AddRendererEffect(LE, "LightingEngine");

            LoadContent();

            Map = new Map(this, tileSize, mapSize);
            //Renderer.AddPostProcess(new BlurEffect(), "Blur");
            SE               = new BlurSwitchEffect();
            SE.MaxTime       = 1f;
            SE.TurnOffAction = delegate() { Renderer.RemovePostProcess("Switch"); };
            Renderer.AddPostProcess(SE, "Switch");

            Camera.Init(GeneralManager.GetPartialRect(0, 0, 1, 1), new Rectangle(0, 0, tileSize * mapSize, tileSize * mapSize));

            PlayerLight = new SpotLight()
            {
                IsEnabled         = true,
                Color             = new Vector4(0.9f, .7f, .7f, 1f),
                Power             = .6f,
                LightDecay        = 600,
                Position          = new Vector3(500, 400, 20),
                SpotAngle         = 1.5f,
                SpotDecayExponent = 3,
                Direction         = new Vector3(0.244402379f, 0.969673932f, 0)
            };
            LE.AddLight(PlayerLight);

            Debug = new FarseerPhysics.DebugViews.DebugViewXNA(Map.PhysicalWorld);
            Debug.AppendFlags(FarseerPhysics.DebugViewFlags.Shape);
            Debug.AppendFlags(FarseerPhysics.DebugViewFlags.AABB);
            Debug.AppendFlags(FarseerPhysics.DebugViewFlags.PerformanceGraph);
            Debug.AppendFlags(FarseerPhysics.DebugViewFlags.Joint);
            Debug.AppendFlags(FarseerPhysics.DebugViewFlags.ContactPoints);
            Debug.DefaultShapeColor  = Color.White;
            Debug.SleepingShapeColor = Color.LightGray;
            Debug.LoadContent(Parent.GraphicsDevice, Parent.Content);

            //Weapon w = new Weapon("test", "Gun", 100, 10, Hands.One, 10, 600, 10, 10, 10);
            //Serializer.Serialize<Weapon>("weapon.xml", w);
        }
示例#36
0
        public override void Draw(DebugViewXNA draw)
        {
            for (int i = 0; i < Path.Count - 1; i++)
            {
                Color color = Color.Lerp(Color.Red, Color.Green, Velocities[i] / MaxSpeed);
                draw.DrawSegment(Path[i].Position, Path[i + 1].Position, color, 0.04f);
            }

            //draw.DrawCircle(FrontPath[NextWaypointIndex].Position, 0.1f, Color.Orange);
            //draw.DrawCircle(FrontPath[PrevWaypointIndex].Position, 0.1f, Color.Orange);
        }
示例#37
0
 protected PhysicsGameScreen()
 {
     TransitionOnTime = TimeSpan.FromSeconds(0.75);
     TransitionOffTime = TimeSpan.FromSeconds(0.75);
     HasCursor = true;
     EnableCameraControl = true;
     _userAgent = null;
     World = null;
     Camera = null;
     DebugView = null;
 }
示例#38
0
 protected PhysicsGameScreen()
 {
     TransitionOnTime    = TimeSpan.FromSeconds(0.75);
     TransitionOffTime   = TimeSpan.FromSeconds(0.75);
     HasCursor           = true;
     EnableCameraControl = true;
     _userAgent          = null;
     World     = null;
     Camera    = null;
     DebugView = null;
 }
示例#39
0
文件: Paddle.cs 项目: jpann/PongBasic
        public Paddle(Texture2D texture,
            Vector2 position,
            World world,
            DebugViewXNA debugViewXNA,
            ContentManager content,
            GraphicsDeviceManager graphics)
            : base(world, debugViewXNA, content, graphics)
        {
            this.mTexture = texture;
            this.mWidth = ConvertUnits.ToSimUnits(this.mTexture.Width);
            this.mHeight = ConvertUnits.ToSimUnits(this.mTexture.Height);
            this.mOrigin = new Vector2(this.mWidth / 2f, this.mHeight / 2f);

            this.mSpriteEffects = SpriteEffects.None;

            this.mPosition = ConvertUnits.ToSimUnits(position);

            this.mBody = BodyFactory.CreateRectangle(this.mWorld,
                this.mWidth,
                this.mHeight,
                1f,
                this.mPosition);

            this.mBody.BodyType = BodyType.Dynamic;

            this.mJointWorldAnchor = this.mPosition;

            this.mFixedPrismJoint = new FixedPrismaticJoint(this.mBody,
                 this.mJointWorldAnchor,
                 this.mJointAxis);

            this.mFixedPrismJoint.LimitEnabled = true;
            this.mFixedPrismJoint.LowerLimit = this.mJointLowerLimit;
            this.mFixedPrismJoint.UpperLimit = this.mJointUpperLimit;
            this.mFixedPrismJoint.Enabled = true;
            this.mWorld.AddJoint(this.mFixedPrismJoint);

            this.mBody.OnCollision += new OnCollisionEventHandler(OnCollision);
            this.mBody.OnSeparation += new OnSeparationEventHandler(OnSeparation);
            this.mBody.FixtureList[0].AfterCollision += new AfterCollisionEventHandler(OnAfterCollision);

            this.mParticleRenderer = new SpriteBatchRenderer
            {
                GraphicsDeviceService = this.mGraphics
            };

            this.mParticleEffect = new ParticleEffect();

            this.mParticleRenderer.LoadContent(this.mContent);
            this.mParticleEffect = this.mContent.Load<ParticleEffect>(@"Effects\basicSparks");
            this.mParticleEffect.LoadContent(this.mContent);
            this.mParticleEffect.Initialise();
        }
示例#40
0
        public GravitySensorManager(World world,
            DebugViewXNA debugViewXNA,
            ContentManager content,
            GraphicsDeviceManager graphics,
            ScreenManager.ScreenManager screenManager)
        {
            this.mWorld = world;
            this.mDebugViewXNA = debugViewXNA;
            this.mContentManager = content;
            this.mGraphicsManager = graphics;
            this.mScreenManager = screenManager;

            this.mEffectCollection.Add("one", this.mContentManager.Load<ParticleEffect>(@"Effects\portalOne"));
            this.mEffectCollection.Add("two", this.mContentManager.Load<ParticleEffect>(@"Effects\portalPurple"));
        }
示例#41
0
        /// <summary>
        /// Initializes a new instance of the <see cref="GravityObject"/> class.
        /// </summary>
        /// <param name="world">The World object.</param>
        /// <param name="debugViewXNA">The DebugViewXNA object.</param>
        /// <param name="content">The ContentManager object.</param>
        /// <param name="graphics">The GraphicsDeviceManager object.</param>
        /// <param name="position">The initial position of the sensor.</param>
        /// <param name="radius">The radius of the sensor's shape.</param>
        /// <param name="density">The density of the sensor.</param>
        /// <param name="strength">The gravity strength of the sensor.</param>
        /// <param name="minRadius">The minimum radius the gravity can affect.</param>
        /// <param name="maxRadius">The maximum radius the gravity can affect.</param>
        public GravityObject(World world,
            DebugViewXNA debugViewXNA,
            ContentManager content,
            GraphicsDeviceManager graphics,
            Vector2 position,
            float radius,
            float density,
            float strength,
            float minRadius,
            float maxRadius)
        {
            this.IsAlive = true;

            this.mWorld = world;
            this.mDebugViewXNA = debugViewXNA;
            this.mContent = content;
            this.mGraphics = graphics;
            //this.mPosition = ConvertUnits.ToSimUnits(position);
            this.mPosition = position;

            this.mRadius = ConvertUnits.ToSimUnits(radius);
            this.mDensity = density;
            this.mStrength = strength;
            this.mMinRadius = minRadius;
            this.mMaxRadius = maxRadius;

            this.mGravity = new GravityController(this.mStrength);
            this.mGravity.MinRadius = this.mMinRadius;
            this.mGravity.MaxRadius = this.mMaxRadius;
            this.mGravity.EnabledOnCategories = this.mEnabledOn;
            this.mGravity.GravityType = this.mGravityType;
            this.mGravity.Enabled = this.IsEnabled;

            this.mWorld.AddController(this.mGravity);

            this.mBody = BodyFactory.CreateBody(this.mWorld);
            this.mBody.Position = this.mPosition;
            this.mBody.IsSensor = true;

            this.mShape = new CircleShape(this.mRadius, this.mDensity);
            this.mBody.CreateFixture(this.mShape);
            this.mBody.CollidesWith = this.mCollidesWith;

            this.mBody.OnCollision += this.OnCollision;
            this.mBody.OnSeparation += this.OnSeparation;

            this.mGravity.AddBody(this.mBody);
        }
示例#42
0
文件: Player.cs 项目: jpann/PongBasic
 public Player(World world,
     DebugViewXNA debugViewXNA,
     ContentManager content,
     GraphicsDeviceManager graphics,
     ScreenManager.ScreenManager screenManager,
     PlayerIndex playerIndex,
     Vector2 position)
 {
     this.mWorld = world;
     this.mDebugViewXNA = debugViewXNA;
     this.mContent = content;
     this.mGraphics = graphics;
     this.mScreenManager = screenManager;
     this.mPlayerIndex = playerIndex;
     this.mPaddlePosition = position;
 }
示例#43
0
        public PlayingView(
            ContentManager content, 
            SpriteBatch spriteBatch,
            PlayingViewModel viewModel,
            LevelView levelView,
            DebugViewXNA debugView, 
            SoundManagerView soundManagerView)
        {
            this.content = content;
            this.soundManagerView = soundManagerView;
            this.spriteBatch = spriteBatch;
            this.viewModel = viewModel;
            this.levelView = levelView;

            this.debugView = debugView;
        }
示例#44
0
        public GameWorld(Camera camera)
        {
            mCamera      = camera;

            mGameObjects = new List<GameObject>();
            mAddList     = new List<GameObject>();
            mRemoveList  = new List<GameObject>();

            mPhysicsWorld = new World(new Vector2(0, 0));
            mDebugView    = new DebugViewXNA(mPhysicsWorld);

            mAwake = false;
            mMaxFadeCountdown = 3f;
            mFadeCountdown = 0;

            mMonsterDeathVolume = .25f;
        }
示例#45
0
文件: Ball.cs 项目: jpann/PongBasic
        private float mSpeedTimerInSeconds = 3.5f; // Increase ball speed every 3.5 seconds

        #endregion Fields

        #region Constructors

        public Ball(Texture2D texture,
            Vector2 position,
            World world,
            DebugViewXNA debugViewXNA,
            ContentManager content,
            GraphicsDeviceManager graphics)
            : base(world, debugViewXNA, content, graphics)
        {
            this.mTexture = texture;
            this.mWidth = ConvertUnits.ToSimUnits(this.mTexture.Width);
            this.mHeight = ConvertUnits.ToSimUnits(this.mTexture.Height);
            this.mOrigin = new Vector2(this.mWidth / 2f, this.mHeight / 2f);

            this.mSpriteEffects = SpriteEffects.None;

            this.mPosition = ConvertUnits.ToSimUnits(position);

            this.mBody = BodyFactory.CreateCircle(this.mWorld,
               this.Radius,
               0.5f,
               this.mPosition);

            this.mBody.BodyType = BodyType.Dynamic;
            this.mBody.Restitution = 1f;
            this.mBody.Friction = 0;
            this.mBody.Inertia = float.MaxValue;

            this.mBody.OnCollision += new OnCollisionEventHandler(OnCollision);
            this.mBody.OnSeparation += new OnSeparationEventHandler(OnSeparation);
            this.mWorld.ContactManager.OnBroadphaseCollision += OnBroadphaseCollision;
            this.mBody.FixtureList[0].AfterCollision += new AfterCollisionEventHandler(OnAfterCollision);

            this.mParticleRenderer = new SpriteBatchRenderer
            {
                GraphicsDeviceService = this.mGraphics
            };

            this.mParticleEffect = new ParticleEffect();

            this.mParticleRenderer.LoadContent(this.mContent);
            this.mParticleEffect = this.mContent.Load<ParticleEffect>(@"Effects\basicSparks");
            this.mParticleEffect.LoadContent(this.mContent);
            this.mParticleEffect.Initialise();

            this.LoadContent();
        }
示例#46
0
		public GDEntityManager(GDGameScreen scrn) : base(scrn)
		{
			PhysicsWorld = new World(Vector2.Zero);

#if DEBUG
			debugView = new DebugViewXNA(PhysicsWorld);
			debugView.LoadContent(GDOwner.Graphics.GraphicsDevice, GDOwner.Game.Content, Textures.DebugFont);
			debugView.AppendFlags(DebugViewFlags.Shape);
			debugView.AppendFlags(DebugViewFlags.DebugPanel);
			debugView.AppendFlags(DebugViewFlags.PerformanceGraph);
			debugView.AppendFlags(DebugViewFlags.ContactPoints);
			debugView.AppendFlags(DebugViewFlags.ContactNormals);
			debugView.AppendFlags(DebugViewFlags.Controllers);
			debugView.TextColor = Color.Black;
			debugView.Enabled = false;
#endif
		}
示例#47
0
        public GameWorld(ChopperGame game)
        {
            _content = game.Content;
            _spriteBatch = game.SpriteBatch;
            _graphicsDevice = game.GraphicsDevice;
            _gameInput = game.GameInput;
            _camera = new Camera2D(_graphicsDevice);
            _world = new World(new Vector2(0, 10));
            _timeStep = (float)game.TargetElapsedTime.TotalSeconds;

            _debugView = new DebugViewXNA(_world);
            _debugView.Flags = 0;
            _debugView.AppendFlags(DebugViewFlags.Shape);
            _debugView.AppendFlags(DebugViewFlags.Joint);
            _debugView.SleepingShapeColor = Color.YellowGreen;

            _crates = new List<Crate>();
        }
示例#48
0
        public GameWorld(BubbleBobbleGame game)
        {
            _content = game.Content;
            _spriteBatch = game.SpriteBatch;
            _graphicsDevice = game.GraphicsDevice;
            _gameInput = game.GameInput;
            _camera = new Camera2D(_graphicsDevice);

            // Creates the farseer world with a gravity
            _world = new World(new Vector2(0, 20));

            _timeStep = (float)game.TargetElapsedTime.TotalSeconds;

            // Setup the debug view
            _debugView = new DebugViewXNA(_world);
            _debugView.AppendFlags(DebugViewFlags.Shape);
            _debugView.AppendFlags(DebugViewFlags.PolygonPoints);
            _debugView.AppendFlags(DebugViewFlags.CenterOfMass);
        }
示例#49
0
        public GameObject(World world,
            DebugViewXNA debugViewXNA,
            ContentManager content,
            GraphicsDeviceManager graphics)
        {
            this.IsAlive = true;
            this.StackDepth = 1;

            this.mWorld = world;
            this.mDebugViewXNA = debugViewXNA;
            this.mContent = content;
            this.mGraphics = graphics;

            this.mWorld.ContactManager.OnBroadphaseCollision += OnBroadphaseCollision;

            this.mInfo = new GameObjectInfoText(this.mContent,
                this.mGraphics,
                ConvertUnits.ToDisplayUnits(this.mPosition),
                Color.White);
        }
示例#50
0
        protected override void Initialize()
        {
            _world = new World(new Vector2(0, 9.8f));
            _debugView = new DebugViewXNA(_world);
            _debugView.AppendFlags(FarseerPhysics.DebugViewFlags.Shape);
            _debugView.DefaultShapeColor = Color.White;
            _debugView.SleepingShapeColor = Color.LightGray;
            _debugView.LoadContent(GraphicsDevice, Content);

            base.Initialize();

            _fluidSimulation = new FluidSimulation(_world, _spriteBatch, _debugFont);
            _projection = Matrix.CreateOrthographic(GraphicsDevice.Viewport.Width, GraphicsDevice.Viewport.Height, 0, 1);
            _view = Matrix.CreateScale(new Vector3(SCALE, -SCALE, 1));

            // Create test geometry
            Body bottomBody = BodyFactory.CreateBody(_world, new Vector2(0, 7f));
            PolygonShape bottomShape = new PolygonShape(1f);
            bottomShape.SetAsBox(12f, 1f);
            bottomBody.CreateFixture(bottomShape);

            Body leftBody = BodyFactory.CreateBody(_world, new Vector2(-11f, 0f));
            PolygonShape leftShape = new PolygonShape(1f);
            leftShape.SetAsBox(1f, 10f);
            leftBody.CreateFixture(leftShape);

            Body rightBody = BodyFactory.CreateBody(_world, new Vector2(11f, 0f));
            PolygonShape rightShape = new PolygonShape(1f);
            rightShape.SetAsBox(1f, 10f);
            rightBody.CreateFixture(rightShape);

            Body rampBody = BodyFactory.CreateBody(_world, new Vector2(6f, -2f));
            PolygonShape rampShape = new PolygonShape(1f);
            rampShape.SetAsBox(5.5f, 0.5f);
            rampBody.CreateFixture(rampShape);
            rampBody.Rotation = -0.25f;

            Body circleBody = BodyFactory.CreateBody(_world, new Vector2(0, -0.2f));
            CircleShape circleShape = new CircleShape(2f, 1f);
            circleBody.CreateFixture(circleShape);
        }
示例#51
0
        public override void LoadContent()
        {
            base.LoadContent();

            //We enable diagnostics to show get values for our performance counters.
            Settings.EnableDiagnostics = true;

            if (World == null)
            {
                World = new World(Vector2.Zero);
            }
            else
            {
                World.Clear();
            }

            if (DebugView == null)
            {
                DebugView = new DebugViewXNA(World);
                DebugView.RemoveFlags(DebugViewFlags.Shape);
                DebugView.RemoveFlags(DebugViewFlags.Joint);
                DebugView.DefaultShapeColor = Color.White;
                DebugView.SleepingShapeColor = Color.LightGray;
                DebugView.LoadContent(ScreenManager.GraphicsDevice, ScreenManager.Content);
            }

            frameRateCounter = new FrameRateCounter(this.ScreenManager);

            if (Camera == null)
            {
                Camera = new Camera2D(ScreenManager.GraphicsDevice);
            }
            else
            {
                Camera.ResetCamera();
            }

            // Loading may take a while... so prevent the game from "catching up" once we finished loading
            ScreenManager.Game.ResetElapsedTime();
        }
        public override void LoadContent()
        {
            base.LoadContent();

            if (World == null)
            {
                World = new World(Vector2.Zero);
            }
            else
            {
                World.Clear();
            }

			#if DEBUG_RENDER
            if (DebugView == null)
            {
                DebugView = new DebugViewXNA(World);
                DebugView.RemoveFlags(DebugViewFlags.Shape);
                DebugView.RemoveFlags(DebugViewFlags.Joint);
                DebugView.DefaultShapeColor = Color.White;
                DebugView.SleepingShapeColor = Color.LightGray;
				DebugView.LoadContent(ScreenManager.GraphicsDevice);

				EnableOrDisableFlag(DebugViewFlags.Shape);
				EnableOrDisableFlag(DebugViewFlags.DebugPanel);
				EnableOrDisableFlag(DebugViewFlags.PerformanceGraph);
				EnableOrDisableFlag(DebugViewFlags.Joint);
				EnableOrDisableFlag(DebugViewFlags.ContactPoints);
				EnableOrDisableFlag(DebugViewFlags.ContactNormals);
				EnableOrDisableFlag(DebugViewFlags.Controllers);
            }
			#endif

			WireUpCamera ();

            // Loading may take a while... so prevent the game from "catching up" once we finished loading
            ScreenManager.Game.ResetElapsedTime();
        }
示例#53
0
        /// <summary>
        /// Initializes a new instance of the DebugDrawSystem class.
        /// </summary>
        /// <param name="entityManager">The EntityManager for the world that this system belongs to.</param>
        /// <param name="world">The physics world.</param>
        /// <param name="graphics">The graphics device.</param>
        /// <param name="content">The content manager.</param>
        public DebugDrawSystem(
            EntityManager entityManager,
            World world,
            GraphicsDevice graphics,
            ContentManager content)
            : base(entityManager)
        {
            this.debugView = new DebugViewXNA(world);
            this.debugView.LoadContent(graphics, content);

            // Set the debug flags
            ////this.debugView.AppendFlags(DebugViewFlags.AABB);
            ////this.debugView.AppendFlags(DebugViewFlags.CenterOfMass);
            ////this.debugView.AppendFlags(DebugViewFlags.ContactNormals);
            ////this.debugView.AppendFlags(DebugViewFlags.ContactPoints);
            ////this.debugView.AppendFlags(DebugViewFlags.Controllers);
            ////this.debugView.AppendFlags(DebugViewFlags.DebugPanel);
            ////this.debugView.AppendFlags(DebugViewFlags.Joint);
            ////this.debugView.AppendFlags(DebugViewFlags.Pair);
            ////this.debugView.AppendFlags(DebugViewFlags.PerformanceGraph);
            ////this.debugView.AppendFlags(DebugViewFlags.PolygonPoints);
            ////this.debugView.AppendFlags(DebugViewFlags.Shape);
        }
示例#54
0
        public override void LoadContent(ContentManager content, GraphicsDevice graph)
		{
			base.LoadContent(content, graph);
            song = new SoundPlayer(Path.Combine(Environment.CurrentDirectory, "Content/Song/VirginInca.wav"));
            song.Load();
            song.Play();
			Settings.UseFPECollisionCategories = true;

            ConvertUnits.SetDisplayUnitToSimUnitRatio(32f);

            if (world == null)
            {
                world = new World(Vector2.Zero);
            }
            else
            {
                world.Clear();
            }

            // register
            world.ContactManager.BeginContact += onBeginContact;
            world.ContactManager.EndContact += onEndContact;
            world.ContactManager.PreSolve += onPreSolve;
            world.ContactManager.PostSolve += onPostSolve;

            world.Gravity = PhysicsUtils.gravity;

            camera.viewportWidth = graph.Viewport.Width;
            camera.viewportHeight = graph.Viewport.Height;
            camera.zoom = 0.85f;
            // NOTE: you should probably unregister on destructor or wherever is relevant...

            if (debugView == null)
            {
                debugView = new DebugViewXNA(world);

                debugView.LoadContent(graph, content);
            }

            projection = Matrix.CreateOrthographicOffCenter(
                0f, ConvertUnits.ToSimUnits(graph.Viewport.Width),
                ConvertUnits.ToSimUnits(graph.Viewport.Height), 0f,
                0f, 1f
            );

            projectileFactory.LoadContent(this, content);

            player.LoadContent(world, content, new Vector2(18, 10), this);


            map.LoadContent(content, world);
			dynMap.LoadContent(content, world, this);

			boss = dynMap.boss;

            mapBack.LoadContent(content);
            enemies = dynMap.listEnnemy;
            CollectibleItem item = new CollectibleItem();
            /*item.LoadContent(world, new Vector2(1, 1), new Vector2(21, 8), content, CollectibleItemType.AMMO);
            collectibleItems.Add(item);*/

			lifeBarFrame.LoadContent(content, "Graphics/cadre", Color.White, Vector2.Zero);
			lifeBar.LoadContent(content, "Graphics/Lifebar2", Color.White, Vector2.Zero);

            projectileBarFrame.LoadContent(content, "Graphics/cadre", Color.White, Vector2.Zero);
            projectileBar.LoadContent(content, "Graphics/Lifebar2", Color.Purple, Vector2.Zero);
        }
示例#55
0
        protected override void Initialize()
        {
            // TODO: Add your initialization logic here

            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new SpriteBatch(GraphicsDevice);

            GameManager.getInstance().Initialize(this, Content, ref graphics);

            // DebugView for Physics objects
            debugview = new DebugViewXNA(GameManager.getInstance().world);
            base.Initialize();
            Components.Add(GameManager.getInstance().uno);
        }
示例#56
0
 public void Draw(SpriteBatch sBatch, DebugViewXNA debugView, Matrix projection, Matrix view)
 {
     mShip.Draw(sBatch, debugView, projection, view);
 }
示例#57
0
        public void Update(DebugViewXNA debugView)
        {
            KeyboardState aCurrentKeyboardState = Keyboard.GetState();
            MouseState aCurrentMouseState = Mouse.GetState();
            UpdateMovement(aCurrentKeyboardState);
            UpdateAbilities(aCurrentKeyboardState, debugView);
            UpdateMouse(aCurrentMouseState);

            aCurrentKeyboardState = UpdateCamera(aCurrentKeyboardState, aCurrentMouseState);
            previousKeyboardState = aCurrentKeyboardState;
        }
示例#58
0
        /// <summary>
        /// Metoda  wywolywana przed LoadContent
        /// </summary>
        public void Initialize()
        {
            // Get the content manager from the application
            contentManager = (Application.Current as App).Content;
            spriteBatch = new SpriteBatch(SharedGraphicsDeviceManager.Current.GraphicsDevice);
            LevelLines = new List<LevelLine>();

            // Dodanie linii levelu.
            LevelLines.Add(new LevelLine(250, SharedGraphicsDeviceManager.Current.GraphicsDevice));
            LevelLines.Add(new LevelLine(500, SharedGraphicsDeviceManager.Current.GraphicsDevice));

            // Inicjalizacja świata
            if (world == null)
            {
                world = new World(Settings.gravity);
            }
            else
            {
                world.Clear();
            }

            if (debugView == null)
            {
                debugView = new DebugViewXNA(world);
                debugView.RemoveFlags(FarseerPhysics.DebugViewFlags.Controllers);
                debugView.RemoveFlags(FarseerPhysics.DebugViewFlags.Joint);

                debugView.LoadContent(SharedGraphicsDeviceManager.Current.GraphicsDevice, contentManager);
            }

            // Tworzenie podlogi
            _floor = BodyFactory.CreateRectangle(world,
                                                ConvertUnits.ToSimUnits(480),
                                                ConvertUnits.ToSimUnits(50),
                                                10f);
            _floor.Position = ConvertUnits.ToSimUnits(240, 775);
            _floor.BodyType = BodyType.Static;
            _floor.IsStatic = true;
            _floor.Restitution = 0.0f;
            _floor.Friction = 2.5f;

            // Tworzenie platformy
            _platform = BodyFactory.CreateRectangle(world,
                                                ConvertUnits.ToSimUnits(250),
                                                ConvertUnits.ToSimUnits(50),
                                                10f);
            _platform.Position = ConvertUnits.ToSimUnits(240, 725);
            _platform.BodyType = BodyType.Static;
            _platform.IsStatic = true;
            _platform.Restitution = 0.0f;
            _platform.Friction = 5.0f;

            // Żaden blok nie spada
            blockOnHisWay = false;

            //Aktywacja gestów - vertical do obracania i horizontaldrag do ruszania klockiem
            TouchPanel.EnabledGestures = GestureType.HorizontalDrag | GestureType.VerticalDrag;

            LoadContent();
        }
        public void Initialize()
        {
            //credits = new Credits();

            theView = new DebugViewXNA(theWorld);
            theView.LoadContent(game.GraphicsDevice, game.Content);
            circlePlayer = new CirclePlayer();
            circlePlayer.Init();
            squarePlayer = new SquarePlayer();
            squarePlayer.Init();

            Texture2D[] textures = new Texture2D[6];
            textures[0] = game.Content.Load<Texture2D>("images/WhiteHexagon");
            textures[1] = game.Content.Load<Texture2D>("images/WhiteOctagon");
            textures[2] = game.Content.Load<Texture2D>("images/WhiteDiamond");
            textures[3] = game.Content.Load<Texture2D>("images/WhiteTriangle");
            textures[4] = game.Content.Load<Texture2D>("images/WhitePantage");
            textures[5] = game.Content.Load<Texture2D>("images/WhiteStar");

            //CircleBar = game.Content.Load<Texture2D>("images/Bar/CircleBar");
            //SquareBar = game.Content.Load<Texture2D>("images/Bar/SquareBar");
            //NeutralBar = game.Content.Load<Texture2D>("images/Bar/NeutralBar");

            Random rand = new Random();
            enemies = new List<Enemy>();
            int j = 0;
            for (int i = 0; i < maxEnemyNumber; i++)
            {
                Enemy enemy = new Enemy();

                enemy.Init(i, textures[j]);
                enemy.Position = new Vector2((float)rand.Next(800), (float)rand.Next(800));
                enemies.Add(enemy);
                j++;
                if (j > 5)
                    j = 0;
            }

            _oldGamePad = GamePad.GetState(PlayerIndex.One);
            _camera = new camera(game, 0);
            sb = new SpriteBatch(game.GraphicsDevice);

            circlePlayer.Position = new Vector2(500, 500);
            squarePlayer.Position = new Vector2(500, 500);
            border = new Border(_theWorld, worldsize.X / 2, worldsize.Y / 2, 10.0f);
        }
示例#60
0
 private KeyboardState UpdateAbilities(KeyboardState aCurrentKeyboardState, DebugViewXNA debugView)
 {
     if (aCurrentKeyboardState.IsKeyDown(Keys.Q))
         player.character.abilities[0].useAbility();
     else if (aCurrentKeyboardState.IsKeyDown(Keys.E))
     {
         player.character.abilities[1].useAbility();
     }
     else if (aCurrentKeyboardState.IsKeyDown(Keys.Space))
     {
         player.creature.autoAttack();
     }
     return aCurrentKeyboardState;
 }