Exemple #1
0
        public static uint CreateTile(MainSystem mainSystem, TileBluePrint tileBluePrint, Vector2 relativPosition, Vector2 tileDimensions)
        {
            uint id = mainSystem.CreateEntityID();
            Vector2 position = new Vector2(relativPosition.X * tileDimensions.X, relativPosition.Y * tileDimensions.Y);

            mainSystem.GetRenderSystem<Texture2DRenderSystem>().CreateTexture2DRenderNode(id, tileBluePrint.Texture2D);
            mainSystem.GetComponent<Position2DComponent>(id).Origin = new Vector2(tileDimensions.Y / 2, tileDimensions.X / 2);
            mainSystem.GetComponent<Position2DComponent>(id).Position = position;

            if (tileBluePrint.HitBoxOutline != null)
            {
                mainSystem.GetRenderSystem<HitBoxRenderSystem>().CreateHitBoxRenderNode(id, tileBluePrint.HitBoxOutline);
                mainSystem.GetComponent<HitBox2DComponent>(id).Position = position;
                mainSystem.GetUpdateSystem<HitBoxCollisionUpdateSystem>().CreateHitBoxCollisionUpadateNode(id, tileBluePrint.HitBoxOutline, null);
                mainSystem.GetComponent<HitBox2DComponent>(id).Position = position;

            }
            
            return id;
        }
        private void CreateMapping(string[][] mapBluePrint, List<TileBluePrint> tileBluePrints)
        {
            foreach (TileBluePrint tileBluePrint in tileBluePrints)
            {
                AddTileBluePrint(tileBluePrint);
            }

            TileMap = new TileBluePrint[mapBluePrint.Length][];
            for (int i = 0; i < mapBluePrint.Length; ++i)
            {
                TileMap[i] = new TileBluePrint[mapBluePrint[i].Length];
                for (int j = 0; j < mapBluePrint[i].Length; ++j)
                {
                    if (TileBluePrintMapping.ContainsKey(mapBluePrint[i][j]))
                    {
                        TileMap[i][j] = TileBluePrintMapping[mapBluePrint[i][j]];
                    }
                }
            }
        }
 private void AddTileBluePrint(TileBluePrint tileBluePrint) 
 {
     TileBluePrintMapping.Add(tileBluePrint.Identifier.ToString(), tileBluePrint);
 }