// Выставляет точные координаты лицам private void SpecifyPositions(List <int> actorsIndices, TDialogueActorArrangementPosition regionType) { // Выставим позиции вдоль оси x. float regionLeft = GetRegionLeft(regionType), regionRight = GetRegionRight(regionType); float left = regionLeft, right = regionLeft; int leftIndex = 0, rightIndex = 0; for (int i = 0; i <= actorsIndices.Count; i++) { if (i == actorsIndices.Count) { rightIndex = actorsIndices.Count; right = regionRight; } else if (_allActors[actorsIndices[i]].PositionType == TDialogueActorArrangementPosition.Custom) { rightIndex = i; right = _allActors[actorsIndices[i]].Position.x; } if (rightIndex > leftIndex) { float actorRegionWidth = (right - left) / (rightIndex - leftIndex); // Выставим позиции лицам между leftIndex (включительно) и rightIndex (не включительно) for (int j = leftIndex; j < rightIndex; j++) { _allActors[actorsIndices[j]].Position.x = left + actorRegionWidth * (j + 0.5f); } leftIndex = rightIndex + 1; } } }
// Правая граница региона заданного типа private float GetRegionRight(TDialogueActorArrangementPosition regionType) { switch (regionType) { case TDialogueActorArrangementPosition.Left: return(GetCenterLeft()); case TDialogueActorArrangementPosition.Center: return(GetCenterRight()); case TDialogueActorArrangementPosition.Right: return(_boundaries.xMax); default: Assert.IsTrue(false); return(0f); } }
// Получить дефолтную позицию по оси x для данного типа позиции private float GetDefaultPosition(TDialogueActorArrangementPosition positionType) { switch (positionType) { case TDialogueActorArrangementPosition.Left: return(_boundaries.xMin); case TDialogueActorArrangementPosition.Center: return((_boundaries.xMax + _boundaries.xMin) / 2); case TDialogueActorArrangementPosition.Right: return(_boundaries.xMax); case TDialogueActorArrangementPosition.Custom: return(0f); default: Assert.IsTrue(false); return(0f); } }
// Находится ли данная позиция в регионе данного типа private bool IsInRegion(float position, TDialogueActorArrangementPosition regionType) { float regionLeft = GetRegionLeft(regionType), regionRight = GetRegionRight(regionType); return(position >= regionLeft && position < regionRight); }