コード例 #1
0
 // returns coorinates as an array from given cell
 public int[] getCoords(Cell cell)
 {
     //get the location of the cell
     int cellInt = myLevel.CellCollection.IndexOf(cell);
     //create array to return
     int[] coords = new int[2];
     // x is equal to the modulus of the cell location by the level width
     coords[0] = cellInt % myLevel.Width;
     // y is equal to the cell location divided by the level height
     coords[1] = cellInt / myLevel.Height;
     return coords;
 }
コード例 #2
0
        // OnClick function for Cell Buttons
        protected void Button_OnClick_For_Cell(object sender, object e)
        {
            if(this.TheClickedButton != null){
                //converting the sender to button
                CustomControl_Button theButton = sender as CustomControl_Button;
                //initiating an instance of Cell class
                if (this.TheClickedButton.Name == "btn_Theseus")
                {

                        if (OldTheseusButton != null)
                        {
                            OldTheseusButton.ClearCharacters();
                            OldTheseusButton = null;
                        }
                        OldTheseusButton = theButton;
                        theButton.ChildCharacter = theseus;

                }
                else if (this.TheClickedButton.Name == "btn_Minotaur")
                {

                        if (OldTheseusButton != null)
                        {
                            OldTheseusButton.ClearCharacters();
                            OldTheseusButton = null;
                        }
                        OldTheseusButton = theButton;
                        theButton.ChildCharacter = minotaur;

                }
                else
                {
                    Cell cell = new Cell();
                    switch (this.TheClickedButton.Name)
                    {
                        case "btn_TileLeft":
                            //Set the type of the instance to CellType.Left
                            cell.Type = CellType.Left;
                            break;
                        case "btn_TileUp":
                            //Set the type of the instance to CellType.Up
                            cell.Type = CellType.Up;
                            break;
                        case "btn_TileBlank":
                            //Set the type of the instance to CellType.Blank
                            //add correct flor tile
                            cell.Type = CellType.Ground;
                            break;
                        case "btn_TileLeftUp":
                            //Set the type of the instance to CellType.LeftUp
                            cell.Type = CellType.LeftUP;
                            break;
                        case "btn_TileExit":
                            //Set the type of the instance to CellType.Exit
                            cell.Type = CellType.Exit;
                            break;
                    }
                    //sets the button
                    theButton.ChildCell = cell;
                }
            }
        }
コード例 #3
0
        private static void loadGameBoard(Level level, object sender, Theseus theseus, Minotaur minotaur)
        {
            int Theseus = level.TheseusLocation;
            int Minotaur = level.MinotaurLocation;
            int Exit = level.ExitLocation;
            int count = 0;

            Button loadButton = sender as Button;
            var theButton = sender as CustomControl_Button;
            Form parentForm = loadButton.FindForm();

            foreach (Cell cell in level.CellCollection)
            {
                theButton = parentForm.Controls.Find(count.ToString(), true).FirstOrDefault() as CustomControl_Button;

                if (Theseus == count)
                {

                    OldTheseusButton = theButton;
                    OldTheseusButton.ChildCharacter = theseus;

                    LevelDesigner.MyLevel.TheseusLocation = LevelDesigner.MyLevel.CellCollection.IndexOf(OldTheseusButton.ChildCell);

                }
                else if (Minotaur == count)
                {
                    OldMinotaurButton = theButton;
                    OldMinotaurButton.ChildCharacter = minotaur;
                    LevelDesigner.MyLevel.MinotaurLocation = LevelDesigner.MyLevel.CellCollection.IndexOf(OldMinotaurButton.ChildCell);

                }
                else if (Exit == count)
                {
                    OldExitButton = theButton;
                    OldExitButton._PreviousCell = theButton.ChildCell;

                    Cell cellll = new Cell() { Type = CellType.Exit };

                    theButton.ChildCell = cellll;

                    LevelDesigner.MyLevel.ExitLocation = LevelDesigner.MyLevel.CellCollection.IndexOf(theButton.ChildCell);

                }

                count++;
            }
                {
            }
        }
コード例 #4
0
 protected Cell CreateOuterwall(string btnname)
 {
     Cell c = new Cell();
     c.Type = CellType.Ground;
     if (btnname == "b1")
     {
         //create a cell
         //make it blank
         c.Type = CellType.LeftUP;
         return c;
     }
     return c;
 }
コード例 #5
0
        protected void ContextMenu_OnClick_For_TileExit(object sender, object e)
        {
            //Converting the button object into menuitem
            var mnu = sender as MenuItem;
            //getting the right click menu(contextmenu) of the option that was clicked(MenuItem)
            ContextMenu MyContextMenu = (ContextMenu)mnu.Parent;
            //get the button of the context btton
            var theButton = MyContextMenu.SourceControl as CustomControl_Button;

            if (OldExitButton != null)
            {
                OldExitButton.DrawBackgroundImage(OldExitButton._PreviousCell.Type);
            }
            OldExitButton = theButton;
            OldExitButton._PreviousCell = OldExitButton.ChildCell;

            //create a cell object with apporiate wall
            Cell cell = new Cell() { Type = CellType.Exit };
            //assign the cell instance to the button
            theButton.ChildCell = cell;
               //     theButton.ChildCell.Type = CellType.Exit;

            LevelDesigner.MyLevel.ExitLocation = LevelDesigner.MyLevel.CellCollection.IndexOf(OldExitButton._PreviousCell);
        }
コード例 #6
0
        public void ClearCharacters()
        {
            _ChildCharacter = null;

            this._ChildCell = this._PreviousCell;
            DrawBackgroundImage(this._ChildCell.Type);

            //this.BackgroundImage = Image.FromFile(LevelDesigner.MyLevel.TileSet["Ground1"]);
        }