Esempio n. 1
0
    public static void InitializeWithScene()
    {
        initSettings  = InitializeSettings.LoadFromResources();
        entityManager = World.Active.GetOrCreateManager <EntityManager>();

        LevelGenerator.ImportWater(entityManager, waterArchetype, initSettings);
        LevelGenerator.ImportMap(entityManager, blockArchetype, initSettings);

        GameObjectsGenerator.ImportPlayer(entityManager, playerArchetype, initSettings);
        GameObjectsGenerator.ImportEnemy(entityManager, enemyArchetype, initSettings);
        GameObjectsGenerator.ImportItem(entityManager, itemArchetype, initSettings);
    }
Esempio n. 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);
    }