Ejemplo n.º 1
0
 static Vector2IntPathDir InquireAlreadyCheckItem(Vector2Int Vector2Int)
 {
     for (int i = 0; i < checker.Count; i++)
     {
         Vector2IntPathDir item = checker[i];
         if (gameModel.instance.Vector2IntEquality(Vector2Int, item.Vector2Int))
         {
             return(item);
         }
     }
     return(null);
 }
Ejemplo n.º 2
0
 static bool  InquireAlreadyCheck(Vector2Int Vector2Int)
 {
     for (int i = 0; i < checker.Count; i++)
     {
         Vector2IntPathDir item = checker[i];
         if (gameModel.instance.Vector2IntEquality(Vector2Int, item.Vector2Int))
         {
             return(true);
         }
     }
     return(false);
 }
Ejemplo n.º 3
0
    //將結果弄成單一路徑
    static List <Vector2Int> compositionRightPath(Vector2Int endPoint)
    {
        if (!isFindEnd)
        {
            return(new List <Vector2Int>());
        }

        Vector2IntPathDir start = checker[checker.Count - 1];

        //List<Vector2IntPathDir> thePathWithDir = new List<Vector2IntPathDir>();
        thePathWithDir.Clear();
        thePathWithDir.Add(start);

        Vector2Int nextPos = moveConverter(thePathWithDir[thePathWithDir.Count - 1].Vector2Int, reverser(thePathWithDir[thePathWithDir.Count - 1].direction));

        //Debug.Log((string)nextPos);

        while (nextPos != endPoint)
        {
            Vector2IntPathDir Vector2IntPathDir = InquireAlreadyCheckItem(nextPos);
            thePathWithDir.Add(Vector2IntPathDir);

            nextPos = moveConverter(thePathWithDir[thePathWithDir.Count - 1].Vector2Int, reverser(thePathWithDir[thePathWithDir.Count - 1].direction));
            //Debug.Log((string)nextPos + (string)endPoint);
        }

        List <Vector2Int> realPath = new List <Vector2Int>();

        for (int i = 0; i < thePathWithDir.Count; i++)
        {
            Vector2IntPathDir item = thePathWithDir[i];
            realPath.Add(item.Vector2Int);
        }
        realPath.Add(endPoint);

        realPath.Reverse();
        return(realPath);
    }
Ejemplo n.º 4
0
    static List <Vector2Int> DiffusionGetNeighbor(Vector2Int objectPos, Vector2Int bakeCenter, Vector2Int endPoint)
    {
        neighborArray.Clear();
        Vector2Int[] dirArray = new Vector2Int[4];
        dirArray[0] = objectPos;
        dirArray[1] = objectPos;
        dirArray[2] = objectPos;
        dirArray[3] = objectPos;

        dirArray[0].y += 1;   // in
        dirArray[1].y -= 1;   // out
        dirArray[2].x -= 1;   // left
        dirArray[3].x += 1;   // right

        for (int i = 0; i < dirArray.Length; i++)
        {
            Vector2IntPathDir item = new Vector2IntPathDir();
            //this
            Vector2Int Vector2Int = dirArray[i];


            if (gameModel.instance.Vector2IntEquality(Vector2Int, bakeCenter))
            {
                continue;
            }

            if (InquireAlreadyCheck(Vector2Int))
            {
                continue;
            }

            if (gameModel.instance.checkThisVectorIntIsWall(Vector2Int))
            {
                continue;
            }



            item.Vector2Int = Vector2Int;

            switch (i)
            {
            case 0:
                item.direction = Direction.Up;
                break;

            case 1:
                item.direction = Direction.Down;
                break;

            case 2:
                item.direction = Direction.Left;
                break;

            case 3:
                item.direction = Direction.Right;
                break;
            }

            checker.Add(item);

            neighborArray.Add(Vector2Int);

            if (gameModel.instance.Vector2IntEquality(Vector2Int, endPoint))
            {
                isFindEnd = true;
                break;
            }
        }
        return(neighborArray);
    }