예제 #1
0
 private static void LoadArchetypes(EntityManager em)
 {
     playerArchetype = ObjectsEntityFactory.CreatePlayerArchetype(em);
     enemyArchetype  = ObjectsEntityFactory.CreateEnemyArchetype(em);
     itemArchetype   = ObjectsEntityFactory.CreateItemArchetype(em);
     blockArchetype  = ObjectsEntityFactory.CreateBlockArchetype(em);
     waterArchetype  = ObjectsEntityFactory.CreateWaterArchetype(em);
 }
예제 #2
0
    public void ReLoadScene()
    {
        EntityManager      em           = World.Active.GetOrCreateManager <EntityManager>();
        InitializeSettings initSettings = InitializeSettings.LoadFromResources();

        EntityArchetype playerArchetype;
        EntityArchetype enemyArchetype;
        EntityArchetype itemArchetype;
        EntityArchetype blockArchetype;
        EntityArchetype waterArchetype;


        int levelLength             = initSettings.levelLength;
        int levelHeight             = initSettings.levelHeight;
        NativeArray <Entity> sector = new NativeArray <Entity>(500, Allocator.Temp);

        sector = em.GetAllEntities(Allocator.Temp);
        for (int i = 0; i < sector.Length; i++)
        {
            em.DestroyEntity(sector[i]);
        }

        playerArchetype = ObjectsEntityFactory.CreatePlayerArchetype(em);
        enemyArchetype  = ObjectsEntityFactory.CreateEnemyArchetype(em);
        itemArchetype   = ObjectsEntityFactory.CreateItemArchetype(em);
        blockArchetype  = ObjectsEntityFactory.CreateBlockArchetype(em);
        waterArchetype  = ObjectsEntityFactory.CreateWaterArchetype(em);

        LevelGenerator.ImportWater(em, waterArchetype, initSettings);

        LevelGenerator.ImportMap(em, blockArchetype, initSettings);

        GameObjectsGenerator.ImportPlayer(em, playerArchetype, initSettings);
        GameObjectsGenerator.ImportEnemy(em, enemyArchetype, initSettings);
        GameObjectsGenerator.ImportItem(em, itemArchetype, initSettings);
    }