Ejemplo n.º 1
0
        private void SetAdjacency(int roomNum, CardinalDirections roomDir, ref Room <T> room, ref Room <T> lastRoom)
        {
            if (roomNum != 1)
            {
                switch (roomDir)
                {
                case CardinalDirections.NORTH:
                    room.SouthID     = lastRoom.ID;
                    lastRoom.NorthID = room.ID;
                    break;

                case CardinalDirections.SOUTH:
                    room.NorthID     = lastRoom.ID;
                    lastRoom.SouthID = room.ID;
                    break;

                case CardinalDirections.EAST:
                    room.WestID     = lastRoom.ID;
                    lastRoom.EastID = room.ID;
                    break;

                case CardinalDirections.WEST:
                    room.EastID     = lastRoom.ID;
                    lastRoom.WestID = room.ID;
                    break;
                }
            }
            else
            {
                lastRoom = room;
            }
        }
Ejemplo n.º 2
0
        public static Vector2 DirectionToVector(CardinalDirections Direction)
        {
            switch (Direction)
            {
            case CardinalDirections.West:
                return(Vector2.left);

            case CardinalDirections.NorthWest:
                return(new Vector2(-1, 1).normalized);

            case CardinalDirections.North:
                return(Vector2.up);

            case CardinalDirections.NorthEast:
                return(new Vector2(1, 1).normalized);

            case CardinalDirections.East:
                return(Vector2.right);

            case CardinalDirections.SouthEast:
                return(new Vector2(1, -1).normalized);

            case CardinalDirections.South:
                return(Vector2.down);

            case CardinalDirections.SouthWest:
                return(new Vector2(-1, -1).normalized);

            default:
                return(Vector2.zero);
            }
        }
Ejemplo n.º 3
0
        private bool valid_tangent(Vector2 node, Vector2 dest, Vector2 best_dest, CardinalDirections dir)
        {
            // If the current destination is closer than the best destination in the travelled direction, it's fine
            if (destination_correct_direction(dest, best_dest, dir))
            {
                return(true);
            }

            // Otherwise the current destination has to at least be closet in tangential directions
            switch (dir)
            {
            case CardinalDirections.Down:
            case CardinalDirections.Up:
                if (dest.X < node.X)
                {
                    return(best_dest.X < dest.X);
                }
                else
                {
                    return(best_dest.X > dest.X);
                }

            case CardinalDirections.Left:
            case CardinalDirections.Right:
                if (dest.Y < node.Y)
                {
                    return(best_dest.Y < dest.Y);
                }
                else
                {
                    return(best_dest.Y > dest.Y);
                }
            }
            throw new ArgumentException();
        }
Ejemplo n.º 4
0
        private void HighlightAttack(bool highlight, Point position)
        {
            CardinalDirections direction    = Direction.GetCardinalDirection(this.Unit.GetPosition(), position);
            List <Point>       pointsInLine = GetPointsInLine(direction);

            pointsInLine?.ForEach(p => SimulateAttack(highlight, p, this.DeltaHealth, this.Knockback, true));
        }
Ejemplo n.º 5
0
 public Ballv5d4d3()
 {
     showBallPositionRect = false;
     showHeadingMarker    = false;
     visible           = true;
     rectCollisionSide = CardinalDirections.NotSet;
 }
Ejemplo n.º 6
0
        private List <Point> GetPointsInLine(CardinalDirections direction)
        {
            if (Board == null)
            {
                return(new List <Point>());
            }

            Point        unit   = this.Unit.GetPosition();
            List <Point> points = new List <Point>();

            switch (direction)
            {
            case CardinalDirections.North:
                points = Board.Where(point => point.x == unit.x && point.z > unit.z).ToList();
                break;

            case CardinalDirections.South:
                points = Board.Where(point => point.x == unit.x && point.z < unit.z).ToList();
                break;

            case CardinalDirections.East:
                points = Board.Where(point => point.z == unit.z && point.x > unit.x).ToList();
                break;

            case CardinalDirections.West:
                points = Board.Where(point => point.z == unit.z && point.x < unit.x).ToList();
                break;
            }

            return(points);
        }
        public IEnumerator Refresh_AttributesArgAllLocationsSizes_DoesNotThrowException(
            [ValueSource(typeof(ValueSourceCommon), "AllViewLocations")]
            CardinalDirections location,
            [ValueSource(typeof(ValueSourceCommon), "AllViewSizes")]
            ViewSizes size
            )
        {
// Set Up
            SetUpCommon.CreateTestCamera();
            SetUpCommon.CreateTestNameCanvas(TestContext.CurrentContext.Test.Name);

            SubjectDetailView detailView =
                SubjectDetailView.GetView(
                    SetUpCommon.GetUICanvas(),
                    size,
                    location
                    );

            IAttributeData aData = ValueSourceCommon.GetMockAttributeData();

// Assert
            Assert.DoesNotThrow(() => {
                detailView.Refresh(aData);
            });
            yield return(new WaitForSeconds(VisualTimer));

// Tear Down
            TearDownCommon.DestroyAllGameObjects();
        }
Ejemplo n.º 8
0
        internal bool move_node(CardinalDirections dir)
        {
            if (ActiveNodeIndex == -1)
            {
                return(false);
            }

            var destination = Destinations.destination(
                NodeOriginalLocations[ActiveNode], dir);

            // Vertical wrap
            if (destination.IsNothing && WrapVerticalSameColumn)
            {
                destination = move_vertical_wrap(dir, destination, true);
            }
            else if (destination.IsNothing && WrapVerticalMove)
            {
                destination = move_vertical_wrap(dir, destination);
            }
            if (destination.IsNothing)
            {
                return(false);
            }

            set_active_node(node_from_location(destination));
            return(true);
        }
Ejemplo n.º 9
0
 public RoverBase(string name, CardinalDirections cardinalDirection = CardinalDirections.N, int speed = 1)
 {
     Name = name;
     CardinalDirection = cardinalDirection;
     Speed             = speed;
     Position          = new CartesianCoordinate();
 }
Ejemplo n.º 10
0
        private List <Point> GetRowsToAttack(Point target)
        {
            Point neoSatanPosition = this.Unit.GetPosition();

            cardinalDirection = Direction.GetCardinalDirection(this.Unit.GetPosition(), target);
            List <Point> rowsToAttack = new List <Point>();

            switch (cardinalDirection)
            {
            case CardinalDirections.South:
            case CardinalDirections.East:
            case CardinalDirections.SouthWest:
            case CardinalDirections.NorthEast:
                cardinalDirectionToRotate = CardinalDirections.South;
                rowsToAttack = this.ValidPositions.Where(p => p.z < neoSatanPosition.z && p.x >= neoSatanPosition.x - 1 && p.x <= neoSatanPosition.x + 1).ToList();
                break;

            case CardinalDirections.North:
            case CardinalDirections.West:
            case CardinalDirections.NorthWest:
            case CardinalDirections.SouthEast:
                cardinalDirectionToRotate = CardinalDirections.West;
                rowsToAttack = this.ValidPositions.Where(p => p.x < neoSatanPosition.x && p.z >= neoSatanPosition.z - 1 && p.z <= neoSatanPosition.z + 1).ToList();
                break;
            }

            return(rowsToAttack);
        }
Ejemplo n.º 11
0
        public Vector Move(CardinalDirections direction, int distance)
        {
            var heading = this.Heading;

            switch (direction)
            {
            case CardinalDirections.Right:
                heading += 90;
                break;

            case CardinalDirections.Back:
                heading += 180;
                break;

            case CardinalDirections.Left:
                heading += 270;
                break;
            }

            var radians  = heading * Math.PI / 180;
            var adjacent = Math.Cos(radians) * distance;
            var opposite = Math.Sin(radians) * distance;

            return(new Vector(this.Heading, Math.Round(this.X + adjacent, 2), Math.Round(this.Y + opposite, 2)));
        }
Ejemplo n.º 12
0
 public GenerationConnectionID(CardinalDirections entry, CardinalDirections exit, ConnectionID enID, ConnectionID exID)
 {
     this.entry.dir = entry;
     this.entry.id  = enID;
     this.exit.dir  = exit;
     this.exit.id   = exID;
 }
Ejemplo n.º 13
0
        } // end of function SetRectangleCollisionSide(Blockv0d1 b)

        private void SetRectangleCollisionSide(Blockv0d2 b, CollisionCheckMarkerv0d1 cc)
        {
            //float angleToRectCenter = AngleBetween2(b.center, cc.position);

            if (cc.position.X < b.position.X + b.size.Width && cc.position.X > b.center.X &&
                cc.position.Y > b.position.Y && cc.position.Y < b.position.Y + b.size.Height)
            {
                rectCollisionSide = CardinalDirections.East;
            }
            if (cc.position.X > b.position.X && cc.position.X < b.position.X + b.size.Width &&
                cc.position.Y < b.position.Y + b.size.Height && cc.position.Y > b.center.Y)
            {
                rectCollisionSide = CardinalDirections.South;
            }

            if (cc.position.X > b.position.X && cc.position.X < b.center.X &&
                cc.position.Y > b.position.Y &&
                cc.position.Y < b.position.Y + b.size.Height)
            {
                rectCollisionSide = CardinalDirections.West;
            }

            if (cc.position.X > b.position.X && cc.position.X < b.position.X + b.size.Width &&
                cc.position.Y > b.position.Y && cc.position.Y < b.center.Y)
            {
                rectCollisionSide = CardinalDirections.North;
            }
        } // end of function SetRectangleCollisionSide(Blockv0d2 b, CollisionCheckMarkerv0d1 cc)
Ejemplo n.º 14
0
        private Vector3 GetPositionOffset(CardinalDirections direction, float yOffset)
        {
            float offset = 0.5f;

            switch (direction)
            {
            case CardinalDirections.North:
                return(new Vector3(0, yOffset, offset));

            case CardinalDirections.NorthEast:
                return(new Vector3(offset, yOffset, offset));

            case CardinalDirections.NorthWest:
                return(new Vector3(-offset, yOffset, offset));

            case CardinalDirections.East:
                return(new Vector3(offset, yOffset, 0));

            case CardinalDirections.SouthEast:
                return(new Vector3(offset, yOffset, -offset));

            case CardinalDirections.SouthWest:
                return(new Vector3(-offset, yOffset, -offset));

            case CardinalDirections.West:
                return(new Vector3(0, yOffset, -offset));

            case CardinalDirections.South:
                return(new Vector3(0, yOffset, -offset));

            default:
                return(new Vector3(0, -yOffset, 0));
            }
        }
Ejemplo n.º 15
0
        public GridPoint GetAdjGridPt(GridPoint gridPt, CardinalDirections direction)
        {
            GridPointMatrix matrix = gridPt.ParentGrid;

            switch (direction)
            {
            case CardinalDirections.N:
                return(matrix[gridPt.GridCoordinatesAbs.X, gridPt.GridCoordinatesAbs.Y - 1]);

            case CardinalDirections.NE:
                return(matrix[gridPt.GridCoordinatesAbs.X - 1, gridPt.GridCoordinatesAbs.Y - 1]);

            case CardinalDirections.E:
                return(matrix[gridPt.GridCoordinatesAbs.X + 1, gridPt.GridCoordinatesAbs.Y]);

            case CardinalDirections.SE:
                return(matrix[gridPt.GridCoordinatesAbs.X + 1, gridPt.GridCoordinatesAbs.Y + 1]);

            case CardinalDirections.S:
                return(matrix[gridPt.GridCoordinatesAbs.X, gridPt.GridCoordinatesAbs.Y + 1]);

            case CardinalDirections.SW:
                return(matrix[gridPt.GridCoordinatesAbs.X - 1, gridPt.GridCoordinatesAbs.Y + 1]);

            case CardinalDirections.W:
                return(matrix[gridPt.GridCoordinatesAbs.X - 1, gridPt.GridCoordinatesAbs.Y]);

            case CardinalDirections.NW:
                return(matrix[gridPt.GridCoordinatesAbs.X - 1, gridPt.GridCoordinatesAbs.Y - 1]);

            default:
                return(null);
            }
        }
Ejemplo n.º 16
0
 void changeFaceDirection(CardinalDirections new_direction)
 {
     if (face_direction != new_direction)
     {
         face_direction = new_direction;
     }
 }
Ejemplo n.º 17
0
 private void SetBallHeadingv2()
 {
     if (velocity.X > 0 && velocity.Y > 0)
     {
         ballHeading = CardinalDirections.SouthEast;
     }
     if (velocity.X < 0 && velocity.Y > 0)
     {
         ballHeading = CardinalDirections.SouthWest;
     }
     if (velocity.X < 0 && velocity.Y < 0)
     {
         ballHeading = CardinalDirections.NorthWest;
     }
     if (velocity.X > 0 && velocity.Y < 0)
     {
         ballHeading = CardinalDirections.NorthEast;
     }
     if (velocity.X == 0 && velocity.Y < 0)
     {
         ballHeading = CardinalDirections.North;
     }
     if (velocity.X == 0 && velocity.Y > 0)
     {
         ballHeading = CardinalDirections.South;
     }
     if (velocity.X < 0 && velocity.Y == 0)
     {
         ballHeading = CardinalDirections.West;
     }
     if (velocity.X > 0 && velocity.Y == 0)
     {
         ballHeading = CardinalDirections.East;
     }
 } // end of function SetBallHeading()
Ejemplo n.º 18
0
        public async Task <IActionResult> Edit(int id, [Bind("ShaftId,Ylower,Yupper,North,Xlower,Xupper,East,Subplot")] ShaftLocation shaftLocation)
        {
            if (id != shaftLocation.ShaftId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    shaftLocation.Lookup = $"{shaftLocation.Xlower}/{shaftLocation.Xupper} {shaftLocation.North} {shaftLocation.Ylower}/{shaftLocation.Yupper} {shaftLocation.East} {shaftLocation.Subplot}";
                    _context.Update(shaftLocation);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ShaftLocationExists(shaftLocation.ShaftId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewBag.NorthSouth = new SelectList(CardinalDirections.NorthSouth(), shaftLocation.North);
            ViewBag.EastWest   = new SelectList(CardinalDirections.EastWest(), shaftLocation.East);
            ViewBag.Subplots   = new SelectList(CardinalDirections.SubPlots(), shaftLocation.Subplot);
            return(View(shaftLocation));
        }
Ejemplo n.º 19
0
        public GridPoint GetAdjGridPt(GridPoint gridPt, CardinalDirections direction)
        {
            GridPointMatrix matrix = gridPt.ParentGrid;

            switch (direction)
            {
                case CardinalDirections.N:
                    return matrix[gridPt.GridCoordinatesAbs.X, gridPt.GridCoordinatesAbs.Y - 1];
                case CardinalDirections.NE:
                    return matrix[gridPt.GridCoordinatesAbs.X - 1, gridPt.GridCoordinatesAbs.Y - 1];
                case CardinalDirections.E:
                    return matrix[gridPt.GridCoordinatesAbs.X + 1, gridPt.GridCoordinatesAbs.Y];
                case CardinalDirections.SE:
                    return matrix[gridPt.GridCoordinatesAbs.X + 1, gridPt.GridCoordinatesAbs.Y + 1];
                case CardinalDirections.S:
                    return matrix[gridPt.GridCoordinatesAbs.X, gridPt.GridCoordinatesAbs.Y + 1];
                case CardinalDirections.SW:
                    return matrix[gridPt.GridCoordinatesAbs.X - 1, gridPt.GridCoordinatesAbs.Y + 1];
                case CardinalDirections.W:
                    return matrix[gridPt.GridCoordinatesAbs.X - 1, gridPt.GridCoordinatesAbs.Y];
                case CardinalDirections.NW:
                    return matrix[gridPt.GridCoordinatesAbs.X - 1, gridPt.GridCoordinatesAbs.Y - 1];
                default:
                    return null;
            }
        }
Ejemplo n.º 20
0
        internal static IEnumerable <CardinalDirections> tangent_directions(
            CardinalDirections dir)
        {
            switch (dir)
            {
            case CardinalDirections.Down:
            case CardinalDirections.Up:
                yield return(CardinalDirections.Left);

                yield return(CardinalDirections.Right);

                break;

            case CardinalDirections.Left:
            case CardinalDirections.Right:
                yield return(CardinalDirections.Down);

                yield return(CardinalDirections.Up);

                break;

            default:
                yield break;
            }
        }
Ejemplo n.º 21
0
        public void MoveLastPointAndAnchor(Vector3 pos, Vector3 anchorPos, CardinalDirections dir, Vector2 dims)
        {
            Vector3 relativePosForRot = rotationAnchors[rotationAnchors.Length - 1] - points[points.Length - 1];

            points[points.Length - 1] = transform.InverseTransformPoint(pos);
            Vector3 newAnchorPos = transform.InverseTransformPoint(pos + (anchorPos.normalized * 5f));

            switch (dir)
            {
            case CardinalDirections.North:
                newAnchorPos.z = dims.y * 0.5f - dims.y * 0.35f;
                break;

            case CardinalDirections.East:
                newAnchorPos.x = dims.x * 0.5f - dims.x * 0.35f;
                break;

            case CardinalDirections.South:
                newAnchorPos.z = dims.y * 0.5f - dims.y * 0.65f;
                break;

            case CardinalDirections.West:
                newAnchorPos.x = dims.x * 0.5f - dims.x * 0.65f;
                break;
            }

            points[points.Length - 2] = newAnchorPos;
            rotationAnchors[rotationAnchors.Length - 1] = points[points.Length - 1] + relativePosForRot;
        }
    private void Move()
    {
        float horizontalOffset = Input.GetAxis("Horizontal");
        float verticalOffset   = Input.GetAxis("Vertical");

        // Translates the player to a new position, at a given speed.
        Vector2 newPos = new Vector2(transform.position.x + horizontalOffset * m_speed,
                                     transform.position.y + verticalOffset * m_speed);

        m_rb2D.MovePosition(newPos);

        // Computes the player main direction (North, Sound, East, West)
        if (Mathf.Abs(horizontalOffset) > Mathf.Abs(verticalOffset))
        {
            if (horizontalOffset > 0)
            {
                m_direction = CardinalDirections.CARDINAL_E;
            }
            else
            {
                m_direction = CardinalDirections.CARDINAL_W;
            }
        }
        else if (Mathf.Abs(horizontalOffset) < Mathf.Abs(verticalOffset))
        {
            if (verticalOffset > 0)
            {
                m_direction = CardinalDirections.CARDINAL_N;
            }
            else
            {
                m_direction = CardinalDirections.CARDINAL_S;
            }
        }
    }
Ejemplo n.º 23
0
        } // end of function BounceV1

        float SetMinBounceAngle(CardinalDirections gh, float angle)
        {
            float minangle = 0;

            switch (gh)
            {
            case CardinalDirections.East:
                break;

            case CardinalDirections.SouthEast:
                break;

            case CardinalDirections.SouthWest:
                break;

            case CardinalDirections.West:
                break;

            case CardinalDirections.NorthWest:
                break;

            case CardinalDirections.North:
                break;

            case CardinalDirections.NorthEast:
                break;

            default:
                break;
            }
            return(minangle);
        }
Ejemplo n.º 24
0
 public async void Flip(CardinalDirections direction)
 {
     if (this.CanManeuver)
     {
         await this.messenger.SendAsync(Commands.Flip, (char)(CardinalDirection)direction);
     }
 }
Ejemplo n.º 25
0
        } // end of function DrawDebugInfo(Graphics g, ref PointF textPos)

        #region moved to v5.4 07/18/2017
        private void SetBallHeading()
        {
            if (angle < pi / 2)
            {
                ballHeading = CardinalDirections.SouthEast;
            }
            if (angle < pi && angle >= pi / 2)
            {
                ballHeading = CardinalDirections.SouthWest;
            }
            if (angle < 3 * pi / 2 && angle >= pi)
            {
                ballHeading = CardinalDirections.NorthWest;
            }
            if (angle < 2 * pi && angle >= 3 * pi / 2)
            {
                ballHeading = CardinalDirections.NorthEast;
            }
            if (angle == 2 * pi || angle == 0)
            {
                ballHeading = CardinalDirections.East;
            }
            if (angle == pi / 2)
            {
                ballHeading = CardinalDirections.South;
            }
            if (angle == pi)
            {
                ballHeading = CardinalDirections.West;
            }
            if (angle == 3 * pi / 2)
            {
                ballHeading = CardinalDirections.North;
            }
        } // end of function SetBallHeading()
        public IEnumerator HideDetail_WithDescriptionDataAllLocationsSizes_DoesNotThrowException(
            [ValueSource(typeof(ValueSourceCommon), "AllViewLocations")]
            CardinalDirections location,
            [ValueSource(typeof(ValueSourceCommon), "AllViewSizes")]
            ViewSizes size
            )
        {
//  Set Up
            SetUpCommon.CreateTestCamera();
            SetUpCommon.CreateTestNameCanvas(
                TestContext.CurrentContext.Test.Name
                );

            Subject subjectUnderTest = new Subject(
                SetUpCommon.GetUICanvas()
                );

            subjectUnderTest.TryAddData(
                ValueSourceCommon.GetMockDescriptionData()
                );

            subjectUnderTest.ShowDetail(location, size);

// Assert
            yield return(new WaitForSeconds(VisualTimer * .5f));

            Assert.DoesNotThrow(() => {
                subjectUnderTest.HideDetail();
            });

            yield return(new WaitForSeconds(VisualTimer * .5f));

// Tear Down
            TearDownCommon.DestroyAllGameObjects();
        }
Ejemplo n.º 27
0
        public static Quaternion GetRotation(CardinalDirections direction, float xRotation, float zRotation)
        {
            switch (direction)
            {
            case CardinalDirections.North:
                return(Quaternion.Euler(xRotation, 0f, zRotation));

            case CardinalDirections.NorthEast:
                return(Quaternion.Euler(xRotation, 45f, zRotation));

            case CardinalDirections.NorthWest:
                return(Quaternion.Euler(xRotation, 315f, zRotation));

            case CardinalDirections.East:
                return(Quaternion.Euler(xRotation, 90f, zRotation));

            case CardinalDirections.SouthEast:
                return(Quaternion.Euler(xRotation, 135f, zRotation));

            case CardinalDirections.SouthWest:
                return(Quaternion.Euler(xRotation, 225f, zRotation));

            case CardinalDirections.West:
                return(Quaternion.Euler(xRotation, 270f, zRotation));

            case CardinalDirections.South:
            default:
                return(Quaternion.Euler(xRotation, 180f, zRotation));
            }
        }
Ejemplo n.º 28
0
    void SpawnCharacters()
    {
        Vector3[] spawnPoints = m_map.GetSpawnPoints(10);
        Vector3   playerSpawnPoint, exitSpawnPoint;

        Helper.FindFurthestPoints(spawnPoints, out playerSpawnPoint, out exitSpawnPoint);
        // playerSpawnPoint = spawnPoints[0];
        // exitSpawnPoint = spawnPoints[1];
        m_player       = Instantiate(m_playerPrefab, playerSpawnPoint, Quaternion.identity);
        m_player.m_map = m_map;

        m_exit = Instantiate(m_exitPrefab, exitSpawnPoint, Quaternion.identity);

        List <Ant> ants = new List <Ant>();

        foreach (Vector3 spawn in spawnPoints)
        {
            if (spawn != playerSpawnPoint && spawn != exitSpawnPoint)
            {
                CardinalDirections randomDirection = (CardinalDirections)Random.Range(0, (int)CardinalDirections.END);
                Debug.Log(spawn);
                Debug.Log(randomDirection);
                Ant newAnt = Instantiate(m_antPrefab, spawn, Quaternion.Euler(0, (int)randomDirection * -90, 0));
                m_map.WorldToGrid(spawn, out newAnt.m_row, out newAnt.m_col);
                newAnt.m_direction = randomDirection;
                ants.Add(newAnt);
            }
        }
        m_ants = new Ant[ants.Count];
        ants.CopyTo(m_ants);
    }
        } // end of function Reset()

        private void LocalLoadAndReset()
        {
            collisionDetected = false;
            rectCollisionSide = CardinalDirections.NotSet;
            IsLaunched        = false;
            initialLaunch     = true;
        } // end of function LocalLoadAndReset()
        public IEnumerator Refresh_LocationAbilitiesArg_DoesNotThrowException(
            [ValueSource(typeof(ValueSourceCommon), "AllViewLocations")]
            CardinalDirections location,
            [ValueSource(typeof(ValueSourceCommon), "AllViewSizes")]
            ViewSizes size
            )
        {
//  Set Up
            SetUpCommon.CreateTestCamera();
            SetUpCommon.CreateTestNameCanvas(
                TestContext.CurrentContext.Test.Name
                );

            SetUpCommon.CreateEventSystem();

            ActionBarView abView =
                ActionBarView.GetView(
                    SetUpCommon.GetUICanvas(),
                    size,
                    location
                    );

// Assert
            Assert.DoesNotThrow(() => {
                abView.Refresh(
                    null,
                    ValueSourceCommon.StubV3ArgActionDict(5)
                    );
            });

            yield return(new WaitForSeconds(VisualTimer));

// Tear Down
            TearDownCommon.DestroyAllGameObjects();
        }
Ejemplo n.º 31
0
        public override string ToString()
        {
            CardinalDirections orientationValue = (CardinalDirections)myOrientation;
            string             directionValue   = orientationValue.ToString();

            return(String.Format("{0} {1} {2}", myX, myY, directionValue));
        }
Ejemplo n.º 32
0
 public static string GetPreSuffixFromOrientation(CardinalDirections orientation)
 {
     switch (orientation) {
     case CardinalDirections.N:
         return "Back";
         break;
     case CardinalDirections.S:
         return "Front";
         break;
     default:
         return "Right";
     }
 }
Ejemplo n.º 33
0
 public static string GetPostSuffixFromFaceDirection(CardinalDirections face_direction)
 {
     switch (face_direction) {
     case CardinalDirections.N:
         return "Back";
         break;
     case CardinalDirections.S:
         return "Front";
         break;
     default:
         return "Right";
     }
 }
Ejemplo n.º 34
0
    public string getSuffix(CardinalDirections orientation)
    {
        string clipSuffix = "";
        string separator = "";
        List<string> post_suffixes;

        if(getObj().resource_identifiers.Second.Count > 1) {
            clipSuffix = GetPreSuffixFromOrientation (orientation);
        }

        getObj().resource_identifiers.Second.TryGetValue (orientation, out post_suffixes);

        if(post_suffixes.Count > 1 && getObj().resource_identifiers.Second.Count > 1) {
            separator = "-";
        }

        clipSuffix = clipSuffix + separator + post_suffixes [UnityEngine.Random.Range (0, post_suffixes.Count)];

        return clipSuffix;
    }
Ejemplo n.º 35
0
    // DETECT COLLISIONS, RAYCAST FORWARD
    // CENTIPEDE PATTERN
    // if collision forward look down, if locked down collision "fall"
    // if hit bottom, invert to up, if locked up "float"
    public void fakeUpdate()
    {
        float rayDepth = 0.2f,
            horizontalX,
            horizontalY,
            verticalX,
            verticalY;
        List<RaycastHit2D> hits = new List<RaycastHit2D>();

        horizontalX = go.transform.localScale.x/2f;
        horizontalY = go.transform.localScale.y/3f;
        verticalX = go.transform.localScale.x/3f;
        verticalY = go.transform.localScale.y/2f;

        switch(direction){
        default:
        case CardinalDirections.North:
            // raycast up

            // cast up right
            hits.AddRange(
                Physics2D.RaycastAll(
                go.transform.position + new Vector3(verticalX, verticalY, 0f),
                Vector2.up,
                rayDepth)
                );
            Debug.DrawRay(
                go.transform.position + new Vector3(verticalX, verticalY, 0f),
                Vector2.up * rayDepth
                );

            // cast up left
            hits.AddRange(
                Physics2D.RaycastAll(
                go.transform.position + new Vector3(-verticalX, verticalY, 0f),
                Vector2.up,
                rayDepth)
                );
            Debug.DrawRay(
                go.transform.position + new Vector3(-verticalX, verticalY, 0f),
                Vector2.up * rayDepth
                );

            // check hits
            foreach ( RaycastHit2D hit in hits ){
                if ( hit.collider != null && hit.collider.gameObject != go ) {
                    direction = CardinalDirections.East;
                }
            }
            break;
        case CardinalDirections.South:
            // raycast down

            // cast down right
            hits.AddRange(
                Physics2D.RaycastAll(
                go.transform.position + new Vector3(verticalX, -verticalY, 0f),
                -Vector2.up,
                rayDepth)
                );
            Debug.DrawRay(
                go.transform.position + new Vector3(verticalX, -verticalY, 0f),
                -Vector2.up * rayDepth
                );

            // cast updownleft
            hits.AddRange(
                Physics2D.RaycastAll(
                go.transform.position + new Vector3(-verticalX, -verticalY, 0f),
                -Vector2.up,
                rayDepth)
                );
            Debug.DrawRay(
                go.transform.position + new Vector3(-verticalX, -verticalY, 0f),
                -Vector2.up * rayDepth
                );

            // check hits
            foreach ( RaycastHit2D hit in hits ){
                if ( hit.collider != null && hit.collider.gameObject != go ) {
                    direction = CardinalDirections.West;
                }
            }
            break;
        case CardinalDirections.East:
            // raycast right

            // cast right top
            hits.AddRange(
                Physics2D.RaycastAll(
                    go.transform.position + new Vector3(horizontalX, horizontalY, 0f),
                    Vector2.right,
                    rayDepth)
                );
            Debug.DrawRay(
                go.transform.position + new Vector3(horizontalX, horizontalY, 0f),
                Vector2.right * rayDepth
                );

            // cast right bottom
            hits.AddRange(
                Physics2D.RaycastAll(
                    go.transform.position + new Vector3(horizontalX, -horizontalY, 0f),
                    Vector2.right,
                    rayDepth)
                );
            Debug.DrawRay(
                go.transform.position + new Vector3(horizontalX, -horizontalY, 0f),
                Vector2.right * rayDepth
                );

            // check hits
            foreach ( RaycastHit2D hit in hits ){
                if ( hit.collider != null && hit.collider.gameObject != go ) {
                    direction = CardinalDirections.South;
                }
            }

            break;
        case CardinalDirections.West:
            // raycast left

            // cast left top
            hits.AddRange(
                Physics2D.RaycastAll(
                go.transform.position + new Vector3(-horizontalX, horizontalY, 0f),
                -Vector2.right,
                rayDepth)
                );
            Debug.DrawRay(
                go.transform.position + new Vector3(-horizontalX, horizontalY, 0f),
                -Vector2.right * rayDepth
                );

            // cast left bottom
            hits.AddRange(
                Physics2D.RaycastAll(
                go.transform.position + new Vector3(horizontalX, -horizontalY, 0f),
                -Vector2.right,
                rayDepth)
                );
            Debug.DrawRay(
                go.transform.position + new Vector3(-horizontalX, -horizontalY, 0f),
                -Vector2.right * rayDepth
                );

            foreach ( RaycastHit2D hit in hits ){
                if ( hit.collider != null && hit.collider.gameObject != go ) {
                    direction = CardinalDirections.North;
                }
            }
            break;
        }
    }
Ejemplo n.º 36
0
	void changeFaceDirection(CardinalDirections new_direction) {
		if (face_direction != new_direction) {
			face_direction = new_direction;
		}
	}
Ejemplo n.º 37
0
	void checkPosUpdate() {
		Vector2 vec = new Vector2(transform.position.x, transform.position.y) - last_position;
		if (vec != Vector2.zero) {		// if it has moved
			stall = 4;
			// set movement direction
			if(vec.y != 0) {
				if(vec.y < 0) {
					face_direction = CardinalDirections.S;
				}
				else if(vec.y > 0) {
					face_direction = CardinalDirections.N;
				}
			}
			if(vec.x != 0) {
				if(vec.x > 0) {
					if(face_direction != CardinalDirections.E) {
						FlipHScale (CardinalDirections.E);
					}
					face_direction = CardinalDirections.E;
				}
				else if(vec.x < 0) {
					if(face_direction != CardinalDirections.W) {
						FlipHScale (CardinalDirections.W);
					}
					face_direction = CardinalDirections.W;
				}
			}
			startAction("running");
			last_position = transform.position;
		} 
		else {
			stall--;
			if(stall <= 0) {
				stopAction("running");
			}
		}
	}
Ejemplo n.º 38
0
	void FlipHScale(CardinalDirections direction) {
		if(direction == CardinalDirections.E) {
			transform.localScale = new Vector3 (1, 1, 1);
		}
		else if (direction == CardinalDirections.W) {
			transform.localScale = new Vector3 (-1, 1, 1);
		}
	}
 public GridPoint GetAdjGridPt(GridPoint gridPt, CardinalDirections direction)
 {
     throw new NotImplementedException();
 }
    private void CreateNewBackground(SpriteRenderer lastBackground, CardinalDirections direction)
    {
        Vector2 lastBackgroundIndex = new Vector2(Mathf.Round((lastBackground.transform.position.x - _initalBackgroundPos.x) / (lastBackground.bounds.extents.x * 2)),
                                                  Mathf.Round((lastBackground.transform.position.y - _initalBackgroundPos.y) / (lastBackground.bounds.extents.y * 2))),
                newBackgroundIndex;
        GameObject newBackground,
                   backgroundToLoad;

        int backgroundType = Random.Range(1, 3),
            backgroundRotation = 90 * Random.Range(0, 4);

        if (backgroundType < 2)
            backgroundToLoad = Background1;
        else
            backgroundToLoad = Background2;

        switch (direction)
        {
            case CardinalDirections.UP:
                newBackgroundIndex = new Vector2(lastBackgroundIndex.x, lastBackgroundIndex.y + 1);
                if (!_activeBackgrounds.Contains(newBackgroundIndex))
                {
                    if (_allBackgrounds.ContainsKey(newBackgroundIndex))
                    {
                        if (_allBackgrounds[newBackgroundIndex][0] < 2)
                            backgroundToLoad = Background1;
                        else
                            backgroundToLoad = Background2;

                        newBackground = (GameObject)Instantiate(backgroundToLoad, new Vector3(lastBackground.transform.position.x, lastBackground.transform.position.y + (lastBackground.bounds.extents.y * 2), 0), Quaternion.AngleAxis(_allBackgrounds[newBackgroundIndex][1], Vector3.forward));
                    }
                    else
                    {
                        newBackground = (GameObject)Instantiate(backgroundToLoad, new Vector3(lastBackground.transform.position.x, lastBackground.transform.position.y + (lastBackground.bounds.extents.y * 2), 0), Quaternion.AngleAxis(backgroundRotation, Vector3.forward));
                        _allBackgrounds.Add(newBackgroundIndex, new int[2] { backgroundType, backgroundRotation });
                    }
                    _allBackgroundSprites.Add(newBackground.GetComponent<SpriteRenderer>());
                    _activeBackgrounds.Add(newBackgroundIndex);
                }
                break;
            case CardinalDirections.DOWN:
                newBackgroundIndex = new Vector2(lastBackgroundIndex.x, lastBackgroundIndex.y - 1);
                if (!_activeBackgrounds.Contains(newBackgroundIndex))
                {
                    if (_allBackgrounds.ContainsKey(newBackgroundIndex))
                    {
                        if (_allBackgrounds[newBackgroundIndex][0] < 2)
                            backgroundToLoad = Background1;
                        else
                            backgroundToLoad = Background2;

                        newBackground = (GameObject)Instantiate(backgroundToLoad, new Vector3(lastBackground.transform.position.x, lastBackground.transform.position.y - (lastBackground.bounds.extents.y * 2), 0), Quaternion.AngleAxis(_allBackgrounds[newBackgroundIndex][1], Vector3.forward));
                    }
                    else
                    {
                        newBackground = (GameObject)Instantiate(backgroundToLoad, new Vector3(lastBackground.transform.position.x, lastBackground.transform.position.y - (lastBackground.bounds.extents.y * 2), 0), Quaternion.AngleAxis(backgroundRotation, Vector3.forward));
                        _allBackgrounds.Add(newBackgroundIndex, new int[2] { backgroundType, backgroundRotation });
                    }
                    _allBackgroundSprites.Add(newBackground.GetComponent<SpriteRenderer>());
                    _activeBackgrounds.Add(newBackgroundIndex);
                }
                break;
            case CardinalDirections.LEFT:
                newBackgroundIndex = new Vector2(lastBackgroundIndex.x - 1, lastBackgroundIndex.y);
                if (!_activeBackgrounds.Contains(new Vector2(lastBackgroundIndex.x - 1, lastBackgroundIndex.y)))
                {
                    if (_allBackgrounds.ContainsKey(newBackgroundIndex))
                    {
                        if (_allBackgrounds[newBackgroundIndex][0] < 2)
                            backgroundToLoad = Background1;
                        else
                            backgroundToLoad = Background2;

                        newBackground = (GameObject)Instantiate(backgroundToLoad, new Vector3(lastBackground.transform.position.x - (lastBackground.bounds.extents.x * 2), lastBackground.transform.position.y, 0), Quaternion.AngleAxis(_allBackgrounds[newBackgroundIndex][1], Vector3.forward));
                    }
                    else
                    {
                        newBackground = (GameObject)Instantiate(backgroundToLoad, new Vector3(lastBackground.transform.position.x - (lastBackground.bounds.extents.x * 2), lastBackground.transform.position.y, 0), Quaternion.AngleAxis(backgroundRotation, Vector3.forward));
                        _allBackgrounds.Add(newBackgroundIndex, new int[2] { backgroundType, backgroundRotation });
                    }
                    _allBackgroundSprites.Add(newBackground.GetComponent<SpriteRenderer>());
                    _activeBackgrounds.Add(newBackgroundIndex);
                }
                break;
            case CardinalDirections.RIGHT:
                newBackgroundIndex = new Vector2(lastBackgroundIndex.x + 1, lastBackgroundIndex.y);
                if (!_activeBackgrounds.Contains(new Vector2(lastBackgroundIndex.x + 1, lastBackgroundIndex.y)))
                {
                    if (_allBackgrounds.ContainsKey(newBackgroundIndex))
                    {
                        if (_allBackgrounds[newBackgroundIndex][0] < 2)
                            backgroundToLoad = Background1;
                        else
                            backgroundToLoad = Background2;

                        newBackground = (GameObject)Instantiate(backgroundToLoad, new Vector3(lastBackground.transform.position.x + (lastBackground.bounds.extents.x * 2), lastBackground.transform.position.y, 0), Quaternion.AngleAxis(_allBackgrounds[newBackgroundIndex][1], Vector3.forward));
                    }
                    else
                    {
                        newBackground = (GameObject)Instantiate(backgroundToLoad, new Vector3(lastBackground.transform.position.x + (lastBackground.bounds.extents.x * 2), lastBackground.transform.position.y, 0), Quaternion.AngleAxis(backgroundRotation, Vector3.forward));
                        _allBackgrounds.Add(newBackgroundIndex, new int[2] { backgroundType, backgroundRotation });
                    }
                    _allBackgroundSprites.Add(newBackground.GetComponent<SpriteRenderer>());
                    _activeBackgrounds.Add(newBackgroundIndex);
                }
                break;
            default:
                break;
        }
    }
 public void Interpret()
 {
     string currentToken = GetToken(currentX, currentY); //retrieves the current token
     if (currentToken == null) //does nothing if the token is null
         return;
     if ("0123456789".IndexOf(currentToken) != -1) { //pushes the integer representation of the token to the stack
         interpreter.Push(Int32.Parse(currentToken));
         return;
     }
     else if ("abcdef".IndexOf(currentToken) != -1) { //pushes the integer representation of the token to the stack
         interpreter.Push(10 + (int)(currentToken[0]) - 97);
         return;
     }
     switch (currentToken) { //performs the correct operation based on the current token
         case "+": //performs the addition operation of the interpreter
             interpreter.Add();
             break;
         case "-": //performs the subtraction operation of the interpreter
             interpreter.Subtract();
             break;
         case "*": //performs the multiplication operation of the interpreter
             interpreter.Multiply();
             break;
         case "/": //performs the division operation of the interpreter
             interpreter.Divide();
             break;
         case "%": //performs the modulus operation of the interpreter
             interpreter.Modulo();
             break;
         case "!": //performs the logical not operation of the interpreter
             interpreter.NOT();
             break;
         case "`": //performs the greater than operation of the interpreter
             interpreter.GreaterThan();
             break;
         case ">": //sets the current direction of the pointer to right
             currentDir = CardinalDirections.RIGHT;
             break;
         case "<": //sets the current direction of the pointer to left
             currentDir = CardinalDirections.LEFT;
             break;
         case "v": //sets the current direction of the pointer to down
             currentDir = CardinalDirections.DOWN;
             break;
         case "^": //sets the current direction of the pointer to up
             currentDir = CardinalDirections.UP;
             break;
         case "?": //sets the current direction of the pointer to a random direction
             int rand = (int)(rng.NextDouble() * 4);
             currentDir = (new CardinalDirections[] {CardinalDirections.RIGHT, CardinalDirections.DOWN,
             CardinalDirections.LEFT, CardinalDirections.UP})[rand];
             break;
         case "[": //sets the current direction of the pointer to one clockwise rotation of the current direction
             currentDir = NewDirection(-1);
             break;
         case "]": //sets the current direction of the pointer to one counter-clockwise rotation of the current direction
             currentDir = NewDirection(1);
             break;
         case "x": //moves the pointer to the location at <x, y> where x and y are popped from the stack
             int newY = interpreter.Pop();
             int newX = interpreter.Pop();
             SetCurrentX(newX);
             SetCurrentY(newY);
             currentDir = NewDirection(2);
             Advance();
             currentDir = NewDirection(2);
             break;
         case "_": //sets the current direction of the pointer to right if the top element of the stack is 0, left otherwise
             if (interpreter.Pop() == 0) {
                 currentDir = CardinalDirections.RIGHT;
             }
             else {
                 currentDir = CardinalDirections.LEFT;
             }
             break;
         case "|": //sets the current direction of the pointer to down if the top element of the stack is 0, up otherwise
             if (interpreter.Pop() == 0) {
                 currentDir = CardinalDirections.DOWN;
             }
             else {
                 currentDir = CardinalDirections.UP;
             }
             break;
         case "w": //performs a clockwise rotation of the pointer if the second element of the stack is larger than the first,
             //counter-clockwise if otherwise
             int b = interpreter.Pop();
             int a = interpreter.Pop();
             if (a < b) {
                 currentDir = NewDirection(-1);
             }
             else if (a > b) {
                 currentDir = NewDirection(1);
             }
             break;
         case @"""": //pushes the string in the playfield onto the stack
             InterpretString();
             break;
         case ":": //duplicates the value on the top of the stack
             interpreter.Duplicate();
             break;
         case @"\": //swaps the values on the top of the stack
             interpreter.Swap();
             break;
         case "$": //disposes of the top value of the stack
             interpreter.Pop();
             break;
         case "n": //clears the stack
             while (!interpreter.GetStack().IsEmpty()) {
                 interpreter.Pop();
             }
             break;
         case ".": //outputs the top element of the stack as an integer
             PushOutput(interpreter.Pop() + " ");
             break;
         case ",": //outputs the top element of the stack as an ASCII character
             PushOutput(((char)interpreter.Pop()).ToString());
             break;
         case "#": //skips the next character
             Jump(1);
             break;
         case "p": //puts a value in the playfield
             Put(interpreter.Pop(), interpreter.Pop(), interpreter.Pop());
             updateNeeded = true;
             break;
         case "g": //retrieves a value from the playfield
             interpreter.Push(Get(interpreter.Pop(), interpreter.Pop()));
             break;
         case "&": //pushes user input the the stack as an integer
             interpreter.Push(Int32.Parse(Prompt(false)));
             break;
         case "~": //pushes user input the the stack as an ASCII character
             interpreter.Push((int)(Prompt(true)[0]));
             break;
         case ";": //jumps over all tokens until the next semicolon
             JumpOver();
             break;
         case "j": //jumps i tokens, where i is the top element of the stack
             Jump(interpreter.Pop());
             break;
         case "k": // interprets the next token n times, where n is the top element of the stack
             int n = interpreter.Pop();
             Advance();
             for (int i = 0; i < n; i++) {
                 Interpret();
             }
             break;
         case "@": //stops the program
             running = false;
             break;
         default: //does nothing
             break;
     }
 }
Ejemplo n.º 42
0
    public void FakeUpdate()
    {
        if ( Input.GetKeyDown(KeyCode.UpArrow) ) {
            current = CardinalDirections.North;
        }

        if ( Input.GetKeyDown(KeyCode.DownArrow) ) {
            current = CardinalDirections.South;
        }

        if ( Input.GetKeyDown(KeyCode.RightArrow) ) {
            current = CardinalDirections.East;
        }

        if ( Input.GetKeyDown(KeyCode.LeftArrow) ) {
            current = CardinalDirections.West;
        }
    }
 private void Jump(int num)
 {
     if (num < 0) {
         currentDir = NewDirection(2);
     }
     for (int i = 0; i < num; i++) {
         Advance();
     }
     if (num < 0) {
         currentDir = NewDirection(2);
     }
 }