public GridElement DetechTouchPositionOnGrid(Vector2 TouchPosition) { int[,] Index_tab = new int[1, 2]; Index_tab = (int[,])DetectPoint.DetechTouchPositionOnGrid(Grid, TouchPosition).Clone(); //Debug.Log(Index_tab[0, 0] + " " + Index_tab[0,1]); GridElement element = Grid[Index_tab[0,0] , Index_tab[0,1] ]; Vector3 Apoint = Camera.main.ViewportToWorldPoint(new Vector3( element.getA().x, element.getA().y, element.getZ()) ); Vector3 Bpoint = Camera.main.ViewportToWorldPoint(new Vector3(element.getC().x, element.getC().y, element.getZ()) ); float x = Bpoint.x - Bpoint.x; GreenField.transform.position = new Vector3(element.getA().x + (element.getB().x - element.getA().x), element.getB().y - (element.getB().y - element.getA().y) , GreenField.transform.position.z); TouchedElement = element; return element; }
public void MenuDto_test() { var root = new GridElement() { Parent = null, Content = "", Id = Guid.NewGuid(), }; var rootchild = new GridElement() { Parent = root, Content = "", Id = Guid.NewGuid(), }; var rootchild2 = new GridElement() { Parent = root, Content = "", Id = Guid.NewGuid(), }; var menu = new List<GridElement> { root,rootchild,rootchild2 }; var dto = menu.ToChildren().ToList(); Assert.AreEqual(1,dto.Count); Assert.AreEqual(2,dto[0].Children.Count()); }
public static void Run() { // ExStart:SetElementLevelThreshold // The path to the documents directory. string dataDir = RunExamples.GetDataDir_OCR(); // Load template file OmrTemplate template = OmrTemplate.Load(dataDir + "questions.amr"); // Load the image to be analyzed OmrImage image = OmrImage.Load(dataDir + "answers.jpg"); // Get the first page of the template OmrPage page = template.Pages[0]; // Create an element by passing the name, location and size GridElement element = new GridElement("grid1", new PointF(10, 20), new SizeF(60, 30)); // Add element to the page page.Elements.Add(element); // Create configuration for the element element.Configuration = new OmrConfig(); // Set the TrimWhitePixels to false element.Configuration.TrimWhitePixels = false; // Create an instance of OmrEngine and pass object of OmrTemplate as parameter OmrEngine engine = new OmrEngine(template); // Extract the data OmrProcessingResult result = engine.ExtractData(new OmrImage[] { image }); // ExEnd:SetElementLevelThreshold }
public void setChunks(GridElement[,] _GridElement, int size) { Debug.Log(_GridElement.Length); int GridIndex_X = 0; int GridIndex_Y = 0; for(int i = 0; i < ChunkArraySize; i++) { for(int j = 0; j < ChunkArraySize; j++) { GridElement element = new GridElement(); element.setA(_GridElement[GridIndex_X, GridIndex_Y].getA()); GridIndex_Y += ChunkElementCount; element.setD(_GridElement[GridIndex_X, GridIndex_Y].getD()); GridIndex_Y -= ChunkElementCount; GridIndex_X += ChunkArraySize; element.setB(_GridElement[GridIndex_X, GridIndex_Y].getB()); GridIndex_Y += ChunkElementCount; element.setC(_GridElement[GridIndex_X, GridIndex_Y].getC()); GridIndex_Y++; GridIndex_X -= ChunkElementCount; } } }
/// <summary> /// GetTextCore /// </summary> /// <param name="value"></param> /// <param name="formatInfo"></param> /// <param name="gridElement"></param> /// <returns></returns> protected override string GetTextCore(object value, CellTextFormatInfo formatInfo, GridElement gridElement) { DataCell cell = gridElement as DataCell; if (cell == null) return null; if (cell.Value == null) { Xceed.Grid.DataRow row = cell.ParentRow as Xceed.Grid.DataRow; if (row == null) return null; if (row.DetailGrids.Count == 0) return null; MyDetailGrid detailGrid = row.DetailGrids[0] as MyDetailGrid; if (detailGrid == null) return null; string functionName, fieldName, format, where; int level = -1; MySummaryRow.ExtractParameters(m_statisticsFormat, out functionName, out fieldName, out format, ref level, out where); cell.Value = Feng.Utils.ConvertHelper.ChangeType(MySummaryRow.GetVariableFunctionResult(detailGrid.GetSortedDataRows(true), functionName, fieldName, format, level, where), cell.ParentColumn.DataType); } return base.GetTextCore(value, formatInfo, gridElement); }
public void AddBlock(int x, int y, Block block, GridElement.ElementState state) { DebugUtilities.Assert(x < PlayWidth); DebugUtilities.Assert(y < PlayHeight); DebugUtilities.Assert(grid[x, y].State == GridElement.ElementState.Empty); grid[x, y].Element = block; grid[x, y].Type = GridElement.ElementType.Block; grid[x, y].State = state; }
protected override string GetTextCore(object value, CellTextFormatInfo formatInfo, GridElement gridElement) { string s = (string)value; if (string.IsNullOrEmpty(s)) return string.Empty; string[] ss = s.Split(new char[] { '/', '-' }, StringSplitOptions.RemoveEmptyEntries); if (ss.Length < 2) return string.Empty; return ss[1]; }
protected override Image GetImageCore(object value, CellImageFormatInfo formatInfo, GridElement gridElement) { if (value == null) return null; if (!Convert.ToBoolean(value)) return Feng.Windows.ImageResource.Get(m_startImage).Reference; else return Feng.Windows.ImageResource.Get(m_stopImage).Reference; }
protected GridElement AGridElement(string type, ApplicationSetting application, Guid id, int position = 0) { var grid = new GridElement { AppliceSetting = application, Type = type, Width = 12, Position = position, Id = id }; return grid; }
private GridElement GetLowestFCost(List <GridElement> nodeList) { GridElement lcn = nodeList[0]; foreach (var node in nodeList) { if (node.fCost < lcn.fCost) { lcn = node; } } return(lcn); }
public void UpdateDescription() { GridElement selectedGE = selectedGO.GetComponent <GridElement>(); if (selectedGE && selectedGE.piece) { pieceDescription.text = selectedGE.piece.name; } else { pieceDescription.text = ""; } }
private GridRow GetRow(Point position) { GridRow result = null; GridElement item = _grid.GetElementAt(position); if (item is GridCell cell) { result = cell.GridRow; } return(result); }
public IContainer Item(int columns = 1) { var container = new Container(); var element = new GridElement { Columns = columns, Child = container }; Grid.Children.Add(element); return(container); }
private void InitGridElement(float x, float y, float z, float width, float length, SceneElement parent) { var folder = new SharpGL.SceneGraph.Primitives.Folder() { Name = "Grid" }; parent.AddChild(folder); var grid = new GridElement(x, y, z, width, length); folder.AddChild(grid); }
/// <summary> /// GetTextCore /// </summary> /// <param name="value"></param> /// <param name="formatInfo"></param> /// <param name="gridElement"></param> /// <returns></returns> protected override string GetTextCore(object value, CellTextFormatInfo formatInfo, GridElement gridElement) { if (value == null) { return string.Empty; // 如果返回null会引发GetFittedWidth异常 // return null; } else { // 不带引号 return EntityHelper.ReplaceEntity(m_displayMember, value, null); } }
public override BaseFrameworkElement BuildPanel(SceneViewModel viewModel, ICollection <BaseFrameworkElement> children) { GridElement gridElement = (GridElement)viewModel.CreateSceneNode(this.PanelType); int num = 0; foreach (BaseFrameworkElement frameworkElement in (IEnumerable <BaseFrameworkElement>)children) { gridElement.Children.Add((SceneNode)frameworkElement); gridElement.RowDefinitions.Add(RowDefinitionNode.Factory.Instantiate(viewModel)); frameworkElement.SetValue(GridElement.RowProperty, (object)num); ++num; } return((BaseFrameworkElement)gridElement); }
private void Update() { Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); if (Physics.Raycast(ray, out mouseHit)) { GridElement gE = mouseHit.transform.gameObject.GetComponent <GridElement>(); if (gE == null) { if (currentHoveredGridElement) { currentHoveredGridElement.GetComponent <MeshRenderer>().material.color = colorOnNormal; return; } } if (Input.GetMouseButtonDown(0)) { currentSelectedGridElement = gE; } if (gE != currentHoveredGridElement) { if (!gE.occupied) { mouseHit.transform.gameObject.GetComponent <MeshRenderer>().material.color = colorOnHover; } else { mouseHit.transform.gameObject.GetComponent <MeshRenderer>().material.color = colorOnOccupied; } } if (currentHoveredGridElement && currentHoveredGridElement != gE) { currentHoveredGridElement.GetComponent <MeshRenderer>().material.color = colorOnNormal; } currentHoveredGridElement = gE; } else { currentHoveredGridElement.GetComponent <MeshRenderer>().material.color = colorOnNormal; } MoveBuilding(); PlaceBuilding(); clicked = clicker.ManoClicked; }
private TextBlock CreateTextBlock(GridElement element, int indexRow, int indexColumn) { var textNew = new TextBlock { Text = element.Text, Margin = new Thickness(2), HorizontalAlignment = element.Alignment, }; System.Windows.Controls.Grid.SetRow(textNew, indexRow); System.Windows.Controls.Grid.SetColumn(textNew, indexColumn); return(textNew); }
protected void RandomTargetElement() { int x, y; GridElement possibruElemento = null; while (possibruElemento == null || !possibruElemento.Walkable) { x = Random.Range(8, 22); y = Random.Range(0, 2); y = y == 0 ? Random.Range(4, 11) : Random.Range(19, 26); possibruElemento = _myAgent.MyGrid.Elements[x, y, 0]; } _myAgent.TargetObject = possibruElemento.transform; }
internal override void MakeVisible(GridElement element) { var pair = element.Container as Tuple <FrameworkElement, FrameworkElement>; if (pair.Item1 != null) { pair.Item1.ClearValue(UIElement.VisibilityProperty); } if (pair.Item2 != null) { pair.Item2.ClearValue(UIElement.VisibilityProperty); } }
private void NormalizeWidthStars(GridElement grid, List <int> widthStarIndices) { double num1 = 0.0; foreach (int column in widthStarIndices) { num1 += grid.GetComputedColumnWidth(column); } foreach (int column in widthStarIndices) { double num2 = RoundingHelper.RoundLength(num1 == 0.0 ? 1.0 : grid.GetComputedColumnWidth(column) / num1); grid.ColumnDefinitions[column].Width = new GridLength(num2, GridUnitType.Star); } }
internal override void Collapse(GridElement element) { var pair = element.Container as Tuple <FrameworkElement, FrameworkElement>; if (pair.Item1 != null) { pair.Item1.Visibility = Visibility.Collapsed; } if (pair.Item2 != null) { pair.Item2.Visibility = Visibility.Collapsed; } }
protected override void performOne(GridElement gridElement, int value) { if (gridElement.unit != null && unitBase.unitCounters["isEnemy"] != gridElement.unit.GetComponent <UnitBase>().unitCounters["isEnemy"]) { gridElement.unit.GetComponent <UnitBase>().unitCounters["hp"] -= value; hasAttacked = true; gridElement.getDamage(value); //Debug.Log("attack"); if (gridElement.unit.GetComponent <UnitBase>().unitCounters["hp"] <= 0) { gridElement.unit.GetComponent <UnitBase>().destroyMe(); } } }
private void NormalizeHeightStars(GridElement grid, List <int> heightStarIndices) { double num1 = 0.0; foreach (int row in heightStarIndices) { num1 += grid.GetComputedRowHeight(row); } foreach (int row in heightStarIndices) { double num2 = RoundingHelper.RoundLength(num1 == 0.0 ? 1.0 : grid.GetComputedRowHeight(row) / num1); grid.RowDefinitions[row].Height = new GridLength(num2, GridUnitType.Star); } }
public void RemoveRow(GridElement grid, int index) { using (SceneEditTransaction editTransaction = grid.ViewModel.CreateEditTransaction(StringTable.UndoUnitRemoveGridline)) { grid.ViewModel.GridRowSelectionSet.Clear(); grid.ViewModel.AnimationEditor.DeleteAllAnimations((SceneNode)grid.RowDefinitions[index]); using (grid.ViewModel.ForceBaseValue()) { List <LayoutCacheRecord> currentRects = this.GetCurrentRects((BaseFrameworkElement)grid); bool isStar1 = grid.RowDefinitions[index - 1].Height.IsStar; bool isStar2 = grid.RowDefinitions[index].Height.IsStar; List <int> heightStarIndices = this.GetHeightStarIndices(grid); grid.CacheComputedRowHeights(); List <double> computedRowHeightCache; int index1; (computedRowHeightCache = grid.ComputedRowHeightCache)[index1 = index - 1] = computedRowHeightCache[index1] + grid.ComputedRowHeightCache[index]; grid.ComputedRowHeightCache.RemoveAt(index); grid.RowDefinitions.RemoveAt(index); if (isStar2) { heightStarIndices.Remove(index); } if (isStar1 || isStar2) { for (int index2 = 0; index2 < heightStarIndices.Count; ++index2) { if (heightStarIndices[index2] > index) { List <int> list; int index3; (list = heightStarIndices)[index3 = index2] = list[index3] - 1; } } this.NormalizeHeightStars(grid, heightStarIndices); } if (!isStar1) { grid.RowDefinitions[index - 1].Height = new GridLength(grid.ComputedRowHeightCache[index - 1]); grid.RowDefinitions[index - 1].ClearValue(RowDefinitionNode.MinHeightProperty); } editTransaction.Update(); grid.ViewModel.RefreshSelection(); this.SetCurrentRects((BaseFrameworkElement)grid, currentRects); grid.UncacheComputedRowHeights(); GridLayoutDesigner.ReselectGridToRestoreAdorners(grid); editTransaction.Commit(); } } }
private void AddPresenterIfNecessary(DocumentCompositeNode visualTreeNode, SceneElement newElement) { Type targetType = (Type)null; if (PlatformTypes.ContentControl.IsAssignableFrom((ITypeId)newElement.Type)) { targetType = newElement.ViewModel.ProjectContext.ResolveType(PlatformTypes.ContentPresenter).RuntimeType; } else if (PlatformTypes.ItemsControl.IsAssignableFrom((ITypeId)newElement.Type)) { targetType = newElement.ViewModel.ProjectContext.ResolveType(PlatformTypes.ItemsPresenter).RuntimeType; } if (!(targetType != (Type)null)) { return; } DocumentNode node = visualTreeNode.SelectFirstDescendantNode(targetType); if (node == null) { PanelElement panelElement = (PanelElement)this.SceneViewModel.GetSceneNode((DocumentNode)visualTreeNode); SceneElement presenterElement = (SceneElement)this.SceneViewModel.CreateSceneNode(targetType); SceneElement sceneElement = this.PreparePresenter(visualTreeNode, presenterElement); GridElement gridElement = panelElement as GridElement; if (gridElement != null) { int count1 = gridElement.ColumnDefinitions.Count; int count2 = gridElement.RowDefinitions.Count; if (count1 > 0) { sceneElement.SetLocalValue(GridElement.ColumnSpanProperty, (object)count1); } if (count2 > 0) { sceneElement.SetLocalValue(GridElement.RowSpanProperty, (object)count2); } } panelElement.Children.Add((SceneNode)sceneElement); } else { SceneElement presenterElement = this.SceneViewModel.GetSceneNode(node) as SceneElement; if (presenterElement == null) { return; } this.PreparePresenter(visualTreeNode, presenterElement); } }
/// <summary> /// Creates grid view model from grid model /// </summary> /// <param name="gridElement">Grid model data</param> /// <param name="templateViewModel">Parent template</param> /// <returns>Created grid view model</returns> private static GridViewModel CreateGridViewModel(GridElement gridElement, TemplateViewModel templateViewModel) { GridViewModel gridViewModel = new GridViewModel( gridElement.Name, gridElement.Top, gridElement.Left, gridElement.Width, gridElement.Height, templateViewModel, gridElement.Orientation); gridViewModel.ChoiceBoxes.Clear(); List <ChoiceBoxViewModel> choiceBoxes = new List <ChoiceBoxViewModel>(); foreach (var omrElement in gridElement.ChoiceBoxes) { var choiceBox = (ChoiceBoxElement)omrElement; ChoiceBoxViewModel choiceBoxViewModel = new ChoiceBoxViewModel( choiceBox.Name, choiceBox.Top - gridElement.Top, choiceBox.Left - gridElement.Left, choiceBox.Width, choiceBox.Height, null, gridViewModel); foreach (OmrBubble modelBubble in choiceBox.Bubbles) { BubbleViewModel bubbleViewModel = new BubbleViewModel( choiceBox.BubbleWidth, choiceBox.BubbleHeight, modelBubble.Top - choiceBox.Top, modelBubble.Left - choiceBox.Left, choiceBoxViewModel); bubbleViewModel.Name = modelBubble.Value; bubbleViewModel.IsValid = modelBubble.IsValid; choiceBoxViewModel.Bubbles.Add(bubbleViewModel); } choiceBoxes.Add(choiceBoxViewModel); } gridViewModel.InitiWithChoiceBoxes(choiceBoxes); return(gridViewModel); }
public string GetActiveSheetXml() { for (int i = 0; i < ActiveSheet.Rows.Count; i++) { for (int j = 0; j < ActiveSheet.ColumnCount; j++) { GridElement e = ActiveSheet.Cells[i, j].Value as GridElement; if (e != null) { ActiveSheet.Cells[i, j].Value = e.Value == null ? "" : e.Value.ToString(); } } } return(Serializer.GetObjectXml(ActiveSheet, "SheetView")); }
public void SaveGrid() { List <GridElement> gridList = new List <GridElement>(); foreach (Transform element in transform) { IGridPiece piece = element.GetComponent <IGridPiece>(); GridElement thisPiece = new GridElement { point = piece.point.ToString(), color = piece.selfColor.ToString() }; gridList.Add(thisPiece); } Debug.Log(gridList.Count); SaveSystem.SaveToJson(gridList); }
protected void CacheRowColumnCounts() { GridElement gridElement = (GridElement)this.Element; if (gridElement == null || gridElement.ColumnDefinitions == null || gridElement.RowDefinitions == null) { this.Columns = 0; this.Rows = 0; } else { this.Columns = gridElement.ColumnDefinitions.Count; this.Rows = gridElement.RowDefinitions.Count; } }
public void RotateRight(GridElement selectedGE) { DoublyLinkedListNode curNode = head; if (selectedGE.piece && selectedGE.piece.GetComponent <GamePiece>() is Unit) { Unit selectedUnit = selectedGE.piece.GetComponent <Unit>(); curNode = FindNode(selectedUnit); } if (activeMenu is GridMenu) { ((GridMenu)activeMenu).ChangeElementSelected(curNode.prev.item.GetComponent <Unit>().gridElement.gameObject); } }
public override void OnElementFound(GridElement element, Texture2D tex) { if (tex.width == 48) { ((IconElement)element).VeryHighResTex = tex; } else if (tex.width == 24) { ((IconElement)element).HighResTex = tex; } else if (tex.width == 10) { ((IconElement)element).LowResTex = tex; } }
protected override string GetTextCore(object value, CellTextFormatInfo formatInfo, GridElement gridElement) { bool? v = Feng.Utils.ConvertHelper.ToBoolean(value); if (v.HasValue) { if (v.Value) return m_yesText; else return m_noText; } else { return null; } }
private void SetColumnWidthCore(GridElement grid, int col, double width) { width = RoundingHelper.RoundLength(width); ColumnDefinitionNode columnDefinitionNode = grid.ColumnDefinitions[col]; if (columnDefinitionNode.Width.IsAuto) { columnDefinitionNode.MinWidth = width; } else { columnDefinitionNode.Width = new GridLength(width); } grid.ComputedColumnWidthCache[col] = width; }
public virtual List <GridElement> GetAdjacentTiles(GridElement current, List <GridElement> freePositions) { Vector2 currentPosition = new Vector2(current.Position.x, current.Position.y); List <Vector2> adjacentTilesPositions = new List <Vector2>() { currentPosition + new Vector2(1, 0), currentPosition + new Vector2(-1, 0), currentPosition + new Vector2(0, 1), currentPosition + new Vector2(0, -1), }; var adjacentTiles = freePositions.Where(x => adjacentTilesPositions.Any(y => new Vector2(x.Position.x, x.Position.y).Equals(y))).ToList(); return(adjacentTiles); }
private void SetRowHeightCore(GridElement grid, int row, double height) { height = RoundingHelper.RoundLength(height); RowDefinitionNode rowDefinitionNode = grid.RowDefinitions[row]; if (rowDefinitionNode.Height.IsAuto) { rowDefinitionNode.MinHeight = height; } else { rowDefinitionNode.Height = new GridLength(height); } grid.ComputedRowHeightCache[row] = height; }
public override void OnButtonDrawn(GridElement element, Rect rect) { Rect smallRect = rect; smallRect.size = new Vector2(16, 16); smallRect.x += 9; smallRect.y += 53; if (PreferencesUI.settings.useNewUI) { GUI.DrawTexture(smallRect, ((StyleElement)element).LowResTex, ScaleMode.ScaleToFit, true, 1.0f, Color.black, 0, 0); } smallRect.x--; smallRect.y--; GUI.DrawTexture(smallRect, ((StyleElement)element).LowResTex); }
public async Task <string> GetElement(int gridId, int xLocation, int yLocation) { //Build magic here to return an object var gridElement = await _context.GridElements.Where( x => x.GridId == gridId && x.XLocation == xLocation && x.YLocation == yLocation).FirstOrDefaultAsync <GridElement> (); if (gridElement == null) { gridElement = new GridElement(_random.Next(), xLocation, yLocation, gridId, 0, _random.Next(3) - 1 == 1); } return(JsonConvert.SerializeObject(gridElement)); }
public void AddHorizontalGridline(GridElement grid, double position) { using (SceneEditTransaction editTransaction = grid.ViewModel.CreateEditTransaction(StringTable.UndoUnitAddGridline)) { using (grid.ViewModel.ForceBaseValue()) { List <LayoutCacheRecord> currentRects = this.GetCurrentRects((BaseFrameworkElement)grid); int rowBeforePosition = grid.GetComputedRowBeforePosition(position); double computedPositionOfRow1 = grid.GetComputedPositionOfRow(rowBeforePosition); double computedPositionOfRow2 = grid.GetComputedPositionOfRow(rowBeforePosition + 1); bool flag = grid.RowDefinitions.Count == 0 || grid.RowDefinitions[rowBeforePosition].Height.IsStar; grid.CacheComputedRowHeights(); this.EnsureOneRow(grid); grid.RowDefinitions.Insert(rowBeforePosition + 1, RowDefinitionNode.Factory.Instantiate(grid.ViewModel)); position = Math.Max(position, computedPositionOfRow1); if (position > computedPositionOfRow2) { grid.ComputedRowHeightCache[rowBeforePosition] = computedPositionOfRow2 - computedPositionOfRow1; grid.ComputedRowHeightCache.Insert(rowBeforePosition + 1, position - computedPositionOfRow2); } else { grid.ComputedRowHeightCache[rowBeforePosition] = position - computedPositionOfRow1; grid.ComputedRowHeightCache.Insert(rowBeforePosition + 1, computedPositionOfRow2 - position); } editTransaction.Update(); grid.ViewModel.DefaultView.UpdateLayout(); if (flag) { List <int> heightStarIndices = this.GetHeightStarIndices(grid); this.NormalizeHeightStars(grid, heightStarIndices); } else { grid.RowDefinitions[rowBeforePosition].Height = new GridLength(grid.ComputedRowHeightCache[rowBeforePosition]); grid.RowDefinitions[rowBeforePosition].ClearValue(RowDefinitionNode.MinHeightProperty); grid.RowDefinitions[rowBeforePosition + 1].Height = new GridLength(grid.ComputedRowHeightCache[rowBeforePosition + 1]); grid.RowDefinitions[rowBeforePosition + 1].ClearValue(RowDefinitionNode.MinHeightProperty); } editTransaction.Update(); grid.ViewModel.RefreshSelection(); this.SetCurrentRects((BaseFrameworkElement)grid, currentRects); grid.UncacheComputedRowHeights(); editTransaction.Commit(); } } grid.ViewModel.DefaultView.AdornerLayer.InvalidateAdornersStructure((SceneElement)grid); }
protected override void computeOne(GridElement gridElement, int value) { //UnityEngine.Debug.Log("move: try"); if (value != 1) { return; } //UnityEngine.Debug.Log("move: compute"); Debug.Log("move compute one"); GameObject temp = gridElement.getAbsoluteXZ(0, 5); GridElement goalPos = isGridElement(temp); goalPos = setGoal(goalPos); Debug.Log("Goalpos (" + goalPos.x + "," + goalPos.z + ")"); int x; int z; if (goalPos != null) { var move = Astar(gridElement, goalPos); x = move[0]; z = move[1]; Debug.Log("x: " + x); Debug.Log("z: " + z); } else { x = 0; z = 0; } // TODO A* for x,z GameObject gridElementObject = gridElement.getByXZ(x, z);//Względne if (gridElementObject != null && gridElementObject.GetComponent <GridElement>().unit == null) { GridElement oldGridElement = unitBase.transform.parent.gameObject.GetComponent <GridElement>(); unitBase.transform.SetParent(gridElementObject.transform); gridElementObject.GetComponent <GridElement>().unit = unitBase.gameObject; unitBase.transform.position = new Vector3(gridElementObject.transform.position.x, gridElementObject.transform.position.y - 0.5f, gridElementObject.transform.position.z); oldGridElement.unit = null; // TODO animation goes brrrrrr } else { //UnityEngine.Debug.Log("dupa"); } }
public void AddVerticalGridline(GridElement grid, double position) { using (SceneEditTransaction editTransaction = grid.ViewModel.CreateEditTransaction(StringTable.UndoUnitAddGridline)) { using (grid.ViewModel.ForceBaseValue()) { List <LayoutCacheRecord> currentRects = this.GetCurrentRects((BaseFrameworkElement)grid); int columnBeforePosition = grid.GetComputedColumnBeforePosition(position); double positionOfColumn1 = grid.GetComputedPositionOfColumn(columnBeforePosition); double positionOfColumn2 = grid.GetComputedPositionOfColumn(columnBeforePosition + 1); bool flag = grid.ColumnDefinitions.Count == 0 || grid.ColumnDefinitions[columnBeforePosition].Width.IsStar; grid.CacheComputedColumnWidths(); this.EnsureOneColumn(grid); grid.ColumnDefinitions.Insert(columnBeforePosition + 1, ColumnDefinitionNode.Factory.Instantiate(grid.ViewModel)); position = Math.Max(position, positionOfColumn1); if (position > positionOfColumn2) { grid.ComputedColumnWidthCache[columnBeforePosition] = positionOfColumn2 - positionOfColumn1; grid.ComputedColumnWidthCache.Insert(columnBeforePosition + 1, position - positionOfColumn2); } else { grid.ComputedColumnWidthCache[columnBeforePosition] = position - positionOfColumn1; grid.ComputedColumnWidthCache.Insert(columnBeforePosition + 1, positionOfColumn2 - position); } editTransaction.Update(); grid.ViewModel.DefaultView.UpdateLayout(); if (flag) { List <int> widthStarIndices = this.GetWidthStarIndices(grid); this.NormalizeWidthStars(grid, widthStarIndices); } else { grid.ColumnDefinitions[columnBeforePosition].Width = new GridLength(grid.ComputedColumnWidthCache[columnBeforePosition]); grid.ColumnDefinitions[columnBeforePosition].ClearValue(ColumnDefinitionNode.MinWidthProperty); grid.ColumnDefinitions[columnBeforePosition + 1].Width = new GridLength(grid.ComputedColumnWidthCache[columnBeforePosition + 1]); grid.ColumnDefinitions[columnBeforePosition + 1].ClearValue(ColumnDefinitionNode.MinWidthProperty); } editTransaction.Update(); grid.ViewModel.RefreshSelection(); this.SetCurrentRects((BaseFrameworkElement)grid, currentRects); grid.UncacheComputedColumnWidths(); editTransaction.Commit(); } } grid.ViewModel.DefaultView.AdornerLayer.InvalidateAdornersStructure((SceneElement)grid); }
public ActionResult Create(GridElement gridelement) { if (ModelState.IsValid) { gridelement.ID = Guid.NewGuid(); gridelement.LastModified = DateTime.Now; gridelement.Created = DateTime.Now; db.GridElements.Add(gridelement); db.SaveChanges(); return RedirectToAction("Index"); } ViewBag.BorderColorIDs = new SelectList(db.Colors, "ID", "Name", gridelement.BorderColorID); ViewBag.GridIDs = new SelectList(db.Grids, "ID", "Name", gridelement.GridID); populateFormViewBag(gridelement); if(gridelement.ImageID != Guid.Empty) gridelement.Image = db.Resources.Single(x => x.ID == gridelement.ImageID); return View(gridelement); }
public override MenuItemDto AddMenuItem(MenuItemDto item, Guid gridId) { var grid = GetGrid(gridId); grid.UpdateResourceList(item.ResourcesLoc, CurrentCulture, Repository); var a = new GridElement { Position = item.Position, Content = item.Content, Type = item.Type, Skin = item.Skin, Parent = Repository.GridElements.Single(x => x.Id == new Guid(item.ParentId)), }; grid.GridElements.Add(a); Repository.SaveChanges(); return a.ToMenuItemDto(grid.GridElements); }
protected override Image GetImageCore(object value, CellImageFormatInfo formatInfo, GridElement gridElement) { string s = (string)value; if (string.IsNullOrEmpty(s)) return null; string[] ss = s.Split(new char[] { '/', '-' }, StringSplitOptions.RemoveEmptyEntries); if (ss.Length < 1) return null; int? idx = ConvertHelper.ToInt(ss[0]); if (!idx.HasValue) return null; Image image = new Bitmap(16, 16); //image = ImageHelper.DrawImageBackgound(image, Color.White, 16, 16); Graphics g = Graphics.FromImage(image); g.FillEllipse(new SolidBrush(m_colors[idx.Value % m_colors.Length]), 0, 0, image.Width, image.Height); return image; }
public ActionResult Edit(GridElement gridelement) { if (ModelState.IsValid) { gridelement.LastModified = DateTime.Now; db.GridElements.Attach(gridelement); db.Entry(gridelement).State = EntityState.Modified; db.SaveChanges(); return RedirectToAction("Index"); } ViewBag.BorderColorIDs = new SelectList(db.Colors, "ID", "Name", gridelement.BorderColorID); ViewBag.GridIDs = new SelectList(db.Grids, "ID", "Name", gridelement.GridID); populateFormViewBag(gridelement); return View(gridelement); }
/* private IEnumerator<GridPoint> CalculatePath() { foreach (var fp in village.SearchClosedFacilityDetailPoints(aqPoint, 3).Select(dp=>dp.GetVillageFromDetail())) { IEnumerable<GridPoint> attackableArea = village[fp].GetAllRangeDetailPoints(AQRange).Intersect( village.GetReachableMap().GetAllReachable(this.AQVillagePoint).SelectMany(p=>p.GetDetailsFromVillage())); if (attackableArea.Count() >= 1) { target = village[fp]; return attackableArea.Select(goalPos => new AStarPathFinder(village.GetDetailMap(), goalPos, aqPoint)) .WhereMin(astar => astar.Cost).Select(astar=>astar.Path).First().GetEnumerator(); } } Console.Out.WriteLine("最短3つは攻撃不可"); return null; // 最短3つは攻撃不可 }*/ private IEnumerator<GridPoint> CalculatePath() { /* foreach (var facility in village.SearchClosedFacility(this.AQElementPoint, 3)) { IEnumerable<GridPoint> attackableArea = facility.GetAllRangeDetailPoints(AQRange).Intersect( village.GetReachableMap().GetAllReachable(this.AQVillagePoint).SelectMany(p => p.GetDetailsFromVillage())); if (attackableArea.Count() >= 1) { foreach(var astar in attackableArea.Select(goalPos => new AStarPathFinder(village.GetDetailMap(), goalPos, aqPoint, 80)) .Where(astar=>astar.Path!=null).WhereMin(astar => astar.Cost)) { this.target = facility; Console.Out.WriteLine("astar cost:"+astar.Cost); return astar.Path.GetEnumerator(); } } } Console.Out.WriteLine("最短3つは攻撃不可"); return null; // 最短3つは攻撃不可*/ var closedTuples = SeachClosedAStarPath().WhereMin(t => t.Item2.Cost); if(closedTuples.Count()==0) { Console.Out.WriteLine("経路無し"); return null; } var closedTuple = closedTuples.First(); if (closedTuples.Count() >= 2) { Console.Out.Write("等距離の移動経路を検出。計算結果が変わる可能性があります cost:" + closedTuple.Item2.Cost); foreach(var t in closedTuples) { Console.Out.Write(" "+t.Item1.FacilityID); } Console.Out.WriteLine(""); } this.target = closedTuple.Item1; return closedTuple.Item2.Path.GetEnumerator(); }
private IEnumerable<Tuple<Facility,AStarPathFinder>> SeachClosedAStarPath() { foreach (var facility in village.SearchClosedFacility(this.AQElementPoint, 3)) { IEnumerable<GridPoint> attackableArea = facility.GetAllRangeDetailPoints(AQRange).Intersect( village.GetReachableMap().GetAllReachable(this.AQVillagePoint).SelectMany(p => p.GetDetailsFromVillage())); if (attackableArea.Count() >= 1) { // 直線距離が離れていた場合に除外なのかもしれない foreach(var astar in attackableArea.Select(goalPos => new AStarPathFinder(village.GetDetailMap(), goalPos, aqPoint, 160)).Where(astar=>astar.Path!= null)) { this.target = facility; yield return Tuple.Create(facility,astar); } } } }
private Brush GetGridBrush(GridElement gridElement) { if(gridElement is Wall) { return Brushes.White; } if(gridElement is Facility) { return Brushes.Yellow; } throw new Exception(); }
/// <summary> /// /// </summary> /// <param name="value"></param> /// <param name="formatInfo"></param> /// <param name="gridElement"></param> /// <returns></returns> protected override Image GetImageCore(object value, CellImageFormatInfo formatInfo, GridElement gridElement) { if (m_images.Count == 0) { return null; } Image ret = null; if ((value != null) && (value != DBNull.Value) && (value != formatInfo.NullValue)) { string[] ss = value.ToString().Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); foreach (string s in ss) { if (m_images.ContainsKey(s)) { Image image = Feng.Windows.Utils.ImageHelper.DrawImageBackgound(m_images[s], Color.White, imageWidth, imageHeight); if (ret == null) { ret = image; } else { ret = Feng.Windows.Utils.ImageHelper.ConcatImage(ret, image, Feng.Windows.Utils.ImageHelper.ImageConcatType.Horizontal); } } } } return ret; }
public static GridElement WithParent(this GridElement source, GridElement parent) { source.Parent = parent; return source; }
public static Grid WithGridElement(this Grid source, GridElement gridElement) { gridElement.Grid = source; source.GridElements.Add(gridElement); return source; }
public void StartRound() { grid = new GridElement[Grid.PlayWidth, Grid.PlayHeight]; matchChecks = new List<MatchCheck>(BlockManager.BlockCapacity); topOccupiedRow = 0; topEffectiveRow = 0; for (int x = 0; x < PlayWidth; x++) { for (int y = 0; y < PlayHeight; y++) { grid[x, y] = new GridElement(); grid[x, y].State = GridElement.ElementState.Empty; grid[x, y].Type = GridElement.ElementType.Empty; grid[x, y].Element = null; } } int shortColumn = Random.Range(0, PlayWidth); for (int x = PlayWidth - 1; x >= 0; x--) { int height = (shortColumn == x ? 2 : 7) + Random.Range(0, 2); if (height - 1 > topOccupiedRow) topOccupiedRow = height - 1; for (int y = height - 1; y >= 1; y--) { int type; do { type = Random.Range(0, Block.TypeCount); if (!(StateAt(x, y + 1) == GridElement.ElementState.Empty) && BlockAt(x, y + 1).Type == type) continue; if (x == Grid.PlayWidth - 1) break; if (!(StateAt(x + 1, y) == GridElement.ElementState.Empty) && BlockAt(x + 1, y).Type == type) continue; break; } while (true); // setup creep creation state if (y == 2) BlockManager.SecondToLastRowCreepTypes[x] = type; if (y == 1) BlockManager.LastRowCreepTypes[x] = type; // create the block BlockManager.CreateIdleBlock(x, y, type); } } topEffectiveRow = topOccupiedRow; }
protected override string GetTextCore(object value, CellTextFormatInfo formatInfo, GridElement gridElement) { return null; }
public void addElementToList(GridElement element) { GridElementList.Add(element); }
public void ChangeState(int x, int y, Object element, GridElement.ElementState state) { DebugUtilities.Assert(grid[x, y].Element == element); grid[x, y].State = state; }
public void Remove(GridElement item) { throw new NotImplementedException(); }
public GridElement Add(GridElement item) { throw new NotImplementedException(); }
/// <summary> /// GetTextCore /// </summary> /// <param name="value"></param> /// <param name="formatInfo"></param> /// <param name="gridElement"></param> /// <returns></returns> protected override string GetTextCore(object value, CellTextFormatInfo formatInfo, GridElement gridElement) { string rawText = base.GetTextCore(value, formatInfo, gridElement); //bool more = false; //if (rawText.Length > 20) //{ // rawText = rawText.Substring(0, 20); // more = true; //} //int idx = rawText.IndexOf(System.Environment.NewLine); //if (idx != -1) //{ // rawText = rawText.Substring(0, idx); // more = true; //} //if (more) //{ // rawText += " ..."; //} rawText = rawText.Replace(System.Environment.NewLine, " "); return rawText; }
private void DrawGridElement(Graphics g, int x, int y, GridElement gridElement) { Point[] points = GetGridElementGraphicsPoints(x, y); if(gridElement != null) { g.FillPolygon(GetGridBrush(gridElement), points); } Pen pen = new Pen(Color.FromKnownColor(KnownColor.Gray)); g.DrawPolygon(pen, points); pen.Dispose(); }
private void populateFormViewBag(GridElement Model) { SelectList widths = new SelectList(new List<int> { 4, 6, 8, 12 }, ((Model != null) ? Model.Width.ToString() : "4")); SelectList sizeClasses = new SelectList(new Dictionary<String, String> { {"Tall", "tall"}, {"Regular", "regular"}, {"Small", "small"}, }, "Value", "Key", ((Model != null) ? Model.SizeClass : "tall")); SelectList headingClasses = new SelectList(new Dictionary<String, String> { {"Very Top", "anchorVeryTop"}, {"Top Middle", "anchorTopMiddle"}, {"Bottom Middle", "anchorBottomMiddle"}, {"Very Bottom", "anchorVeryBottom"}, }, "Value", "Key", ((Model != null) ? Model.HeadingClass : "anchorVeryTop")); ViewBag.Widths = widths; ViewBag.SizeClasses = sizeClasses; ViewBag.HeadingClasses = headingClasses; }