Esempio n. 1
0
        private void OnSquareMapAddItem(object sender, EventArgs<PresentSquareMapItemParameter> e)
        {
            /* game engine commands us to add an item to square map - nothing easier than that.
             * we create the control, set sizes, position and square and finally add them to our
             * panel representing the map.
             * */

            this.SuspendLayout();

            /* create square */
            SquareControl square = new SquareControl();

            /* use item guid as key */
            square.Name = e.Value.Id.ToString();

            /* set item identification values */
            square.ItemId = e.Value.Id;
            square.ItemPosition = e.Value.Position;

            /* position and size */
            square.Width = SQUARE_WIDTH;
            square.Height = SQUARE_HEIGHT;
            square.Left = e.Value.Position.X * SQUARE_WIDTH;
            square.Top = e.Value.Position.Y * SQUARE_HEIGHT;

            /* set square to present */
            square.ChangeSquare(e.Value.SquareId, e.Value.SquareType);

            /* add to map */
            this.panelMap.Controls.Add(square);

            this.ResumeLayout();
        }
Esempio n. 2
0
        private void OnPipeQueueEnqueue(object sender, EventArgs<PresentSquareParameter> e)
        {
            /* game engine just added a new pipe in queue. we reflect this change by adding
             * a square control to our queue panel as well and then reorder all controls on
             * panel.
             * */

            this.panelQueue.SuspendLayout();

            /* create control */
            SquareControl squareControl = new SquareControl();

            /* use square id as key */
            squareControl.Name = e.Value.Id.ToString();

            /* size */
            squareControl.Width = SQUARE_WIDTH;
            squareControl.Height = SQUARE_HEIGHT;

            /* set square to present */
            squareControl.ChangeSquare(e.Value.Id, e.Value.Type);

            /* add to panel */
            this.panelQueue.Controls.Add(squareControl);

            /* reorder controls */
            int y = 0;
            foreach (SquareControl control in this.panelQueue.Controls)
            {
                /* highlight first pipe */
                if (y == 0)
                {
                    control.IsHighlighted = true;
                }
                else
                {
                    control.IsHighlighted = false;
                }

                /* position */
                control.Left = 0;
                control.Top = y;

                y += 30;
            }

            this.panelQueue.ResumeLayout();
        }