Ejemplo n.º 1
0
    //SIGHT

    /*
     * dir must be a (1,0) (0,1) (-1,0) (0,-1)
     */
    public Vector2Int GetRandomAroundPos()
    {
        var gp      = GetGridPos();
        var size    = Pawn.DIR_ARRAY.Length;
        var rnd_idx = Random.Range(0, size);
        var rnd_pos = Pawn.DIR_ARRAY[rnd_idx];

        while (Board.GetGridType(rnd_pos) != 0)
        {
            rnd_idx--;
            if (rnd_idx < 0)
            {
                rnd_idx = Pawn.DIR_ARRAY.Length;
            }
            rnd_pos = Pawn.DIR_ARRAY[rnd_idx];
            size--;
            if (size < 0)
            {
                Debug.LogError("F**k! Infinite Loop!");
                break;
            }
        }
        return(rnd_pos);
    }