Пример #1
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="gameField">Игровое поле, которому принадлежит ячейка.</param>
        /// <param name="x">Индекс ряда ячейки на игровом поле.</param>
        /// <param name="y">Индекс столбца ячейки на игровом поле.</param>
        /// <param name="size">Размер ячейки (в пикселях).</param>
        public GameCell(GameField gameField, int row, int column, int size, FrameExample frameExample = null)
            : base()
        {
            this.FrameExample = frameExample;

            pictureBox = new PictureBox();
            pictureBox.Dock = DockStyle.Fill;
            this.Controls.Add(pictureBox);
            this.AllowDrop = true;

            this.gameField = gameField;
            this.Size = size;
            pictureBox.SizeMode = PictureBoxSizeMode.StretchImage;

            String imageFile;
            if (frameExample != null)
            {
                //Фрейм-прототип этого экземпляра должен быть унаследован от фрейма-объекта, который должен содержать слот "image".
                imageFile = (string)frameExample.Value("image");
                if (imageFile == null)
                    throw new NullReferenceException("slot 'image' not found for frame " + frameExample.BaseFrame.FrameName + " with id " + frameExample.BaseFrame.FrameId.ToString());
            }
            else
            {
                imageFile = "Images\\grass.jpg";
            }
            pictureBox.Image = Image.FromFile(imageFile);

            this.Row = row;
            this.Column = column;
            this.DragEnter += new DragEventHandler(GameCell_DragEnter);
            this.DragDrop += new DragEventHandler(GameCell_DragDrop);
            pictureBox.Click += new EventHandler(pictureBox_Click);
        }
Пример #2
0
        public object doMLVForPoint(GameCell gameCell)
        {
            log();
            object result="Клетка пуста.";
            if (gameCell.FrameExample != null && gameCell.FrameExample.BaseFrame != null && gameCell.FrameExample.BaseFrame.FrameId != -1)
            {
                situations = gatherSituationsList();

                situationExample = new FrameExample();
                Slot slotAgent = new Slot();
                slotAgent.SlotName = "agent";
                slotAgent.SlotType = SlotType.Frame;
                slotAgent.SlotInheritance = SlotInherit.Override;
                slotAgent.IsSystem = false;
                situationExample.AddSlot(slotAgent);
                situationExample.SetValue("agent", gameCell.FrameExample);
                Frame situationToCheck = this.getNextFrameToCheck();

                while (!situationExample.ContainsSlot("action") && situationToCheck != null) //пока не определили целевой слот "действие"
                {
                    checkedFramesIDs.Add(situationToCheck.FrameId);
                    if (checkSituation(situationToCheck, situationExample))
                    {
                        Slot actionSlot = situationToCheck.GetSlotByName("action");
                        situationExample.AddSlot(actionSlot);
                        situationExample.SetValue(actionSlot.SlotName, actionSlot.SlotDefault);
                    }
                    situationToCheck = this.getNextFrameToCheck();
                }
                result = null;
                if (situationExample.ContainsSlot("action"))
                    result = situationExample.Value("action");
            }
            return result;
        }