Ejemplo n.º 1
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);
 }
Ejemplo n.º 2
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);
        }
Ejemplo n.º 3
0
        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();
        }
Ejemplo n.º 4
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();
        }
Ejemplo n.º 5
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;
        }
Ejemplo n.º 6
0
        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();
        }
Ejemplo n.º 7
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);
        }
Ejemplo n.º 8
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);
            }
        }
Ejemplo n.º 9
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;
        }
Ejemplo n.º 10
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();
        }
Ejemplo n.º 11
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);
 }
Ejemplo n.º 12
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
        }
Ejemplo n.º 13
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();
        }
Ejemplo n.º 14
0
        public override void StartFrame()
        {
            if (!m_debugView.Loaded && Engine.Renderer != null)
            {
                m_debugView.LoadContent(Engine.Renderer.Device, Engine.AssetManager.ContentManager);
                m_debugView.AppendFlags(FarseerPhysics.DebugViewFlags.CenterOfMass);
                m_debugView.AppendFlags(FarseerPhysics.DebugViewFlags.PolygonPoints);
                m_debugView.AppendFlags(FarseerPhysics.DebugViewFlags.ContactPoints);
                m_debugView.AppendFlags(FarseerPhysics.DebugViewFlags.Shape);

                Engine.Renderer.RenderLayers["DebugPhysicsOverlay"].Renderables.Add(this);
            }

            float timeCoef = Engine.Debug.EditSingle("TimeCoef", 0.85f);

            Engine.World.UpdatePrePhysics();
            m_world.Step(Engine.GameTime.ElapsedMS * 0.001f * timeCoef);

            //fix rigidBody
            foreach (var go in Engine.World.GameObjects)
            {
                if (go.RigidBodyCmp != null)
                {
                    go.RigidBodyCmp.UpdateGameObjectPosition();
                }
            }

            Engine.World.UpdatePostPhysics();
        }
        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);
        }
Ejemplo n.º 16
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();
            }
        }
Ejemplo n.º 17
0
        public void Setup()
        {
            _dragon = new Dragon(this)
            {
                Position = _dragonStartPosition
            };
            _allGameOjbects.Add(_dragon);

            _walls.Add(new Wall(this, new Rectangle(0, 0, WorldWidth, 16)));
            _walls.Add(new Wall(this, new Rectangle(0, 0, 16, WorldHeight)));
            _walls.Add(new Wall(this, new Rectangle(0, WorldHeight - 16, WorldWidth, 16)));
            _walls.Add(new Wall(this, new Rectangle(WorldWidth - 16, 0, 16, WorldHeight)));


            _walls.Add(new Wall(this, new Rectangle(200, 450, 208, 16))
            {
                SolidWall = false
            });
            _walls.Add(new Wall(this, new Rectangle(408, 350, 16, 116)));

            CreateBackgroudTexture();
            SetupCamera();

            _debugView.LoadContent(_graphicsDevice, _content);
        }
Ejemplo n.º 18
0
        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);
        }
Ejemplo n.º 19
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);
 }
Ejemplo n.º 20
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);
 }
Ejemplo n.º 21
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();
 }
Ejemplo n.º 22
0
        /// <summary>
        /// Load content
        /// </summary>
        /// <param name="contentManager"></param>
        public override void LoadContent(Microsoft.Xna.Framework.Content.ContentManager contentManager)
        {
            // Loads the scene and so on
            base.LoadContent(contentManager);
            _scene.LoadContent(contentManager);

            #if DEBUG && !SILVERLIGHT
            view.LoadContent(this.Game.GraphicsDevice, contentManager);
            #endif
        }
Ejemplo n.º 23
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");
        }
Ejemplo n.º 24
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");
        }
Ejemplo n.º 25
0
 public PhysicsBase()
 {
     World     = new World(new Vector2(0, 0));
     DebugView = new DebugViewXNA(World);
     DebugView = new DebugViewXNA(World);
     DebugView.RemoveFlags(DebugViewFlags.Shape);
     DebugView.RemoveFlags(DebugViewFlags.Joint);
     DebugView.DefaultShapeColor  = Color.White;
     DebugView.SleepingShapeColor = Color.LightGray;
     DebugView.LoadContent(GraphicsExt.graphics.GraphicsDevice, ContentExt.Content);
 }
Ejemplo n.º 26
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);
        }
Ejemplo n.º 27
0
 public override void Awake()
 {
     activated        = true;
     physicsDebugView = new DebugViewXNA(Physics.world);
     //physicsDebugView.DrawSolidShapes = false;
     physicsDebugView.LoadContent(Application.Instance.GraphicsDevice);
     material = new Material()
     {
         name = "Debug material", color = Color.white, renderQueue = 100000, shaderName = "Transparent"
     };
     base.Awake();
 }
Ejemplo n.º 28
0
        public void Initialize(RenderContext context)
        {
            //Create new savedata file if it doesn't exist yet
            if (!File.Exists(SaveDataFile))
            {
                SaveData data = new SaveData();
                data.HighestDistance = 0;

                XmlWriter.SaveScore(data, SaveDataFile);
            }
            SaveScore(); // actually loads the score

            isActive = true;

            m_ViewPort = context.GraphicsDevice.Viewport;

            //Load a font
            TextRenderer.SetFont(context.Content.Load <SpriteFont>("Font/Standard"));

            //Create player an set him at center of screen
            m_StartPos = new Vector2(context.ViewPortSize.X * 0.25f, context.ViewPortSize.Y * 0.25f);
            m_Player   = new Player(context, m_StartPos);
            m_Player.Initialize(context);
            m_Player.Translate(m_StartPos);

            context.Player = m_Player;

            //Generate a random level
            m_LevelManager = new LevelManager();
            m_LevelManager.Initialize(context);

            //AddParalaxing backgrounds
            m_BgManager = new BackgroundManager(context);
            m_BgManager.AddBackgound(new Background("background", new Vector2(0, 0), 1.0f, false, context));
            m_BgManager.AddBackgound(new Background("1", new Vector2(60, 20), 1.0f, false, context));
            m_BgManager.AddBackgound(new Background("2", new Vector2(100, 70), 1, false, context));
            m_BgManager.AddBackgound(new Background("3", new Vector2(200, 40), 1, false, context));
            m_BgManager.AddBackgound(new Background("4", new Vector2(300, 50), 1, false, context));
            m_BgManager.AddBackgound(new Background("5", new Vector2(400, 200), 1, false, context));

           #if (DEBUG)
            m_MonoDebug = new DebugViewXNA(context.World);
            m_MonoDebug.AppendFlags(DebugViewFlags.DebugPanel);
            m_MonoDebug.DefaultShapeColor  = Color.Red;
            m_MonoDebug.SleepingShapeColor = Color.LightGray;
            m_MonoDebug.LoadContent(context.GraphicsDevice, context.Content);
           #endif

            SoundManager.Play("Background", true);

            HitScreen  = new GameSprite("Textures/GUI/hit", context);
            PickScreen = new GameSprite("Textures/GUI/pickupHit", context);
        }
Ejemplo n.º 29
0
        public void LoadContent()
        {
            _spriteBatch = new SpriteBatch(_graphics);
            _world       = new DynamicEntityWorld(_game.Services);
            var pp = _graphics.PresentationParameters;

            _debugView = new DebugViewXNA(_world.PhysicsWorld);
            _debugView.LoadContent(_graphics, _content);

            _camera     = new DefaultCamera(null, new Viewport(0, 0, pp.BackBufferWidth, pp.BackBufferHeight));
            _cameraNode = _world.Scene.Root.CreateChild("Camera");
            _cameraNode.Attach(_camera);

            // Create the tile map.
            var terrainSize = new Vector2(4096.0f, 2048.0f);

            _terrain = new Terrain(terrainSize, 128.0f, 7)
            {
                DebugEnabled = false,
                Position     = new Vector3(50.0f, -terrainSize.Y / 2.0f, 0.0f),
                TextureName  = @"Textures\SpaceRock"
            };
            _world.Add(_terrain);

            GenerateTunnels(new Vector2(50.0f, 0));

            // Create the circle brush.
            _circleBrush = new CircleBrush(2.5f);

            _circleBrushNode = _world.Scene.CreateSceneNode();
            _circleBrushNode.Attach(new CircleRenderable(2.5f, 64)
            {
                Color = Vector3.One
            });

            // Dust cloud
            _dustCloud          = _world.Scene.CreateSceneNode("DustCloud");
            _dustCloud.Position = new Vector3(0.0f, 0.0f, -1.0f);
            _dustCloud.Attach(new DustCloud());
            _world.Scene.Root.AddChild(_dustCloud);

            // Player
            _playerEntity = new SpaceShip();
            _playerEntity.Attach(new PlayerController());
            _playerEntity.Orientation = Quaternion.CreateFromAxisAngle(Vector3.UnitZ, MathHelper.ToRadians(90.0f));
            _world.Add(_playerEntity);

            _payloadEntity             = new Payload();
            _payloadEntity.Orientation = Quaternion.CreateFromAxisAngle(Vector3.UnitZ, MathHelper.ToRadians(90.0f));
            _world.Add(_payloadEntity);

            _payloadChain = PayloadChain.Connect(_playerEntity, _payloadEntity, Vector2.UnitX * -20.0f);
        }
Ejemplo n.º 30
0
        public override void OnEnter()
        {
            //Camera
            GameWorldManager.Instance.SpawnEntity("camera", "camera1", new Vector3(0, -1300, 600));
            GameWorldManager.Instance.SpawnEntity("robot", "robot1", new Vector3(-400f, -1000f, 0f), 2f);
            GameWorldManager.Instance.SpawnEntity("crate", "crate", new Vector3(-50f, -1200f, 0f), 3f);
            GameWorldManager.Instance.SpawnEntity("crate", "crate2", new Vector3(-50f, -1100f, 0f), 2.6f);
            GameWorldManager.Instance.SpawnEntity("crate", "crate3", new Vector3(-50f, -1000f, 0f), 2f);
            GameWorldManager.Instance.SpawnEntity("crate", "crate4", new Vector3(-50f, -900f, 0f), 1.5f);
            //GameWorldManager.Instance.SpawnEntity( "crate", "crate5", new Vector3( 500f, -850f, 0f ), 0.1f );

            Robot = GameWorldManager.Instance.GetEntity("robot1");
            //Quaternion rotation = new Quaternion( 1f, 2f, 1f, 2f );
            //rotation.Normalize();
            //Robot.SetRotation( rotation );
            Robot.PhysicsEntity.Enabled = true;

            Robot.RegisterComponent("force", new SentientForceComponent());
            Robot.RegisterComponent(
                "control",
                new CarControlComponent(new List <string> {
                "GearJoint1", "GearJoint2", "GearJoint3"
            }, new List <float> {
                5f, 5f, 5f
            })
                );

            CameraController camControl = new CameraController(GameWorldManager.Instance.GetEntity("robot1"), SceneManager.Instance.GetCurrentCamera());

            ControllerRepository.Instance.RegisterController("camcontrol", camControl);
            FrameUpdateManager.Instance.Register(camControl);

            Camera = GameWorldManager.Instance.GetEntity("camera1");

            _cameraMoving          = false;
            _actionFreeze          = false;
            _actionSpawn           = false;
            _actionReset           = false;
            _debugViewState        = false;
            _actionToggleDebugView = false;


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

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

            _debugView.TextColor = Color.Black;

            _view = Matrix.Identity;
        }
Ejemplo n.º 31
0
        public override void LoadContent()
        {
            LoadAssets();

            base.LoadContent();
            spriteBatch    = ScreenManager.SpriteBatch;
            GraphicsDevice = ScreenManager.GraphicsDevice;
            // Start the game
            Start();


            DebugView = new DebugViewXNA(_world);
            DebugView.LoadContent(GraphicsDevice, ScreenManager.Game.Content);
        }
Ejemplo n.º 32
0
        void SetDebugView()
        {
            DebugViewFlags flags = 0;

            if (_debugView != null)
            {
                flags = _debugView.Flags;
            }
            _debugView = new DebugViewXNA(_gameLevel.World);
            _debugView.DefaultShapeColor  = Color.White;
            _debugView.SleepingShapeColor = Color.LightGray;
            _debugView.LoadContent(GraphicsDevice, new Viewport(0, 0, this.Size.Width, this.Size.Height), Content);
            _debugView.Flags = flags;
        }
Ejemplo n.º 33
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
		}
Ejemplo n.º 34
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);
        }
Ejemplo n.º 35
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();
        }
Ejemplo n.º 36
0
        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();
        }
Ejemplo n.º 37
0
        private void SetupDebug()
        {
            // create and configure the debug view
            _debugView = new DebugViewXNA ( PhysicsWorld );

            _debugView.AppendFlags ( DebugViewFlags.PerformanceGraph );
            _debugView.AppendFlags ( DebugViewFlags.CenterOfMass );
            _debugView.AppendFlags ( DebugViewFlags.Shape );
            _debugView.AppendFlags ( DebugViewFlags.DebugPanel );
            //_debugView.AppendFlags(DebugViewFlags.AABB);

            _debugView.DefaultShapeColor = Color.White;
            _debugView.SleepingShapeColor = Color.LightGray;
            _debugView.LoadContent ( GraphicsDevice, Content );
        }
Ejemplo n.º 38
0
        protected override void LoadContent()
        {
            RasterizerState rs = new RasterizerState();
            rs.CullMode = CullMode.None;
            GraphicsDevice.RasterizerState = rs;
            font = Content.Load<SpriteFont>("font");

            car.LoadContent(Content);
            basicEffect = new BasicEffect(GraphicsDevice)
            {
                TextureEnabled = true,
                VertexColorEnabled = true,
            };

            debug = new DebugViewXNA(world);
            debug.LoadContent(GraphicsDevice, Content);

            dashboard.LoadContent(Content);
        }
Ejemplo n.º 39
0
        public override void Initialize(Vector2 gravity)
        {
            world = new World(gravity);
            world.ContactManager.BeginContact += OnContact;
            world.ContactManager.EndContact += ContactOver;

            FarseerPhysics.Settings.VelocityIterations = 3;
            FarseerPhysics.Settings.PositionIterations = 1;

            FarseerPhysics.Settings.ContinuousPhysics = false;
            FarseerPhysics.Settings.EnableDiagnostics = false;

            FarseerPhysics.Settings.MaxPolygonVertices = 32;
            #if WINDOWS || WINDOWS_PHONE
            _debugView = new DebugViewXNA(world);
            _debugView.LoadContent(BaseGame.Get.GraphicsDevice, BaseGame.Get.Content);
            #endif
        }
Ejemplo n.º 40
0
        protected override void Initialize()
        {
            base.Initialize();

            Camera = new Camera(Vector2.One, Vector3.Zero);

            // create default level
            LevelManager = Container.Resolve<LevelManager>();
            LevelManager.LevelLoaded += new LevelLoadedEventHandler(LevelLoaded);

            debugView = new DebugViewXNA(LevelManager.PhysicsManager.World);
            debugView.LoadContent(GraphicsDevice, Content);

            Database = Container.Resolve<SQLiteDatabase>();

            log4net.Config.XmlConfigurator.Configure();

            Database = Container.Resolve<SQLiteDatabase>();

            Logger.Info("EngineGame initialized");

            ScreenManager.Initialize();
        }
Ejemplo n.º 41
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();
        }
Ejemplo n.º 42
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);
        }
Ejemplo n.º 43
0
        public override void LoadContent()
        {
            LoadAssets ();

            base.LoadContent ();
            spriteBatch = ScreenManager.SpriteBatch;
            GraphicsDevice = ScreenManager.GraphicsDevice;
            // Start the game
            Start ();

            DebugView = new DebugViewXNA(_world);
            DebugView.LoadContent(GraphicsDevice,ScreenManager.Game.Content);
        }
Ejemplo n.º 44
0
 protected override void LoadContent()
 {
     spriteBatch = new SpriteBatch(GraphicsDevice);
     debug = new DebugViewXNA(world);
     debug.LoadContent(GraphicsDevice, Content);
 }
Ejemplo n.º 45
0
        void DebugDraw()
        {
            Matrix view2 = Matrix.CreateScale(32); //default 32
            view2 *= Game1.DebugCam.view;

            debugActive = true;

            DebugView = new DebugViewXNA(Game1.world);
            DebugView.AppendFlags(FarseerPhysics.DebugViewFlags.DebugPanel);
            DebugView.DefaultShapeColor = Color.Red;
            DebugView.SleepingShapeColor = Color.Green;
            DebugView.StaticShapeColor = Color.Violet;
            DebugView.LoadContent(Game1.graphics.GraphicsDevice, Game1.content);
            DebugView.RenderDebugData(ref Game1.DebugCam.projection, ref view2);
        }
Ejemplo n.º 46
0
		public override void LoadContent(ContentManager content, GraphicsDevice graph)
		{
			base.LoadContent(content, graph);

			Settings.UseFPECollisionCategories = true;

			ConvertUnits.SetDisplayUnitToSimUnitRatio(32f);

            ServiceHelper.Get<SoundService>().AddSound("zap", "Sounds/zap.wav");

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

			world.Gravity = gravity;

			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
			);

			///////////////////////////////////////////////////////////////////////////////
			player = BodyFactory.CreateCapsule(world, 0.5f, 0.8f, 1f);

			player.CollisionCategories = Category.Cat2;
			player.CollidesWith = Category.Cat1;

			player.BodyType = BodyType.Dynamic;
			player.Position = new Vector2(10, 3);
			player.FixedRotation = true;

			playerAnimation.LoadContent(
				content,
				"Graphics/CodingMadeEasyPlatformer/Hero1", Color.White,
				ConvertUnits.ToDisplayUnits(player.Position),
				200, new Vector2(3, 4)
			);

			playerAnimation.ScaleToBody(player);

			playerAnimation.isActive = true;

			for (int i = 0; i < 5; ++i)
			{
				Body platform = BodyFactory.CreateRectangle(world, 2f, 2f, 1f);

				platform.CollisionCategories = Category.Cat1;
				platform.CollidesWith = Category.Cat2;

				platform.BodyType = BodyType.Static;
				platform.Position = new Vector2(2 + (i * 3), 10);

				Image platformImage = new Image();
				platformImage.LoadContent(
					 content,
					 "Graphics/minecraft", Color.White,
					 ConvertUnits.ToDisplayUnits(platform.Position)
				 );

				platformImage.ScaleToBody(platform);

				platforms.Add(platform);
				platformsImages.Add(platformImage);
			}
		}
Ejemplo n.º 47
0
        public void LoadContent()
        {
            m_debug.LoadContent();

            var pp = m_graphics.PresentationParameters;

            // Create our entity world.
            m_world = new DynamicEntityWorld(m_game.Services);

            // Create the debug view.
            m_debugView = new DebugViewXNA(m_world.PhysicsWorld);
            m_debugView.LoadContent(m_graphics, m_content);

            // Create the camera.
            m_camera = new DefaultCamera(null, new Viewport(0, 0, pp.BackBufferWidth, pp.BackBufferHeight));
            m_cameraNode = m_world.Scene.Root.CreateChild("Camera");
            m_cameraNode.Attach(m_camera);

            // Create the player.
            m_player = new Entities.Player(
                new StaticSprite(Vector2.One * 10.0f, m_content.Load<Texture2D>(@"Sprites\Ship01"), "Player"));

            m_player.Attach(new Controllers.PlayerMovement(m_camera));
            m_world.Add(m_player);

            m_player.Position = new Vector2(0.0f, 0.0f);

            // Create the layers.
            m_playerLayer = new DefaultLayer(typeof(ISprite), "Player", 0.5f) { Scene = m_world.Scene };
            m_backgroundLayer = new DefaultLayer(0.0f) { Scene = m_world.Scene };

            // Create the background.
            var deepSpaceSprite = new StaticSprite(Vector2.One * 200.0f, m_content.Load<Texture2D>(@"Textures\Background01"), null) { BlendState = BlendState.Additive };
            var lessDeepSpaceSprite = new StaticSprite(Vector2.One * 400.0f, m_content.Load<Texture2D>(@"Textures\Background02"), null) { BlendState = BlendState.Additive };

            m_deepSpaceNode = m_cameraNode.CreateChild("Background_DeepSpace");
            m_deepSpaceNode.Depth = -1.0f; // Move the background into the back.
            m_deepSpaceNode.Attach(deepSpaceSprite);

            m_lessDeepSpaceNode = m_cameraNode.CreateChild("Background_LessDeepSpace");
            m_lessDeepSpaceNode.Depth = -0.9f; // Move the background into the back, but in front of the other background.
            m_lessDeepSpaceNode.Attach(lessDeepSpaceSprite);

            m_backgroundLayer.AddRenderable(deepSpaceSprite);
            m_backgroundLayer.AddRenderable(lessDeepSpaceSprite);

            // Create the dust cloud.
            var dustCloud = new Movables.DustCloud(100);

            m_dustCloudNode = m_world.Scene.Root.CreateChild("DustCloud");
            m_dustCloudNode.Depth = -0.8f;
            m_dustCloudNode.Attach(dustCloud);

            m_backgroundLayer.AddRenderable(dustCloud);

            // Create the planet.
            m_terrainLayer = new DefaultLayer(typeof(Entities.TerrainRegion), null, 0.0f) { Scene = m_world.Scene };
            m_miscLayer = new DefaultLayer(typeof(ISprite), "MISC_", -0.5f) { Scene = m_world.Scene };

            CreatePlanet();
        }
Ejemplo n.º 48
0
 public virtual void Initialize()
 {
     Settings.EnableDiagnostics = true;
     DebugView = new DebugViewXNA(World);
     DebugView.LoadContent(CCDrawManager.GraphicsDevice, CCApplication.SharedApplication.Content);
 }
Ejemplo n.º 49
0
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            //Steup StartScreen

            MenuSong = Content.Load<Song>("Sounds/Menu_Song_mixdown");
            font = Content.Load<SpriteFont>("Sprites/font");

            isActive = false;
            ScreenList.Add(new FirstScreen(MenuSong,font));
            ScreenList.Add(new SecondScreen(MenuSong, font));
            ScreenList.Add(new EndScreen());
            ScreenList[0].setActive(true);
            firstbackground = Content.Load<Texture2D>("Sprites/Start_Screen_Background");

            //end states
            p1WinsImage = Content.Load<Texture2D>("Sprites/P1_Wins");
            p2WinsImage = Content.Load<Texture2D>("Sprites/P2_Wins");
            drawGameImage = Content.Load<Texture2D>("Sprites/Draw");
            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new SpriteBatch(GraphicsDevice);

            background = Content.Load<Texture2D>("Sprites/Lava_Scrolling_Bkrnd_2048");
            foreground = Content.Load<Texture2D>("Sprites/Foreground");
            boxTex = Content.Load<Texture2D>("Sprites/ToyBox");
            Texture2D carsSpriteSheet = Content.Load<Texture2D>("Sprites/Cars_test");
            myBackground = new ScrollingBackground();
            myBackground.Load(GraphicsDevice, background);

            //explosion texture
            explosionTexture = Content.Load<Texture2D>("Sprites/Explosion_Sprite_Sheet");

            //pENCIL wALLS TOP
            pencilTex = Content.Load<Texture2D>("Sprites/Bottom_pencil");
            pencilTexSide = Content.Load<Texture2D>("Sprites/Side_Pencil");
            pencilWallTop = new PencilWall[5];
            pencilWallTop[0] = new PencilWall(pencilTex, new Vector2(125, 100), world, "up");
            pencilWallTop[1] = new PencilWall(pencilTex, new Vector2(465, 100), world, "up");
            pencilWallTop[2] = new PencilWall(pencilTex, new Vector2(795, 100), world, "up");
            pencilWallTop[3] = new PencilWall(pencilTex, new Vector2(1135, 100), world, "up");
            pencilWallTop[4] = new PencilWall(pencilTex, new Vector2(1455, 100), world, "up");

            //PencilWalls Bot
            pencilWallBot = new PencilWall[5];

            pencilWallBot[0] = new PencilWall(pencilTex, new Vector2(125, 950), world, "down");
            pencilWallBot[1] = new PencilWall(pencilTex, new Vector2(455, 950), world, "down");
            pencilWallBot[2] = new PencilWall(pencilTex, new Vector2(785, 950), world, "down");
            pencilWallBot[3] = new PencilWall(pencilTex, new Vector2(1125, 950), world, "down");
            pencilWallBot[4] = new PencilWall(pencilTex, new Vector2(1445, 950), world, "down");

            //PencilWalls Left
            pencilWallLeft = new PencilWall[3];
            pencilWallLeft[0] = new PencilWall(pencilTexSide, new Vector2(100, 130), world, "left");
            pencilWallLeft[1] = new PencilWall(pencilTexSide, new Vector2(100, 410), world, "left");
            pencilWallLeft[2] = new PencilWall(pencilTexSide, new Vector2(100, 690), world, "left");

            pencilWallRight = new PencilWall[3];
            pencilWallRight[0] = new PencilWall(pencilTexSide, new Vector2(1775, 130), world, "right");
            pencilWallRight[1] = new PencilWall(pencilTexSide, new Vector2(1775, 410), world, "right");
            pencilWallRight[2] = new PencilWall(pencilTexSide, new Vector2(1775, 690), world, "right");

            //collision spark
            collisionSpark = Content.Load<Texture2D>("Sprites/SINGLE_Spark_Sprite_Sheet");

            //Background music
            effect = new SoundEffect[3];
            effect[0] = Content.Load<SoundEffect>("Sounds/Car_Crash001");
            effect[1] = Content.Load<SoundEffect>("Sounds/Car_Crash002");
            effect[2] = Content.Load<SoundEffect>("Sounds/Car_Crash003");

            //loading
             //   firstbackground = Content.Load<Texture2D>("Sprites/ToyBox");
            secondbackground = Content.Load<Texture2D>("Sprites/Players");
            CarP1 = Content.Load<Texture2D>("Sprites/Select_cars");
            CarP2 = Content.Load<Texture2D>("Sprites/Select_cars");
            one = Content.Load<Texture2D>("Sprites/One");
            two = Content.Load<Texture2D>("Sprites/Two");
            three = Content.Load<Texture2D>("Sprites/Three");

            car1 = new AnimatedSprite(carsSpriteSheet, 3, 6,explosionTexture,4,5,car1StartingPos, world, selectP2);
            car2 = new AnimatedSprite(carsSpriteSheet, 3, 6, explosionTexture, 4, 5, car2StartingPos, world, selectP1);
            boxPlatform = new BoxPlatform(boxTex, new Vector2(650, 350), world);

            car1.player1.OnCollision += MyOnCollision;
            car2.player1.OnCollision += MyOnCollision;
            //DebugViewXNA view objects
            _font = Content.Load<SpriteFont>("Sprites/font");
            _batch = new SpriteBatch(graphics.GraphicsDevice);
            _debugView = new DebugViewXNA(world);
            _debugView.AppendFlags(DebugViewFlags.DebugPanel);
            _debugView.DefaultShapeColor = Color.White;
            _debugView.SleepingShapeColor = Color.LightGray;
            _debugView.LoadContent(GraphicsDevice, Content);

            // TODO: use this.Content to load your game content here
        }
Ejemplo n.º 50
0
 public virtual void Initialize()
 {
     Settings.EnableDiagnostics = true;
     DebugView = new DebugViewXNA(World);
     DebugView.LoadContent(GameInstance.GraphicsDevice, GameInstance.Content);
 }
Ejemplo n.º 51
0
        /// <summary>
        /// Initialization
        /// </summary>
        public override void Initialize()
        {
            base.Initialize();

            /**
             *
             * TUTAJ ODBYWA SIE PRZYPISANIE CONTROLSOW
             *
             * */

            GameInputManager = new InputManager();
            GameInputManager.AddAction("BackToMenu");
            GameInputManager.AddAction("RepeatLevel");
            GameInputManager.AddAction("Pause");
            GameInputManager.AddAction("CCW");
            GameInputManager.AddAction("CW");
            GameInputManager.AddAction("Left");
            GameInputManager.AddAction("Right");

            GameInputManager["RepeatLevel"].Add(Keys.Enter);
            GameInputManager["BackToMenu"].Add(Keys.Escape);
            GameInputManager["Pause"].Add(Keys.P);
            GameInputManager["CCW"].Add(Keys.Up);
            GameInputManager["CW"].Add(Keys.Down);
            GameInputManager["Left"].Add(Keys.Left);
            GameInputManager["Right"].Add(Keys.Right);

            // Wysokosci podlogi i platformy
            floorHeight = 15;
            platformHeight = 40;
            highestBodyPosition = 1000;

            // Ustawienie flag zwyciestwa lub przegranej
            failFlag                = false;
            lineReached             = false;
            winFlag                 = false;
            countDownStarted        = false;
            notStableFlag           = false;
            afterWinProcedureDone   = false;
            pauseFlag               = false;
            // Utworzenie timera ktory bedzie zliczał w doł w przypadku osiagniecia wysokosci,
            // Czas odliczania to 3 - arg. sec TimeSpan'a
            CountDownTimer = new TimerGtt(TimerGttModes.COUNTDOWN, new TimeSpan(0, 0, 0, 3, 0));

            // Ustawienie defaultowych danych, w calej grze dane są z tej zmiennej brane
            Settings = new GameSettings(OptionsHandler.blocksFriction, OptionsHandler.blocksBounciness, 0.12f, new Vector2(0.0f, 1.0f),
                                        new Vector2(this.GraphicsDevice.Viewport.Width / 2, 40));

            // Standardowy "Efekt" do rysowania prymitywów w XNA
            basicEffect = new BasicEffect(GraphicsDevice);
            basicEffect.VertexColorEnabled = true;
            basicEffect.Projection = Matrix.CreateOrthographicOffCenter
               (0, GraphicsDevice.Viewport.Width,     // left, right
                GraphicsDevice.Viewport.Height, 0,    // bottom, top
                0, 1);                                         // near, far plane

            // Stworzenie batchy do rysowania
            spriteBatch = new SpriteBatch(GraphicsDevice);
            hudBatch = new SpriteBatch(GraphicsDevice);
            endingBatch = new SpriteBatch(GraphicsDevice);

            // Stworzenie kontenera na linie levelu
            LevelLines = new List<LevelLine>();

            // Dodanie linii levelu.
            LevelLines.Add(new LevelLine(TargetHeight, 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(GraphicsDevice, Game.Content);
            }

            // Tworzenie podlogi
            _floor = BodyFactory.CreateRectangle(world,
                                                ConvertUnits.ToSimUnits(GraphicsDevice.Viewport.Width),
                                                ConvertUnits.ToSimUnits(floorHeight),
                                                10f);
            //_floor.Position = ConvertUnits.ToSimUnits(GraphicsDevice.Viewport.Width / 2, GraphicsDevice.Viewport.Height - 50);
            Vector2 posi = new Vector2(GraphicsDevice.Viewport.Width / 2, GraphicsDevice.Viewport.Height - floorHeight/2);
            _floor.Position = ConvertUnits.ToSimUnits(posi);
            _floor.BodyType = BodyType.Static;
            _floor.IsStatic = true;
            _floor.Restitution = 0.1f;
            _floor.Friction = 2.5f;
            _floor.OnCollision += new OnCollisionEventHandler(CheckFloorCollision);
            // Tworzenie platformy
            _platform = BodyFactory.CreateRectangle(world,
                                                ConvertUnits.ToSimUnits(platformWidth),
                                                ConvertUnits.ToSimUnits(platformHeight),
                                                10f);
            //_platform.Position = ConvertUnits.ToSimUnits(GraphicsDevice.Viewport.Width / 2, GraphicsDevice.Viewport.Height - 100);
            Vector2 posi2 = new Vector2(GraphicsDevice.Viewport.Width / 2, GraphicsDevice.Viewport.Height - platformHeight/2 - floorHeight);
            _platform.Position = ConvertUnits.ToSimUnits(posi2);
            _platform.BodyType = BodyType.Static;
            _platform.IsStatic = true;
            _platform.Restitution = 0.1f;
            _platform.Friction = 5.0f;

            // Żaden blok nie spada
            blockOnHisWay = false;

            // lista bloków leżących na platformie
            yOfBlocksOnPlatform = new List<float>();

            timer = new Timer(1000);
            timer.Elapsed += new System.Timers.ElapsedEventHandler(timerCallback);
            timer.Start();
        }
Ejemplo n.º 52
0
        public override void LoadContent()
        {
            // We add to the GameServices objects that we want to be able to use accross different classes
            // without having to pass them explicitly every time.
            GraphicsDevice = GameServices.GetService<GraphicsDevice>();
            Content = GameServices.GetService<ContentManager>();
            graphics = GameServices.GetService<GraphicsDeviceManager>();
            soundManager = GameServices.GetService<SoundManager>();

            ScreenManager.AddScreen(RankScreen, null, false);
            ScreenManager.AddScreen(PauseScreen, null, false);

            world = new World(new Vector2(0, 0));
            GameServices.AddService<World>(world);

            this.world.ContactManager.PostSolve += new PostSolveDelegate(PostSolve);

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

            // Create a new track
            randomRaceTrack = RandomTrack.createTrack();

            randomRaceTrack.polygonList = polygonsList;

            int[] crucialPoints = { 300, 600, 1000 };
            Logic = new GameLogic(crucialPoints, randomRaceTrack.curvePointsMiddle.Count);

            randomRaceTrack.gameLogic = Logic;
            Logic.DidFinishLap += randomRaceTrack.ResetStickyNotes;

            mySneezesManager.randomTrack = randomRaceTrack;

            LoadPaperEffect();

            screenRenderer = new ScreenRenderer();
            GameServices.AddService<ScreenRenderer>(screenRenderer);
            Logic.DidEliminateCar += screenRenderer.setSadToPlayer;
            Logic.DidFinishLap += screenRenderer.setLap;

            for (int i = 0; i < 4; i++)
            {
                Car aCar = new Car(world, Content.Load<Texture2D>("Images/small_car"), Color.White, randomRaceTrack, i, playerIndexes[i]);
                Cars.Add(aCar);
            }

            assetCreator = new AssetCreator(graphics.GraphicsDevice);
            assetCreator.LoadContent(this.Content);

            defaultViewport = GraphicsDevice.Viewport;

            isFullHd=(ScreenManager.preferredHeight!=720);

            // Single screen mode only
            cameraFollowing = new Camera(defaultViewport, Vector2.Zero, new Vector2(defaultViewport.Width / 2, defaultViewport.Height / 2), 0.0f, Cars.Count, isFullHd);
            //ZOOM:

            //low res:
            //0.95 for 2 players
            //0.93 for 3 players
            //0.91 for 4 players

            //high res:
            //0.95 for 4 players

            GameServices.AddService<Camera>(cameraFollowing);

            mySneezesManager.camera = cameraFollowing;

            //generate starting positions and angles
            int startingPoint = 0;
               // positionCars(startingPoint);

            _debugView = new DebugViewXNA(world);
            _debugView.AppendFlags(FarseerPhysics.DebugViewFlags.Shape);
            _debugView.AppendFlags(FarseerPhysics.DebugViewFlags.DebugPanel);
            _debugView.AppendFlags(FarseerPhysics.DebugViewFlags.PerformanceGraph);
            _debugView.AppendFlags(FarseerPhysics.DebugViewFlags.Joint);
            _debugView.AppendFlags(FarseerPhysics.DebugViewFlags.ContactPoints);
            _debugView.AppendFlags(FarseerPhysics.DebugViewFlags.ContactNormals);
            _debugView.AppendFlags(FarseerPhysics.DebugViewFlags.Controllers);
            _debugView.AppendFlags(FarseerPhysics.DebugViewFlags.CenterOfMass);
            _debugView.AppendFlags(FarseerPhysics.DebugViewFlags.AABB);
            _debugView.DefaultShapeColor = Color.White;
            _debugView.SleepingShapeColor = Color.LightGray;
            _debugView.LoadContent(GraphicsDevice, Content);

            basicVert = new VertexPositionColorTexture[maxNumberOfTriangles];
            for (int i = 0; i < maxNumberOfTriangles; i++) basicVert[i].TextureCoordinate = new Vector2(-1);

            verticesBorders = new VertexPositionColorTexture[randomRaceTrack.curvePointsInternal.Count];

            fluid = new Fluid();
            fluid.Init();

            currentPoses = new Vector2[4];
            prevPoses = new Vector2[4];

            currentMousePos = new Vector2(100);
            prevMousePos = new Vector2(0);

            quad = new QuadRenderComponent(ScreenManager.Game, cameraFollowing, ScreenManager.GraphicsDevice.Viewport.Width, ScreenManager.GraphicsDevice.Viewport.Height);
            ScreenManager.Game.Components.Add(quad);

            fluidUpdateThread = new Thread(this.UpdateFluid);
            fluidUpdateThread.Start();

            mySneezesManager.fluid = fluid;

            fluidEffect = Content.Load<Effect>("Shaders/FluidEffect");
            fluidEffect.Parameters["random"].SetValue(randomTex);

            texInk = new Texture2D(graphics.GraphicsDevice,
                fluid.m_w, fluid.m_h, true,
                SurfaceFormat.Color);
            buffer = new RenderTarget2D(GraphicsDevice, ScreenManager.GraphicsDevice.Viewport.Width, ScreenManager.GraphicsDevice.Viewport.Height, true,
                SurfaceFormat.Color, GraphicsDevice.PresentationParameters.DepthStencilFormat);

            //gaussian = new GaussianBlur(ScreenManager.Game);
        }
Ejemplo n.º 53
0
        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);
        }
Ejemplo n.º 54
0
        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            // TODO: Add your initialization logic here

            base.Initialize();

            PhysicsConstants.Gravity = Vector2.Zero;

            EditorProperties.Instance = new EditorProperties()
            {
                ShowGridLines = false,
                GridLineSpacing = 16,
                EnableSnapping = false,
                ResolutionX = ResolutionWidth,
                ResolutionY = ResolutionHeight
            };

            camera = new Camera(Vector2.One, Vector3.Zero);

            // create default level
            LevelManager = Container.Resolve<LevelManager>();
            LevelManager.LevelLoaded += new LevelLoadedEventHandler(
                () =>
                {
                    debugView = new DebugViewXNA(LevelManager.PhysicsManager.World);
                    debugView.LoadContent(GraphicsDevice, Content);
                });
            LevelManager.GeometryReset += new GeometryResetEventHandler(
                () =>
                {
                    debugView = new DebugViewXNA(LevelManager.PhysicsManager.World);
                    debugView.LoadContent(GraphicsDevice, Content);
                });

            debugView = new DebugViewXNA(LevelManager.PhysicsManager.World);
            debugView.LoadContent(GraphicsDevice, Content);

            // set up state machine
            initState = new DefaultEditorState(this, camera, TextureCache);
            stateMachine = new StateMachine<LevelManager>(initState, LevelManager);
            initState.StateMachine = stateMachine;

            Database = Container.Resolve<SQLiteDatabase>();

            // this is a hack to activate the game inside a wpf control automatically
            typeof(Game).GetMethod("HostActivated", BindingFlags.NonPublic | BindingFlags.Instance)
                .Invoke(this, new object[] { this, null });
        }
Ejemplo n.º 55
0
 protected virtual void LevelLoaded()
 {
     debugView = new DebugViewXNA(LevelManager.PhysicsManager.World);
     debugView.LoadContent(GraphicsDevice, Content);
 }
Ejemplo n.º 56
0
        public void LoadContent()
        {
            _spriteBatch = new SpriteBatch(_graphics);
            _world = new DynamicEntityWorld(_game.Services);
            var pp = _graphics.PresentationParameters;

            _debugView = new DebugViewXNA(_world.PhysicsWorld);
            _debugView.LoadContent(_graphics, _content);

            _camera = new DefaultCamera(null, new Viewport(0, 0, pp.BackBufferWidth, pp.BackBufferHeight));
            _cameraNode = _world.Scene.Root.CreateChild("Camera");
            _cameraNode.Attach(_camera);

            // Create the tile map.
            var terrainSize = new Vector2(4096.0f, 2048.0f);
            _terrain = new Terrain(terrainSize, 128.0f, 7)
            {
                DebugEnabled = false,
                Position = new Vector3(50.0f, -terrainSize.Y / 2.0f, 0.0f),
                TextureName = @"Textures\SpaceRock"
            };
            _world.Add(_terrain);

            GenerateTunnels(new Vector2(50.0f, 0));

            // Create the circle brush.
            _circleBrush = new CircleBrush(2.5f);

            _circleBrushNode = _world.Scene.CreateSceneNode();
            _circleBrushNode.Attach(new CircleRenderable(2.5f, 64)
            {
                Color = Vector3.One
            });

            // Dust cloud
            _dustCloud = _world.Scene.CreateSceneNode("DustCloud");
            _dustCloud.Position = new Vector3(0.0f, 0.0f, -1.0f);
            _dustCloud.Attach(new DustCloud());
            _world.Scene.Root.AddChild(_dustCloud);

            // Player
            _playerEntity = new SpaceShip();
            _playerEntity.Attach(new PlayerController());
            _playerEntity.Orientation = Quaternion.CreateFromAxisAngle(Vector3.UnitZ, MathHelper.ToRadians(90.0f));
            _world.Add(_playerEntity);

            _payloadEntity = new Payload();
            _payloadEntity.Orientation = Quaternion.CreateFromAxisAngle(Vector3.UnitZ, MathHelper.ToRadians(90.0f));
            _world.Add(_payloadEntity);

            _payloadChain = PayloadChain.Connect(_playerEntity, _payloadEntity, Vector2.UnitX * -20.0f);
        }
        private void LoadWorld()
        {
            ConvertUnits.SetDisplayUnitToSimUnitRatio(64f);

            world = new World(new Vector2(0, 9.81f));

            debugView = new DebugViewXNA(world);
            debugView.LoadContent(graphics.GraphicsDevice, Content);

            List<Body> bodies = new List<Body>();
            foreach (var objLayer in map.Map.ObjectGroups)
            {
                foreach (var obj in objLayer.Objects)
                {
                    Body body = U.InsertBody(obj, world);
                    body.UserData = new UserData();
                    bodies.Add(body);
                }
            }
            IterateBodies(bodies);
        }
Ejemplo n.º 58
0
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            // Initialize camera controls
            _screenCenter = new Vector2(_graphics.GraphicsDevice.Viewport.Width / 2, _graphics.GraphicsDevice.Viewport.Height / 2);
            _Camera = new Camera2D(Window.ClientBounds, new Rectangle(0, 0, 2000, 2000));
            _Camera.Position = _screenCenter;

            _batch = new SpriteBatch(_graphics.GraphicsDevice);
            _font = Content.Load<SpriteFont>(@"GameScreen/Fonts/diagnosticFont");
            _World = new World(new Vector2(0, 20));

            _Level = new Level("Level 1", _Camera);
            _Level.LoadContent(_graphics.GraphicsDevice, Content);
            Layer layer = _Level.AddLayer("Layer 1", Vector2.One);

            Box box1 = Factory.Instance.AddBox(layer, "Ground", @"General/Textures/FrozenMetalGroundV1[1]", new Vector2(800, 700), 937, 32);
            box1.Limbs[0].Body.BodyType = FarseerPhysics.Dynamics.BodyType.Static;

            Body ground = BodyFactory.CreateRectangle(_World, 937 / MeterInPixels, 32 / MeterInPixels, 1);
            ground.BodyType = BodyType.Static;
            ground.Position = new Vector2(800, 700) / MeterInPixels;
            ground.Friction = .5f;

            for (int i = 0; i <= 5; i++)
            {
                Box box2 = Factory.Instance.AddBox(layer, "Box", @"General/Textures/BlueBoxV1[1]", new Vector2(500 + 50 * i, 50), 26, 27);
                box2.Limbs[0].Body.Restitution = .1f * i;
                box2.Limbs[0].Body.Mass = 1 + 10 * i;
            }

            box = BodyFactory.CreateRectangle(_World, 26 / MeterInPixels, 27 / MeterInPixels, 1);
            box.BodyType = BodyType.Dynamic;
            box.Restitution = .5f;
            //box.Mass = 51;
            box.Position = new Vector2(900, 50) / MeterInPixels;
            box.Position = (_screenCenter / MeterInPixels);

            _debugViewLevel = new DebugViewXNA(_Level.World);
            _debugViewLevel.Enabled = true;
            _debugViewLevel.LoadContent(_graphics.GraphicsDevice, Content);

            _debugView = new DebugViewXNA(_World);
            _debugView.Enabled = true;
            _debugView.LoadContent(_graphics.GraphicsDevice, Content);
        }
Ejemplo n.º 59
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);
        }
Ejemplo n.º 60
0
        protected override void Initialize()
        {
            //primBatch = new PrimitiveBatch(GraphicsDevice);
            World = new World(new Vector2(0, 9.81f));
            Mathe = new Mathe();
            Settings = new Settings(graphics);
            Camera = new Camera(GraphicsDevice.Viewport, Settings.Widescreen);
            Contents = new Contents(Content, GraphicsDevice);
            Debug = new DebugView(Contents,Camera);
            Objectdatabase = new Objectdatabase(Content);
            Backgrounddatabase = new Backgrounddatabase(Content);
            Enemydatabase = new Enemydatabase(Content);
            Animationsmanager = new Animationsmanager();
            Keymanager = new Keymanager(Contents, DebugFlag.Inputstats);
            Player = new Player(Mathe, Contents, World, DebugFlag.PlayerStats);
            Cursor = new Cursor(Camera, Keymanager, Contents, Settings);
            Windowmanager = new Windowmanager(Settings, Cursor, DebugFlag.WindowStats, Contents, GraphicsDevice);
            DepressionHandler = new DyingHope.DepressionHandler();
            Itemmanager = new Itemmanager(Mathe, DepressionHandler, Content, Player);
            Backgroundmanager = new Backgroundmanager(Player, Backgrounddatabase, DebugFlag.BackgrundStats, Contents);
            Levermanager = new Levermanager(Contents.Meiryo8, Player, Cursor, Mathe, Animationsmanager, Contents);
            Objectmanager = new Objectmanager(Objectdatabase, Animationsmanager, Player, (DebugFlag.ObjectInformation | DebugFlag.CollisonShape | DebugFlag.ObjectmanagerStats));
            Enemymanager = new Enemymanager(Objectmanager, Mathe, Content, Enemydatabase, Player);
            Windowmanager.Windowdatabase = new Windowdatabase(Contents, Player, Inputmanager);
            Windowmanager.AddWindow(Windowtype.MainMenue);
            Eventmanager = new Eventmanager(Mathe, Player, Enemymanager, DepressionHandler, Objectmanager, Objectdatabase, Levermanager);
            Levelmanager = new Levelmanager(Player, Objectmanager, Animationsmanager, Backgroundmanager, Enemymanager, Itemmanager, Levermanager, Eventmanager, Contents);
            Editor = new Editor(Windowmanager, Enemymanager, Backgroundmanager, Backgrounddatabase, Objectmanager, Objectdatabase, Eventmanager, Contents, Cursor, Player, Keymanager, Levelmanager, Itemmanager, Levermanager);
            Debugview = new DebugViewXNA(World);
            Console.WriteLine(((DebugFlag.ObjectInformation | DebugFlag.CollisonShape | DebugFlag.ObjectmanagerStats)& DebugFlag.ObjectmanagerStats));
            light = new SoundObjekt(Settings, Contents.Emitter, Contents.Light, new Vector2(3500 - 576, 700), new Vector2(100, 0), 200);
            rain = new SoundObjekt(Settings, Contents.Emitter, Contents.Rain, new Vector2(6000 - 576, 0), new Vector2(1000, 0), 400);
            levelTheme = new List<MSong> { new MSong(Contents.StadtAnfang, 0), new MSong(Contents.StadtLoop, -1), new MSong(Contents.StadtEnde, 0), new MSong(Contents.ParkAnfang, 0), new MSong(Contents.ParkLoop, -1), new MSong(Contents.ParkEnde, 0), new MSong(Contents.SchuleAnfang, 0), new MSong(Contents.SchuleLoop, -1), new MSong(Contents.StadtEnde, 0), new MSong(Contents.MonsterAnfang, 0), new MSong(Contents.MonsterLoop, -1), new MSong(Contents.Ende, 0) };
            menueTheme = new List<MSong> { new MSong(Contents.Menue_Theme, 99) };
            BackgroundMusic = new BackgroundMusic(Settings, menueTheme);
            Inputmanager = new Inputmanager(Contents, Camera, Player, Keymanager, Cursor, Enemymanager, Windowmanager, Backgroundmanager, Backgrounddatabase, Objectmanager, Objectdatabase, Eventmanager, Levelmanager, Levermanager, Content, Editor, Debug, DepressionHandler, Mathe, Itemmanager, BackgroundMusic);

            //Testemitter-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
            //testEmitter = new Emitter(new Vector2(3000, 850), DebugFlag.Pertikle);
            //testEmitter.startParticel = 50;
            //testEmitter.EmitterAngel = new List<Vector2> { new Vector2(180, 180) };
            //testEmitter.EmitterRange = new Vector2(1000, 50);
            //testEmitter.EmitterMaxParticel = 100;
            //testEmitter.EmitterUpdate = 100f;
            //testEmitter.EmitterTexture = Contents.Emitter;
            //testEmitter.ParticelStayOnMax = new Vector2(0, 0);
            //testEmitter.ParticelLifeDrain = new Vector2(1, 1);
            //testEmitter.ParticelLifeTime = new Vector2(5000f, 50000f);
            //testEmitter.ParticelSize = new Vector2(0.1f, 0.5f);
            //testEmitter.ParticelTexture = new List<Texture2D> { Contents.Nebel, Contents.Nebel2 };
            //testEmitter.Origin = new Vector2(Contents.Emitter.Width / 2, Contents.Emitter.Height / 2);
            //testEmitter.PerticelPower = new Vector2(0.50f, 0.8f);
            //testEmitter.particelNeverDie = false;
            //testEmitter.spawnprofile = Spawnprofile.FadeIn;
            //testEmitter.bewegungsprofil = Bewegungsprofile.Linear;
            //testEmitter.Start();

            //rainEmitter = new Emitter(new Vector2(6000, -10), DebugFlag.Pertikle);
            //rainEmitter.startParticel = 0;
            //rainEmitter.particelPerUpdate = new Vector2(1, 100);
            //rainEmitter.EmitterAngel = new List<Vector2> { new Vector2(270, 270) };
            //rainEmitter.EmitterRange = new Vector2(1000, 0);
            //rainEmitter.EmitterMaxParticel = 60000;
            //rainEmitter.EmitterUpdate = 10f;
            //rainEmitter.EmitterTexture = Contents.Emitter;
            //rainEmitter.ParticelStayOnMax = new Vector2(0, 0);
            //rainEmitter.ParticelLifeDrain = new Vector2(1, 1);
            //rainEmitter.ParticelLifeTime = new Vector2(500f, 2000f);
            //rainEmitter.ParticelSize = new Vector2(0.5f, 1.5f);
            //rainEmitter.ParticelTexture = new List<Texture2D> { Contents.Rain1 };
            //rainEmitter.Origin = new Vector2(Contents.Emitter.Width / 2, Contents.Emitter.Height / 2);
            //rainEmitter.PerticelPower = new Vector2(10.50f, 20.8f);
            //rainEmitter.particelNeverDie = false;
            //rainEmitter.spawnprofile = Spawnprofile.Instant;
            //rainEmitter.bewegungsprofil = Bewegungsprofile.Linear;
            //rainEmitter.Start();

            menue = new Emitter(new Vector2(GraphicsDevice.Viewport.Width / 2, (GraphicsDevice.Viewport.Height / 2)+20), DebugFlag.Pertikle);
            menue.startParticel = 0;
            menue.particelPerUpdate = new Vector2(1, 5);
            menue.EmitterAngel = new List<Vector2> { new Vector2(0, 360) };
            menue.EmitterRange = new Vector2(250, 50);
            menue.EmitterMaxParticel = 6000;
            menue.EmitterUpdate = 100f;
            menue.EmitterTexture = Contents.Emitter;
            menue.ParticelStayOnMax = new Vector2(0, 100);
            menue.ParticelLifeDrain = new Vector2(1, 1);
            menue.ParticelLifeTime = new Vector2(1000f, 3000f);
            menue.ParticelSize = new Vector2(0.065f, 0.09f);
            menue.ParticelTexture = new List<Texture2D> { Contents.Partikel1, Contents.Partikel2, Contents.Partikel3 };
            menue.Origin = new Vector2(Contents.Emitter.Width / 2, Contents.Emitter.Height / 2);
            menue.PerticelPower = new Vector2(0.2f, 0.9f);
            menue.particelNeverDie = false;
            menue.spawnprofile = Spawnprofile.FadeIn;
            menue.bewegungsprofil = Bewegungsprofile.LinearRandom;
            menue.Start();

            //Debug-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
            Debug.Add(Player);
            Debug.Add(Objectmanager);
            Debug.Add(Keymanager);
            Debug.Add(Backgroundmanager);
            Debug.Add(Windowmanager);
            Debug.Add(DepressionHandler);
            //Debug.Add(testEmitter);
            //Debug.AppendFlag(DebugFlag.PlayerStats, false);
            //Debug.AppendFlag(DebugFlag.ObjectmanagerStats,false);
            //Debug.AppendFlag(DebugFlag.ObjectInformation, true);
            //Debug.AppendFlag(DebugFlag.CollisonShape, true);
            Debugview.DebugPanelPosition = new Vector2(500, 100);
            Debugview.AppendFlags(DebugViewFlags.DebugPanel);
            Debugview.LoadContent(GraphicsDevice, Content);

            base.Initialize();
        }