Пример #1
0
 private void RotateDir(RelativeDirection direction)
 {
     _selectedDir = _selectedDir.Turn(direction);
     _t.rotation  = _selectedDir.GetBearingRotation();
     FMODUnity.RuntimeManager.PlayOneShot(selectSound, new Vector3(0, 0, 0));
     UpdatePathPreview();
 }
Пример #2
0
        static int CalculateWaypointFollowingDistance(
            string[] lines, int waypointX, int waypointY)
        {
            int x = 0;
            int y = 0;

            foreach (string line in lines)
            {
                // Console.WriteLine($"Waypoint: {waypointX}, {waypointY} - Position: {x}, {y}");
                // Console.WriteLine(line);

                char prefix = line[0];
                if (prefix is 'F')
                {
                    int units = Int32.Parse(line.Substring(1));
                    // Console.WriteLine($"Previous position: {x}, {y}. Moving: {waypointX * units}, {waypointY * units}");
                    x += waypointX * units;
                    y += waypointY * units;
                    // Console.WriteLine($"Moved to: {x}, {y}");
                }
                else if (prefix is 'L' or 'R')
                {
                    // Console.WriteLine($"Previous waypoint: {waypointX}, {waypointY}");
                    RelativeDirection relativeDirection = prefix.ToRelativeDirection();
                    int degrees = Int32.Parse(line.Substring(1));
                    (waypointX, waypointY) = RotatePoints(waypointX, waypointY, relativeDirection, degrees);
                    // Console.WriteLine($"Rotating waypoint {relativeDirection} {degrees} degrees. New waypoint: {waypointX}, {waypointY}");
                }
Пример #3
0
        /// <summary>
        /// Generates an instruction for an immidiate turn.
        /// </summary>
        /// <param name="instruction"></param>
        /// <param name="first_street_count_to"></param>
        /// <param name="first_street_to"></param>
        /// <param name="first_direction"></param>
        /// <param name="second_street_to"></param>
        /// <param name="second_direction"></param>
        /// <returns></returns>
        public Instruction GenerateImmidiateTurn(Instruction instruction, int first_street_count_to, TagsCollection first_street_to,
                                                 RelativeDirection first_direction, TagsCollection second_street_to, RelativeDirection second_direction)
        {
//            if (first_street_count_to == 1)
//            {
//                instruction.Text = string.Format("Neem de 1ste afslag {0}, de {1} op, en ga onmiddellijk {2} op de {3}.",
//                    TurnDirection(first_direction.Direction),
//                    this.GetName("nl", first_street_to),
//                    TurnDirection(second_direction.Direction),
//                    this.GetName("nl", second_street_to));
//            }
//            else
//            {
//                instruction.Text = string.Format("Neem de {4}de afslag {0}, de {1} op, en ga onmiddellijk {2} op de {3}.",
//                    TurnDirection(first_direction.Direction),
//                    this.GetName("nl", first_street_to),
//                    TurnDirection(second_direction.Direction),
//                    this.GetName("nl", second_street_to),
//                    first_street_count_to);
            //            }
            instruction.Text = string.Format("Draai {0} en daarna direct {1}",
                                             TurnDirection(first_direction.Direction),
                                             TurnDirection(second_direction.Direction));

            // returns the instruction with text.
            return(instruction);
        }
Пример #4
0
 private Move(TurnPlan owner, RelativeDirection direction, TileVector destination, int energyCost)
 {
     Owner       = owner;
     Direction   = direction;
     Destination = destination;
     EnergyCost  = energyCost;
 }
Пример #5
0
        public void Turn(RelativeDirection direction)
        {
            AbsoluteDirection newDirection;

            switch (direction)
            {
            case RelativeDirection.Right:
                newDirection = (AbsoluteDirection)((int)(m_direction + 1) % 4);
                break;

            case RelativeDirection.Left:
                newDirection = (AbsoluteDirection)((int)(m_direction + 3) % 4);
                break;

            case RelativeDirection.Back:
                newDirection = (AbsoluteDirection)((int)(m_direction + 2) % 4);
                break;

            default:
                newDirection = AbsoluteDirection.North;
                break;
            }
            m_direction = newDirection;
            NotifyObservers();
        }
Пример #6
0
 public CompositeSectionModel(string heading, IEnumerable <string> paragraphs, ImageModel image, RelativeDirection imageAlignment)
 {
     Heading        = heading;
     Paragraphs     = paragraphs;
     Image          = image;
     ImageAlignment = imageAlignment;
 }
Пример #7
0
    /// <summary>
    /// Pushes this pawn relative to the given cell.
    /// </summary>
    public void TakePush(Cell origin, RelativeDirection direction, int amount)
    {
        // Get direction of push
        Vector2Int travelDirection = Coordinate.GetRelativeDirections(origin.Coordinate, direction).Single();

        TakePush(travelDirection, amount);
    }
Пример #8
0
        /// <summary>
        /// Generates a poi instruction.
        /// </summary>
        /// <param name="entryIdx"></param>
        /// <param name="box"></param>
        /// <param name="list"></param>
        /// <param name="direction"></param>
        internal void GeneratePoi(int entryIdx, GeoCoordinateBox box,
                                  List <PointPoi> list, RelativeDirection direction)
        {
            // create a new instruction first.
            Instruction instruction           = new Instruction(entryIdx, box, list);
            Instruction direction_instruction = null;

            // pass the instruction to the languate generator.
            if (direction == null)
            {
                instruction = _generator.GeneratePoi(instruction, list, null);
            }
            else
            {
                // create a direction instruction.
                if (direction.Direction == RelativeDirectionEnum.TurnBack)
                {
                    direction_instruction = new Instruction(entryIdx, box, list);
                    direction_instruction = _generator.GenerateSimpleTurn(direction_instruction, direction.Direction);
                }

                // generates the instructions.
                instruction = _generator.GeneratePoi(instruction, list, null);
            }

            // add the instruction to the instructions list.
            _instructions.Add(instruction);

            // add the direction instruction.
            if (direction_instruction != null)
            {
                _instructions.Add(direction_instruction);
            }
        }
Пример #9
0
        public void Turn(RelativeDirection paramDirection)
        {
            if (this.Speed != 0)
            {
                AbsoluteDirection newDirection;
                switch (paramDirection)
                {
                case RelativeDirection.Right:
                    newDirection = (AbsoluteDirection)((int)(this.mDirection + 1) % 4);
                    break;

                case RelativeDirection.Left:
                    newDirection = (AbsoluteDirection)((int)(this.mDirection + 3) % 4);
                    break;

                case RelativeDirection.Back:
                    newDirection = (AbsoluteDirection)((int)(this.mDirection + 2) % 4);
                    break;

                default:
                    newDirection = AbsoluteDirection.North;
                    break;
                }

                if (this.Speed < 0)
                {
                    newDirection = (AbsoluteDirection)(((int)newDirection + 2) % 4);
                }


                this.mDirection = newDirection;
            }
        }
        private void Awake()
        {
            if (viewContainerTransform != null)
            {
                viewContainerTransform.localPosition = Vector3.zero;
            }

            if (transform.up != Vector3.up)
            {
                Debug.LogErrorFormat("Initial rotation of '{0}' is not valid. It will be changed.", name);
                transform.rotation = Quaternion.LookRotation(transform.forward, Vector3.up);
            }
            relativeDirection      = RelativeDirection.SAME_DIRECTION;
            CurrentDirection       = transform.forward;
            CurrentTargetDirection = CurrentDirection;
            CurrentMoveActionType  = MoveActionType.NO_MOVE;

            myRigidbody = GetComponent <Rigidbody>();
            if (myRigidbody == null)
            {
                Debug.LogErrorFormat("Object '{0}' contains no rigidbody.");
            }

            degRotationSpeed = Mathf.Max(degRotationSpeedInInspector, MIN_DEG_ROTATION_SPEED);
            speed            = Mathf.Max(speed, MIN_SPEED);
            StopAllMovements();
            IsFallingNow = true;
        }
        /// <summary>
        /// Generates an instruction for an immidiate turn.
        /// </summary>
        /// <param name="instruction"></param>
        /// <param name="firstStreetCountTo"></param>
        /// <param name="first_street_to"></param>
        /// <param name="first_direction"></param>
        /// <param name="second_street_to"></param>
        /// <param name="second_direction"></param>
        /// <returns></returns>
        public Instruction GenerateImmidiateTurn(Instruction instruction, int firstStreetCountTo,
                                                 TagsCollectionBase first_street_to, RelativeDirection first_direction,
                                                 TagsCollectionBase second_street_to, RelativeDirection second_direction)
        {
            firstStreetCountTo++;
            if (firstStreetCountTo == 1)
            {
                instruction.Text = string.Format("Take the first turn {0}, on the {1}, and turn immidiately {2} on the {3}.",
                                                 TurnDirection(first_direction.Direction),
                                                 this.GetName("en", first_street_to),
                                                 TurnDirection(second_direction.Direction),
                                                 this.GetName("en", second_street_to));
            }
            else
            {
                instruction.Text = string.Format("Take the {4}d turn {0}, on the {1}, and turn immidiately {2} on the {3}.",
                                                 TurnDirection(first_direction.Direction),
                                                 this.GetName("en", first_street_to),
                                                 TurnDirection(second_direction.Direction),
                                                 this.GetName("en", second_street_to),
                                                 firstStreetCountTo);
            }

            // returns the instruction with text.
            return(instruction);
        }
Пример #12
0
        /// <summary>
        /// Constructor of the InstructionProperties.
        /// </summary>
        /// <param name="Instruction">The instruction to convert to a GeoJsonFeature.</param>
        /// <param name="Next">The next instruction.</param>
        /// <param name="route">The Route object.</param>
        public InstructionProperties(Instruction Instruction, Instruction Next, Route route)
        {
            this.type        = "Feature";
            this.properties  = new Dictionary <string, string> ();
            this.geometry    = new GeoJsonPoint(route.Shape[Instruction.Shape]);
            this.Instruction = Instruction;

            properties.Add("instruction", Instruction.Text);
            Route.Meta meta = route.ShapeMetaFor(Instruction.Shape);

            properties.Add("colour", Instruction.GetAttribute("cyclecolour", route));
            properties.Add("ref", Instruction.GetAttribute("cycleref", route));

            float time;
            float dist;

            route.DistanceAndTimeAt(Instruction.Shape, out dist, out time);
            properties.Add("distance", dist.ToString(new CultureInfo("en-US")));

            properties.Add("type", Instruction.Type);

            if (Next != null)
            {
                Route.Meta nextMeta = route.ShapeMetaFor(Next.Shape);
                properties.Add("nextColour", Next.GetAttribute("cyclecolour", route));
                properties.Add("nextRef", Next.GetAttribute("cycleref", route));

                if (Instruction.Type != "start" && Instruction.Type != "stop")
                {
                    this.Angle = route.RelativeDirectionAt(Instruction.Shape);
                    properties.Add("angle", Angle.Direction.ToString());
                }
            }
        }
Пример #13
0
        public static MarioState ApplyInput(MarioState marioState, RelativeDirection direction, int numQSteps = 4)
        {
            MarioState withHSpeed = ComputeAirHSpeed(marioState, direction);
            MarioState moved      = AirMove(withHSpeed, numQSteps);
            MarioState withYSpeed = ComputeAirYSpeed(moved);

            return(withYSpeed);
        }
Пример #14
0
 public void RequestTurn(RelativeDirection direction)
 {
     m_module?.Turn(direction);
     if (m_view != null)
     {
         SetView();
     }
 }
Пример #15
0
        protected override RelativeDirection[] SetPath()
        {
            var path = new RelativeDirection[QuaterLength * 4];                 // initial value is Forward

            path[QuaterLength]     = TurnDirection;
            path[QuaterLength * 3] = TurnDirection.Mirror();
            return(path);
        }
Пример #16
0
 public virtual void RequestTurn(RelativeDirection paramDirection)
 {
     if (this.model != null)
     {
         model.Turn(paramDirection);
         this.NotifyObservers();
     }
 }
Пример #17
0
        /// <summary>
        /// Returns the quadrant of the target vehicle on the track relative to the origin vehicle.
        /// </summary>
        public static RelativeQuadrant GetRelativeQuadrant(BaseVehicleDriver targetDriver, BaseVehicleDriver originDriver)
        {
            Vector2           relativePosition = GetRelativePosition2D(targetDriver, originDriver);
            RelativeDirection relativeX        = relativePosition.x < 0f ? RelativeDirection.Left : RelativeDirection.Right;
            RelativeDirection relativeZ        = relativePosition.y < 0f ? RelativeDirection.Back : RelativeDirection.Front;
            RelativeQuadrant  quadrant         = (RelativeQuadrant)(relativeX | relativeZ);

            return(quadrant);
        }
Пример #18
0
        protected override RelativeDirection[] SetPath()
        {
            var path = new RelativeDirection[SideLength * 6];

            for (var i = 0; i < 6; i++)
            {
                path[i * SideLength] = TurnDirection;
            }
            return(path);
        }
Пример #19
0
 public void NeighbourChanged(RelativeDirection neighD)
 {
     //change neighbourCode using neighD
     //set sprite using neighbourCode and BrickManager sprites
     setNeighCode(neighD);
     if (drilledAmount >= 100)
     {
         setDrilledSprite();
     }
 }
Пример #20
0
 public void Drilling(int row, int column, RelativeDirection drilledPosition)
 {
     //Debug.Log ("[BrickManager]: row:"+row+" column:"+column);
     Debug.Log ("column:" + column);
     int brickid = row * COLUMN + column + COLUMN_BY_2;
     if (brickid < 0 || column == 25 || column == -26)
         return;
     //Debug.Log ("brickid:"+brickid);
     bricksList [brickid].StratDrilling (drilledPosition);
 }
Пример #21
0
        public Direction Turn(RelativeDirection rd)
        {
            if (_dir == 0)
            {
                return(None);
            }
            var dir = 1 + (((int)_dir + (int)rd - 1) & 3);

            return(new Direction((DirectionValue)dir));
        }
        /// <summary>
        /// Moves an robot in an straight line. Applies collisions
        /// </summary>
        /// <param name="robotId">the id of the robot to move</param>
        /// <param name="amount">the number of fields to move</param>
        /// <param name="forward">the relative direction to move to</param>
        /// <returns>the new position of the robot after the movement executed</returns>
        /// <exception cref="ArgumentOutOfRangeException">If the robot is not fetchable</exception>
        public Position Move(int robotId, int amount, RelativeDirection forward)
        {
#if DEBUG
            Console.Out.WriteLine("Robot : " + robotId + " moves " + amount + " fields " + forward);
#endif
            if (_game.Entitys[robotId] is RobotInfo {
            } robotInfo)
            {
                Direction resultDirection = DirectionExtension.ResolveDirection(forward, robotInfo.Direction);
                return(Move(robotInfo, amount, resultDirection));
            }
Пример #23
0
 private Direction GetCardinalDirectionAtRelativeDirection(RelativeDirection direction)
 {
     switch (direction)
     {
         case RelativeDirection.LEFT: return GetLeftCardinalDirection();
         case RelativeDirection.RIGHT: return GetRightCardinalDirection();
         case RelativeDirection.FORWARDS: return GetCardinalDirection();
         case RelativeDirection.BACKWARDS: return GetBackwardCardinalDirection();
         default: throw new FacingHelper.InvalidDirectionException();
     }
 }
Пример #24
0
 /// <summary>
 /// Generates an instruction for a POI.
 /// </summary>
 /// <param name="direction"></param>
 /// <param name="pois"></param>
 /// <returns></returns>
 protected override string GeneratePOI(RelativeDirection direction, List <PointPoi> pois)
 {
     if (direction == null)
     {
         return(string.Format("Poi"));
     }
     else
     {
         return(string.Format("Poi:{0}", direction.Direction));
     }
 }
Пример #25
0
        public static MarioState ApplyInputRepeatedly(MarioState marioState, RelativeDirection direction, int numQSteps)
        {
            int numFrames       = numQSteps / 4;
            int remainderQSteps = numQSteps % 4;

            for (int i = 0; i < numFrames; i++)
            {
                marioState = ApplyInput(marioState, direction);
            }
            return(remainderQSteps == 0 ? marioState : ApplyInput(marioState, direction, remainderQSteps));
        }
Пример #26
0
 /// <summary>
 /// Generates POI instruction.
 /// </summary>
 /// <param name="direction"></param>
 /// <param name="pois"></param>
 /// <returns></returns>
 protected override string GeneratePOI(RelativeDirection direction, List <PointPoi> pois)
 {
     if (direction != null)
     {
         return(string.Format("GeneratePoi:{0}_{1}", pois.Count, direction.Direction.ToString()));
     }
     else
     {
         return(string.Format("GeneratePoi:{0}", pois.Count));
     }
 }
        public void ConstructorArgumentsGetAssigned()
        {
            var          direction      = new RelativeDirection(0);
            const double travelDistance = 38.3;

            var instruction = new RelativeInstruction(
                direction: direction,
                travelDistance: travelDistance);

            Assert.Equal(direction, instruction.Direction);
            Assert.Equal(travelDistance, instruction.TravelDistance);
        }
Пример #28
0
    public void Drilling(int row, int column, RelativeDirection drilledPosition)
    {
        //Debug.Log ("[BrickManager]: row:"+row+" column:"+column);
        Debug.Log("column:" + column);
        int brickid = row * COLUMN + column + COLUMN_BY_2;

        if (brickid < 0 || column == 25 || column == -26)
        {
            return;
        }
        //Debug.Log ("brickid:"+brickid);
        bricksList [brickid].StratDrilling(drilledPosition);
    }
Пример #29
0
        /*
         * Move towards a new direction.
         * Throw exception if there is no valid cell to move into this direction.
         */
        public void Move(RelativeDirection towards)
        {
            //Get the new cell to move into
            var to = Grid.AdjacentTo(At, Facing, towards);

            //if there is no cell available in the given direction, throw an exception
            if (to == null)
            {
                throw new InvalidOperationException(
                          String.Format("There is no cell to move in the direction of {0}.", towards));
            }
            Move((Cell)to);
        }
Пример #30
0
    void AddTriangle(Vector3 v0, Vector3 v1, Vector3 v2, AtlasTexture atlasTexture, RelativeDirection rightAngle)
    {
        int vertexIndex = vertices.Count;

        vertices.Add(v0);
        vertices.Add(v1);
        vertices.Add(v2);

        triangles.Add(vertexIndex);
        triangles.Add(vertexIndex + 1);
        triangles.Add(vertexIndex + 2);

        AddTriangleTexture(atlasTexture, rightAngle);
    }
Пример #31
0
        /// <summary>
        /// Generates an immidiate turn instruction.
        /// </summary>
        /// <param name="entryIdx"></param>
        /// <param name="box"></param>
        /// <param name="before_name"></param>
        /// <param name="first_direction"></param>
        /// <param name="first_street_count_to"></param>
        /// <param name="second_direction"></param>
        /// <param name="first_street_to"></param>
        /// <param name="second_street_to"></param>
        /// <param name="list"></param>
        internal void GenerateImmidiateTurn(int entryIdx, GeoCoordinateBox box,
                                            TagsCollectionBase before_name, RelativeDirection first_direction, int first_street_count_to,
                                            RelativeDirection second_direction, TagsCollectionBase first_street_to, TagsCollectionBase second_street_to, List <PointPoi> list)
        {
            // create a new instruction first.
            Instruction instruction = new Instruction(entryIdx, box);

            // pass the instruction to the language generator.
            instruction = _generator.GenerateImmidiateTurn(
                instruction, first_street_count_to, first_street_to, first_direction, second_street_to, second_direction);

            // add the instruction to the instructions list.
            _instructions.Add(instruction);
        }
Пример #32
0
        public override void Succes()
        {
            // get the last arc and the last point.
            var latestArc         = (this.FinalMessages[this.FinalMessages.Count - 2] as MicroPlannerMessageArc).Arc;
            var latestPoint       = (this.FinalMessages[this.FinalMessages.Count - 1] as MicroPlannerMessagePoint).Point;
            var secondLatestArc   = (this.FinalMessages[this.FinalMessages.Count - 4] as MicroPlannerMessageArc).Arc;
            var secondLatestPoint = (this.FinalMessages[this.FinalMessages.Count - 3] as MicroPlannerMessagePoint).Point;

            // count the number of streets in the same turning direction as the turn
            // that was found.
            int count = 0;

            if (MicroPlannerHelper.IsLeft(latestPoint.Angle.Direction, this.Planner.Interpreter))
            {
                count = MicroPlannerHelper.GetLeft(this.FinalMessages, this.Planner.Interpreter);
            }
            else if (MicroPlannerHelper.IsRight(latestPoint.Angle.Direction, this.Planner.Interpreter))
            {
                count = MicroPlannerHelper.GetRight(this.FinalMessages, this.Planner.Interpreter);
            }

            // construct the box indicating the location of the resulting find by this machine.
            var point1 = latestPoint.Location;
            var box    = new GeoCoordinateBox(
                new GeoCoordinate(point1.Latitude - 0.001f, point1.Longitude - 0.001f),
                new GeoCoordinate(point1.Latitude + 0.001f, point1.Longitude + 0.001f));

            // get all the names/direction/counts.
            var nextName    = latestPoint.Next.Tags;
            var betweenName = latestArc.Tags;
            var beforeName  = secondLatestArc.Tags;

            int firstCount = count;

            RelativeDirection firstTurn  = secondLatestPoint.Angle;
            RelativeDirection secondTurn = latestPoint.Angle;

            // let the scentence planner generate the correct information.
            var metaData = new Dictionary <string, object>();

            metaData["first_street"]     = beforeName;
            metaData["first_direction"]  = firstTurn;
            metaData["second_street"]    = betweenName;
            metaData["second_direction"] = secondTurn;
            metaData["count_before"]     = firstCount;
            metaData["pois"]             = latestPoint.Points;
            metaData["type"]             = "immidiate_turn";
            this.Planner.SentencePlanner.GenerateInstruction(metaData, latestPoint.EntryIdx, box, latestPoint.Points);
        }
Пример #33
0
 public void Move(RelativeDirection direction)
 {
     if (!IsMoving())
     {
         Tile destinationTile = GetTileInDirection(direction);
         if (destinationTile != null)
         {
             SetCurrentTile(destinationTile);
             interpolant = 0.0f;
             start = transform.position;
             finish = transform.position;
             finish += FacingHelper.GetDirectionVector(GetCardinalDirectionAtRelativeDirection(direction));
         }
     }
 }
Пример #34
0
 public static void Move(GameObject gameObject, RelativeDirection direction)
 {
     ExecuteEvents.Execute(gameObject, MovementEventData.Create(direction), MovementEventHandler);
 }
Пример #35
0
        public PutBodyRestriction(JointType jointType1, JointType jointType2, RelativeDirection direction, bool dont = false)
            : base(body =>
            {
                var distanceThreshold = Z3Math.Real(0.01);
                
                var joint1Position = body.GetJointZ3Position(jointType1);
                var joint2Position = body.GetJointZ3Position(jointType2);

                var expr = Z3.Context.MkTrue();

                switch (direction)
                {
                    case RelativeDirection.InFrontOfYour:
                        expr = Z3.Context.MkGt(joint1Position.Z, Z3Math.Add(joint2Position.Z, distanceThreshold));
                        break;

                    case RelativeDirection.BehindYour:
                        expr = Z3.Context.MkLt(joint1Position.Z, Z3Math.Sub(joint2Position.Z, distanceThreshold));
                        break;

                    case RelativeDirection.ToTheRightOfYour:
                        expr = Z3.Context.MkGt(joint1Position.X, Z3Math.Add(joint2Position.X, distanceThreshold));
                        break;

                    case RelativeDirection.ToTheLeftOfYour:
                        expr = Z3.Context.MkLt(joint1Position.X, Z3Math.Sub(joint2Position.X, distanceThreshold));
                        break;

                    case RelativeDirection.OnTopOfYour:
                        expr = Z3.Context.MkGt(joint1Position.Y, Z3Math.Add(joint2Position.Y, distanceThreshold));
                        break;

                    case RelativeDirection.BelowYour:
                        expr = Z3.Context.MkLt(joint1Position.Y, Z3Math.Sub(joint2Position.Y, distanceThreshold));
                        break;
                }

                if (dont) expr = Z3.Context.MkNot(expr);
                return expr;
            },
            body =>
            {
                var stopwatch = new Stopwatch();
                stopwatch.Start();
                var distanceThreshold = 0.01;

                var point1 = body.Positions[jointType1];
                var point2 = body.Positions[jointType2];

                var targetValue = 1.0;
                var currentValue = 1.0;
                var lowerBound = 0.0;

                // inverting direction if expression is negated
                if (dont)
                {
                    switch (direction)
                    {
                        case RelativeDirection.ToTheRightOfYour: direction = RelativeDirection.ToTheLeftOfYour; break;
                        case RelativeDirection.ToTheLeftOfYour:  direction = RelativeDirection.ToTheRightOfYour; break;
                        case RelativeDirection.OnTopOfYour:      direction = RelativeDirection.BelowYour; break;
                        case RelativeDirection.BelowYour:        direction = RelativeDirection.OnTopOfYour; break;
                        case RelativeDirection.InFrontOfYour:    direction = RelativeDirection.BehindYour; break;
                        case RelativeDirection.BehindYour:       direction = RelativeDirection.InFrontOfYour; break;
                    }
                }

                switch (direction)
                {
                    case RelativeDirection.ToTheRightOfYour:
                        currentValue = point1.X;
                        targetValue = point2.X + distanceThreshold;
                        lowerBound = -1.0;
                        break;

                    case RelativeDirection.ToTheLeftOfYour:
                        currentValue = point1.X;
                        targetValue = point2.X - distanceThreshold;
                        lowerBound = 1.0;
                        break;

                    case RelativeDirection.OnTopOfYour:
                        currentValue = point1.Y;
                        targetValue = point2.Y + distanceThreshold;
                        lowerBound = -1.0;
                        break;

                    case RelativeDirection.BelowYour:
                        currentValue = point1.Y;
                        targetValue = point2.Y - distanceThreshold;
                        lowerBound = 1.0;
                        break;

                    case RelativeDirection.InFrontOfYour:
                        currentValue = point1.Z;
                        targetValue = point2.Z + distanceThreshold;
                        lowerBound = -1.0;
                        break;

                    case RelativeDirection.BehindYour:
                        currentValue = point1.Z;
                        targetValue = point2.Z - distanceThreshold;
                        lowerBound = 1.0;
                        break;
                }

                var percentage = PercentageCalculator.calc(lowerBound, targetValue, currentValue);
                //Console.WriteLine("put " + stopwatch.ElapsedTicks);
                return percentage;
            },
            jointType1,
            jointType2)
        {
            this.JointType1 = jointType1;
            this.JointType2 = jointType2;

            this.Direction = direction;

            if (dont)
            {
                this.isNegated = true;
            }
            else
            {
                this.isNegated = false;
            }
        }
Пример #36
0
 public void RequestTurn(RelativeDirection paramValue)
 {
     Model.Turn(paramValue);
 }
Пример #37
0
 public void Turn(RelativeDirection rdTurnDirection)
 {
     dOrientation = GetNewDirection(rdTurnDirection);
 }
Пример #38
0
 public static Task<Message[]> DownloadMessages(this DiscordClient client, Channel channel, int limit = 100, ulong? relativeMessageId = null, RelativeDirection relativeDir = RelativeDirection.Before, bool useCache = true)
 {
     if (channel == null) throw new ArgumentNullException(nameof(channel));
     return channel.DownloadMessages(limit, relativeMessageId, relativeDir, useCache);
 }
Пример #39
0
 //can be optimize this method
 public void StratDrilling(RelativeDirection drilledPostion)
 {
     if ((int)mineralType >= (int)MineralType.Stone)
         return;
     if (drilledAmount < 100) {
         canSave = true;
         drilledAmount+=GameControl.current.drillerStrenght(brickType);//calculated by brick strength && drill machine strength
         int nonDrilledSpriteIndex = Mathf.Min(drilledAmount,100)/17;//may be 17,18,19
         spr.sprite = BrickManager.current.NonDrilledBrick[nonDrilledSpriteIndex];
     } else {
         setNeighCode(drilledPostion);
         Drilled();
         BrickManager.current.NeighbourChanged(id);
         StoreNMission.current.DigBrick();
         GameControl.current.SetScore(Constants.BRICK_DIGGING_SCORE[(int)brickType]);
     }
 }
Пример #40
0
 public async Task<Message[]> DownloadMessages(int limit = 100, ulong? relativeMessageId = null, 
     RelativeDirection relativeDir = RelativeDirection.Before, bool useCache = true)
 {
     if (limit < 0) throw new ArgumentOutOfRangeException(nameof(limit));
     if (limit == 0 || Type != ChannelType.Text) return new Message[0];
     
     try
     {
         var request = new GetMessagesRequest(Id)
         {
             Limit = limit,
             RelativeDir = relativeMessageId.HasValue ? relativeDir == RelativeDirection.Before ? "before" : "after" : null,
             RelativeId = relativeMessageId ?? 0
         };
         var msgs = await Client.ClientAPI.Send(request).ConfigureAwait(false);
         return msgs.Select(x =>
         {
             Message msg = null;
             if (useCache)
             {
                 msg = AddMessage(x.Id, GetUser(x.Author.Id), x.Timestamp.Value);
                 var user = msg.User;
                 if (user != null)
                     user.UpdateActivity(msg.EditedTimestamp ?? msg.Timestamp);
             }
             else
                 msg = new Message(x.Id, this, GetUser(x.Author.Id));
             msg.Update(x);
             return msg;
         })
         .ToArray();
     }
     catch (HttpException ex) when (ex.StatusCode == HttpStatusCode.Forbidden)
     {
         return new Message[0];
     }
 }
Пример #41
0
 public static MovementEventData Create(RelativeDirection relativeDirection)
 {
     return new MovementEventData(EventSystem.current, relativeDirection);
 }
Пример #42
0
 private MovementEventData(EventSystem eventSystem, RelativeDirection relativeDirection)
     : base(eventSystem)
 {
     this.relativeDirection = relativeDirection;
 }
Пример #43
0
 private Direction GetNewDirection(RelativeDirection rdTurnDirection)
 {
     return ReverseDirectionIndexTable[(DirectionIndexTable[dOrientation] + RelativeDirectionConversionTable[rdTurnDirection]) % 4];
 }
Пример #44
0
 private void setNeighCode(RelativeDirection relDir)
 {
     neighbourCode=neighbourCode.Remove((int)relDir,1);
     neighbourCode=neighbourCode.Insert((int)relDir,"0");
     canSave = true;
 }
Пример #45
0
 public Direction Turn( RelativeDirection rd )
 {
     if (_dir == 0)
         return None;
     var dir = 1 + (((int) _dir + (int) rd - 1) & 3);
     return new Direction((DirectionValue)dir);
 }
Пример #46
0
 private IEnumerator IE_Blast(RelativeDirection drilledPostion)
 {
     yield return new WaitForSeconds (1f);
     MAudioManager.current.PlayFx (AudioName.Explosion);
     yield return new WaitForSeconds (0.2f);
     if (mineral && mineralType == MineralType.Stone) {
         Destroy(mineral);
         //brick drilled
         drilledAmount = 100;
         setNeighCode(drilledPostion);
         Drilled();
         BrickManager.current.NeighbourChanged(id);
         StoreNMission.current.BlastStone();
         GameControl.current.SetScore(Constants.STONE_BLAST_SCORE);
     }
 }
Пример #47
0
 public static RotationEventData Create(RelativeDirection relativeDirection)
 {
     return new RotationEventData(EventSystem.current, relativeDirection);
 }
Пример #48
0
 public void NeighbourChanged(RelativeDirection neighD)
 {
     //change neighbourCode using neighD
     //set sprite using neighbourCode and BrickManager sprites
     setNeighCode (neighD);
     if (drilledAmount >= 100) {
         setDrilledSprite();
     }
 }
Пример #49
0
 private Tile GetTileInDirection(RelativeDirection direction)
 {
     return currentTile.GetNeighbour(GetCardinalDirectionAtRelativeDirection(direction));
 }
Пример #50
0
        public void Turn(RelativeDirection paramDirection)
        {
            AbsoluteDirection newDirection;

            switch(paramDirection)
            {
                case RelativeDirection.Right:
                    newDirection = (AbsoluteDirection)((int)(this.mDirection + 1) %4);
                    break;
                case RelativeDirection.Left:
                    newDirection = (AbsoluteDirection)((int)(this.mDirection + 3) %4);
                    break;
                case RelativeDirection.Back:
                    newDirection = (AbsoluteDirection)((int)(this.mDirection + 2) %4);
                    break;
                default:
                    newDirection = AbsoluteDirection.North;
                    break;
            }

            this.mDirection = newDirection;

            this.NotifyObservers();
        }
Пример #51
0
 public Point GetAdjacentPoint(RelativeDirection rdDirection, Point pCurrentLocation)
 {
     Direction dDesiredDirection = GetNewDirection(rdDirection);
     Point pPointAdjustment = AdjacentPointXYAdjustmentTable[dDesiredDirection];
     return new Point(pCurrentLocation.X + pPointAdjustment.X, pCurrentLocation.Y + pPointAdjustment.Y);
 }
Пример #52
0
        public PutBodyRestriction(JointType jointType1, JointType jointType2, RelativeDirection direction, bool dont = false)
            : base(body =>
            {
                ArithExpr distanceThreshold = Z3Math.Real(0.1);

                Z3Point3D joint1Position = body.GetJointPosition(jointType1);
                Z3Point3D joint2Position = body.GetJointPosition(jointType2);

                BoolExpr expr = Z3.Context.MkTrue();

                switch (direction)
                {
                    case RelativeDirection.InFrontOfYour:
                        expr = Z3.Context.MkGt(joint1Position.Z, Z3Math.Add(joint2Position.Z, distanceThreshold));
                        break;

                    case RelativeDirection.BehindYour:
                        expr = Z3.Context.MkLt(joint1Position.Z, Z3Math.Sub(joint2Position.Z, distanceThreshold));
                        break;

                    case RelativeDirection.ToTheRightOfYour:
                        expr = Z3.Context.MkGt(joint1Position.X, Z3Math.Add(joint2Position.X, distanceThreshold));
                        break;

                    case RelativeDirection.ToTheLeftOfYour:
                        expr = Z3.Context.MkLt(joint1Position.X, Z3Math.Sub(joint2Position.X, distanceThreshold));
                        break;

                    case RelativeDirection.OnTopOfYour:
                        expr = Z3.Context.MkGt(joint1Position.Y, Z3Math.Add(joint2Position.Y, distanceThreshold));
                        break;

                    case RelativeDirection.BelowYour:
                        expr = Z3.Context.MkLt(joint1Position.Y, Z3Math.Sub(joint2Position.Y, distanceThreshold));
                        break;
                }

                if (dont) expr = Z3.Context.MkNot(expr);

                return expr;
            },
            //JointTypeHelper.GetListFromLeafToRoot(jointType1).Union(JointTypeHelper.GetListFromLeafToRoot(jointType2)).ToList())
            jointType1,
            jointType2)
        {
            this.JointType1 = jointType1;
            this.JointType2 = jointType2;

            this.Direction = direction;
            if (dont)
            {
                this.isNegated = true;
            }
            else
            {
                this.isNegated = false;
            }
        }
Пример #53
0
 public void Blast(RelativeDirection drilledPostion)
 {
     StartCoroutine ("IE_Blast", drilledPostion);
 }