public void SetLinesColor(UnitSide side) { var col = ColorDictionary.GetSideColor(side); this.Renderer.startColor = col; this.Renderer.endColor = col; }
public void SetLines(UnitSide side, Vector3[] basePoints, int layerMask, int cutNumber, float fromHeight, float underHeight, float buffer) { if (basePoints == null) { return; } int count = 0; if (cutNumber < 1) { SetPoints(linePoints, basePoints, out count); } else { pointList.Clear(); Vector3 point = Vector3.zero; for (var i = 0; i < basePoints.Length; i++) { if (i == 0) { point = basePoints[i]; pointList.Add(point); } else { var end = basePoints[i]; for (int j = 1; j <= cutNumber; j++) { pointList.Add((end * j + point * (cutNumber - j)) / cutNumber); } point = end; } } SetPoints(linePoints, pointList, out count); } for (var i = 0; i < count; i++) { var p = linePoints[i]; if (Physics.Raycast(new Vector3(p.x, fromHeight, p.z), Vector3.down, out var hit, fromHeight - underHeight, layerMask:layerMask) == false) { continue; } linePoints[i] = new Vector3(p.x, hit.point.y + buffer, p.z); } var col = ColorDictionary.GetSideColor(side); this.Renderer.startColor = col; this.Renderer.endColor = col; this.Renderer.positionCount = count; this.Renderer.SetPositions(linePoints); }
void UpdateState(UnitState state) { stateRenderer.material.color = ColorDictionary.GetStateColor(state); }
void UpdateSide(UnitSide side) { sideRenderer.material.color = ColorDictionary.GetSideColor(side); }
public override void Initialize() { Instance = this; }