Ejemplo n.º 1
0
        public static TileMap Load(TileMapBluePrint tileMapBluePrint, MainSystem mainSystem)
        {
            TileMap tileMap = new TileMap();

            for (int i = 0; i < tileMapBluePrint.TileMap.Length; ++i)
            {
                for (int j = 0; j < tileMapBluePrint.TileMap[i].Length; ++j)
                {
                    if (tileMapBluePrint.TileMap[i][j] != null)
                    {
                        tileMap.TileIDs.Add(TileFactory.CreateTile(mainSystem, tileMapBluePrint.TileMap[i][j], new Vector2(i, j), tileMapBluePrint.TileDimensions));
                    }
                }
            }

            return tileMap;
        }
Ejemplo n.º 2
0
        public RougeSpyGameScene(SceneHandler handler, string name, IConnector connector, GraphicsDeviceManager graphicsDeviceManager)
            : base(handler, name, connector, graphicsDeviceManager)
        {
            //movement system
            MainSystem.UpdateComplexSystem.AddSubSystem(new InputUpdateSystem(MainSystem));
            MainSystem.UpdateComplexSystem.AddSubSystem(new CalculateMovementUpdateSystem(MainSystem));
            MainSystem.UpdateComplexSystem.AddSubSystem(new HitBoxCollisionUpdateSystem(MainSystem));
            MainSystem.UpdateComplexSystem.AddSubSystem(new ApplyMovementUpdateSystem(MainSystem));
            MainSystem.UpdateComplexSystem.AddSubSystem(new HitBoxUpdateSystem(MainSystem));

            //render system
            MainSystem.RenderComplexSystem.AddSubSystem(new Texture2DRenderSystem(MainSystem));
            MainSystem.RenderComplexSystem.AddSubSystem(new HitBoxRenderSystem(MainSystem, 2));

            //Player
            PlayerID = MainSystem.CreateEntityID();
            MainSystem.GetUpdateSystem<InputUpdateSystem>().CreateInputNode(PlayerID, new GamePadInput());
            MainSystem.GetUpdateSystem<CalculateMovementUpdateSystem>().CreateMovementNode(PlayerID);
            MainSystem.GetUpdateSystem<ApplyMovementUpdateSystem>().CreateMovementNode(PlayerID);
            MainSystem.GetComponent<Motion2DComponent>(PlayerID).Acceleration = 0.2f;
            MainSystem.GetComponent<Motion2DComponent>(PlayerID).Decceleration = 0.3f;
            MainSystem.GetComponent<Motion2DComponent>(PlayerID).MaxSpeed = 10.0f;
            Texture2D texture = AssetLoader.Instance.Load<Texture2D>("Player_Alpha_64_43");
            MainSystem.GetRenderSystem<Texture2DRenderSystem>().CreateTexture2DRenderNode(PlayerID, texture);
            MainSystem.GetComponent<Position2DComponent>(PlayerID).Position = new Vector2(200);
            MainSystem.GetComponent<Position2DComponent>(PlayerID).Origin = new Vector2(texture.Width / 2, texture.Height / 2);

            List<Vector2> points = new List<Vector2>();
            points.Add(Vector2.Zero);
            points.Add(new Vector2(texture.Width - 24, 0));
            points.Add(new Vector2(texture.Width - 24, texture.Height));
            points.Add(new Vector2(0, texture.Height));
            MainSystem.GetUpdateSystem<HitBoxUpdateSystem>().CreateHitBoxNode(PlayerID, points);
            MainSystem.GetComponent<HitBox2DComponent>(PlayerID).Offset = new Vector2(12, 0);
            MainSystem.GetUpdateSystem<HitBoxCollisionUpdateSystem>().CreateHitBoxCollisionUpadateNode(PlayerID, points, new PositionCorrectionHitBoxIntersectionReaction(MainSystem, PlayerID));
            MainSystem.GetRenderSystem<HitBoxRenderSystem>().CreateHitBoxRenderNode(PlayerID, points);

            string[][] blueprint = new string[3][];
            blueprint[0] = new string[] { "w", "w", "w" };
            blueprint[1] = new string[] { "w", " ", "w" };
            blueprint[2] = new string[] { "w", "w", "w" };

            List<Vector2> hitBoxOutline = new List<Vector2>();
            hitBoxOutline.Add(new Vector2(0, 0));
            hitBoxOutline.Add(new Vector2(64, 0));
            hitBoxOutline.Add(new Vector2(64, 64));
            hitBoxOutline.Add(new Vector2(0, 64));

            List<TileBluePrint> tileBluePrints = new List<TileBluePrint>();
            tileBluePrints.Add(new TileBluePrint("w", AssetLoader.Instance.Load<Texture2D>("WoodenTileA"), hitBoxOutline));
            TileMapBluePrint tileMapBluePrint = new TileMapBluePrint(blueprint, tileBluePrints, new Vector2(64,64));
            TileMapLoader.Load(tileMapBluePrint, MainSystem);            
        }