Пример #1
0
    private void Clear()
    {
        //Remove tiles
        if (tiles != null)
        {
            for (int i = 0; i < tiles.Length; i++)
            {
                if (tiles[i])
                {
                    tilesPool.ReturnTile(tiles[i]);
                }
            }
            tiles = null;
        }

        //Remove entities
        for (int i = 0; i < entities.Count; i++)
        {
            entityFactory.DestroyEntity(entities[i]);
        }
        entities.Clear();

        //Clear events queue
        dungeonEventsQueue.Clear();

        //Remove shadow tiles
        if (shadowTiles != null)
        {
            for (int i = 0; i < shadowTiles.Length; i++)
            {
                if (shadowTiles[i])
                {
                    shadowTilesPool.ReturnShadowTile(shadowTiles[i]);
                }
            }

            shadowTiles = null;
        }

        currentDungeonEventHandler = null;

        if (dungeon != null)
        {
            dungeon.SetDungeonListener(null);
            dungeon = null;
        }

        for (int i = combinedTilesContainer.childCount - 1; i >= 0; i--)
        {
            GameObject.Destroy(combinedTilesContainer.GetChild(i).gameObject);
        }
    }
Пример #2
0
    private void UpdateEventsQueue()
    {
        if (currentDungeonEventHandler == null)
        {
            if (!dungeonEventsQueue.IsEmpty)
            {
                DungeonEvent dungeonEvent = dungeonEventsQueue.DequeueEvent();

                currentDungeonEventHandler = eventHandlerFactory.CreateEventHandler(this, dungeonEvent);
            }
        }

        if (currentDungeonEventHandler != null)
        {
            if (currentDungeonEventHandler.Update())
            {
                currentDungeonEventHandler = null;
            }
        }
    }