public override void Resolve(IsoTransform isoTransform) { Remove(isoTransform); var xyPos = Isometric.IsoToUnitySpace(isoTransform.Position); isoTransform.transform.position = new Vector3(xyPos.x, xyPos.y, isoTransform.transform.position.z); var index = GetTile(isoTransform); int insertIndex; if (!_tileDictionary.ContainsKey(index)) { _tileDictionary[index] = new List <IsoTransform>(); insertIndex = ~_sortedIndices.BinarySearch(index); _sortedIndices.Insert(insertIndex, index); } insertIndex = _tileDictionary[index].BinarySearch(isoTransform, _yComparer); if (insertIndex < 0) { insertIndex = ~insertIndex; } _tileDictionary[index].Insert(insertIndex, isoTransform); _inverseTileDictionary.Add(isoTransform, index); }
public Hexagon(IsoTransform isoTransform) { var isoMin = isoTransform.Position - isoTransform.Size / 2; var isoMax = isoTransform.Position + isoTransform.Size / 2; _min = new Vector2(isoMin.x + isoMin.y, isoMin.z + isoMin.y); _max = new Vector2(isoMax.x + isoMax.y, isoMax.z + isoMax.y); var left = Isometric.IsoToUnitySpace(isoTransform.Position + new Vector3(-isoTransform.Size.x / 2, -isoTransform.Size.y / 2, isoTransform.Size.z / 2)).x; var right = Isometric.IsoToUnitySpace(isoTransform.Position + new Vector3(isoTransform.Size.x / 2, -isoTransform.Size.y / 2, -isoTransform.Size.z / 2)).x; _h = new Vector2(left, right); }
private void ZAxisHandle() { Handles.color = Handles.zAxisColor; var screenHandlePos = Isometric.IsoToUnitySpace(_isoHandlePos); var deltaMovement = Handles.Slider(screenHandlePos, Isometric.IsoToUnitySpace(Vector3.forward)) - screenHandlePos; if (!(Mathf.Abs(deltaMovement.y) > Mathf.Epsilon)) { return; } ApplyZAxisChanges(deltaMovement.y); _isoHandlePos = _selectedObjects.Aggregate(Vector3.zero, (runningSum, t) => runningSum + t.Position) / _selectedObjects.Count; }
public override void Resolve(IsoTransform isoTransform) { if (isoTransform == null) { return; } //apply xy screen position var posXY = Isometric.IsoToUnitySpace(isoTransform.Position); isoTransform.transform.position = new Vector3(posXY.x, posXY.y, isoTransform.transform.position.z); //add if not exists SortingState sortingState; if (!_isoTransformToSortingState.TryGetValue(isoTransform, out sortingState)) { sortingState = new SortingState(isoTransform); _nodes.Add(sortingState); _isoTransformToSortingState.Add(isoTransform, sortingState); } //remove from parent dependencies for (int i = 0; i < sortingState.ParentDependencies.Count; i++) { sortingState.ParentDependencies[i].ChildDependencies.Remove(sortingState); } sortingState.ParentDependencies.Clear(); //remove from child dependencies for (int i = 0; i < sortingState.ChildDependencies.Count; i++) { var childDependency = sortingState.ChildDependencies[i]; childDependency.ParentDependencies.Remove(sortingState); } sortingState.ChildDependencies.Clear(); sortingState.Hexagon = new Hexagon(isoTransform); CalculateDependencies(sortingState); }
public override void Resolve(IsoTransform isoTransform) { isoTransform.transform.position = Isometric.IsoToUnitySpace(isoTransform.Position); _entities.Add(isoTransform); }