public void MoveTo(Vector3 newGridPos) { isBeingMoved = true; targetMovingGridPosition = newGridPos; previousMovingGridPosition = MasterGrid.GetCubeGridPosition(transform.gameObject); moveTimer = 0f; }
void Update() { ManageInputState(); if (!inputLocked) { if (Input.GetMouseButtonDown(0)) { RaycastHit hit; Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); // if you clicked an empty space, activate the camera if (!Physics.Raycast(ray, out hit)) { inputState = InputState.Camera; } else { GameObject cube = hit.transform.gameObject; UpdateSelectedCubeArray(cube); if (selectedCubes.Count == 2) { // are these cubes right next to each other? if (MasterGrid.CubesAreAdjacent(selectedCubes[0], selectedCubes[1])) { StartMove(); } else { CancelSelectedCubes(); } } } } else if (Input.GetMouseButtonUp(0)) { inputState = InputState.Game; } } else { if (!AnyCubeIsMoving() && selectedCubes.Count > 0) { GameObject cube1 = selectedCubes[0]; GameObject cube2 = selectedCubes[1]; lastMovedCubes = selectedCubes; selectedCubes = new List <GameObject>(); MasterGrid.UpdateSelectedCubePositions(cube1, cube2); StartCoroutine(TriggerCubeDeletionChain(new List <GameObject> { cube1, cube2 }, true)); } else if (!AnyCubeIsMoving()) { inputLocked = false; } } }
protected void MasterGrid_DetailRowExpandedChanged(object sender, ASPxGridViewDetailRowEventArgs e) { if (e.Expanded == false) { string key = MasterGrid.GetRowValues(e.VisibleIndex, MasterGrid.KeyFieldName).ToString(); Session["DetailGrid" + key] = null; } }
protected void MasterGrid_CustomCallback(object sender, ASPxGridViewCustomCallbackEventArgs e) { var splited = e.Parameters.Split(new[] { '_' }, StringSplitOptions.RemoveEmptyEntries); if (splited.Length != 2) { return; } Categories.UpdateCategory(Convert.ToInt32(splited[0]), Convert.ToInt32(splited[1])); MasterGrid.DataBind(); }
//Since the grid is "infinite", we need a way to add some sort of boundaries to our calculations. //We will use the highest and lowest x and y points to do this and draw a square around the largest possible area //in the entire grid. This master grid will contain all other coordinates since its corners are using the highest and lowest points //available. public void InitMasterGrid(bool lazy = false) { var maxX = Coordinates.Aggregate((agg, next) => next.x >= agg.x ? next : agg); var maxY = Coordinates.Aggregate((agg, next) => next.y >= agg.y ? next : agg); var minX = Coordinates.Aggregate((agg, next) => next.x <= agg.x ? next : agg); var minY = Coordinates.Aggregate((agg, next) => next.y <= agg.y ? next : agg); Grid = new MasterGrid(maxX.x, maxY.y, minX.x, minY.y); Console.WriteLine( $"Max X: {maxX.x} {maxX} | Max Y: {maxY.y} {maxY} | Min X: {minX.x} {minX}| Min Y: {minY.y} {minY}"); if (lazy) { return; } Grid.InitGridData(Coordinates); Grid.FillGrid(Coordinates); }
/// <summary> /// 반응형 레이아웃 적용 /// </summary> private void BasicGrid_SizeChanged(object sender, SizeChangedEventArgs e) { if (BasicGrid.ActualWidth >= 686) { // 큰 창일 때 ViewModel.IsWidthBigEnough = true; MasterGrid.Margin = new Thickness(10, 50, 0, 10); MasterGrid.Width = MASTERGRID_WIDTH; MasterGrid.HorizontalAlignment = HorizontalAlignment.Left; DetailGrid.Margin = new Thickness(MASTERGRID_WIDTH + 20, 50, 10, 0); ViewModel.SetDetailGridVisible(); if (BasicGrid.FindName("MultiSearchGrid") != null) { Grid g = (Grid)BasicGrid.FindName("MultiSearchGrid"); g.HorizontalAlignment = HorizontalAlignment.Right; g.Width = MULTISEARCHGRID_WIDTH; } } else if (BasicGrid.ActualWidth < 686) { // 작은 창일 때 ViewModel.IsWidthBigEnough = false; MasterGrid.Margin = new Thickness(10, 50, 10, 10); MasterGrid.ClearValue(WidthProperty); MasterGrid.HorizontalAlignment = HorizontalAlignment.Stretch; DetailGrid.Margin = new Thickness(10, 50, 10, 0); ViewModel.SetDetailGridCollapsed(); if (BasicGrid.FindName("MultiSearchGrid") != null) { Grid g = (Grid)BasicGrid.FindName("MultiSearchGrid"); g.HorizontalAlignment = HorizontalAlignment.Stretch; g.ClearValue(WidthProperty); } } //뒤로가기 키 지우기 ViewModel.IsTitleBarBackButtonEnabled = false; }
// TODO maybe make every cube manage its own moving state. have a static list of gameObjects and when a cube is moving, // it adds itself to that list and when it's done moving it removes itself. then you can just check the list.Count // to see if any blocks are moving private bool AnyCubeIsMoving() { // continually check if everything has stopped falling/moving bool anyBlockIsMoving = false; List <GameObject> allCubes = MasterGrid.GetAllCubes(); // check if any cubes are moving or falling for (int i = 0; i < allCubes.Count; i++) { if (allCubes[i] == null) { continue; } CubeController cc = allCubes[i].GetComponent <CubeController>(); if (cc.isMovingOrFalling()) { anyBlockIsMoving = true; break; } } return(anyBlockIsMoving); }
private void MasterGridView_PopupMenuShowing(object sender, DevExpress.XtraGrid.Views.Grid.PopupMenuShowingEventArgs e) { try { e.Menu.Items.Add(new DevExpress.Utils.Menu.DXMenuItem("Select Report Data Range", (o1, e1) => { Controls.Add(_RangeSelector); _RangeSelector.BtnLoad.Click += new EventHandler(BtnLoad_Click); _RangeSelector.BringToFront(); _RangeSelector.Location = new Point(e.Point.X + 20, e.Point.Y + 20); _RangeSelector.Show(); _RangeSelector.DtFrom.Focus(); })); var formatRulesMenu = new DXPopupMenu(); var view = sender as GridView; DXMenuItem Copy; DXMenuItem SAR; DXMenuItem Collapse; DXMenuItem Expand; DXMenuItem FixLeft; DXMenuItem FixRight; DXMenuItem UnFix; Copy = new DXMenuItem("Copy", (o1, e1) => { view.OptionsSelection.MultiSelect = true; view.CopyToClipboard(); }); SAR = new DXMenuItem("Select All Records", (o1, e1) => { view.OptionsSelection.MultiSelect = true; view.SelectAll(); }); Expand = new DXMenuItem("Expand All", (o1, e1) => { MasterGridView.ExpandAllGroups(); }); Collapse = new DXMenuItem("Collapse All", (o1, e1) => { MasterGridView.CollapseAllGroups(); }); FixLeft = new DXMenuItem("Fix Column Left", (o1, e1) => { MasterGridView.OptionsView.ColumnAutoWidth = false; var hitInfo = MasterGridView.CalcHitInfo(MasterGrid.PointToClient(Control.MousePosition)); if (hitInfo.InRowCell) { int rowHandle = hitInfo.RowHandle; DevExpress.XtraGrid.Columns.GridColumn column = new DevExpress.XtraGrid.Columns.GridColumn(); column = hitInfo.Column; column.Fixed = DevExpress.XtraGrid.Columns.FixedStyle.Left; } }); FixRight = new DXMenuItem("Fix Column Right", (o1, e1) => { MasterGridView.OptionsView.ColumnAutoWidth = false; var hitInfo = MasterGridView.CalcHitInfo(MasterGrid.PointToClient(Control.MousePosition)); if (hitInfo.InRowCell) { int rowHandle = hitInfo.RowHandle; DevExpress.XtraGrid.Columns.GridColumn column = new DevExpress.XtraGrid.Columns.GridColumn(); column = hitInfo.Column; column.Fixed = DevExpress.XtraGrid.Columns.FixedStyle.Right; } }); UnFix = new DXMenuItem("Unfix Column", (o1, e1) => { MasterGridView.OptionsView.ColumnAutoWidth = false; var hitInfo = MasterGridView.CalcHitInfo(MasterGrid.PointToClient(Control.MousePosition)); if (hitInfo.InRowCell) { int rowHandle = hitInfo.RowHandle; DevExpress.XtraGrid.Columns.GridColumn column = new DevExpress.XtraGrid.Columns.GridColumn(); column = hitInfo.Column; column.Fixed = DevExpress.XtraGrid.Columns.FixedStyle.None; } }); e.Menu.Items.Add(Copy); e.Menu.Items.Add(SAR); e.Menu.Items.Add(Collapse); e.Menu.Items.Add(Expand); e.Menu.Items.Add(FixLeft); e.Menu.Items.Add(FixRight); e.Menu.Items.Add(UnFix); } catch (Exception ex) { ProjectFunctions.SpeakError(ex.Message); } }
public void UpdateGridZ(int z) { gridZ = z; MasterGrid.UpdateCubePosition(gameObject, new Vector3Int(gridX, gridY, gridZ)); }
/// <summary> /// Page Init event; creates all required controls in a page. /// </summary> /// <param name="sender">The page sending the event.</param> /// <param name="e"></param> protected void Page_Init(object sender, EventArgs e) { var user = HttpContext.Current.Session["user"] as User; int userId = 0; if (user != null) { userId = user.Id; } int assemblyTypeId = HttpContext.Current.Session["assemblyType"].ToString().ToInt32(0); //if (userId == 0 || assemblyTypeId == 0) //{ // invalid state. forced to logout // TODO: User RolePermissionHelper.Logout // RolePermissionHelper.RedirectToLogin(); // Response.Redirect("/Account/Logout.aspx"); //} var masterPage = this.Controls[0] as IMainMaster; if (masterPage == null) { Response.Write("<p>Your master page must implement IMainMaster interface.</p>"); } //Schema is loaded during login var schemaInfo = Application["SchemaInfo"] as SchemaInfo; tableMeta = schemaInfo.Tables.Where(s => s.Name.Equals(tableName, StringComparison.InvariantCultureIgnoreCase)).FirstOrDefault(); if (tableMeta == null) { var page = this.Controls[0] as IMainMaster; page.MainContent.Controls.Add(new LiteralControl(string.Format("<h2>{0}</h2>", "Invalid Page"))); return; } //header info string StationAct = Request.QueryString["StationAct"].ToString(); int ProductionLineId = Convert.ToInt32(Request.QueryString["ProductionLineId"]); string Date1 = Request.QueryString["Date1"].ToString(); //DateTime Date = DateTime.Parse(dt); string header = ""; //parameter to the stored procedure //if it is a stored procedure, use comma as separator for paramater/filter. do not user AND/OR logical operation string queryFilter = null; if (tableMeta.TableType == ETableType.StoredProcedure) { queryFilter = string.Format("Date1={0}{1}ProductionLineId={2}{3}StationAct={4}", Date1, AppConfiguration.SP_FILTER_SEPARATOR, ProductionLineId, AppConfiguration.SP_FILTER_SEPARATOR, StationAct); } else { if (StationAct != "") { queryFilter = "StationAct=" + StationAct; if (ProductionLineId > 0) { queryFilter += " AND ProductionLineId=" + ProductionLineId; } if (Date1 != null) { queryFilter += " AND Date=" + Date1; } } } //create the page var gridCreator = new MasterGrid(this, this.tableMeta); masterGrid = gridCreator.Render(userId, assemblyTypeId, queryFilter); //create filter panel var filterPanelCreator = new FilterPanel(this, this.tableMeta); filterPanel = filterPanelCreator.Render(userId, assemblyTypeId); //create hidden field to store temporary data var field = new ASPxHiddenField(); field.ID = HIDDEN_FIELD_ID; field.ClientInstanceName = HIDDEN_FIELD_ID; //var scriptManager = new ASPxScriptManager(); var panel = new System.Web.UI.WebControls.Panel(); panel.CssClass = "mainContent"; panel.Controls.Add(new LiteralControl(string.Format("<h2 class='grid-header'>{0}</h2>", tableMeta.Caption))); panel.Controls.Add(new LiteralControl(string.Format("<p>" + StationAct + " Line " + ProductionLineId + " On " + Date1 + "</p>"))); if (filterPanel != null) { panel.Controls.Add(filterPanel); } panel.Controls.Add(masterGrid); if (masterGrid.Width.Value > 0) { panel.Width = masterGrid.Width; } panel.Controls.Add(field); if (tableMeta.ShowExportButton) { var buttonPanel = new System.Web.UI.WebControls.Panel(); buttonPanel.CssClass = "grid-button-panel"; buttonPanel.Width = new Unit("100%"); //buttonPanel.BorderWidth = new Unit("1px"); //add export button ASPxButton btnExport = new ASPxButton(); btnExport.ID = "btnExportGrid"; btnExport.Text = "Export to Excel"; btnExport.Click += btnExport_click; btnExport.CssClass = "btn-export-xls"; //btnExport.Width = new Unit("100%"); #if _BTN_NATIVE_ btnExport.CssClass = "btn btn-export btn-xs"; btnExport.Native = true; #endif buttonPanel.Controls.Add(btnExport); panel.Controls.Add(buttonPanel); //add exporter grid gridExporter = new ASPxGridViewExporter(); gridExporter.GridViewID = masterGrid.ID; //string.Concat(table, "GridView"); gridExporter.ID = "GridExport"; gridExporter.FileName = tableMeta.Name + " (" + header + ")"; gridExporter.ExportedRowType = GridViewExportedRowType.All; panel.Controls.Add(gridExporter); ////add script manager //panel.Controls.Add(scriptManager); } masterPage.MainContent.Controls.Add(panel); masterPage.PageTitle.Controls.Add(new LiteralControl(tableMeta.Caption)); ////re-apply the filtering if necessary //if (tableMeta.ShowFilterPanel) //{ // GridViewHelper.ApplyGridViewFilter(masterGrid, filterPanel, tableMeta); //} //else //{ // masterGrid.DataBind(); //} }
void Start() { //front MasterGrid.AddCube(-1, 0, 0, CubeColor.Gray, cubePrefab); MasterGrid.AddCube(-2, 0, 0, CubeColor.White, cubePrefab); MasterGrid.AddCube(0, 0, 0, CubeColor.Red, cubePrefab); MasterGrid.AddCube(1, 0, 0, CubeColor.Green, cubePrefab); MasterGrid.AddCube(2, 0, 0, CubeColor.Gray, cubePrefab); MasterGrid.AddCube(-1, 1, 0, CubeColor.Blue, cubePrefab); MasterGrid.AddCube(-2, 1, 0, CubeColor.Red, cubePrefab); MasterGrid.AddCube(0, 1, 0, CubeColor.Blue, cubePrefab); MasterGrid.AddCube(1, 1, 0, CubeColor.Gray, cubePrefab); MasterGrid.AddCube(2, 1, 0, CubeColor.Red, cubePrefab); MasterGrid.AddCube(-1, 2, 0, CubeColor.Red, cubePrefab); MasterGrid.AddCube(-2, 2, 0, CubeColor.White, cubePrefab); MasterGrid.AddCube(0, 2, 0, CubeColor.Green, cubePrefab); MasterGrid.AddCube(1, 2, 0, CubeColor.Green, cubePrefab); MasterGrid.AddCube(2, 2, 0, CubeColor.Red, cubePrefab); MasterGrid.AddCube(-1, 3, 0, CubeColor.Red, cubePrefab); MasterGrid.AddCube(-2, 3, 0, CubeColor.Gray, cubePrefab); MasterGrid.AddCube(0, 3, 0, CubeColor.Gray, cubePrefab); MasterGrid.AddCube(1, 3, 0, CubeColor.Red, cubePrefab); MasterGrid.AddCube(2, 3, 0, CubeColor.Gray, cubePrefab); MasterGrid.AddCube(-1, 4, 0, CubeColor.Gray, cubePrefab); MasterGrid.AddCube(-2, 4, 0, CubeColor.Red, cubePrefab); MasterGrid.AddCube(0, 4, 0, CubeColor.White, cubePrefab); MasterGrid.AddCube(1, 4, 0, CubeColor.Green, cubePrefab); MasterGrid.AddCube(2, 4, 0, CubeColor.Red, cubePrefab); //back MasterGrid.AddCube(-1, 0, 1, CubeColor.Red, cubePrefab); MasterGrid.AddCube(-2, 0, 1, CubeColor.Blue, cubePrefab); MasterGrid.AddCube(0, 0, 1, CubeColor.Red, cubePrefab); MasterGrid.AddCube(1, 0, 1, CubeColor.Red, cubePrefab); MasterGrid.AddCube(2, 0, 1, CubeColor.Gray, cubePrefab); MasterGrid.AddCube(-1, 1, 1, CubeColor.White, cubePrefab); MasterGrid.AddCube(-2, 1, 1, CubeColor.Red, cubePrefab); MasterGrid.AddCube(0, 1, 1, CubeColor.Green, cubePrefab); MasterGrid.AddCube(1, 1, 1, CubeColor.Gray, cubePrefab); MasterGrid.AddCube(2, 1, 1, CubeColor.Red, cubePrefab); MasterGrid.AddCube(-1, 2, 1, CubeColor.Red, cubePrefab); MasterGrid.AddCube(-2, 2, 1, CubeColor.Green, cubePrefab); MasterGrid.AddCube(0, 2, 1, CubeColor.White, cubePrefab); MasterGrid.AddCube(1, 2, 1, CubeColor.Blue, cubePrefab); MasterGrid.AddCube(2, 2, 1, CubeColor.Blue, cubePrefab); MasterGrid.AddCube(-1, 3, 1, CubeColor.Blue, cubePrefab); MasterGrid.AddCube(-2, 3, 1, CubeColor.Gray, cubePrefab); MasterGrid.AddCube(0, 3, 1, CubeColor.Gray, cubePrefab); MasterGrid.AddCube(1, 3, 1, CubeColor.Green, cubePrefab); MasterGrid.AddCube(2, 3, 1, CubeColor.Blue, cubePrefab); MasterGrid.AddCube(-1, 4, 1, CubeColor.Gray, cubePrefab); MasterGrid.AddCube(-2, 4, 1, CubeColor.White, cubePrefab); MasterGrid.AddCube(0, 4, 1, CubeColor.Green, cubePrefab); MasterGrid.AddCube(1, 4, 1, CubeColor.White, cubePrefab); MasterGrid.AddCube(2, 4, 1, CubeColor.Red, cubePrefab); }
private IEnumerator TriggerCubeDeletionChain(List <GameObject> cubesToTest, bool isFirstMove) { //grab all of the cube chains we will be checking List <List <GameObject> > cubeChains = new List <List <GameObject> >(); foreach (GameObject cube in cubesToTest) { //if this cube is in an existing chain that we have, skip it. bool cubeAlreadyInChain = false; foreach (var chain in cubeChains) { foreach (var c in chain) { if (c.GetInstanceID() == cube.GetInstanceID()) { cubeAlreadyInChain = true; break; } } if (cubeAlreadyInChain) { break; } } if (cubeAlreadyInChain) { continue; } // add this unique cube chain cubeChains.Add(MasterGrid.GetColorChain(cube)); } Debug.Log(cubeChains.Count); // delete the cubes in each chain that needs it bool chainsWereDeleted = false; foreach (List <GameObject> cubeChain in cubeChains) { if (CubeChainShouldDelete(cubeChain)) { chainsWereDeleted = true; foreach (GameObject c in cubeChain) { // does this need a null check? DestroyImmediate(c.gameObject); } } } // if any cubes were removed, we need to clean the grid of null values // and update "floating" cubes to their new positions and make them fall. if (chainsWereDeleted) { MasterGrid.Clean(); int highestCubeYValue = 0; foreach (var cube in MasterGrid.GetAllCubes()) { if (cube.GetComponent <CubeController>().GetGridPosition().y > highestCubeYValue) { highestCubeYValue = cube.GetComponent <CubeController>().GetGridPosition().y; } } // TODO should be able to start with 1 i think 0 height cubes should never be set to fall right? for (int i = 1; i <= highestCubeYValue; i++) { foreach (var cube in MasterGrid.GetAllCubes()) { if (cube.GetComponent <CubeController>().GetGridPosition().y == i) { int cubesBelow = MasterGrid.GetCubesBelow(cube); if (cube.GetComponent <CubeController>().GetGridPosition().y != cubesBelow) { cube.GetComponent <CubeController>().UpdateGridY(cubesBelow); cube.GetComponent <CubeController>().SetFalling(); } } } } yield return(new WaitUntil(() => AnyCubeIsMoving() == false)); Debug.Log("freedom!"); // recursion! StartCoroutine(TriggerCubeDeletionChain(MasterGrid.GetAllCubes(), false)); } else if (isFirstMove) { MoveCubesBack(); yield return(new WaitUntil(() => AnyCubeIsMoving() == false)); MasterGrid.UpdateSelectedCubePositions(lastMovedCubes[0], lastMovedCubes[1]); lastMovedCubes = new List <GameObject>(); } }