Exemplo n.º 1
0
Arquivo: Player.cs Projeto: MrEk0/Room
    private List <Vector2> FormListOfCrossedPoints(Vector2 playerPos, PathDirections pathDirections)
    {
        List <Vector2> crossedPoints       = new List <Vector2>();
        List <int>     crossedPointIndexes = new List <int>();

        for (int i = 0; i < colliderPaths.Count; i++)
        {
            Vector2[] path = colliderPaths[i];

            for (int j = 0; j < path.Length; j++)
            {
                int  k         = j == path.Length - 1 ? 0 : j + 1;
                bool isCrossed = isLinesIntersected(playerPos, mousePos, path[j], path[k]);

                if (pathDirections == PathDirections.RightAngled && isCrossed)
                {
                    CheckRightAngledCrossing(playerPos, crossedPointIndexes, path, j, k);
                }
                if (pathDirections == PathDirections.LeftAngled && isCrossed)
                {
                    CheckLeftAngledCrossing(playerPos, crossedPointIndexes, path, j, k);
                }
            }
            crossedPoints = GetReformedPointsList(crossedPoints, crossedPointIndexes, path);
        }

        return(crossedPoints);
    }
Exemplo n.º 2
0
        public PathOrientation(JToken json)
        {
            var pointOffset   = (int)json[JsonNames.PointOffset];
            var pathDirection = (PathDirections)Enum.Parse(typeof(PathDirections), (string)json[JsonNames.PathDirection]);

            m_pointOffset   = pointOffset;
            m_pathDirection = pathDirection;
        }
Exemplo n.º 3
0
 public void Flip()
 {
     if (PathDirection == PathDirections.Clockwise)
     {
         PathDirection = PathDirections.Counterclockwise;
     }
     else
     {
         PathDirection = PathDirections.Clockwise;
     }
 }
Exemplo n.º 4
0
Arquivo: Player.cs Projeto: MrEk0/Room
    private void CheckDistanceToTarget(List <Vector2> path)
    {
        if (path.Count < 2)
        {
            return;
        }

        Vector2 lastPoint             = path[path.Count - 1];
        Vector2 preLastPoint          = path[path.Count - 2];
        float   distanceFromPrevPoint = Vector2.Distance(preLastPoint, mousePos);
        float   distanceFromLastPoint = Vector2.Distance(lastPoint, mousePos) + Vector2.Distance(preLastPoint, lastPoint);

        PathDirections pathDirection = DefineDirections(preLastPoint);
        List <Vector2> crossedPoints = FormListOfCrossedPoints(preLastPoint, pathDirection);

        ChechIfPointLinesCrossed(lastPoint, preLastPoint, distanceFromPrevPoint, distanceFromLastPoint, crossedPoints);
    }
Exemplo n.º 5
0
Arquivo: Player.cs Projeto: MrEk0/Room
    private PathDirections DefineDirections(Vector2 playerPos)
    {
        PathDirections pathDirection = PathDirections.LeftAngled;

        if (playerPos.x >= mousePos.x && playerPos.y > mousePos.y ||
            playerPos.x <= mousePos.x && playerPos.y < mousePos.y)
        {
            pathDirection = PathDirections.RightAngled;
        }
        else if (playerPos.x < mousePos.x && playerPos.y >= mousePos.y ||
                 playerPos.x > mousePos.x && playerPos.y <= mousePos.y)
        {
            pathDirection = PathDirections.LeftAngled;
        }

        return(pathDirection);
    }
Exemplo n.º 6
0
Arquivo: Player.cs Projeto: MrEk0/Room
    private void CreatePlayerPath(Vector2 playerPos)
    {
        mousePos = GetRightMousePosition();

        PathDirections pathDirection = DefineDirections(playerPos);
        List <Vector2> crossedPoints = FormListOfCrossedPoints(playerPos, pathDirection);

        if (crossedPoints.Count == 0)
        {
            target = mousePos;
        }
        else
        {
            FormFinalPath(playerPos, crossedPoints);
            animator.SetBool(PATH, true);
            isPathCreated = true;
        }
    }
Exemplo n.º 7
0
 public void AddPath(List <Direction> path)
 {
     PathDirections.Add(path);
 }
Exemplo n.º 8
0
 public PathOrientation(int pointOffset, PathDirections pathDirection)
 {
     m_pointOffset   = pointOffset;
     m_pathDirection = pathDirection;
 }