public void UpdateMaxGrade() { this.MaxGrade = Mathf.Abs(this.Grade); // average grade also matters for blocking for (int i = 0; i < this.PathCells.Count; i++) { float height1 = this.PathCells[i].cachedHeight; for (int j = 0; j < 3; j++) { float height2 = this.TargetDistCells[i][j].cell.cachedHeight; float delta = this.TargetDistCells[i][j].dist; this.MaxGrade = Mathf.Max(this.MaxGrade, Mathf.Abs(PathingUtil.GetGrade(height1, height2, delta))); } } this.MaxGrade = Mathf.Max(this.MaxGrade, this.To.LocalGrade); }
public void UpdateLocalGrade() { float centerHeight = this.cells[0].cachedHeight; this.LocalGrade = 0f; for (int i = 1; i <= 4; i++) { float height = this.cells[i].cachedHeight; this.LocalGrade = Mathf.Max(this.LocalGrade, Mathf.Abs(PathingUtil.GetGrade(centerHeight, height, cellDelta))); } for (int i = 5; i <= 8; i++) { float height = this.cells[i].cachedHeight; this.LocalGrade = Mathf.Max(this.LocalGrade, Mathf.Abs(PathingUtil.GetGrade(centerHeight, height, cellDeltaDiag))); } }
public void ResetCache(CombatGameState combat) { MapMetaData mapMetaData = combat.MapMetaData; HexGrid hexGrid = combat.HexGrid; CacheNodeLink.PathBlockerGradeMultiplier = combat.Constants.MoveConstants.PathBlockerGradeMultiplier; this.SetDimensions(mapMetaData, hexGrid); this.cacheNodes = new CacheNode[this.Width, this.Height]; for (int x = 0; x < this.Width; x++) { for (int z = 0; z < this.Height; z++) { Vector3 pos = this.WorldPosFromNode(x, z); this.cacheNodes[x, z] = new CacheNode(pos, mapMetaData); } } for (int x = 0; x < this.Width; x++) { for (int z = 0; z < this.Height; z++) { CacheNode from = this.cacheNodes[x, z]; for (int k = 0; k < 8; k++) { Point diff = PathingUtil.GetForwardDelta(k); CacheNode to = this.GetNodeAt(x + diff.X, z + diff.Z); if (to != null) { from.NeighborLinks[k] = new CacheNodeLink(from, to, this.DistFromAngle(k), k, mapMetaData); } } } } }
public void UpdateGrade() { this.Grade = PathingUtil.GetGrade(this.From.GetHeight(), this.To.GetHeight(), this.Distance); }