Пример #1
0
    // Use this for initialization
    void Start()
    {
        X = new IntegerArray[SizeX];
        for (int i = 0; i < SizeX; i++)
        {
            X[i]   = new IntegerArray();
            X[i].Z = new int[SizeZ];
            for (int j = 0; j < SizeZ; j++)
            {
                X[i][j] = 5;
            }
        }
        BuildOuterWall();
        CarveRooms();
        ArrangeGrid();

        FloorBuilder fb = gameObject.AddComponent <FloorBuilder>();

        int[,] grid = new int[SizeX, SizeZ];
        for (int i = 0; i < SizeX; i++)
        {
            for (int j = 0; j < SizeZ; j++)
            {
                grid[i, j] = X[i][j];
                // Debug.Log(i + ", " + j); // This checks out fine
            }
        }
        fb.BuildFloor(grid, parent);
    }
Пример #2
0
        public IActionResult Post([FromBody] IntegerArray data)
        {
            _integerArrayService.TryOrderIntegerArray(data.Value, out int[] orderedData);

            _jsonFileHandlerService.TryWriteToFile(orderedData);

            return(Ok(orderedData));
        }
Пример #3
0
 public void AddSubElement(IStringifiable subElement)
 {
     if (subElement is IntegerArray)
     {
         IntegerArray a = (IntegerArray)subElement;
         if (a.Name.Equals("A"))
         {
             this.DataIntA = a.Data;
         }
         else if (a.Name.Equals("B"))
         {
             this.DataIntB = a.Data;
         }
         else if (a.Name.Equals("C"))
         {
             this.DataIntC = a.Data;
         }
     }
     else if (subElement is DoubleArray)
     {
         DoubleArray a = (DoubleArray)subElement;
         if (a.Name.Equals("A"))
         {
             this.DataA = a.Data;
         }
         else if (a.Name.Equals("B"))
         {
             this.DataB = a.Data;
         }
         else if (a.Name.Equals("C"))
         {
             this.DataC = a.Data;
         }
     }
     else if (subElement is ObjectString)
     {
         if (this.DataObjectList == null)
         {
             this.DataObjectList = new List <object>();
         }
         ObjectString obj = (ObjectString)subElement;
         Type         type;
         if (Stringifiable.TryGetType(obj.ClassName, out type))
         {
             object o = UV.Lib.Utilities.ConvertType.ChangeType(type, obj.Data);
             this.DataObjectList.Add(o);
         }
     }
     else if (subElement is IStringifiable)      // todo storage of values
     {
         if (this.DataObjectList == null)
         {
             this.DataObjectList = new List <object>();
         }
         this.DataObjectList.Add(subElement);
     }
 }
Пример #4
0
    void ArrangeGrid()
    {
        IntegerArray[] temp = new IntegerArray[SizeX];
        for (int i = 0; i < SizeX; i++)
        {
            temp[i]   = new IntegerArray();
            temp[i].Z = new int[SizeZ];
            for (int j = 0; j < SizeZ; j++)
            {
                temp[i][j] = X[i][j];
            }
        }
        for (int x = 0; x < SizeX; x++)
        {
            for (int z = 0; z < SizeZ; z++)
            {
                if (X[x][z] == 2)
                {
                    switch (GetNeighbouringWalls(x, z))
                    {
                    case 0:
                        temp[x][z] = 5;
                        break;

                    case 1:
                        temp[x][z] = 0;
                        break;

                    case 2:
                        temp[x][z] = DetermineFlatOrCorner(x, z);
                        if ((temp[x][z] == 4) && (IsOnEdge(x, z)))
                        {
                            temp[x][z] = 8;
                        }
                        break;

                    case 3:
                        temp[x][z] = 6;
                        break;

                    case 4:
                        temp[x][z] = 2;
                        break;
                    }
                }
            }
        }
        X = temp;
    }
Пример #5
0
        //public  int CompareWithMany(byte[] stand,IEnumerable<Fingerprint> list)
        //{
        //    int[,] standart = Make2DArray(ByteToIntArray(stand), 338, 248);

        //    Dictionary<int, Fingerprint> answer = new Dictionary<int, Fingerprint>();
        //    foreach(var item in list)
        //    {

        //    }
        //    return 0;
        //}
        //private T[,] Make2DArray<T>(T[] input, int height, int width)
        //{
        //    T[,] output = new T[height, width];
        //    for (int i = 0; i < height; i++)
        //    {
        //        for (int j = 0; j < width; j++)
        //        {
        //            output[i, j] = input[i * width + j];
        //        }
        //    }
        //    return output;
        //}
        //private T[] Make1DArray<T>(T[,] input, int height, int width)
        //{
        //    T[] output = new T[height * width];
        //    System.Buffer.BlockCopy(input, 0, output, 0, 8);
        //    return output;
        //}
        //private  byte[] IntToByteArr(int[] arr)
        //{
        //    byte[] result = new byte[arr.Length * sizeof(int)];
        //    Buffer.BlockCopy(arr, 0, result, 0, result.Length);
        //    return result;
        //}
        //private int[]ByteToIntArray(byte[] arr)
        //{
        //    int[] result = arr.Select(x => (int)x).ToArray();
        //    return result;
        //}
        public static List <IntegerArray> ToArray(int[,] fingerprint)
        {
            List <IntegerArray> list = new List <IntegerArray>();

            for (int i = 0; i < fingerprint.GetLength(0); i++)
            {
                for (int j = 0; j < fingerprint.GetLength(1); j++)
                {
                    IntegerArray array = new IntegerArray();
                    array.IndexX = i;
                    array.IndexY = j;
                    array.Value  = fingerprint[i, j];
                    list.Add(array);
                }
            }
            return(list);
        }
Пример #6
0
        public static MeshPrimitive WithIndicesAccessor(this MeshPrimitive primitive, PrimitiveType primitiveType, IReadOnlyList <Int32> values)
        {
            var root = primitive.LogicalParent.LogicalParent;

            // create an index buffer and fill it
            var view  = root.UseBufferView(new Byte[4 * values.Count], 0, null, 0, BufferMode.ELEMENT_ARRAY_BUFFER);
            var array = new IntegerArray(view.Content);

            array.FillFrom(0, values);

            var accessor = root.CreateAccessor();

            accessor.SetIndexData(view, 0, values.Count, IndexEncodingType.UNSIGNED_INT);

            primitive.DrawPrimitiveType = primitiveType;
            primitive.SetIndexAccessor(accessor);

            return(primitive);
        }
Пример #7
0
        public List <IStringifiable> GetElements()
        {
            List <IStringifiable> elements = new List <IStringifiable>();

            if (this.DataIntA != null)
            {
                IntegerArray a = new IntegerArray();
                a.Name = "A";
                a.Data = this.DataIntA;
                elements.Add(a);
            }
            if (this.DataIntB != null)
            {
                IntegerArray a = new IntegerArray();
                a.Name = "B";
                a.Data = this.DataIntB;
                elements.Add(a);
            }
            if (this.DataIntC != null)
            {
                IntegerArray a = new IntegerArray();
                a.Name = "C";
                a.Data = this.DataIntC;
                elements.Add(a);
            }
            if (this.DataA != null)
            {
                DoubleArray a = new DoubleArray();
                a.Name = "A";
                a.Data = this.DataA;
                elements.Add(a);
            }
            if (this.DataB != null)
            {
                DoubleArray a = new DoubleArray();
                a.Name = "B";
                a.Data = this.DataB;
                elements.Add(a);
            }
            if (this.DataC != null)
            {
                DoubleArray a = new DoubleArray();
                a.Name = "C";
                a.Data = this.DataC;
                elements.Add(a);
            }
            if (this.DataObjectList != null)
            {
                foreach (object o in this.DataObjectList)
                {
                    if (o is IStringifiable)
                    {
                        elements.Add((IStringifiable)o);
                    }
                    else
                    {
                        ObjectString objStr = new ObjectString();
                        objStr.ClassName = o.GetType().FullName;
                        objStr.Data      = o.ToString();
                        elements.Add(objStr);
                    }
                }
            }



            return(elements);
        }