Exemple #1
0
//	void Start()
//	{
//		this.InitializeGrid ();
//	}
        #endif

    /**A function to create the grid illustrated by the gizmo function OnDrawGizmos().
     * Creates a grid of Gridbox objects.*/
    public void InitializeGrid()
    {
        GameObject grid_hierarchy_container = new GameObject();

        grid_hierarchy_container.gameObject.name = "Grid Container";

        int box_index = 0;

        //Draw the whole grid
        for (int row = 0; row < this.m_GridBoxesPerFloorZ; row++)
        {
            Vector3 adjustment_vertical = this.m_StartingPosition - new Vector3(0.0f, 0.0f, this.m_GridBoxSize.z * row);
            for (int column = 0; column < this.m_GridBoxesPerFloorX; column++)
            {
                GameObject gridbox = GameObject.Instantiate(this.m_GridBox_Prefab, grid_hierarchy_container.transform);
                gridbox.name = "Gridbox_" + box_index;
                Vector3 adjustment_horizontal = new Vector3(column * this.m_GridBoxSize.x, 0.0f, 0.0f);
                gridbox.transform.position   = adjustment_horizontal + adjustment_vertical;
                gridbox.transform.localScale = this.m_GridBoxSize;

                GridBox box = gridbox.GetComponent <GridBox> ();
                box.InitializeNeighbors(box_index++, this.m_GridBoxesPerFloorX, this.m_GridBoxesPerFloorZ);
                box.VerifyObstructionStatus();
                this.m_Grid.Add(box);
            }
        }        //end for

                #if TESTING_NEIGHBOR_ASSIGNMENT
        for (int index = 0; index < this.m_Grid.Count; index++)
        {
            this.m_Grid [index].PrintNeighbors(index);
        }
                #endif
    }    //end f'n InitializeGrid()
Exemple #2
0
        private void Form1_MouseDown(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Left)
            {
                for (var x = 0; x < width; x++)
                {
                    for (var y = 0; y < height; y++)
                    {
                        if (rectangles[x][y].BoxRect.Contains(e.Location))
                        {
                            lastBoxType   = rectangles[x][y].BoxType;
                            lastBoxSelect = rectangles[x][y];
                            switch (lastBoxType)
                            {
                            case BoxType.Normal:
                            case BoxType.Wall:
                                rectangles[x][y].SwitchBox();
                                Invalidate();
                                break;

                            case BoxType.Start:
                            case BoxType.End:

                                break;
                            }
                        }
                    }
                }
            }
        }
 public void Render(IEnumerable <Cell> livingCells)
 {
     GridBox.Image = GetGridBitmap(livingCells);
     GridBox.Refresh();
     SetGenerationNumber(_gameEngine.GetGenerationNumber());
     SetNumberOfLivingCells(_gameEngine.GetNumberOfLivingCells());
 }
        private void Form1_MouseDown(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Left)
            {
                for (int widthTrav = 0; widthTrav < width; widthTrav++)
                {
                    for (int heightTrav = 0; heightTrav < height; heightTrav++)
                    {
                        if (m_rectangles[widthTrav][heightTrav].boxRec.IntersectsWith(new Rectangle(e.Location, new Size(1, 1))))
                        {
                            m_lastBoxType   = m_rectangles[widthTrav][heightTrav].boxType;
                            m_lastBoxSelect = m_rectangles[widthTrav][heightTrav];
                            switch (m_lastBoxType)
                            {
                            case BoxType.Normal:
                            case BoxType.Wall:
                                m_rectangles[widthTrav][heightTrav].SwitchBox();
                                this.Invalidate();
                                break;

                            case BoxType.Start:
                            case BoxType.End:

                                break;
                            }
                        }
                    }
                }
            }
        }
    public void RecursiveCall(GameObject originNode, int spread)
    {
        if (spread <= 0)
        {
            return;
        }
        GridBox originNodeScript = originNode.GetComponent <GridBox> ();

        originNodeScript.SetLinked(true);
        Vector3 originNodeLoc = new Vector3(originNodeScript.gridLocX, originNodeScript.gridLocZ, originNodeScript.gridLocY);

        AddCubeToPathFindingList(originNodeLoc, originNode);

        List <GameObject> legalNeighboursRef = originNodeScript.GetLegalNeighbours();

        //Debug.Log ("originNode x z y " + originNode.GetComponent<GridBox> ().gridLocX + " " + originNode.GetComponent<GridBox> ().gridLocZ + " " + originNode.GetComponent<GridBox> ().gridLocY + " Spread: " + spread);
        for (int i = 0; i < legalNeighboursRef.Count; i++)
        {
            GridBox neighNodeScript = legalNeighboursRef [i].GetComponent <GridBox> ();
            Vector3 neighgridLoc    = new Vector3(neighNodeScript.gridLocX, neighNodeScript.gridLocZ, neighNodeScript.gridLocY);
            if (pathfindingCubeList [neighgridLoc] == null)
            {
                RecursiveCall(legalNeighboursRef [i], spread - 1);
            }
        }
        return;
    }
    public void BuildMapGrid()
    {
        if (gridField != null)
        {
            foreach (GridBox element in gridField)
            {
                element.Delete();
            }
        }

        gridField = new GridBox[2 * mapSize, 2 * mapSize];

        for (int y = -mapSize; y < mapSize; y++)
        {
            for (int x = -mapSize; x < mapSize; x++)
            {
                //for (int z = -mapSize; z < mapSize; z++)
                //{
                //gridField[x + mapSize, y + mapSize, z + mapSize] = new GridBox(x, y, z, gridBoxSize);
                //gridField[x + mapSize, y + mapSize, z + mapSize].SetPosition();
                gridField[x + mapSize, y + mapSize] = new GridBox(x, y, gridBoxSize);
                //gridField[x + mapSize, y + mapSize].SetPosition((x * 1.5f) + (y * gridBoxSize), y);
                gridField[x + mapSize, y + mapSize].SetPosition(x * gridBoxSize, (y * gridBoxSize) - (Mathf.Abs(x % 2) * .5f * gridBoxSize));
                //}
            }
        }
    }
    public void FuzzySuccessFind()
    {
        var nothing = new Material(1, 1);
        var space = new GridBox(new Box(new Position(10, 10, 10), new Position(28, 36, 28)));
        foreach (var block in space.Blocks())
        {
            this.Provider.SetMaterial(this.Filler, block);
        }
        var size = new Position(9, 13, 9);
        var toFind = new Box(new Position(15, 17, 15), new Position(23, 29, 23));
        var randoms = new RandomBlocks(space);
        foreach (var i in Enumerable.Range(0, 100))
        {
            var finishingBlock = randoms
                .Where(b => toFind.Outfits(new Box(b, b)))
                .First();

            var checker = new FilledBoxChecker(this.Surveyor, finishingBlock, size, this.Filler);

            var emptyCount = randoms.Generator.Next(15) + 1;
            var empties = randoms.Where(b => !toFind.Outfits(new Box(b, b))).Take(emptyCount).ToList();
            foreach(var empty in empties)
            {
                this.Provider.SetMaterial(nothing, empty);
            }

            Assert.IsTrue(null != checker.MachineSpace());

            foreach(var empty in empties)
            {
                this.Provider.SetMaterial(this.Filler, empty);
            }
        }
    }
Exemple #8
0
        public void CountSides()
        {
            var mult  = new GridBox(new Box(new Position(1, 1, 2), new Position(3, 2, 2)));
            var count = mult.Sides().Count();

            Assert.AreEqual(count, 22);
        }
        public ActionResult Index()
        {
            List <GridBox> productList = new List <GridBox>();
            GridBox        grid        = new GridBox();

            connectionString();
            con.Open();
            string query = "Select * from ClientRegistration";

            using (SqlCommand cmd = new SqlCommand(query))
            {
                cmd.Connection = con;

                using (SqlDataReader sdr = cmd.ExecuteReader())
                {
                    while (sdr.Read())
                    {
                        productList.Add(new GridBox
                        {
                            FullName    = sdr["FullName"].ToString(),
                            Email       = sdr["Email"].ToString(),
                            Location    = sdr["Location"].ToString(),
                            WorkType    = sdr["WorkType"].ToString(),
                            Image       = sdr["Image"].ToString(),
                            Description = sdr["Description"].ToString(),
                            PhoneNumber = sdr["PhoneNumber"].ToString(),
                            HourlyRate  = sdr["HourlyRate"].ToString(),
                        });
                    }
                }
                con.Close();
            }
            ViewBag.Customers = productList;
            return(View());
        }
 public void FuzzyFailToFind()
 {
     var nothing = new Material(1, 1);
     var space = new GridBox(new Box(new Position(10, 10, 10), new Position(42, 12, 42)));
     foreach (var block in space.Blocks())
     {
         this.Provider.SetMaterial(this.Filler, block);
     }
     var randoms = new RandomBlocks(space);
     foreach (var i in Enumerable.Range(0, 100))
     {
         var finishingBlock = randoms.First();
         var checker = new FilledBoxChecker(this.Surveyor, finishingBlock, new Position(33, 3, 33), this.Filler);
         var emptyCount = randoms.Generator.Next(15) + 1;
         var empties = randoms.Where(b => b != finishingBlock).Take(emptyCount).ToList();
         foreach(var empty in empties)
         {
             this.Provider.SetMaterial(nothing, empty);
         }
         Assert.AreEqual(null, checker.MachineSpace());
         foreach(var empty in empties)
         {
             this.Provider.SetMaterial(this.Filler, empty);
         }
     }
 }
Exemple #11
0
    public void startup()
    {
        GridBox gb1 = new GridBox(panel);

        GridBox gb2 = new GridBox(panel2);

        Debug.Log(PhotonNetwork.player.ID);
        if (PhotonNetwork.player.ID == 2)
        {
            Debug.Log("I Am player 2");
            playersTurn = false;
            oPlayerCastArea.Add(gb2);
            playerCastArea.Add(gb1);
        }
        else
        {
            playersTurn = true;
            oPlayerCastArea.Add(gb1);
            playerCastArea.Add(gb2);
        }

        PhotonView view = PhotonView.Find(6);


        gridMatrix = new Card[20, 12];
    }
 private void Form1_MouseUp(object sender, MouseEventArgs e)
 {
     if (e.Button == MouseButtons.Left)
     {
         m_lastBoxSelect = null;
     }
 }
Exemple #13
0
        public void OneCubeBlock()
        {
            var block = new Position(4, 4, 4);
            var mult  = new GridBox(new Box(block, block));
            var exist = mult.Blocks().First((b) => b == block);

            Assert.AreEqual(1, mult.Blocks().Count());
        }
Exemple #14
0
        public AdjacentsSurveyor(Box box, MachineEntity anchor)
        {
            var grid = new GridBox(box);

            this.Sides     = grid.Sides().Index().Loop().GetEnumerator();
            this.Surveyor  = new BlockSurveyor(anchor);
            this.Adjacents = Enumerable.Repeat <SegmentEntity>(null, grid.SidesCount()).ToList();
        }
Exemple #15
0
        public SudokuCell(int row, int column)
        {
            if (row < 0 || row > 8 || column < 0 || column > 8)
            {
                throw new ArgumentOutOfRangeException("Rows and Columns must be in the range 0 to 8.");
            }
            _row    = row;
            _column = column;
            this.Reset();

            if (row < 3)
            {
                if (column < 3)
                {
                    _square = GridBox.TL;
                }
                else if (column < 6)
                {
                    _square = GridBox.TC;
                }
                else
                {
                    _square = GridBox.TR;
                }
            }
            else if (row < 6)
            {
                if (column < 3)
                {
                    _square = GridBox.CL;
                }
                else if (column < 6)
                {
                    _square = GridBox.CC;
                }
                else
                {
                    _square = GridBox.CR;
                }
            }
            else
            {
                if (column < 3)
                {
                    _square = GridBox.BL;
                }
                else if (column < 6)
                {
                    _square = GridBox.BC;
                }
                else
                {
                    _square = GridBox.BR;
                }
            }
        }
    /**A function to tell us whether or not the player should be in the process of accelerating.
     * We're accelerating where we're not within [movement flag's radius] of the final GridBox in the [this.m_Path]; we define the last term in the sequence as being at index [size - 1]*/
    private bool PlayerShouldBeAccelerating_PathfindingMove()
    {
        Vector2 current_position         = new Vector2(this.transform.position.x, this.transform.position.z);
        GridBox path_last_element        = this.m_Path [this.m_Path.Count - 1];
        Vector2 flag_position            = new Vector2(path_last_element.gameObject.transform.position.x, path_last_element.gameObject.transform.position.z);
        Vector2 flag_to_current_position = flag_position - current_position;
        float   distance_to_flag         = flag_to_current_position.magnitude;

        return(distance_to_flag > this.m_MovementFlagInstanceRadius);
    }
Exemple #17
0
 /**A function to compute the F values for every element in the open list whose F value is still set to default value 0*/
 private void ComputeFValuesForOpenList()
 {
     foreach (int grid_box_index in this.m_OpenList)
     {
         GridBox grid_box = this.m_Grid [grid_box_index];
         if (grid_box.GetF() == 0)
         {
             grid_box.ComputeF();
         }
     }
 }
Exemple #18
0
 public void UpdateCoordinate(GridBox gridBox, Coordinate c)
 {
     try
     {
         grid[c.X, c.Y] = gridBox;
     }
     catch (IndexOutOfRangeException ex)
     {
         Debug.LogError(string.Format("Cannot access grid coordinate ({0},{1})", c.X, c.Y));
     }
 }
        /// provide configured storage, graphics, and occupied box (single or mulit-block)
        public PowerStorageMachine(ModCreateSegmentEntityParameters parameters, PowerStorage storage, Position size, G graphics)
            : base(parameters, graphics)
        {
            Storage = storage;
            var center = new Position(parameters);
            var shift  = size / 2;
            var box    = new GridBox(new Box(center - shift, center + shift));
            var probes = Direction.All().SelectMany(
                (d) => box.Side(d).Select((p) => new PciSurveyor.Probe(p, d))
                );

            Surveyor = new PciSurveyor(probes, this);
        }
Exemple #20
0
    // Find next valid dot above the given location
    private GridBox GetNextActiveDotAbove(Coordinate coordinate)
    {
        for (int j = coordinate.Y - 1; j >= 0; j--)
        {
            GridBox aboveGridBox = grid[coordinate.X, j];
            if (aboveGridBox != null && aboveGridBox.GridDot != null && !aboveGridBox.IsUpdatingCoordinate)
            {
                return(aboveGridBox);
            }
        }

        return(null);
    }
Exemple #21
0
    public Matrix()
    {
        data = new GridBox[8, 8];

        for (var i = 0; i < 8; i++)
        {
            for (var j = 0; j < 8; j++)
            {
                data[i, j] = new GridBox();
                data[i, j].SetIndex(i, j);
            }
        }
    }
    void Start()
    {
        Ray current_gridbox_ray = new Ray(this.transform.position + Vector3.up, -Vector3.up);

        foreach (RaycastHit current_gridbox_hit in Physics.RaycastAll(current_gridbox_ray))
        {
            GridBox current_gridbox = current_gridbox_hit.collider.gameObject.GetComponent <GridBox> ();
            if (current_gridbox != null)
            {
                this.m_GridBoxCurrentIndex = current_gridbox.GetBoxIndex();
                break;
            }
        }
    }
    public void DoNotGetConfusedByManyPossibilities()
    {
        var box = new Box(new Position(10, 10, 10), new Position(12, 12, 12));
        foreach (var block in new GridBox(new Box(new Position(8, 8, 8), new Position(15, 15, 15))).Blocks())
        {
            this.Provider.SetMaterial(this.Filler, block);
        }

        var finishingBlock = new Position(10, 11, 10);
        var checker = new FilledBoxChecker(this.Surveyor, finishingBlock, new Position(3, 3, 3), this.Filler);
        var grid = new GridBox(checker.MachineSpace().Value);
        Assert.AreEqual(27, grid.BlocksCount());
        Assert.AreEqual(finishingBlock, grid.Blocks().FirstOrDefault(b => b == finishingBlock));
    }
Exemple #24
0
        public void LargerBlock()
        {
            var mult       = new GridBox(new Box(new Position(-1, 4, 2), new Position(1, 4, 2)));
            var cubeCoords = new [] {
                new Position(-1, 4, 2),
                new Position(0, 4, 2),
                new Position(1, 4, 2)
            };

            foreach (var block in mult.Blocks())
            {
                var exist = cubeCoords.First((b) => b == block);
            }
        }
Exemple #25
0
    /**A function to ensure a gridbox can be used for pathfinding.
     * Specifically, ensures that the gridbox has a proper positive index value, that the gridbox isn't obstructed, and that the gridbox hasn't yet been checked for pathfinding.
     * Note: If a gridbox has been assigned a distance from the flag gridbox, we say of it that it has been checked for pathfinding.*/
    private bool GridBoxIsValidForPathfinding(int gridbox_index)
    {
        bool grid_box_exists = (gridbox_index != -1);

        if (!grid_box_exists)
        {
//			Debug.Log ("grid box doesn't exist");
            return(false);
        }
        else
        {
            GridBox grid_box = this.m_Grid [gridbox_index];
//			Debug.Log ("grid box is not obstructed: " + !grid_box.IsGridBoxObstructed () + " grid box has not been checked for pathfinding: " + !grid_box.GridboxHasBeenCheckedForPathfinding ());
            return(!grid_box.IsGridBoxObstructed() && !grid_box.GridboxHasBeenCheckedForPathfinding());
        }
    }
        public ActionResult Delete(string Email)
        {
            connectionString();
            String     sql = "Delete from ClientRegistration where Email ='" + Email + "'";
            SqlCommand cmd = new SqlCommand(sql, con);

            con.Open();
            if (cmd.ExecuteNonQuery().ToString() == "1")
            {
                List <GridBox> productList = new List <GridBox>();
                GridBox        grid        = new GridBox();


                string query = "Select * from ClientRegistration";

                using (SqlCommand cmds = new SqlCommand(query))
                {
                    cmds.Connection = con;

                    using (SqlDataReader sdr = cmds.ExecuteReader())
                    {
                        while (sdr.Read())
                        {
                            productList.Add(new GridBox
                            {
                                FullName    = sdr["FullName"].ToString(),
                                Email       = sdr["Email"].ToString(),
                                Location    = sdr["Location"].ToString(),
                                WorkType    = sdr["WorkType"].ToString(),
                                Image       = sdr["Image"].ToString(),
                                Description = sdr["Description"].ToString(),
                                PhoneNumber = sdr["PhoneNumber"].ToString(),
                                HourlyRate  = sdr["HourlyRate"].ToString(),
                            });
                        }
                    }
                    con.Close();
                }
                ViewBag.Customers = productList;
                ViewBag.Message   = "Data has been Deleted Successfully !!!";
                return(View("~/Views/Dashboard/Index.cshtml"));
            }
            else
            {
                return(View());
            }
        }
        public SearchGridForm()
        {
            InitializeComponent();
            this.DoubleBuffered = true;

            m_resultBox      = new List <ResultBox>();
            this.Width       = (width + 1) * 20;
            this.Height      = (height + 1) * 20 + 100;
            this.MaximumSize = new Size(this.Width, this.Height);
            this.MaximizeBox = false;


            m_rectangles = new GridBox[width][];
            for (int widthTrav = 0; widthTrav < width; widthTrav++)
            {
                m_rectangles[widthTrav] = new GridBox[height];
                for (int heightTrav = 0; heightTrav < height; heightTrav++)
                {
                    if (widthTrav == (width / 3) && heightTrav == (height / 2))
                    {
                        m_rectangles[widthTrav][heightTrav] = new GridBox(widthTrav * 20, heightTrav * 20 + 50, BoxType.Start);
                    }
                    else if (widthTrav == 41 && heightTrav == (height / 2))
                    {
                        m_rectangles[widthTrav][heightTrav] = new GridBox(widthTrav * 20, heightTrav * 20 + 50, BoxType.End);
                    }
                    else
                    {
                        m_rectangles[widthTrav][heightTrav] = new GridBox(widthTrav * 20, heightTrav * 20 + 50, BoxType.Normal);
                    }
                }
            }
            cbbJumpType.Items.Add("Always");
            cbbJumpType.Items.Add("Never");
            cbbJumpType.Items.Add("IfAtLeastOneWalkable");
            cbbJumpType.Items.Add("OnlyWhenNoObstacles");
            cbbJumpType.SelectedIndex = 0;

            m_resultLine = new List <GridLine>();

            searchGrid = new StaticGrid(width, height);
            // searchGrid = new DynamicGrid();
            //searchGrid = new DynamicGridWPool(SingletonHolder<NodePool>.Instance);

            jumpParam = new JumpPointParam(searchGrid, true, (DiagonalMovement)cbbJumpType.SelectedIndex, HeuristicMode.EUCLIDEAN);//new JumpPointParam(searchGrid, startPos, endPos, cbCrossCorners.Checked, HeuristicMode.EUCLIDEANSQR);
            jumpParam.UseRecursive = cbUseRecursive.Checked;
        }
Exemple #28
0
    public List <Dot> GetAllDotsOfColor(DotColor color)
    {
        List <Dot> dotsOfColor = new List <Dot>();

        for (int i = 0; i < Globals.GridWidth; i++)
        {
            for (int j = 0; j < Globals.GridHeight; j++)
            {
                GridBox gridBox = grid[i, j];
                if (gridBox != null && gridBox.GridDot != null && gridBox.GridDot.Color == color)
                {
                    dotsOfColor.Add(gridBox.GridDot);
                }
            }
        }
        return(dotsOfColor);
    }
Exemple #29
0
    public void playToGridCube(GridMatrix gm, Transform cube)
    {
        Vector2 gridPos = gm.worldToGrid(cube.position);

        if (rank == Rank.Conduit)
        {
            GridBox newArea = new GridBox(new Vector2(cube.position.x, cube.position.z), new Vector2(range, range));
            gm.AddToPlayersCastArea(newArea);
        }
        transform.parent = cube;
        transform.Find("Model").gameObject.SetActive(true);
        transform.localPosition = new Vector3(0, 0, 0);
        transform.Find("Model").localPosition = new Vector3(0, 1, 0);
        transform.Find("card 1").gameObject.SetActive(false);
        Debug.Log("played card");
        played = true;
    }
Exemple #30
0
        public void OneCubeSides()
        {
            var mult       = new GridBox(new Box(new Position(8, -4, 0), new Position(8, -4, 0)));
            var sideCoords = new [] {
                new Position(8, -5, 0),
                new Position(8, -3, 0),
                new Position(9, -4, 0),
                new Position(7, -4, 0),
                new Position(8, -4, -1),
                new Position(8, -4, 1),
            };

            foreach (var side in mult.Sides())
            {
                var exist = sideCoords.First((c) => c == side);
            }
        }