Exemplo n.º 1
0
        void WalkFromPoint(Int2 point, int distance, int energy)
        {
            if (energy < 0)
            {
                return;
            }

            if (!Int2.InBox(contentSize - Int2.One, point))
            {
                return;
            }
            if (distance >= CollisionMap[point.x, point.y])
            {
                return;
            }
            CollisionMap[point.x, point.y] = distance;
            if (distance > maxDistance)
            {
                maxDistance = distance;
            }
            if (diagonalCollisions)
            {
                WalkFromPoint(point + Int2.Up + Int2.Right, distance + 1, energy - 1);
                WalkFromPoint(point + Int2.Down + Int2.Right, distance + 1, energy - 1);
                WalkFromPoint(point + Int2.Up + Int2.Left, distance + 1, energy - 1);
                WalkFromPoint(point + Int2.Down + Int2.Left, distance + 1, energy - 1);
            }
            WalkFromPoint(point + Int2.Up, distance + 1, energy - 1);
            WalkFromPoint(point + Int2.Right, distance + 1, energy - 1);
            WalkFromPoint(point + Int2.Down, distance + 1, energy - 1);
            WalkFromPoint(point + Int2.Left, distance + 1, energy - 1);

            return;
        }
Exemplo n.º 2
0
        public bool RotateShip()
        {
            if (!Int2.InBox(MyMap.ContentSize - Int2.One, leftUpCorner + (rightDownCorner - leftUpCorner).Flipped()))
            {
                return(false);
            }

            Int2[] prevPositions = new Int2[lenght - 1];
            for (int i = 0; i < Decks.Length; i++)
            {
                if (i > 0)
                {
                    prevPositions[i - 1] = new Int2(Decks[i].Position.x, Decks[i].Position.y);
                }
                Decks[i].Position = Decks[i].Position - leftUpCorner;
                Decks[i].Position.Flip();
                Decks[i].Position = Decks[i].Position + leftUpCorner;
                rightDownCorner   = Decks[lenght - 1].Position;
            }
            UpdateCollisionState();
            MyMap.UpdateTiles(prevPositions);
            return(true);
        }
Exemplo n.º 3
0
        public bool MoveBy(Int2 delta)
        {
            if (BoardState == OnBoardState.putDown)
            {
                return(false);
            }

            if (!Int2.InBox(MyMap.ContentSize - Int2.One, leftUpCorner + delta) || !Int2.InBox(MyMap.ContentSize - Int2.One, rightDownCorner + delta))
            {
                return(false);
            }
            Int2[] prevPositions = new Int2[lenght];
            for (int i = 0; i < lenght; i++)
            {
                prevPositions[i]   = new Int2(Decks[i].Position.x, Decks[i].Position.y);
                Decks[i].Position += delta;
            }
            leftUpCorner    += delta;
            rightDownCorner += delta;
            UpdateCollisionState();
            MyMap.UpdateTiles(prevPositions);
            return(true);
        }