Пример #1
0
 public HexVectorComponent CreateHexVectorComponent(HexAxis positiveDirection, int magnitude)
 {
     return(new HexVectorComponent
     {
         Direction = magnitude >= 0 ? positiveDirection : _oppositeDirections[positiveDirection],
         Magnitude = Math.Abs(magnitude)
     });
 }
        private int GetComponent(HexAxis axis)
        {
            if (_selectedUnit == null || _selectedUnit.Vectors == null)
            {
                return(0);
            }

            return(_selectedUnit.GetDirectionValue(axis));
        }
        private void AssingComponentValue(int value, HexAxis axis)
        {
            if (_selectedUnit == null || _selectedUnit.Vectors == null)
            {
                return;
            }

            _selectedUnit.AssginDirectionValue(axis, (uint)Math.Abs(value));
        }
Пример #4
0
        public int GetMagnitudeAlongDirection(RawHexVector rawVector, HexAxis direction)
        {
            if (rawVector == null || rawVector.Components == null)
            {
                return(0);
            }

            return(GetValueAlongDirection(direction, rawVector.Components));
        }
Пример #5
0
        private int VectorComponentToMagnitude(HexVectorComponent vectorComponent, HexAxis positiveDirection)
        {
            if (vectorComponent == null)
            {
                return(0);
            }

            int coordinateSign = vectorComponent.Direction == positiveDirection ? +1 : -1;

            return(coordinateSign * vectorComponent.Magnitude);
        }
Пример #6
0
        private HexVectorComponent ConsolidateCardinalDirection(HexAxis direction, IEnumerable <HexVectorComponent> components)
        {
            int speedSum = GetValueAlongDirection(direction, components);

            speedSum -= GetValueAlongDirection(_oppositeDirections[direction], components);

            return(new HexVectorComponent
            {
                Direction = speedSum >= 0 ? direction : _oppositeDirections[direction],
                Magnitude = Math.Abs(speedSum)
            });
        }
Пример #7
0
        private void CheckVector(HexAxis primaryAxis, int primaryMag, HexAxis secondaryAxis, int secondaryMag, HexAxis verticalAxis, int verticalMag)
        {
            var vectorA = new HexVector(primaryAxis, primaryMag, secondaryAxis, secondaryMag, verticalAxis, verticalMag);

            var result = ServiceFactory.Library.AvidCalculator.ProjectVectorToAvid(vectorA);

            result.Should().NotBeNull();
            result.AbovePlane.Should().BeTrue();
            result.Ring.Should().Be(AvidRing.Magenta);
            result.Direction.Should().Be(AvidDirection.Undefined);
            result.Magnitude.Should().Be(27);
        }
Пример #8
0
        private void CheckMovement(int initialCf, int initialDa, int initialAlt,
                                   HexAxis moveAxis, uint moveMagnitude,
                                   int finalCf, int finalDa, int finalAlt, int finalDaValue)
        {
            var coordinate = new HexGridCoordinate
            {
                CfCoordinate = initialCf,
                DaCoordinate = initialDa,
                Altitude     = initialAlt
            };

            _calculator.Move(coordinate, moveAxis, moveMagnitude);
            CheckCoord(coordinate, finalCf, finalDa, finalAlt, finalDaValue);
        }
Пример #9
0
        public void AddOrUpdateVectorDirection(RawHexVector rawVector, int value, HexAxis direction)
        {
            var affectedComponents = rawVector.Components.Where(hvc => hvc.Direction == direction).ToList();

            if (value > 0)
            {
                if (affectedComponents.Count > 0)
                {
                    var firstComponent = affectedComponents[0];
                    affectedComponents.Remove(firstComponent);
                    firstComponent.Magnitude = value;
                }
                else
                {
                    rawVector.AddComponent(direction, value);
                }
            }

            rawVector.RemoveComponents(affectedComponents);
        }
Пример #10
0
        public HexVector(
            HexAxis directionA, int magnitudeA,
            HexAxis directionB, int magnitudeB,
            HexAxis directionZ, int magnitudeZ)
            : base()
        {
            if (directionA == HexAxis.Up || directionA == HexAxis.Down || directionA == HexAxis.Undefined)
            {
                throw new ArgumentException(string.Format("DirectionA should be planar and defined, but found {0}", directionA), "directionA");
            }

            if (directionB == HexAxis.Up || directionB == HexAxis.Down || directionB == HexAxis.Undefined)
            {
                throw new ArgumentException(string.Format("DirectionB should be planar and defined, but found {0}", directionB), "directionA");
            }

            if ((directionZ != HexAxis.Up && directionZ != HexAxis.Down) || directionZ == HexAxis.Undefined)
            {
                throw new ArgumentException(string.Format("DirectionA should be vertical and defined, but found {0}", directionZ), "directionA");
            }

            if (magnitudeA < 0 || magnitudeB < 0 || magnitudeZ < 0)
            {
                throw new ArgumentException(string.Format("All magnitudes should be positive (actual magnitudes are: A{0}, B{1}, Z{2}).", magnitudeA, magnitudeB, magnitudeZ));
            }

            if (magnitudeA >= magnitudeB)
            {
                PrimaryComponent   = new HexVectorComponent(directionA, magnitudeA);
                SecondaryComponent = new HexVectorComponent(directionB, magnitudeB);
            }
            else
            {
                PrimaryComponent   = new HexVectorComponent(directionB, magnitudeB);
                SecondaryComponent = new HexVectorComponent(directionA, magnitudeA);
            }

            VerticalComponent = new HexVectorComponent(directionZ, magnitudeZ);
        }
Пример #11
0
        public HexVector(
            HexAxis directionA, int magnitudeA,
            HexAxis directionB, int magnitudeB,
            HexAxis directionZ, int magnitudeZ)
            :base()
        {
            if (directionA == HexAxis.Up || directionA == HexAxis.Down || directionA == HexAxis.Undefined)
            {
                throw new ArgumentException(string.Format("DirectionA should be planar and defined, but found {0}", directionA), "directionA");
            }

            if (directionB == HexAxis.Up || directionB == HexAxis.Down || directionB == HexAxis.Undefined)
            {
                throw new ArgumentException(string.Format("DirectionB should be planar and defined, but found {0}", directionB), "directionA");
            }

            if ((directionZ != HexAxis.Up && directionZ != HexAxis.Down) || directionZ == HexAxis.Undefined)
            {
                throw new ArgumentException(string.Format("DirectionA should be vertical and defined, but found {0}", directionZ), "directionA");
            }

            if (magnitudeA < 0 || magnitudeB < 0 || magnitudeZ < 0)
            {
                throw new ArgumentException(string.Format("All magnitudes should be positive (actual magnitudes are: A{0}, B{1}, Z{2}).", magnitudeA, magnitudeB, magnitudeZ));
            }

            if (magnitudeA >= magnitudeB)
            {
                PrimaryComponent = new HexVectorComponent(directionA, magnitudeA);
                SecondaryComponent = new HexVectorComponent(directionB, magnitudeB);
            }
            else
            {
                PrimaryComponent = new HexVectorComponent(directionB, magnitudeB);
                SecondaryComponent = new HexVectorComponent(directionA, magnitudeA);
            }

            VerticalComponent = new HexVectorComponent(directionZ, magnitudeZ);
        }
 public VectorComponentViewModel(HexAxis direction)
 {
     _direction        = direction;
     _hexVectorUtility = ServiceFactory.Library.HexVectorUtility;
 }
Пример #13
0
 public HexVectorComponent(HexAxis direction, int magnitude)
 {
     Direction = direction;
     Magnitude = magnitude;
 }
Пример #14
0
 public void Move(HexGridCoordinate position, HexAxis direction, uint distance)
 {
     position.AddComponent(new HexVectorComponent(direction, (int)distance));
     _hexVectorUtility.ConsolidateVector(position);
     EliminateBeComponent(position);
 }
Пример #15
0
 public void AddComponent(HexAxis direction, int magnitude)
 {
     AddComponent(new HexVectorComponent(direction, magnitude));
 }
 public VectorComponentViewModel(HexAxis direction)
 {
     _direction = direction;
     _hexVectorUtility = ServiceFactory.Library.HexVectorUtility;
 }
Пример #17
0
        private HexVectorComponent ReplaceVectorComponent(int coordinateValue, HexVectorComponent existingComponent, HexAxis positiveAxis, HexAxis negativeAxis)
        {
            if (existingComponent != null)
            {
                _components.Remove(existingComponent);
            }

            var newComponent = new HexVectorComponent(coordinateValue >= 0 ? positiveAxis : negativeAxis, Math.Abs(coordinateValue));

            _components.Add(newComponent);

            return(newComponent);
        }
Пример #18
0
        private void CheckMovement(int initialCf, int initialDa, int initialAlt,
                                   HexAxis moveAxis, uint moveMagnitude,
                                   int finalCf, int finalDa, int finalAlt, int finalDaValue)
        {
            var coordinate = new HexGridCoordinate
            {
                CfCoordinate = initialCf,
                DaCoordinate = initialDa,
                Altitude = initialAlt
            };

            _calculator.Move(coordinate, moveAxis, moveMagnitude);
            CheckCoord(coordinate, finalCf, finalDa, finalAlt, finalDaValue);
        }
Пример #19
0
        private HexVectorComponent ReplaceVectorComponent(int coordinateValue, HexVectorComponent existingComponent, HexAxis positiveAxis, HexAxis negativeAxis)
        {
            if (existingComponent != null)
            {
                _components.Remove(existingComponent);
            }

            var newComponent = new HexVectorComponent(coordinateValue >= 0 ? positiveAxis : negativeAxis, Math.Abs(coordinateValue));

            _components.Add(newComponent);

            return newComponent;
        }
Пример #20
0
        public void EliminateComponentsAlongCardinalDirection(RawHexVector rawVector, HexAxis direction)
        {
            var affectedComponents = rawVector.Components.Where(hvc => hvc.Direction == direction ||
                                                                hvc.Direction == _oppositeDirections[direction]).ToArray();

            foreach (var component in affectedComponents)
            {
                rawVector.RemoveComponent(component);
            }
        }
Пример #21
0
 public static void CheckComponent(HexVectorComponent component, HexAxis expectedDirection, int expectedMagnitude)
 {
     component.Direction.Should().Be(expectedDirection);
     component.Magnitude.Should().Be(expectedMagnitude);
 }
Пример #22
0
 public void Move(HexGridCoordinate position, HexAxis direction, uint distance)
 {
     position.AddComponent(new HexVectorComponent(direction, (int)distance));
     _hexVectorUtility.ConsolidateVector(position);
     EliminateBeComponent(position);
 }
Пример #23
0
        private void CheckVectorComponent(HexGridCoordinate testCoordinate, int expectedMagnitude, HexAxis positiveAxis, HexAxis negativeAxis)
        {
            if (expectedMagnitude == 0)
            {
                return;
            }

            testCoordinate.Components.Should().ContainSingle(hvc => hvc.Magnitude == Math.Abs(expectedMagnitude) &&
                                                             hvc.Direction == (expectedMagnitude < 0 ? negativeAxis : positiveAxis));
        }
Пример #24
0
 private int GetValueAlongDirection(HexAxis direction, IEnumerable <HexVectorComponent> components)
 {
     return(components.Where(hvc => hvc.Direction.Equals(direction)).Sum(hvc => hvc.Magnitude));
 }
Пример #25
0
        private void CheckVectorComponent(HexGridCoordinate testCoordinate, int expectedMagnitude, HexAxis positiveAxis, HexAxis negativeAxis)
        {
            if (expectedMagnitude == 0)
            {
                return;
            }

            testCoordinate.Components.Should().ContainSingle(hvc => hvc.Magnitude == Math.Abs(expectedMagnitude) &&
                                                                    hvc.Direction == (expectedMagnitude < 0 ? negativeAxis : positiveAxis));
        }
        private void AssingComponentValue(int value, HexAxis axis)
        {
            if (_selectedUnit == null || _selectedUnit.Vectors == null)
            {
                return;
            }

            _selectedUnit.AssginDirectionValue(axis, (uint)Math.Abs(value));
        }
Пример #27
0
 public void AssginDirectionValue(HexAxis direction, uint newValue)
 {
     _hexVectorUtility.AddOrUpdateVectorDirection(Vectors, (int)newValue, direction);
     OnVelocityChanged();
 }
Пример #28
0
 public int GetDirectionValue(HexAxis direction)
 {
     return _hexVectorUtility.GetMagnitudeAlongDirection(Vectors, direction);
 }
Пример #29
0
        private void CheckVector(HexAxis primaryAxis, int primaryMag, HexAxis secondaryAxis, int secondaryMag, HexAxis verticalAxis, int verticalMag)
        {
            var vectorA = new HexVector(primaryAxis, primaryMag, secondaryAxis, secondaryMag, verticalAxis, verticalMag);

            var result = ServiceFactory.Library.AvidCalculator.ProjectVectorToAvid(vectorA);

            result.Should().NotBeNull();
            result.AbovePlane.Should().BeTrue();
            result.Ring.Should().Be(AvidRing.Magenta);
            result.Direction.Should().Be(AvidDirection.Undefined);
            result.Magnitude.Should().Be(27);
        }
Пример #30
0
 public int GetDirectionValue(HexAxis direction)
 {
     return(_hexVectorUtility.GetMagnitudeAlongDirection(Vectors, direction));
 }
        private int GetComponent(HexAxis axis)
        {
            if (_selectedUnit == null || _selectedUnit.Vectors == null)
            {
                return 0;
            }

            return _selectedUnit.GetDirectionValue(axis);
        }
Пример #32
0
        private int VectorComponentToMagnitude(HexVectorComponent vectorComponent, HexAxis positiveDirection)
        {
            if (vectorComponent == null)
            {
                return 0;
            }

            int coordinateSign = vectorComponent.Direction == positiveDirection ? +1 : -1;

            return coordinateSign * vectorComponent.Magnitude;
        }
Пример #33
0
 public void Move(HexAxis direction)
 {
     _hexGridCalculator.Move(Position, direction, 1);
     OnMoved();
 }
Пример #34
0
        public int GetMagnitudeAlongCardinalDirection(RawHexVector rawVector, HexAxis direction)
        {
            var component = ConsolidateCardinalDirection(direction, rawVector.Components);

            return(component.Direction == direction ? component.Magnitude : -component.Magnitude);
        }
Пример #35
0
 public void AssginDirectionValue(HexAxis direction, uint newValue)
 {
     _hexVectorUtility.AddOrUpdateVectorDirection(Vectors, (int)newValue, direction);
     OnVelocityChanged();
 }
Пример #36
0
 public void Move(HexAxis direction)
 {
     _hexGridCalculator.Move(Position, direction, 1);
     OnMoved();
 }