Exemplo n.º 1
0
        public void SetObject(SceneObjectContainer selectObject, Vector3 position, bool instancing = false)
        {
            var sceneObject = GUIAuxiliar.Instanciate(selectObject.Prefab, transform, position, selectObject.Rotation, selectObject.Scale, instancing);
            var dataObject  = new LevelObjectData(sceneObject, position);

            listOfObjects.Add(dataObject);
        }
Exemplo n.º 2
0
        public WallInfo(SceneObjectContainer c, Transform t, Vector3 position, bool instancing)
        {
            var wallInfo = c.GetAsWall();

            height        = wallInfo.height;
            transitable   = wallInfo.transitable;
            this.position = position;
            //TODO
            prefabObject = GUIAuxiliar.Instanciate(wallInfo.prefab, t, c.preview.transform.position, c.preview.transform.rotation, Vector3.one, instancing);
        }
Exemplo n.º 3
0
        internal void SetObjectAsInfoOnly(SceneObjectContainer sceneObj, GameObject realObject)
        {
            var newInfo = new ObjectInfo();

            newInfo.gameObject   = realObject;
            newInfo.yOffset      = sceneObj.Size.y;
            newInfo.pivot        = sceneObj.Pivot;
            newInfo.realPosition = realObject.transform.position;
            objectList.Add(newInfo);
        }
Exemplo n.º 4
0
        internal void AddWall(SceneObjectContainer obj, Transform t, int wallIndex, bool instancing)
        {
            WallInfo preWall = walls[wallIndex];

            if (preWall.prefabObject != null)
            {
                GUIAuxiliar.Destroy(preWall.prefabObject);
            }
            WallInfo wall = new WallInfo(obj, t, preWall.position, instancing);

            walls[wallIndex] = wall;
        }
Exemplo n.º 5
0
 public void SetObjetIntoCell(SceneObjectContainer selectObject, Vector3 triangleIndex, Vector3 offset, bool instancing = false)
 {
     if (selectObject != null)
     {
         Cell c = GetCell(triangleIndex);
         //Si el el modulo es igual a 1, significa que mide 1 sola casilla.
         if (selectObject.CellCountSize == 1)
         {
             c.AddObject(selectObject, transform, offset, instancing);
         }
         else
         {
             //obtenemos el indice del objeto.
             int        index         = cells.ToList().IndexOf(c);
             Vector2Int indexPosition = Get2DIndex(index);
             AddObjectToCell(selectObject.CellSize, indexPosition, c, selectObject);
         }
     }
 }
Exemplo n.º 6
0
        //Añade un objeto a la lista de la celda.
        internal void AddObject(SceneObjectContainer obj, Transform t, Vector3 offset, bool instancing = false)
        {
            Transform  parent  = t;
            ObjectInfo newInfo = new ObjectInfo();

            if (objectList.Count >= 1)
            {
                var last = objectList.Last();
                newInfo.realPosition = lastObjectPos + offset - obj.Pivot;
            }
            else
            {
                newInfo.realPosition = obj.Position + offset;
            }
            newInfo.yOffset = obj.Size.y;
            newInfo.pivot   = obj.Pivot;

            newInfo.gameObject = GUIAuxiliar.Instanciate(obj.Prefab, parent, newInfo.realPosition, obj.Rotation, obj.Scale, instancing);
            objectList.Add(newInfo);
        }
Exemplo n.º 7
0
        public void SetWallIntoCell(SceneObjectContainer selectObject, Vector3 triangleIndex, int wallPos, Vector3 off, bool instancing = false)
        {
            Cell c = GetCell(triangleIndex);

            c.AddWall(selectObject, transform, wallPos, instancing);
        }
Exemplo n.º 8
0
        /**
         * Add a Prefab Object into the cells. Takes the size of the object in cells an puts into the middle.
         *
         */
        private void AddObjectToCell(Vector2Int size, Vector2Int indexPosition, Cell mainCell, SceneObjectContainer sceneObject, bool instancing = false)
        {
            var cellToObtain = new Cell[size.x * size.y];

            if (indexPosition.x + size.x >= xSize)
            {
                indexPosition.x = xSize - size.x;
            }

            if (indexPosition.y + size.y >= ySize)
            {
                indexPosition.y = xSize - size.y;
            }
            //Calculamos las celdas adyacentes.
            Vector3 position = Vector3.zero;

            for (int i = 0; i < size.x; i++)
            {
                for (int j = 0; j < size.y; j++)
                {
                    int index = i + j * size.x;
                    cellToObtain[index] = cells[getIndex(indexPosition.x + i, indexPosition.y + j)];

                    position += transform.TransformPoint(cellToObtain[index].lastObjectPos);
                }
            }
            position /= sceneObject.CellCountSize;
            position -= sceneObject.Pivot;
            GameObject realObject;

            realObject = GUIAuxiliar.Instanciate(sceneObject.Prefab, transform, position, sceneObject.Rotation, sceneObject.Scale, instancing);
            var newInfo = new ObjectInfo(cellToObtain, realObject, realObject.transform.position, sceneObject.Pivot, sceneObject.Size.y, size);

            Array.ForEach(cellToObtain, element => element.SetObjectAsInfoOnly(newInfo));
        }