Пример #1
0
    public void Start()
    {
        // Create the root widget group
        m_rootWidgetGroup = new WidgetGroup(null, Screen.width, Screen.height, 0.0f, 0.0f);
        m_rootWidgetGroup.SetWidgetEventListener(this);

        m_widgetEventDispatcher = new WidgetEventDispatcher();
        m_widgetEventDispatcher.Start(m_rootWidgetGroup);

        // Create the background
        m_backgroundGroup       = new WidgetGroup(m_rootWidgetGroup, Screen.width, Screen.height, 0.0f, 0.0f);
        m_backgroundTiles       = null;
        m_wallTiles             = null;
        m_backgroundObjectTiles = null;

        // Create the foreground object group
        m_entityGroup = new WidgetGroup(m_rootWidgetGroup, Screen.width, Screen.height, 0.0f, 0.0f);

        // Create the foreground tile group
        m_foregroundGroup       = new WidgetGroup(m_rootWidgetGroup, Screen.width, Screen.height, 0.0f, 0.0f);
        m_foregroundObjectTiles = null;

        // Create the foreground UI
        m_foregroundUIGroup = new WidgetGroup(m_rootWidgetGroup, Screen.width, Screen.height, 0.0f, 0.0f);

        // Create game button
        m_logoutButton = new ButtonWidget(m_foregroundUIGroup, buttonStyle, 0, 0, "Logout");

        // Create the event navigation buttons
        {
            float layoutX = 0;
            float layoutY = Screen.height - buttonStyle.Height;

            m_firstEventButton = new ButtonWidget(m_foregroundUIGroup, buttonStyle, layoutX, layoutY, "<<");

            layoutX += m_firstEventButton.Width;
            m_previousEventButton = new ButtonWidget(m_foregroundUIGroup, buttonStyle, layoutX, layoutY, "<");

            layoutX += m_previousEventButton.Width;
            m_playPauseEventButton = new ButtonWidget(m_foregroundUIGroup, buttonStyle, layoutX, layoutY, "||");

            layoutX          += m_playPauseEventButton.Width;
            m_nextEventButton = new ButtonWidget(m_foregroundUIGroup, buttonStyle, layoutX, layoutY, ">");

            layoutX          += m_nextEventButton.Width;
            m_lastEventButton = new ButtonWidget(m_foregroundUIGroup, buttonStyle, layoutX, layoutY, ">>");
        }
    }
Пример #2
0
    public void Start()
    {
        // Create the root widget group
        m_rootWidgetGroup = new WidgetGroup(null, Screen.width, Screen.height, 0.0f, 0.0f);
        m_rootWidgetGroup.SetWidgetEventListener(this);

        m_widgetEventDispatcher = new WidgetEventDispatcher();
        m_widgetEventDispatcher.Start(m_rootWidgetGroup);

        // Create the background
        m_backgroundGroup = new WidgetGroup(m_rootWidgetGroup, Screen.width, Screen.height, 0.0f, 0.0f);
        m_backgroundTiles = null;
        m_wallTiles = null;
        m_backgroundObjectTiles = null;

        // Create the foreground object group
        m_entityGroup = new WidgetGroup(m_rootWidgetGroup, Screen.width, Screen.height, 0.0f, 0.0f);

        // Create the foreground tile group
        m_foregroundGroup = new WidgetGroup(m_rootWidgetGroup, Screen.width, Screen.height, 0.0f, 0.0f);
        m_foregroundObjectTiles = null;

        // Create the foreground UI
        m_foregroundUIGroup = new WidgetGroup(m_rootWidgetGroup, Screen.width, Screen.height, 0.0f, 0.0f);

        // Create game button
        m_logoutButton = new ButtonWidget(m_foregroundUIGroup, buttonStyle, 0, 0, "Logout");

        // Create the event navigation buttons
        {
            float layoutX = 0;
            float layoutY = Screen.height - buttonStyle.Height;

            m_firstEventButton = new ButtonWidget(m_foregroundUIGroup, buttonStyle, layoutX, layoutY, "<<");

            layoutX += m_firstEventButton.Width;
            m_previousEventButton = new ButtonWidget(m_foregroundUIGroup, buttonStyle, layoutX, layoutY, "<");

            layoutX += m_previousEventButton.Width;
            m_playPauseEventButton = new ButtonWidget(m_foregroundUIGroup, buttonStyle, layoutX, layoutY, "||");

            layoutX += m_playPauseEventButton.Width;
            m_nextEventButton = new ButtonWidget(m_foregroundUIGroup, buttonStyle, layoutX, layoutY, ">");

            layoutX += m_nextEventButton.Width;
            m_lastEventButton = new ButtonWidget(m_foregroundUIGroup, buttonStyle, layoutX, layoutY, ">>");
        }
    }
Пример #3
0
    public void RebuildRoom(RoomData room)
    {
        if (m_backgroundTiles == null)
        {
            m_backgroundTiles = new TileGridWidget(m_backgroundGroup, "BackgroundTiles", Screen.width, Screen.height, 3, 0.0f, 0.0f);
        }

        if (m_wallTiles == null)
        {
            m_wallTiles = new TileGridWidget(m_backgroundGroup, "WallTiles", Screen.width, Screen.height, 2, 0.0f, 0.0f);
        }

        if (m_backgroundObjectTiles == null)
        {
            m_backgroundObjectTiles = new TileGridWidget(m_backgroundGroup, "BackgroundObjects", Screen.width, Screen.height, 1, 0.0f, 0.0f);
        }

        if (m_foregroundObjectTiles == null)
        {
            m_foregroundObjectTiles = new TileGridWidget(m_foregroundGroup, "ForegroundObjects", Screen.width, Screen.height, 0, 0.0f, 0.0f);
        }

        // Covert the tile IDs over to sprite sheet indices
        RoomTemplate roomTemplate = room.StaticRoomData.RoomTemplate;

        TileGridTemplate floorGrid = roomTemplate.FloorGridTemplate;
        m_backgroundTiles.LoadMap(
            floorGrid.TileIndices,
            floorGrid.RowCount, floorGrid.ColomnCount,
            floorGrid.TileSetImageName, floorGrid.TileWidth, floorGrid.TileHeight);

        TileGridTemplate wallGrid = roomTemplate.WallGridTemplate;
        m_wallTiles.LoadMap(
            wallGrid.TileIndices,
            wallGrid.RowCount, wallGrid.ColomnCount,
            wallGrid.TileSetImageName, wallGrid.TileWidth, wallGrid.TileHeight);

        TileGridTemplate backgroundObjGrid = roomTemplate.BackgroundObjectsTemplate;
        m_backgroundObjectTiles.LoadMap(
            backgroundObjGrid.TileIndices,
            backgroundObjGrid.RowCount, backgroundObjGrid.ColomnCount,
            backgroundObjGrid.TileSetImageName, backgroundObjGrid.TileWidth, backgroundObjGrid.TileHeight);

        TileGridTemplate foregroundObjGroup = roomTemplate.BackgroundObjectsTemplate;
        m_foregroundObjectTiles.LoadMap(
            foregroundObjGroup.TileIndices,
            foregroundObjGroup.RowCount, foregroundObjGroup.ColomnCount,
            foregroundObjGroup.TileSetImageName, foregroundObjGroup.TileWidth, foregroundObjGroup.TileHeight);

        //TODO: rebuildRoom: Use animated tile entities from the room template
        /*var tileIdGrid:Array = room.staticRoomData.backgroundTileGrid;
        var tileIndices:Array = new Array();
        for (var listIndex:uint = 0; listIndex < tileIdGrid.length; listIndex++)
        {
            var tileId:uint = tileIdGrid[listIndex];
            var tileDescriptor:TileDescriptor= currentTileSet.getTileDescriptorById(tileId);
            var sheetIndex:int = tileDescriptor.sheetIndex;

            // Create an animated tile for any tile that has more than one frame
            if (tileDescriptor.frameCount > 1)
            {
                var tileColomn:uint = listIndex % room.staticRoomData.tileColomns;
                var tileRow:uint = uint(listIndex / room.staticRoomData.tileColomns);
                var tileX:Number = Number(tileColomn) * currentTileSet.TileWidth;
                var tileY:Number = Number(tileRow) * currentTileSet.TileHeight;

                new AnimatedTileWidget(m_backgroundGroup, currentTileSet, tileDescriptor, tileX, tileY);
            }

            tileIndices.push(sheetIndex);
        }*/
    }
Пример #4
0
    public void RebuildRoom(RoomData room)
    {
        if (m_backgroundTiles == null)
        {
            m_backgroundTiles = new TileGridWidget(m_backgroundGroup, "BackgroundTiles", Screen.width, Screen.height, 3, 0.0f, 0.0f);
        }

        if (m_wallTiles == null)
        {
            m_wallTiles = new TileGridWidget(m_backgroundGroup, "WallTiles", Screen.width, Screen.height, 2, 0.0f, 0.0f);
        }

        if (m_backgroundObjectTiles == null)
        {
            m_backgroundObjectTiles = new TileGridWidget(m_backgroundGroup, "BackgroundObjects", Screen.width, Screen.height, 1, 0.0f, 0.0f);
        }

        if (m_foregroundObjectTiles == null)
        {
            m_foregroundObjectTiles = new TileGridWidget(m_foregroundGroup, "ForegroundObjects", Screen.width, Screen.height, 0, 0.0f, 0.0f);
        }

        // Covert the tile IDs over to sprite sheet indices
        RoomTemplate roomTemplate = room.StaticRoomData.RoomTemplate;

        TileGridTemplate floorGrid = roomTemplate.FloorGridTemplate;

        m_backgroundTiles.LoadMap(
            floorGrid.TileIndices,
            floorGrid.RowCount, floorGrid.ColomnCount,
            floorGrid.TileSetImageName, floorGrid.TileWidth, floorGrid.TileHeight);

        TileGridTemplate wallGrid = roomTemplate.WallGridTemplate;

        m_wallTiles.LoadMap(
            wallGrid.TileIndices,
            wallGrid.RowCount, wallGrid.ColomnCount,
            wallGrid.TileSetImageName, wallGrid.TileWidth, wallGrid.TileHeight);

        TileGridTemplate backgroundObjGrid = roomTemplate.BackgroundObjectsTemplate;

        m_backgroundObjectTiles.LoadMap(
            backgroundObjGrid.TileIndices,
            backgroundObjGrid.RowCount, backgroundObjGrid.ColomnCount,
            backgroundObjGrid.TileSetImageName, backgroundObjGrid.TileWidth, backgroundObjGrid.TileHeight);

        TileGridTemplate foregroundObjGroup = roomTemplate.BackgroundObjectsTemplate;

        m_foregroundObjectTiles.LoadMap(
            foregroundObjGroup.TileIndices,
            foregroundObjGroup.RowCount, foregroundObjGroup.ColomnCount,
            foregroundObjGroup.TileSetImageName, foregroundObjGroup.TileWidth, foregroundObjGroup.TileHeight);

        //TODO: rebuildRoom: Use animated tile entities from the room template

        /*var tileIdGrid:Array = room.staticRoomData.backgroundTileGrid;
         * var tileIndices:Array = new Array();
         * for (var listIndex:uint = 0; listIndex < tileIdGrid.length; listIndex++)
         * {
         *      var tileId:uint = tileIdGrid[listIndex];
         *      var tileDescriptor:TileDescriptor= currentTileSet.getTileDescriptorById(tileId);
         *      var sheetIndex:int = tileDescriptor.sheetIndex;
         *
         *      // Create an animated tile for any tile that has more than one frame
         *      if (tileDescriptor.frameCount > 1)
         *      {
         *              var tileColomn:uint = listIndex % room.staticRoomData.tileColomns;
         *              var tileRow:uint = uint(listIndex / room.staticRoomData.tileColomns);
         *              var tileX:Number = Number(tileColomn) * currentTileSet.TileWidth;
         *              var tileY:Number = Number(tileRow) * currentTileSet.TileHeight;
         *
         *              new AnimatedTileWidget(m_backgroundGroup, currentTileSet, tileDescriptor, tileX, tileY);
         *      }
         *
         *      tileIndices.push(sheetIndex);
         * }*/
    }