public List <HexCell> DefaultGetBasicAttackCells() { // if (Abilities.Any(a => a.OverridesGetBasicAttackCells)) // { // if (Abilities.Count(a => a.OverridesGetBasicAttackCells) > 1) // throw new Exception("Więcej niż jedna umiejętność próbuje nadpisać komórki podstawowego ataku!"); // // return Abilities.Single(a => a.OverridesGetBasicAttackCells).GetBasicAttackCells(); // } List <HexCell> cellRange; switch (Type) { case FightType.Ranged: cellRange = ParentCell.GetNeighbors(BasicAttackRange.Value, false, false, true); break; case FightType.Melee: cellRange = ParentCell.GetNeighbors(BasicAttackRange.Value, true, false, true); break; default: throw new ArgumentOutOfRangeException(); } return(cellRange); }
public int nunsplitghost; // # of ghost unsplit cells I store public void AddParentCell(int id, int iparent, int nx, int ny, int nz, double[] lo, double[] hi) { GrowPcells(1); ParentCell p = new ParentCell(); p.id = id; p.mask = 1; if (iparent >= 0) { p.level = pcells[iparent].level + 1; p.nbits = pcells[iparent].nbits + pcells[iparent].newbits; } else { p.level = p.nbits = 0; } p.newbits = IdBits(nx, ny, nz); p.iparent = iparent; p.grandparent = 0; // set by caller if (p.nbits + p.newbits > maxbits) { sparta.DumpError("Cell ID has too many bits"); } p.nx = nx; p.ny = ny; p.nz = nz; p.lo[0] = lo[0]; p.lo[1] = lo[1]; p.lo[2] = lo[2]; p.hi[0] = hi[0]; p.hi[1] = hi[1]; p.hi[2] = hi[2]; pcells.Add(p); nparent++; }
public void PinToParent(bool changePosition = true) { if (ParentCell == null) { return; } ParentCell.PinCellObject(this, changePosition); }
/// <summary> /// 展开节点 /// </summary> public void Expand() { if (ParentCell != null) { ParentCell.CollapseAll(); } Collapsed = false; ShowChild(true); base.DataGridView.InvalidateCell(this); }
/// <summary> /// Called from the axon that is the source of the signal for this target dendrite. /// Modifies the weighted signal at which this dendrite is supplying signal to its parent cell. /// Parent neuron is excited on a separate thread to allow this to finish in a finite time without stack overflow. /// </summary> /// <param name="signal">Signal to be applied to this cell.</param> public void Excite(double signal) { IncomingRawSignal = signal; OnDendriteExcited(); ThreadPool.QueueUserWorkItem((x) => { try { Thread.CurrentThread.Name = string.Format("Signal propagation thread from dendrite of {0}", ParentCell); } catch { } //Ignore errors resulting from failed thread rename. ParentCell.Excite(WeightedSignal); }); }
public List <HexCell> DefaultGetBasicMoveCells() { // if (Abilities.Any(a => a.OverridesGetMoveCells)) // { // if (Abilities.Count(a => a.OverridesGetMoveCells) > 1) // throw new Exception("Więcej niż jedna umiejętność próbuje nadpisać komórki ruchu!"); // // return Abilities.Single(a => a.OverridesGetMoveCells).GetMoveCells(); // } List <HexCell> cellRange = ParentCell.GetNeighbors(Speed.Value, true, true); cellRange.RemoveAll(cell => cell.CharacterOnCell != null); //we don't want to allow stepping into our characters! return(cellRange); }
/// <summary> /// clone /// </summary> public object Clone() { var ret = new Cell(); ret.GlobalID = this.GlobalID; ret.TransformationParams = this.TransformationParams.CloneAs(); ret.NodeIndices = this.NodeIndices.CloneAs(); ret.CellFaceTags = this.CellFaceTags == null ? null : this.CellFaceTags.CloneAs(); Debug.Assert(typeof(CellFaceTag).IsValueType); ret.Type = this.Type; ret.CoarseningClusterID = CoarseningClusterID; ret.ParentCell = ParentCell != null?ParentCell.CloneAs() : null; ret.RefinementLevel = this.RefinementLevel; ret.CoarseningClusterSize = this.CoarseningClusterSize; ret.CoarseningLeafIndex = this.CoarseningLeafIndex; return(ret); }
public int id_find_child(int iparent, double[] x) { ParentCell p = pcells[iparent]; double[] lo = p.lo; double[] hi = p.hi; int nx = p.nx; int ny = p.ny; int nz = p.nz; int ix = (int)((x[0] - lo[0]) * nx / (hi[0] - lo[0])); int iy = (int)((x[1] - lo[1]) * ny / (hi[1] - lo[1])); int iz = (int)((x[2] - lo[2]) * nz / (hi[2] - lo[2])); if (ix == nx) { ix--; } if (iy == ny) { iy--; } if (iz == nz) { iz--; } cellint ichild = iz * nx * ny + iy * nx + ix + 1; cellint idchild = p.id | (ichild << p.nbits); if (hash[idchild] == hash[hash.Keys.Last()]) { return(-1); } int index = hash[idchild]; if (index > 0) { return(index - 1); } return(id_find_child(-index - 1, x)); }
public void IdChildLohi(int iparent, int ichild, double[] lo, double[] hi) { ParentCell p = pcells[iparent]; ichild--; int nx = p.nx; int ny = p.ny; int nz = p.nz; int ix = ichild % nx; int iy = (ichild / nx) % ny; int iz = ichild / (nx * ny); double[] plo = p.lo; double[] phi = p.hi; lo[0] = plo[0] + ix * (phi[0] - plo[0]) / nx; lo[1] = plo[1] + iy * (phi[1] - plo[1]) / ny; lo[2] = plo[2] + iz * (phi[2] - plo[2]) / nz; hi[0] = plo[0] + (ix + 1) * (phi[0] - plo[0]) / nx; hi[1] = plo[1] + (iy + 1) * (phi[1] - plo[1]) / ny; hi[2] = plo[2] + (iz + 1) * (phi[2] - plo[2]) / nz; if (ix == nx - 1) { hi[0] = phi[0]; } if (iy == ny - 1) { hi[1] = phi[1]; } if (iz == nz - 1) { hi[2] = phi[2]; } }
private void PaintGroupPlus(Graphics graphics, Pen gridPen, Brush bruBK, DataGridViewCellStyle cellStyle, Rectangle rectLeft, bool collapsed) { Pen pen = new Pen(DataGridView.GridColor, 1); pen.DashStyle = DashStyle.Dot; graphics.FillRectangle(bruBK, rectLeft); int left = rectLeft.Left + (groupLevel - 1) * PLUS_WIDTH; //画 Left, Top, Right 三根线 graphics.DrawLine(gridPen, left, rectLeft.Top, rectLeft.Right, rectLeft.Top);//上 graphics.DrawLine(gridPen, rectLeft.Right, rectLeft.Bottom, rectLeft.Left, rectLeft.Bottom); //最左边的一条线 graphics.DrawLine(gridPen, rectLeft.Left, rectLeft.Top, rectLeft.Right, rectLeft.Top); //如果是该级别的最后一个节点,则需要画一个底线,以便将整个组封闭起来 bool drawBottomLine = false; for (int i = 1; i < groupLevel; i++) { if (!ParentCell.IsLastCell(ParentCell.groupLevel))//上层不是最后一个节点 { graphics.DrawLine(pen, rectLeft.Left + (i - 1) * PLUS_WIDTH + PLUS_WIDTH / 2, rectLeft.Top , rectLeft.Left + (i - 1) * PLUS_WIDTH + PLUS_WIDTH / 2, rectLeft.Bottom); } } //如果有子结点, 则需要画一个方框, 里面有+号或-号 if (childCells != null && childCells.Count > 0) { groupPlusRect = new Rectangle((groupLevel - 1) * PLUS_WIDTH + rectLeft.Left + (PLUS_WIDTH - 12) / 2 , rectLeft.Top + (rectLeft.Height - 12) / 2, 12, 12); graphics.DrawRectangle(gridPen, groupPlusRect); graphics.DrawLine(Pens.Black, groupPlusRect.Left + 3, groupPlusRect.Top + groupPlusRect.Height / 2 , groupPlusRect.Right - 3, groupPlusRect.Top + groupPlusRect.Height / 2); if (collapsed) { graphics.DrawLine(Pens.Black, groupPlusRect.Left + groupPlusRect.Width / 2, groupPlusRect.Top + 3 , groupPlusRect.Left + groupPlusRect.Width / 2, groupPlusRect.Bottom - 3); } } else { //横 graphics.DrawLine(pen, rectLeft.Left + (groupLevel - 1) * PLUS_WIDTH + PLUS_WIDTH / 2, rectLeft.Top + rectLeft.Height / 2 , rectLeft.Left + (groupLevel - 1) * PLUS_WIDTH + PLUS_WIDTH, rectLeft.Top + rectLeft.Height / 2); //竖 if (!IsLastCell((groupLevel - 1))) { graphics.DrawLine(pen, rectLeft.Left + (groupLevel - 1) * PLUS_WIDTH + PLUS_WIDTH / 2, rectLeft.Top , rectLeft.Left + (groupLevel - 1) * PLUS_WIDTH + PLUS_WIDTH / 2, rectLeft.Bottom); } else { graphics.DrawLine(pen, (groupLevel - 1) * PLUS_WIDTH + rectLeft.Left + (PLUS_WIDTH - 8) / 2 + 4, rectLeft.Top + (rectLeft.Height - 8) / 2 - 6, (groupLevel - 1) * PLUS_WIDTH + rectLeft.Left + (PLUS_WIDTH - 8) / 2 + 4, rectLeft.Top + (rectLeft.Height - 8) / 2 + 4); } } pen.Dispose(); pen = null; }
public List <HexCell> DefaultGetBasicMoveCells() => IsFlying ? ParentCell.GetNeighbors(Speed.Value, SearchFlags.StopAtEnemyCharacters) : ParentCell.GetNeighbors(Speed.Value, SearchFlags.StopAtEnemyCharacters | SearchFlags.StopAtWalls);
protected override void OnChildMeasureInvalidated() { base.OnChildMeasureInvalidated(); ParentCell?.ForceUpdateSize(); }
cellint id_find_face(double[] x, int icell, int dim, double[] olo, double[] ohi) { ParentCell p = pcells[icell]; double[] lo = p.lo; double[] hi = p.hi; // go down a level to find (ix,iy,iz) of new cell that contains pt x int nx = p.nx; int ny = p.ny; int nz = p.nz; int ix = (int)((x[0] - lo[0]) * nx / (hi[0] - lo[0])); int iy = (int)((x[1] - lo[1]) * ny / (hi[1] - lo[1])); int iz = (int)((x[2] - lo[2]) * nz / (hi[2] - lo[2])); if (ix == nx) { ix--; } if (iy == ny) { iy--; } if (iz == nz) { iz--; } // calculate lo/hi of new cell // exact same math as in id_child_lohi() double[] newlo = new double[3], newhi = new double[3]; newlo[0] = lo[0] + ix * (hi[0] - lo[0]) / nx; newlo[1] = lo[1] + iy * (hi[1] - lo[1]) / ny; newlo[2] = lo[2] + iz * (hi[2] - lo[2]) / nz; newhi[0] = lo[0] + (ix + 1) * (hi[0] - lo[0]) / nx; newhi[1] = lo[1] + (iy + 1) * (hi[1] - lo[1]) / ny; newhi[2] = lo[2] + (iz + 1) * (hi[2] - lo[2]) / nz; if (ix == nx - 1) { newhi[0] = hi[0]; } if (iy == ny - 1) { newhi[1] = hi[1]; } if (iz == nz - 1) { newhi[2] = hi[2]; } // if new cell does not fully overlap olo/ohi face, return parent ID if (dim != 0 && (newlo[0] > olo[0] || newhi[0] < ohi[0])) { return(p.id); } if (dim != 1 && (newlo[1] > olo[1] || newhi[1] < ohi[1])) { return(p.id); } if (dim != 2 && (newlo[2] > olo[2] || newhi[2] < ohi[2])) { return(p.id); } // id = ID of new cell // if I don't store new ID, it's a child ID, return it // if I do store new ID, determine if parent or child cell // if child, return it // if parent, recurse cellint ichild = ((cellint)iz) * nx * ny + ((cellint)iy) * nx + ix + 1; cellint id = p.id | (ichild << p.nbits); if (hash[id] == hash[hash.Keys.Last()]) { return(id); } icell = hash[id]; if (icell > 0) { return(id); } return(id_find_face(x, -icell - 1, dim, olo, ohi)); }