Beispiel #1
0
 public static Vector2 GetPositionInLimit(Vector2 MIN, Vector2 MAX)
 {
     if (TileCurrent == null)
     {
         Debug.Log("Tile Current không tồn tại, trả về giá trị mặc định");
         return((MIN + MAX) / 2);
     }
     return(GetPositionInLimit(TileCurrent.WorldToCell(MIN), TileCurrent.WorldToCell(MAX), new Vector2(), false));
 }
Beispiel #2
0
 public static Vector2 GetPositionInLimit(Vector2 MIN, Vector2 MAX, Vector2 from, bool CanMoTo = true)
 {
     if (TileCurrent == null)
     {
         Debug.Log("Tile Current không tồn tại, trả về giá trị mặc định");
         return(from);
     }
     return(GetPositionInLimit(TileCurrent.WorldToCell(MIN), TileCurrent.WorldToCell(MAX), from, CanMoTo));
 }
Beispiel #3
0
    public static Vector2 GetPositionInGoundCurrent(Vector2Int halfsizeNear, Vector2 center, bool CanMoTo = true)
    {
        if (RoundBase.RoundCurrent == null)
        {
            Debug.Log("RoundCurrent Is Null");
            return(center);
        }
        if (TileCurrent == null)
        {
            Debug.Log("Tile Current không tồn tại, trả về giá trị mặc định");
            return(center);
        }
        Vector3Int centerCell = TileCurrent.WorldToCell(center);
        Vector3Int Min        = centerCell - new Vector3Int(halfsizeNear.x - 1, halfsizeNear.y - 1, 0);
        Vector3Int Max        = centerCell + new Vector3Int(halfsizeNear.x, halfsizeNear.y, 0);

        RoundEnemy.RoundCurrent.Data.GetCellLimit(out Vector2Int MIN, out Vector2Int MAX);
        MIN.x = Mathf.Max(MIN.x, Min.x);
        MIN.y = Mathf.Max(MIN.y, Min.y);
        MAX.x = Mathf.Min(Max.x, MAX.x);
        MAX.y = Mathf.Min(Max.y, MAX.y);
        Debug.Log(MIN + "&" + MAX);
        return(GetPositionInLimit(MIN, MAX, center, CanMoTo));
    }