Ejemplo n.º 1
0
    public static Vector2 GetSlopeDirection(Vector2 direction)
    {
        TileSystem tileSystem   = TileSystem.Instance;
        Vector2    newDirection = direction;

        if (direction.y == -1 && (direction.x == 1 || direction.x == -1))
        {
            //SOUTH_EAST, SOUTH_WEST
            newDirection.y = -tileSystem.GetSlope();
        }
        else if (direction.y == 1 && (direction.x == 1 || direction.x == -1))
        {
            //NORTH_EAST, NORTH_WEST
            newDirection.y = tileSystem.GetSlope();
        }
        return(newDirection);
    }
Ejemplo n.º 2
0
    void PCMove(out Vector2 newPosition, out Vector2Int lookDirection)
    {
        TileSystem tileSystem = TileSystem.Instance;

        //Vector2Int lookDirection = new Vector2Int();
        //Vector2 newPosition = Vector2.zero

        lookDirection = Vector2Int.zero;
        newPosition   = Vector2.zero;

        if (Input.GetKey(KeyCode.UpArrow))
        {
            if (Input.GetKey(KeyCode.RightArrow))
            {
                newPosition   += new Vector2(1.0f, tileSystem.GetSlope());
                lookDirection += new Vector2Int(1, 1);
            }
            else if (Input.GetKey(KeyCode.LeftArrow))
            {
                newPosition   += new Vector2(-1.0f, tileSystem.GetSlope());
                lookDirection += new Vector2Int(-1, 1);
            }
            //else
            //{
            //	newPosition += new Vector2(0.0f, 1.0f);
            //	lookDirection += new Vector2Int(0, 1);
            //}
        }
        if (Input.GetKey(KeyCode.DownArrow))
        {
            if (Input.GetKey(KeyCode.RightArrow))
            {
                newPosition   += new Vector2(1.0f, -tileSystem.GetSlope());
                lookDirection += new Vector2Int(1, -1);
            }
            else if (Input.GetKey(KeyCode.LeftArrow))
            {
                newPosition   += new Vector2(-1.0f, -tileSystem.GetSlope());
                lookDirection += new Vector2Int(-1, -1);
            }
            //else
            //{
            //	newPosition += new Vector2(0.0f, -1.0f);
            //	lookDirection += new Vector2Int(0, -1);
            //}
        }

        //if (Input.GetKey(KeyCode.LeftArrow))
        //{
        //	if (!Input.GetKey(KeyCode.UpArrow) && !Input.GetKey(KeyCode.DownArrow))
        //	{
        //		newPosition += new Vector2(-1.0f, 0.0f);
        //		lookDirection += new Vector2Int(-1, 0);
        //	}
        //}
        //else if (Input.GetKey(KeyCode.RightArrow))
        //{
        //	if (!Input.GetKey(KeyCode.UpArrow) && !Input.GetKey(KeyCode.DownArrow))
        //	{
        //		newPosition += new Vector2(1.0f, 0.0f);
        //		lookDirection += new Vector2Int(1, 0);
        //	}
        //}
    }