Example #1
0
 public void PrepareBoard()
 {
     Array.Clear(board, 0, board.Length);
     board[wolfPosition.GetX(), wolfPosition.GetY()] = WOLF;
     for (int i = 0; i < 5; i++)
     {
         board[sheepPositions[i].GetX(), sheepPositions[i].GetY()] = SHEEP;
     }
 }
Example #2
0
 public static bool isValid(Position position)
 {
     if (position.GetX() < 0 || position.GetX() > UpperRight.GetX() || position.GetY() < 0 || position.GetY() > UpperRight.GetY())
     {
         System.Console.WriteLine($"{position.GetX()},{position.GetY()}");
         System.Console.WriteLine($"{UpperRight.GetX()},{UpperRight.GetY()}");
         return(false);
     }
     return(true);
 }
Example #3
0
        public void TestPositionCreation()
        {
            Position thisPosition = new Position(6, 5);

            Assert.True(thisPosition.GetY() == 5);
            Assert.True(thisPosition.GetX() == 6);
            thisPosition.SetY(2);
            thisPosition.SetX(2);
            Assert.True(thisPosition.GetY() == 2);
            Assert.True(thisPosition.GetX() == 2);
        }
 private static void ChooseEnemyDirection(List <Position> path, Position currentPos, Position goalPos)
 {
     if (!path.Any())
     {
         List <Position> randomPositions = GetAdjacent(currentPos, true);
         if (randomPositions.Any())
         {
             int      index        = random.Next(randomPositions.Count);
             Position tempPosition = randomPositions[index];
             int      X            = tempPosition.GetX();
             int      Y            = tempPosition.GetY();
             ListDirectionSelector(X, Y, tempPosition);
         }
         else
         {
             //System.Diagnostics.Debug.WriteLine("no adjacents");
             CleanUpEnemy();
         }
     }
     else
     {
         Position goTo = Path[0];
         int      X    = goTo.GetX();
         int      Y    = goTo.GetY();
         ListDirectionSelector(X, Y, currentPos);
         path.RemoveAt(0);
     }
 }
Example #5
0
    public int Score()
    {
        if (wolfPosition.GetY() == 0)
        {
            return(0);
        }
        queue.Clear();
        queue.Enqueue(wolfPosition);
        while (queue.Count != 0)
        {
            Position currentPos = queue.Dequeue();
            for (int i = 0; i < 4; i++)
            {
                if (CanMove(0, currentPos + possibleWolfMoves[i]))
                {
                    Position newPos = currentPos + possibleWolfMoves[i];
                    board[newPos.GetX(), newPos.GetY()] = board[currentPos.GetX(), currentPos.GetY()] + 1;
                    queue.Enqueue(newPos);
                }
            }
        }
        int min = MAX;

        for (int i = 1; i <= 10; i += 2)
        {
            if ((board[i, 0] > MIN) && (board[i, 0] < min))
            {
                min = board[i, 0];
            }
        }
        return(min - 1);
    }
Example #6
0
 public static Position RandomPositionInRange(Position minPosition, Position maxPosition)
 {
     return new Position(Random.Range(minPosition.GetX(),
                                      maxPosition.GetX() + 1),
                         Random.Range(minPosition.GetY(),
                  maxPosition.GetY() + 1));
 }
Example #7
0
 public void SetMazePosition(Position mazePosition)
 {
     MazePosition = mazePosition;
     GetComponent<MazePieceController>().SetPosition(
         mazePosition.GetX(),
         mazePosition.GetY());
 }
Example #8
0
    public bool CanMove(Position start, Position end)
    {
        if (start == null)
        {
            return(false);
        }
        int sX = start.GetX();
        int sY = start.GetY();
        int eX = end.GetX();
        int eY = end.GetY();

        if (!end.IsOccupied())
        {
            if (start.GetOccupied() == "W" || start.GetOccupied() == "S")
            {
                // Up-Left
                if (sX != 0 && sY != 9)
                {
                    if (eX == sX - 1 && eY == sY + 1)
                    {
                        return(true);
                    }
                }

                // Up-Right
                if (sX != 9 && sY != 9)
                {
                    if (eX == sX + 1 && eY == sY + 1)
                    {
                        return(true);
                    }
                }
            }
            if (start.GetOccupied() == "W")
            {
                // Down-Left
                if (sX != 0 && sY != 0)
                {
                    if (eX == sX - 1 && eY == sY - 1)
                    {
                        return(true);
                    }
                }

                // Down-Right
                if (sX != 9 && sY != 0)
                {
                    if (eX == sX + 1 && eY == sY - 1)
                    {
                        return(true);
                    }
                }
            }
        }
        return(false);
    }
Example #9
0
 public bool equalsTo(Position p)
 {
     if (this.x == p.GetX() && this.y == p.GetY())
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }
Example #10
0
        private double CalculateDegreeByPos(Position position)
        {
            Position centerPoint = GetCenter();
            double   degree      = Math.Atan2(position.GetY() - centerPoint.GetY(), position.GetX() - centerPoint.GetX());

            if (degree < 0)
            {
                degree += _doubledPI;
            }
            return(degree);
        }
Example #11
0
    public void shoot(string id, Position target)
    {
        Single  tX        = CoordinatsUtil.parseCoordinations(target.GetX());
        Single  tY        = CoordinatsUtil.parseCoordinations(target.GetY());
        Single  tZ        = CoordinatsUtil.parseCoordinations(target.GetZ());
        Vector3 targetPos = new Vector3(tX, tY, tZ);

        GameObject            client   = clients[id];
        AnotherPlayerShooting shooting = client.GetComponent <AnotherPlayerShooting>();

        shooting.shoot(targetPos);
    }
Example #12
0
        public string Explore(string commands)
        {
            System.Console.WriteLine("Exploring...");
            foreach (var command in commands)
            {
                switch (command)
                {
                case 'L':
                    _orientation = RotateLeft(_orientation);
                    break;

                case 'R':
                    _orientation = RotateRight(_orientation);
                    break;

                case 'M':
                    Move(command);
                    break;
                }
                System.Console.WriteLine($"{_currentPosition.GetX()} {_currentPosition.GetY()} {_orientation}");
            }
            return($"{_currentPosition.GetX()} {_currentPosition.GetY()} {_orientation}");
        }
Example #13
0
    public void MoveEntity(Entity entity, Position targetPosition)
    {
        int x = targetPosition.GetX();
        int y = targetPosition.GetY();

        if (grid[x, y] != null)
        {
            throw new System.Exception();
        }
        grid[x, y] = entity;
        x          = entity.Position.GetX();
        y          = entity.Position.GetY();
        grid[x, y] = null;
    }
Example #14
0
        /// <summary>
        ///     Calls a drag event
        /// </summary>
        /// <param name="driver">The WebDriver to execute on</param>
        /// <param name="dragFrom">The WebElement to simulate on</param>
        /// <param name="eventName">The event name to call</param>
        /// <param name="mousePosition">The mouse click area in the element</param>
        /// <param name="data">The data transfer data</param>
        /// <returns>The updated data transfer data</returns>
        private static object Html5SimulateEvent(
            IWebDriver driver,
            IWebElement dragFrom,
            string eventName,
            Position mousePosition,
            object data)
        {
            var fromLocation = dragFrom.Location;
            var fromSize     = dragFrom.Size;
            var clientX      = fromLocation.X + mousePosition.GetX(fromSize.Width);
            var clientY      = fromLocation.Y + mousePosition.GetY(fromSize.Height);

            return(Html5SimulateEvent(driver, dragFrom, eventName, clientX, clientY, data));
        }
Example #15
0
    public void PlaceEntity(Entity entity, Position targetPosition)
    {
        int x = targetPosition.GetX();
        int y = targetPosition.GetY();

        if (grid[x, y] == null)
        {
            entity.Position = targetPosition;
            grid[x, y]      = entity;
        }
        else
        {
            throw new System.Exception();
        }
    }
Example #16
0
        private void RearrangeContacts()
        {
            Position centerPoint = GetCenter();

            _alpha += _degreeDiff;

            foreach (var item in _contacts)
            {
                int x = (int)(Radius * Math.Cos(_alpha)) + centerPoint.GetX() - ItemRadius;
                int y = (int)(Radius * Math.Sin(_alpha)) + centerPoint.GetY() - ItemRadius;
                item.SetPosition(x, y);
                item.SetConfines();
                _alpha += _alphaStep;
            }
        }
 private static void ListDirectionSelector(int X, int Y, Position position)
 {
     if (X > position.GetX())
     {
         enemyDirection = Direction.East;
         position.Left++;
     }
     else if (X < position.GetX())
     {
         enemyDirection = Direction.West;
         position.Left--;
     }
     else if (Y > position.GetY())
     {
         enemyDirection = Direction.South;
         position.Top++;
     }
     else if (Y < position.GetY())
     {
         enemyDirection = Direction.North;
         position.Top--;
     }
     enemyPoints.Add(position);
 }
Example #18
0
    public List <Vector3> GetPath(Vector2 start_, Vector2 goal_)
    {
        pathPlanner.PathplannerParameter param = new pathPlanner.PathplannerParameter();
        param.startNode = pathplannerMap.GetNodeByIndex((int)start_.x, (int)start_.y);
        param.goalNode  = pathplannerMap.GetNodeByIndex((int)goal_.x, (int)goal_.y);

        Array <object> nodes = pathfinder.FindPath(param);
        List <Vector3> path  = new List <Vector3>();

        for (int i = 0; i < nodes.length; ++i)
        {
            Position pos = ((Node)nodes[i]).GetPosition();
            path.Add(new Vector3(pos.GetX(), 0, pos.GetY()));// y has no effect
        }

        return(path);
    }
Example #19
0
    public static Vector3[] WorldPathFromPosition(Position startPosition, Position endPosition, Maze maze)
    {
        setGoalPosition(endPosition);
        int w = maze.Width();
        int h = maze.Height();
        bool[][] path = Util.InitializeMatrixAsJaggedArray(new bool[w][], w, h);
        bool[][] visited = Util.InitializeMatrixAsJaggedArray(new bool[w][], w, h);
        if (arraySearch(ref path,
                    ref visited,
                    startPosition.GetX(),
                    startPosition.GetY())) {
            return MazePieceController.GetWorldPath(MazePiecesFromPositions(
                pathFromSpaces(path, startPosition, new List<Position>()).ToArray(),
                MazeController.Instance.GetMazePieceControllers()));

        } else {
            return null;
        }
    }
            public override bool Equals(object o)
            {
                if (this == o)
                {
                    return(true);
                }
                if (o == null || GetType() != o.GetType())
                {
                    return(false);
                }

                Position that = (Position)o;

                if (GetX() != that.GetX())
                {
                    return(false);
                }
                return(GetY() == that.GetY());
            }
Example #21
0
        /// <summary>
        ///     Drags and drops a web element from source to target
        /// </summary>
        /// <param name="driver">The WebDriver to execute on</param>
        /// <param name="dragFrom">The WebElement to drag from</param>
        /// <param name="dragTo">The WebElement to drag to</param>
        /// <param name="dragFromPosition">The place to click on the dragFrom</param>
        /// <param name="dragToPosition">The place to release on the dragTo</param>
        public static void Html5DragAndDrop(
            IWebDriver driver,
            IWebElement dragFrom,
            IWebElement dragTo,
            Position dragFromPosition,
            Position dragToPosition)
        {
            var fromLocation = dragFrom.Location;
            var toLocation   = dragTo.Location;
            var fromSize     = dragFrom.Size;
            var toSize       = dragTo.Size;

            // Get Client X and Client Y locations
            var dragFromX = fromLocation.X + dragFromPosition.GetX(fromSize.Width);
            var dragFromY = fromLocation.Y + dragFromPosition.GetY(fromSize.Height);
            var dragToX   = toLocation.X + dragToPosition.GetX(toSize.Width);
            var dragToY   = toLocation.Y + dragToPosition.GetY(toSize.Height);

            Html5DragAndDrop(driver, dragFrom, dragTo, dragFromX, dragFromY, dragToX, dragToY);
        }
Example #22
0
    private static List<Position> pathFromSpaces(bool[][] pathSpaces, 
	                                              Position currentPosition, 
	                                              List<Position> path)
    {
        if (path.Count != 0 && path.Contains(goalPosition))
            return path;

        int x = currentPosition.GetX ();
        int y = currentPosition.GetY ();

        Position newPosition;
        if (inBounds(x, y+1) &&
            pathSpaces[x][y+1] &&
            !path.Contains(newPosition = new Position(x, y+1))) {

            path.Add(newPosition);
            path = pathFromSpaces(pathSpaces, x, y+1, path);

        } else if (inBounds(x+1, y) &&
                   pathSpaces[x+1][y] &&
                   !path.Contains(newPosition = new Position(x+1, y))) {

            path.Add(newPosition);
            path = pathFromSpaces(pathSpaces, x+1, y, path);

        }  else if (inBounds(x, y-1) &&
                    pathSpaces[x][y-1] &&
                    !path.Contains(newPosition = new Position(x, y-1))) {

            path.Add(newPosition);
            path = pathFromSpaces(pathSpaces, x, y-1, path);

        }  else if (inBounds(x-1, y) &&
                    pathSpaces[x-1][y] &&
                    !path.Contains(newPosition = new Position(x-1, y))) {

            path.Add (newPosition);
            path = pathFromSpaces(pathSpaces, x-1, y, path);

        }
        return path;
    }
Example #23
0
 private static bool inBounds(Position position)
 {
     Maze maze = MazeController.Instance.GetCurrentMaze();
     int x = position.GetX();
     int y = position.GetY();
     return (x >= 0 &&
             x < maze.Width() &&
             y >= 0 &&
             y < maze.Height() &&
             !isWall(maze.GetPieces()[x][y]));
 }
Example #24
0
 public float Distance(Position position)
 {
     return Mathf.Sqrt(
         Mathf.Pow(x - position.GetX(), 2) +
         Mathf.Pow(y - position.GetY(), 2));
 }
Example #25
0
File: Maze.cs Project: imann24/VR
 public bool WithinMazeOuterBounds(Position position)
 {
     return Util.WithinRange(position.GetX(), Width()) &&
         Util.WithinRange(position.GetY(), Height());
 }
Example #26
0
 bool CanMove(int index, Position p)
 {
     return(CanMove(index, p.GetX(), p.GetY()));
 }
Example #27
0
    public int CalculateBestMove(string player, int recLevel, int AILevel, int alpha, int beta)
    {
        if (recLevel == 0)
        {
            PrepareBoard();
        }
        int test = NULL;

        if (recLevel >= AILevel * 2)
        {
            int score = Score();
            PrepareBoard();
            return(score);
        }
        int  bestMove = NULL;
        bool isSheep  = player == "Sheep";
        int  minimax  = isSheep ? MIN : MAX;

        for (int i = 0; i < (isSheep ? 10 : 4); i++)
        {
            int      currentPiece = isSheep ? i / 2 + 1 : 0;
            Position currentPos   = currentPiece == 0 ? wolfPosition : sheepPositions[currentPiece - 1];
            Position currentMove  = isSheep ? possibleSheepMoves[i % 2] : possibleWolfMoves[i];
            if (CanMove((isSheep ? currentPiece - 1 : currentPiece), currentPos + currentMove))
            {
                TempMove(currentPiece, currentMove.GetX(), currentMove.GetY());
                test = CalculateBestMove(isSheep ? "Wolf" : "Sheep", recLevel + 1, AILevel, alpha, beta);
                TempMove(currentPiece, -currentMove.GetX(), -currentMove.GetY());
                if ((test > minimax && isSheep) || (test <= minimax && !isSheep) || (bestMove == NULL))
                {
                    minimax  = test;
                    bestMove = i;
                }

                if (isSheep)
                {
                    alpha = Math.Max(alpha, test);
                }
                else
                {
                    beta = Math.Min(beta, test);
                }
                if (alpha > beta)
                {
                    break;
                }
            }
        }
        if (bestMove == NULL)
        {
            int score = Score();
            PrepareBoard();
            return(score);
        }

        if (recLevel == 0 && bestMove != NULL)
        {
            Piece        wolf  = Main.Instance.GetWolf();
            List <Piece> sheep = Main.Instance.GetSheep();
            if (player == "Sheep")
            {
                Position s = sheepPositions[bestMove / 2] + possibleSheepMoves[bestMove % 2];
                Main.Instance.AutoMovePiece(sheep[bestMove / 2], (bestMove / 2), s.GetX(), s.GetY());
            }
            else
            {
                Position w = new Position(wolfPosition + possibleWolfMoves[bestMove]);
                Main.Instance.AutoMovePiece(wolf, 0, w.GetX(), w.GetY());
            }
        }
        return(minimax);
    }
Example #28
0
File: Maze.cs Project: imann24/VR
 public MazePiece MazePieceFromPosition(Position position)
 {
     return pieces[position.GetX()][position.GetY()];
 }
Example #29
0
File: Maze.cs Project: imann24/VR
 // Overloaded method for the position
 public void ModifyPiece(Position position, MazePiece newType)
 {
     ModifyPiece(position.GetX(),
                 position.GetY(),
                 newType);
 }
Example #30
0
    private void CompleteMove()
    {
        Position temp1 = LocalMessage.MonsterRoute[currentIndex];

        if (temp1.GetLine() == LocalMessage.EndGrid.line && temp1.GetColumn() == LocalMessage.EndGrid.column)
        {
            ArriveEndPoint();
            return;
        }
        Position temp2 = LocalMessage.MonsterRoute[++currentIndex];

        transform.localEulerAngles = DIRECTION[temp1.GetDirection()];
        iTween.moveTo(gameObject, Vector3.Distance(temp1.GetPixel(), temp2.GetPixel()) / MoveSpeed, 0, temp2.GetX(), temp2.GetY(), -8.5f, iTween.EasingType.linear, "CompleteMove", null);
    }
Example #31
0
    //MonsterProperties.cs调用
    public void SetMoveSpeed(float speed)
    {
        MoveSpeed = speed;
        Position temp1 = new Position();

        if (StartMove)
        {
            temp1.SetPixelPosition(UIFunction.GetPixelPosition(LocalMessage.StartGrid));
            StartMove = false;
        }
        else
        {
            temp1.SetPixelPosition(transform.localPosition);
        }
        Position temp2 = LocalMessage.MonsterRoute[currentIndex];

        iTween.moveTo(gameObject, Vector3.Distance(temp1.GetPixel(), temp2.GetPixel()) / MoveSpeed, 0, temp2.GetX(), temp2.GetY(), -8.5f, iTween.EasingType.linear, "CompleteMove", null);
    }
 public void SetH(Position goal)
 {
     this.H = Math.Abs(GetX() - goal.GetX()) + Math.Abs(GetY() - goal.GetY());
 }
        private static List <Position> GetAdjacent(Position node, bool isRandom)
        {
            int X = node.GetX();
            int Y = node.GetY();

            List <Position> adj   = new List <Position>();
            Position        temp1 = new Position()
            {
                Left = X - 1,
                Top  = Y
            };
            Position temp2 = new Position()
            {
                Left = X + 1,
                Top  = Y
            };
            Position temp3 = new Position()
            {
                Left = X,
                Top  = Y - 1
            };
            Position temp4 = new Position()
            {
                Left = X,
                Top  = Y + 1
            };

            if (!isRandom)
            {
                if (IsWalkable(temp1) && !closedList.Contains(temp1))
                {
                    adj.Add(temp1);
                }
                if (IsWalkable(temp2) && !closedList.Contains(temp2))
                {
                    adj.Add(temp2);
                }
                if (IsWalkable(temp3) && !closedList.Contains(temp3))
                {
                    adj.Add(temp3);
                }
                if (IsWalkable(temp4) && !closedList.Contains(temp4))
                {
                    adj.Add(temp4);
                }
            }
            else
            {
                if (IsWalkable(temp1))
                {
                    adj.Add(temp1);
                }
                if (IsWalkable(temp2))
                {
                    adj.Add(temp2);
                }
                if (IsWalkable(temp3))
                {
                    adj.Add(temp3);
                }
                if (IsWalkable(temp4))
                {
                    adj.Add(temp4);
                }
            }

            return(adj);
        }
Example #34
0
 public static Vector3 PositionFromIndex(Position position, float height = defaultHeight, float anchorOffset = 0)
 {
     return PositionFromIndex (position.GetX(), position.GetY(), height, anchorOffset);
 }
Example #35
0
        public Bitmap PaintGraph()
        {
            int    _imageSizeX = imageSizeX;
            int    _imageSizeY = imageSizeY;
            double multiplierX = 1;
            double multiplierY = 1;

            if (multiplier != null)
            {
                multiplierX = multiplier.GetValueOrDefault().Width;
                multiplierY = multiplier.GetValueOrDefault().Height;
                _imageSizeX = (int)(imageSizeX * multiplierX);
                _imageSizeY = (int)(imageSizeY * multiplierY);
            }

            Bitmap bm = new Bitmap(imageSizeX, imageSizeY);

            using (Graphics gfx = Graphics.FromImage(bm))
                using (SolidBrush brush = new SolidBrush(bgColor))
                {
                    gfx.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
                    gfx.FillRectangle(brush, 0, 0, imageSizeX, imageSizeY);

                    // Find max and min values  in a graph
                    double defaultValueX = graphPointArray[0].GetPoints()[0].GetX();
                    double defaultValueY = graphPointArray[0].GetPoints()[0].GetY();

                    double minX = defaultValueX;
                    double minY = defaultValueY;

                    double initialMax = defaultValueX;
                    foreach (GraphPointArray gpa in graphPointArray)
                    {
                        foreach (Position p in gpa.GetPoints())
                        {
                            if (p.GetX() < minX)
                            {
                                minX = p.GetX();
                            }
                            if (p.GetY() < minY)
                            {
                                minY = p.GetY();
                            }

                            if (p.GetX() > initialMax)
                            {
                                initialMax = p.GetX();
                            }
                            if (p.GetY() > initialMax)
                            {
                                initialMax = p.GetY();
                            }
                        }
                    }

                    Console.WriteLine("minX = " + minX);
                    Console.WriteLine("minY = " + minY);

                    // If minX or minY value is less than zero: increase everything by min*(-1)
                    if (minX < 0)
                    {
                        foreach (GraphPointArray gpa in graphPointArray)
                        {
                            for (int pointIndex = 0; pointIndex < gpa.GetPoints().Count; pointIndex++)
                            {
                                Position p    = gpa.GetPoints()[pointIndex];
                                Position newP = new Position(p.GetX() + (-1 * minX), p.GetY());
                                gpa.GetPoints()[pointIndex] = newP;
                            }
                        }
                    }
                    if (minY < 0)
                    {
                        foreach (GraphPointArray gpa in graphPointArray)
                        {
                            for (int pointIndex = 0; pointIndex < gpa.GetPoints().Count; pointIndex++)
                            {
                                Position p    = gpa.GetPoints()[pointIndex];
                                Position newP = new Position(p.GetX(), p.GetY() + (-1 * minY));
                                gpa.GetPoints()[pointIndex] = newP;
                            }
                        }
                    }


                    double max = graphPointArray[0].GetPoints()[0].GetX();
                    double min = graphPointArray[0].GetPoints()[0].GetX();
                    foreach (GraphPointArray gpa in graphPointArray)
                    {
                        foreach (Position p in gpa.GetPoints())
                        {
                            if (p.GetX() > max)
                            {
                                max = p.GetX();
                            }
                            if (p.GetY() > max)
                            {
                                max = p.GetY();
                            }

                            if (p.GetX() < min)
                            {
                                min = p.GetX();
                            }
                            if (p.GetY() < min)
                            {
                                min = p.GetY();
                            }
                        }
                    }
                    Console.WriteLine("max = " + max);
                    Console.WriteLine("min = " + min);


                    Position previousPoint = null;
                    foreach (GraphPointArray gpa in graphPointArray)
                    {
                        Color color = gpa.GetColor();
                        Pen   pen   = new Pen(color);
                        pen.Width = circleSize;
                        foreach (Position p in gpa.GetPoints())
                        {
                            double _minX = 0;
                            double _minY = 0;
                            if (minX > 0)
                            {
                                _minX = minX;
                            }
                            if (minX < 0)
                            {
                                _minX = -minX;
                            }

                            if (minY > 0)
                            {
                                _minY = minY;
                            }
                            if (minY < 0)
                            {
                                _minY = -minY;
                            }
                            double _x = ((p.GetX() - _minX) / (max - _minX));
                            double _y = ((p.GetY()) / (max));
                            int    x  = (int)(_x * _imageSizeX);
                            int    y  = (int)(imageSizeY - (_y * _imageSizeY));

                            Console.WriteLine("p.GetX() = " + p.GetX());
                            Console.WriteLine("p.GetY() = " + p.GetY());
                            Console.WriteLine("max = " + max);
                            Console.WriteLine("_x = " + _x);
                            Console.WriteLine("_y = " + _y);
                            Console.WriteLine("x = " + x);
                            Console.WriteLine("y = " + y);
                            Console.WriteLine();
                            gfx.DrawEllipse(pen,
                                            new Rectangle(
                                                x - circleSize / 2,
                                                y - circleSize / 2,
                                                circleSize,
                                                circleSize)
                                            );


                            if (previousPoint != null)
                            {
                                if (drawLine)
                                {
                                    Pen pen1 = new Pen(color);
                                    pen1.Width = 2;
                                    gfx.DrawLine(pen1,
                                                 new Point(x, y),
                                                 new Point((int)previousPoint.GetX(), (int)previousPoint.GetY())
                                                 );
                                }
                            }


                            previousPoint = new Position(x, y);
                        }

                        previousPoint = null;
                    }

                    Font arialFont = new Font("Arial", 10);
                    gfx.DrawString("(y = " + (initialMax / multiplierY) + ")", arialFont, Brushes.White, new PointF(10f, 10f));
                    gfx.DrawString("(x = " + minX + ", y = " + minY + ")", arialFont, Brushes.White, new PointF(10f, imageSizeY - 20f));
                    gfx.DrawString("(x = " + (initialMax / multiplierX) + ")", arialFont, Brushes.White, new PointF(imageSizeY - 80f, imageSizeY - 20f));


                    Font         hugeArialFont = new Font("Arial", 14);
                    StringFormat nameFormat    = new StringFormat();
                    nameFormat.LineAlignment = StringAlignment.Center;
                    nameFormat.Alignment     = StringAlignment.Center;
                    gfx.DrawString(name, hugeArialFont, Brushes.White, new PointF(imageSizeX / 2, imageSizeY / 2), nameFormat);


                    Pen penBorders = new Pen(Color.White);
                    gfx.DrawLine(penBorders,
                                 new Point(0, 0),
                                 new Point(0, imageSizeY - 1)
                                 );
                    gfx.DrawLine(penBorders,
                                 new Point(0, 0),
                                 new Point(imageSizeX - 1, 0)
                                 );
                    gfx.DrawLine(penBorders,
                                 new Point(0, imageSizeY - 1),
                                 new Point(imageSizeX - 1, imageSizeY - 1)
                                 );
                    gfx.DrawLine(penBorders,
                                 new Point(imageSizeX - 1, 0),
                                 new Point(imageSizeX - 1, imageSizeY - 1)
                                 );

                    renderedImage = bm;
                }

            return(bm);
        }
Example #36
0
 public MazePieceController MazePieceControllerFromPosition(Position position)
 {
     return currentMazePieceControllers[position.GetX()][position.GetY()];
 }
Example #37
0
 public Position(Position p)
 {
     this.x   = p.GetX();
     this.y   = p.GetY();
     occupied = "N";
 }
Example #38
0
 public Absorber(Position p)
 {
     SetType(TypeGizmo.ABSORBER);
     SetPos(p.GetX(), 0);    // Absorber的pos是算在最左邊的
 }
Example #39
0
 public static int Area(Position position1, Position position2)
 {
     return Mathf.Abs(position1.GetX() - position2.GetX()) *
         Mathf.Abs(position1.GetY() - position2.GetY());
 }