Пример #1
0
 protected virtual ToolStripMenuItem CreateMenuStripItem(ICellElement allSelectedCellsElem)
 {
     return(new ToolStripMenuItem(allSelectedCellsElem.ToString())
     {
         Tag = allSelectedCellsElem
     });
 }
Пример #2
0
 protected virtual void DeleteCellElement(ICellElement cellElem, Cell cell)
 {
     if (cell.Elements.Contains(cellElem))
     {
         cell.Elements.Remove(cellElem);
     }
     this.cellElemList[cellElem].Remove(cell);
 }
Пример #3
0
        protected virtual void AddCellElement(ICellElement cellElem)
        {
            if (!this.environmentControl.Environment.CellElements.ContainsKey(cellElem.IdToken))
            {
                this.environmentControl.Environment.CellElements.Add(cellElem.IdToken, cellElem);
            }

            this.cellElemList[cellElem] = new HashSet <Cell>();
            this.cellListBox.Items.Add(cellElem);
        }
Пример #4
0
 protected virtual void SelectedCellsDeleteElement(ICellElement cellElement)
 {
     if (cellElement != null)
     {
         foreach (var cell in this.selectedCells)
         {
             this.DeleteCellElement(cellElement, cell);
         }
     }
     this.RefreshForm(false);
 }
Пример #5
0
 public bool Equals(ICellElement cellElement)
 {
     return(cellElement is CellElement &&
            cellElement.IdToken == this.IdToken &&
            cellElement.Color.Equals(this.Color) &&
            cellElement.ImagePath == this.ImagePath &&
            ((CellElement)cellElement).Reward.Equals(this.Reward) &&
            cellElement.Visible == this.Visible &&
            cellElement.Walkable == this.Walkable &&
            cellElement.HasSmell == this.HasSmell);
 }
Пример #6
0
        protected virtual void DeleteCellElement(ICellElement cellElem)
        {
            foreach (var cell in this.cellElemList[cellElem])
            {
                cell.Elements.Remove(cellElem);
            }

            this.environmentControl.Environment.CellElements.Remove(cellElem.IdToken);
            this.cellElemList.Remove(cellElem);
            this.cellListBox.Items.Remove(cellElem);
            this.RefreshForm(false);
        }
Пример #7
0
        public virtual void MoveToElement(ICellElement element, ICellElement toElement)
        {
            if ((element == null) || (toElement == null))
            {
                return;
            }
            var cellCloserToElement = this.GetNextCellInShortPath(element.Cell, toElement.Cell);

            if (cellCloserToElement != null)
            {
                element.Cell = cellCloserToElement;
            }
        }
Пример #8
0
        public CellElementForm(ICellElement cellElement)
        {
            InitializeComponent();

            this.CellElement = cellElement;
            this.LoadCellElementInfo();

            this.Visible      = false;
            this.DialogResult = DialogResult.None;
            this.nameTextBox.Focus();
            this.selectFileDialog.Filter      = Util.GetImageFilesDialogFilter();
            this.selectFileDialog.FilterIndex = ImageCodecInfo.GetImageEncoders().Length;
            this.colorPanel.DoubleClick      += this.ColorPanelDoubleClick;
        }
Пример #9
0
        public virtual void MoveFromElement(ICellElement element, ICellElement fromElement)
        {
            if ((element == null) || (fromElement == null))
            {
                return;
            }

            var cellFartherFromElement = this.GetNextCellToFartherFromCell(element.Cell, fromElement.Cell);

            if (cellFartherFromElement != null)
            {
                element.Cell = cellFartherFromElement;
            }
        }
Пример #10
0
        private void LoadEnvironment(IEnvironment environment)
        {
            this.CreateEnvironmentControl(environment);
            this.selectedCellElem = null;
            this.selectedCells.Clear();
            this.AddCellElements(environment);
            this.RefreshForm(true);

            //enables menus
            this.printToolStripMenuItem.Enabled          =
                this.saveToolStripMenuItem.Enabled       =
                    this.saveAsToolStripMenuItem.Enabled =
                        this.cellMenuStrip.Enabled       = true;
        }
Пример #11
0
        public virtual void MoveRandomly(ICellElement element)
        {
            if (element == null)
            {
                return;
            }
            var neighbourCells = this.GetNeighbourCells(element.Cell);
            var randNeighbour  = neighbourCells[this.rand.Next(neighbourCells.Count)];

            if ((randNeighbour != null) && this.IsWalkable(randNeighbour))
            {
                element.Cell = randNeighbour;
            }
        }
        protected virtual void ResetDots()
        {
            //puts all dots to visible
            foreach (var dotElement in this.dotCells.Values)
            {
                dotElement.Visible = dotElement.ForceRepaint = true;
            }

            //resets final dot (if exists)
            if (this.finalDot != null)
            {
                this.finalDot.IdToken = this.finalDot == this.BigDot ? BIG_DOT_ID : DOT_ID;
            }
            this.finalDot = null;
        }
Пример #13
0
        protected virtual void AddCellElement(ICellElement cellElem, Cell cell)
        {
            if ((cell != null) && (!cell.Elements.Contains(cellElem)))
            {
                cell.Elements.Add(cellElem);
            }

            if ((cell != null) && cell.Environment.CellElements.ContainsKey(cellElem.IdToken) &&
                !this.cellElemList[cellElem].Contains(cell))
            {
                this.cellElemList[cellElem].Add(cell);
            }

            this.RefreshForm(false);
        }
        protected void IdentifyFinalDot()
        {
            //checks for final dot
            if (this.numDotsEaten != this.numTotalDots - 1)
            {
                return;
            }

            //changes remaining dot id to final
            foreach (var dotElement in this.dotCells.Values.Where(dotElement => dotElement.Visible))
            {
                //found the visible (and final) dot, mark it
                this.finalDot         = dotElement;
                this.finalDot.IdToken = FINAL_DOT_ID;
                break;
            }
        }
Пример #15
0
        protected void DrawFinishedTask(ICellElement cellElement, Graphics graphics)
        {
            if (!(cellElement is CellAgent))
            {
                return;
            }

            //checks if agent finished task
            var agent             = (CellAgent)cellElement;
            var agentFinishedTask = agent.Environment.AgentFinishedTask(
                agent, agent.ShortTermMemory.PreviousState, agent.ShortTermMemory.CurrentAction);

            if (agentFinishedTask)
            {
                graphics.DrawRectangle(new Pen(Color.Red, 10), new Rectangle(new Point(0, 0), this.Size));
            }
        }
Пример #16
0
        public Bitmap GetElementBitmap(ICellElement element)
        {
            //check new image (not loaded or path changed)
            if (!this._elementBitmapPaths.ContainsKey(element) ||
                element.ImagePath != this._elementBitmapPaths[element])
            {
                Bitmap bitmap = null;
                if (File.Exists(element.ImagePath))
                {
                    bitmap = (Bitmap)Image.FromFile(element.ImagePath);
                }
                if (this._elementBitmaps.ContainsKey(element) && (this._elementBitmaps[element] != null))
                {
                    this._elementBitmaps[element].Dispose();
                }

                this._elementBitmaps[element]     = bitmap;
                this._elementBitmapPaths[element] = element.ImagePath;
            }
            return(this._elementBitmaps[element]);
        }
Пример #17
0
        protected void LoadCellElementInfo()
        {
            if (this.CellElement == null)
            {
                this.CellElement = new CellElement {
                    IdToken = "new cell element"
                }
            }
            ;

            this.nameTextBox.Text        = this.CellElement.IdToken;
            this.descTextBox.Text        = this.CellElement.Description;
            this.imgPathTextBox.Text     = this.CellElement.ImagePath;
            this.visibleCheckBox.Checked = this.CellElement.Visible;
            this.walkCheckBox.Checked    = this.CellElement.Walkable;
            this.smellCheckBox.Checked   = this.CellElement.HasSmell;
            this.colorPanel.BackColor    = this.colorDialog.Color = this.CellElement.Color.ToColor();
            this.rwdNumericUpDown.Value  = (decimal)this.CellElement.Reward;

            if (File.Exists(this.CellElement.ImagePath))
            {
                this.pictureBox.Load(this.CellElement.ImagePath);
            }
        }
Пример #18
0
 public bool Equals(ICellElement cellElem)
 {
     return((cellElem is CellAgent) && (((CellAgent)cellElem).IdToken == this.IdToken));
 }
Пример #19
0
 private void CellListBoxSelectedIndexChanged(object sender, EventArgs e)
 {
     this.selectedCellElem = this.cellListBox.SelectedItem as ICellElement;
 }
Пример #20
0
 public Cell GetFarthestCell(ICellElement fromElement)
 {
     return(fromElement.Cell != null?this.GetFarthestCell(fromElement.Cell) : null);
 }
Пример #21
0
 public KeeperGhost(ICellElement otherElement)
 {
     this.otherElement = otherElement;
 }