Esempio n. 1
0
        private RCT createRCT(CRD start, string furnitureDirection, int width, int height)
        {
            this.furnitureDirection = furnitureDirection;
            RCT rct;

            switch (furnitureDirection)
            {
            case "l":
                rct         = new RCT(start, width, height);
                this.origin = rct.Start.Clone();
                break;

            case "r":
                rct         = new RCT(start, width, height);
                this.origin = rct.End.Clone();
                break;

            case "t":
                rct    = new RCT(start, height, width);
                origin = new CRD(rct.Start.x, rct.End.z);
                break;

            case "b":
                rct         = new RCT(start, height, width);
                this.origin = new CRD(rct.End.x, rct.Start.z);
                break;

            default:
                rct         = new RCT(start, width, height);
                this.origin = rct.Start.Clone();
                break;
            }
            return(rct);
        }
Esempio n. 2
0
 public void CreateDoorway(CRD crd, string order = "Default")
 {
     if (rct.isContainCRD(crd))
     {
         MapElement.SetOrder(CreateNonOpenablePortal(new RCT(crd, crd), "InnerPortal", "OuterPortal"), order);
     }
 }
Esempio n. 3
0
 public Furniture(string name, CRD start, int floor, string furnitureDirection, int prefabNumber) : base(new RCT(start, 0, 0), floor)
 {
     this.name         = name;
     this.prefabNumber = prefabNumber;
     Init();
     this.rct = createRCT(start, furnitureDirection, monoFurniture.Width, monoFurniture.Height);
 }
Esempio n. 4
0
        public RCT(List <Node> list)
        {
            Stage stage = Stage.GetStage();
            int   minSX = stage.rct.End.x, minSZ = stage.rct.End.z, maxEX = stage.rct.Start.x, maxEZ = stage.rct.Start.z;

            for (int i = 0; i < list.Count; i++)
            {
                if (list[i].crd.x < minSX)
                {
                    minSX = list[i].x;
                }
                if (list[i].crd.z < minSZ)
                {
                    minSZ = list[i].z;
                }
                if (list[i].crd.x > maxEX)
                {
                    maxEX = list[i].x;
                }
                if (list[i].crd.z > maxEZ)
                {
                    maxEZ = list[i].z;
                }
            }
            this.end    = new CRD(minSX, minSZ);
            this.start  = new CRD(maxEX, maxEZ);
            this.width  = end.z - start.z + 1;
            this.height = end.x - start.x + 1;
            this.sq     = width * height;
        }
Esempio n. 5
0
 public void CreateDoubleDoorway(CRD crd, string order = "Default")
 {
     if (rct.isContainCRD(crd))
     {
         MapElement.SetOrder(CreateDoublePortal(crd, false), order);
     }
 }
Esempio n. 6
0
 public RCT(CRD start, CRD end)
 {
     this.end    = new CRD(end.x, end.z);
     this.start  = new CRD(start.x, start.z);
     this.width  = end.z - start.z + 1;
     this.height = end.x - start.x + 1;
     this.sq     = width * height;
 }
Esempio n. 7
0
 public RCT(CRD start, int width, int height)
 {
     this.end    = new CRD(start.x + height - 1, start.z + width - 1);
     this.start  = new CRD(start.x, start.z);
     this.width  = width;
     this.height = height;
     this.sq     = width * height;
 }
Esempio n. 8
0
        public static CRD GetRandomCRD(RCT rct)
        {
            int dHeigth = Mathf.RoundToInt(Random.Range(0, (rct.Height - 1) * 100) / 100);
            int dWidth  = Mathf.RoundToInt(Random.Range(0, (rct.Width - 1) * 100) / 100);
            CRD crd     = new CRD(rct.Start.x + dHeigth, rct.Start.z + dWidth);

            return(crd);
        }
Esempio n. 9
0
 public bool isContainCRD(CRD crd)// проверяет находится ли координата внутри прямоугольника
 {
     if ((crd.x < this.Start.x) || (crd.z < this.Start.z) || (crd.x > this.End.x) || (crd.z > this.End.z))
     {
         return(false);
     }
     else
     {
         return(true);
     }
 }
Esempio n. 10
0
        public static Node GetNode(CRD crd, int floornumber)// возвращает узел
        {
            Stage stage = Stage.GetStage();
            Floor floor = stage.floors.Find(x => x.number == floornumber);

            if (floor != null)
            {
                return(floor.GetNode(crd.x, crd.z));
            }
            return(new Node());
        }
Esempio n. 11
0
 public bool checkMap(CRD crd, bool[,] map)
 {
     if (map[crd.x - rct.Start.x, crd.z - rct.Start.z])
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }
Esempio n. 12
0
        public List <MapElement> CreateDoublePortal(CRD crd, bool openable = false)
        {
            string crdDirection = rct.GetDirection(crd), twinNode;

            switch (crdDirection)
            {
            case "l":
                twinNode = "b";
                break;

            case "r":
                twinNode = "t";
                break;

            case "t":
                twinNode = "l";
                break;

            case "b":
                twinNode = "r";
                break;

            default:
                twinNode = "t";
                break;
            }
            CRD twinCRD = Stage.GetNode(crd).GetSibling(twinNode).crd;
            List <MapElement> RightPortals;
            List <MapElement> LeftPortals;

            if (openable)
            {
                RightPortals = CreateOpenablePortal(new RCT(crd, crd), "InnerDoubleDoorR", "InnerDoublePortalL", "OuterDoublePortalL");
                LeftPortals  = CreateOpenablePortal(new RCT(twinCRD, twinCRD), "InnerDoubleDoorL", "InnerDoublePortalR", "OuterDoublePortalR");
            }
            else
            {
                RightPortals = CreateOpenablePortal(new RCT(crd, crd), "InnerDoublePortalR", "InnerDoublePortalL", "OuterDoublePortalL");
                LeftPortals  = CreateOpenablePortal(new RCT(twinCRD, twinCRD), "InnerDoublePortalL", "InnerDoublePortalR", "OuterDoublePortalR");
            }
            List <MapElement> list = new List <MapElement>();

            for (int i = 0; i < 2; i++)
            {
                Portal p1 = RightPortals[i] as Portal;
                Portal p2 = LeftPortals[i] as Portal;
                Portal.BindTwin(p1, p2);
            }
            list.AddRange(RightPortals);
            list.AddRange(LeftPortals);
            return(list);
        }
Esempio n. 13
0
        private void createQuads(CRD crd, Vector3 rotation, int width)//Добавление фона карты одна сторона
        {
            CRD ncrd     = new CRD(crd.x, crd.z);
            int quadWidt = 1;

            while (width > 0)
            {
                if (width >= 20)
                {
                    quadWidt = 20;
                }
                else if (width >= 10)
                {
                    quadWidt = 10;
                }
                else if (width >= 5)
                {
                    quadWidt = 5;
                }
                else if (width >= 3)
                {
                    quadWidt = 3;
                }
                else if (width >= 1)
                {
                    quadWidt = 1;
                }

                if (ncrd.z < 0)
                {
                    createQuad(new CRD(ncrd.x, ncrd.z), rotation, quadWidt);
                    ncrd.x += quadWidt;
                }
                else if (ncrd.z >= stage.width)
                {
                    createQuad(new CRD(ncrd.x + quadWidt - 1, ncrd.z), rotation, quadWidt);
                    ncrd.x += quadWidt;
                }
                else if (ncrd.x < 0)
                {
                    createQuad(new CRD(ncrd.x, ncrd.z + quadWidt - 1), rotation, quadWidt);
                    ncrd.z += quadWidt;
                }
                else if (ncrd.x >= stage.height)
                {
                    createQuad(new CRD(ncrd.x, ncrd.z), rotation, quadWidt);
                    ncrd.z += quadWidt;
                }
                width -= quadWidt;
            }
        }
Esempio n. 14
0
        public string GetDirection(CRD crd)
        {
            string direction, vDirection, hDirection;
            int    VD, HD;
            int    DSX = crd.x - start.x;
            int    DEX = end.x - crd.x;
            int    DSZ = crd.z - start.z;
            int    DEZ = end.z - crd.z;

            if (DSX < DEX)
            {
                VD         = DSX;
                vDirection = "t";
            }
            else
            {
                VD         = DEX;
                vDirection = "b";
            }
            if (DSZ < DEZ)
            {
                HD         = DSZ;
                hDirection = "l";
            }
            else
            {
                HD         = DEZ;
                hDirection = "r";
            }
            if (HD == VD)
            {
                direction = hDirection + vDirection;
            }
            else
            {
                if (HD < VD)
                {
                    direction = hDirection;
                }
                else
                {
                    direction = vDirection;
                }
            }
            return(direction);
        }
Esempio n. 15
0
        public void addFurniture(string name, CRD start, string furnitureDirection)//добавление мебели
        {
            Furniture furniture = new Furniture(name, start, floorNumber, furnitureDirection, getPrefabNuber());
            bool      collision = false;

            for (int i = 0; i < childElements.Count; i++)
            {
                if (childElements[i].rct.checkCollision(furniture.rct))//проверка столкновений с другими дочерними элементами
                {
                    collision = true;
                    break;
                }
            }
            if (!collision && rct.isContainRCT(furniture.rct))//проверка столкновений и вписывается ли мебель в элемент
            {
                addNewElement(furniture);
            }
        }
Esempio n. 16
0
 public Node(int x, int z, Floor floor, bool movable)
 {
     id = iterator;
     iterator++;
     this.crd        = new CRD(x, z);
     this.x          = x;
     this.z          = z;
     this.y          = z;
     this.floor      = floor;
     this.busy       = false;
     this.isWalkable = movable;
     this.name       = "cell[" + x + "," + z + "]:" + floor.number;
     this.links      = new List <NodeLink>();
     this.Layers     = new List <NodeLayer>();
     this.shelters   = new List <Shelter>();
     meshHeight      = 0;
     noMeshHeight    = 0;
 }
Esempio n. 17
0
        private void createQuad(CRD crd, Vector3 rotation, int width)//Добавление фона карты один элемент
        {
            Floor   floor        = stage.floors.Find(x => x.number == stage.groundFloor) as Floor;
            Vector3 position     = new Vector3(crd.x, floor.number * floor.height, crd.z);
            int     prefabNumber = 0;
            string  size;

            if (width == -1)
            {
                size = "Corner";
            }
            else
            {
                size = width.ToString();
            }
            GameObject cellInstance = GameObject.Instantiate(Resources.Load("Stage/" + stage.DesignName + "/Background/" + stage.order + "/" + size + "/" + prefabNumber), position, Quaternion.Euler(rotation)) as GameObject;

            cellInstance.transform.name = "bg-[" + position.x + "," + position.z + "]";
        }
Esempio n. 18
0
        public static List <RCT> Cuttind(RCT rct1, RCT rct2) // получает два прямоугольника и получает несколько новых являющихся частями порезанных старых
        {
            rct1.End.StepRB();
            rct2.End.StepRB();
            List <int> xlines  = new List <int>();
            List <int> zlines  = new List <int>();
            List <RCT> newRCTs = new List <RCT>();

            xlines.Add(rct1.Start.x);
            xlines.Add(rct1.End.x);
            xlines.Add(rct2.Start.x);
            xlines.Add(rct2.End.x);

            zlines.Add(rct1.Start.z);
            zlines.Add(rct1.End.z);
            zlines.Add(rct2.Start.z);
            zlines.Add(rct2.End.z);

            xlines.Sort();
            zlines.Sort();

            rct1.End.StepLT();
            rct2.End.StepLT();
            CRD star, end;

            for (int x = 0; x < xlines.Count - 1; x++)
            {
                for (int z = 0; z < zlines.Count - 1; z++)
                {
                    star = new CRD(xlines[x], zlines[z]);
                    end  = new CRD(xlines[x + 1], zlines[z + 1]);
                    end.StepLT();
                    RCT rct = new RCT(star, end);
                    if (rct1.checkCollision(rct) || rct2.checkCollision(rct))
                    {
                        newRCTs.Add(rct);
                    }
                }
            }
            return(newRCTs);
        }
Esempio n. 19
0
 public override void HookAfterAddNodesToMapElement()
 {
     foreach (Node node in childNodes)
     {
         node.isWalkable = true;
         for (int x = -1; x <= 1; x++)
         {
             for (int z = -1; z <= 1; z++)
             {
                 CRD crd = new CRD(node.x + x, node.z + z);
                 if ((x != 0 || z != 0) && rct.isContainCRD(crd))
                 {
                     float w = 1;
                     if (x != 0 && z != 0)
                     {
                         w = 1.5f;
                     }
                     node.LinkNode(Stage.GetNode(crd, floorNumber), w);
                 }
             }
         }
     }
 }
Esempio n. 20
0
        public void createParkingPlaces()
        {
            if (parentElement.GetType() == typeof(BackgroundStreet))
            {
                return;
            }
            string            outerStartDirection, outerEndDirection;
            int               maxParkingSize = 2;
            int               placeSize = 4;
            CRD               startParking = rct.CloneStart();
            List <MapElement> mapElements = new List <MapElement>();
            int               count = 1;
            int               parkingSize = count * placeSize;
            int               start, ocorner, icorner;

            if (axis == 'v')
            {
                if (rct.Width < 2 || rct.Height < placeSize)
                {
                    return;
                }
                startParking.x++;

                while (parkingSize + placeSize + 1 < rct.Height - 2 && count < maxParkingSize)
                {
                    count++;
                    parkingSize += placeSize + 1;
                }

                if (rct.Start != parentElement.rct.Start)
                {
                    start               = startParking.z;
                    ocorner             = startParking.z;
                    icorner             = startParking.z + maxParkingSize - 1;
                    outerStartDirection = "lb";
                    outerEndDirection   = "lt";
                }
                else
                {
                    start               = rct.End.z - 1;
                    ocorner             = rct.End.z;
                    icorner             = rct.End.z - maxParkingSize + 1;
                    outerStartDirection = "rb";
                    outerEndDirection   = "rt";
                }
                SidewalkParking parking = new SidewalkParking(new RCT(new CRD(startParking.x, start), 2, parkingSize), floorNumber, axis, placeSize);
                // С этим позже могут быть проблемы, т.к. угловая нода не попадает в объект parking
                CRD cornerCRD = new CRD(parking.rct.Start.x, icorner);
                mapElements.Add(new SidewalkParkingInnerCorner(new RCT(cornerCRD, 1, 1), floorNumber, parking.rct.GetDirection(cornerCRD)));
                cornerCRD = new CRD(parking.rct.End.x, icorner);
                mapElements.Add(new SidewalkParkingInnerCorner(new RCT(cornerCRD, 1, 1), floorNumber, parking.rct.GetDirection(cornerCRD)));
                //
                mapElements.Add(parking);
                mapElements.Add(new SidewalkParkingOuterCorner(new RCT(new CRD(parking.rct.Start.x - 1, ocorner), 1, 1), floorNumber, outerStartDirection));
                mapElements.Add(new SidewalkParkingOuterCorner(new RCT(new CRD(parking.rct.End.x + 1, ocorner), 1, 1), floorNumber, outerEndDirection));
            }
            else
            {
                if (rct.Height < 2 || rct.Width < placeSize)
                {
                    return;
                }
                startParking.z++;
                while (parkingSize + placeSize + 1 < rct.Width - 2 && count < maxParkingSize)
                {
                    count++;
                    parkingSize += placeSize + 1;
                }
                if (rct.Start != parentElement.rct.Start)
                {
                    start               = startParking.x;
                    ocorner             = startParking.x;
                    icorner             = startParking.x + maxParkingSize - 1;
                    outerStartDirection = "rt";
                    outerEndDirection   = "lt";
                }
                else
                {
                    start               = rct.End.x - 1;
                    ocorner             = rct.End.x;
                    icorner             = rct.End.x - maxParkingSize + 1;
                    outerStartDirection = "rb";
                    outerEndDirection   = "lb";
                }
                SidewalkParking parking = new SidewalkParking(new RCT(new CRD(start, startParking.z), parkingSize, 2), floorNumber, axis, placeSize);
                // С этим позже могут быть проблемы, т.к. угловая нода не попадает в объект parking
                CRD cornerCRD = new CRD(icorner, parking.rct.Start.z);
                mapElements.Add(new SidewalkParkingInnerCorner(new RCT(cornerCRD, 1, 1), floorNumber, parking.rct.GetDirection(cornerCRD)));
                cornerCRD = new CRD(icorner, parking.rct.End.z);
                mapElements.Add(new SidewalkParkingInnerCorner(new RCT(cornerCRD, 1, 1), floorNumber, parking.rct.GetDirection(cornerCRD)));
                //
                mapElements.Add(parking);
                mapElements.Add(new SidewalkParkingOuterCorner(new RCT(new CRD(ocorner, parking.rct.Start.z - 1), 1, 1), floorNumber, outerStartDirection));
                mapElements.Add(new SidewalkParkingOuterCorner(new RCT(new CRD(ocorner, parking.rct.End.z + 1), 1, 1), floorNumber, outerEndDirection));
            }
            addNewElements(mapElements);
        }
Esempio n. 21
0
 public static Node GetNode(CRD crd)
 {
     return(GetNode(crd, 1));
 }
Esempio n. 22
0
 public void Grow()
 {
     Start = Start.ReturnStepLT();
     End   = End.ReturnStepRB();
 }
Esempio n. 23
0
 public void CreateColumn(CRD crd)
 {
     addNewElement(new Column(crd, floorNumber));
 }
Esempio n. 24
0
 public void Thin()
 {
     Start = Start.ReturnStepRB();
     End   = End.ReturnStepLT();
 }
Esempio n. 25
0
 public CrossroadSidewalk(RCT rct, int floor, CRD corner) : base(rct, floor)
 {
     this.corner = corner;
 }
Esempio n. 26
0
 public Column(CRD crd, int floor, bool asInterior = false) : base(new RCT(crd, crd), floor)
 {
     AsInterior = asInterior;
 }