Пример #1
0
        public async Task <IActionResult> UpdateHandler([FromRoute] int id, Rug rug)
        {
            await _rugLogic.Update(rug.Id, rug);

            return(RedirectToAction("Index"));
        }
Пример #2
0
        public async Task <IActionResult> AddHandler(Rug rug)
        {
            await _rugLogic.Save(rug);

            return(RedirectToAction("Index"));
        }
Пример #3
0
        public static void AddRug_Callback(Mobile from, Map map, Point3D start, Point3D end, object state)
        {
            Rug tr = (Rug)state;

            int height = end.Y - start.Y + 1;
            int width  = end.X - start.X + 1;

            Item item;

            for (int x = 0; x < width; x++)
            {
                int xcord = start.X + x;

                for (int y = 0; y < height; y++)
                {
                    int ycord = start.Y + y;

                    item = new Item();

                    if (xcord == start.X)
                    {
                        if (ycord == start.Y)
                        {
                            item.ItemID = tr.Top;
                        }
                        else if (ycord == end.Y)
                        {
                            item.ItemID = tr.Left;
                        }
                        else
                        {
                            item.ItemID = tr.West;
                        }
                    }
                    else if (ycord == start.Y)
                    {
                        if (xcord == end.X)
                        {
                            item.ItemID = tr.Right;
                        }
                        else
                        {
                            item.ItemID = tr.North;
                        }
                    }
                    else if (xcord == end.X)
                    {
                        if (ycord == end.Y)
                        {
                            item.ItemID = tr.Bottom;
                        }
                        else
                        {
                            item.ItemID = tr.East;
                        }
                    }
                    else if (ycord == end.Y)
                    {
                        item.ItemID = tr.South;
                    }
                    else
                    {
                        item.ItemID = tr.Center;
                    }

                    item.Movable = false;
                    item.MoveToWorld(new Point3D(xcord, ycord, start.Z), map);
                }
            }
        }
Пример #4
0
        private static void GenRug(Mobile m, RugType typ)
        {
            Rug rug = Rug.GetRug(typ);

            BoundingBoxPicker.Begin(m, new BoundingBoxCallback(AddRug_Callback), rug);
        }
    private void PlaceRugs()
    {
        foreach (Rug rug in placedRugs)
        {
            Destroy(rug.gameObject);
        }
        placedRugs.Clear();

        for (int i = 0; i < numberOfRugs; i++)
        {
            Rug rugPrefab = SelectRandom(rugs);

            bool rugHasParents = rugPrefab.parentFurniture.Count > 0;
            bool rugFits;
            // pick random location
            // resize
            int newRugX = (int)rugPrefab.xMax;
            int newRugZ = (int)rugPrefab.zMax;

            Vector3 rugOrigin;

            if (!rugPrefab.forceMax)
            {
                newRugX = random.Next((int)rugPrefab.xMax) + 1;
                newRugZ = random.Next((int)rugPrefab.zMax) + 1;
            }


            for (int attempt = 0; attempt < 5; attempt++)
            {
                if (rugHasParents)
                {
                    // get list of placed parents
                    List <Furniture> possibleParents = placedFurniture.FindAll((Furniture furniture) =>
                    {
                        return(rugPrefab.parentFurniture.Contains(furniture.type));
                    });

                    // pick one
                    Furniture parentFurniture = SelectRandom(possibleParents);
                    rugOrigin = parentFurniture.origin;
                    // resize

                    // align based on size & position

                    //if it fits
                    rugFits = RugFits(rugOrigin, newRugX, newRugZ);
                }
                else
                {
                    // select psitions that will fit dimensions
                    List <Vector3> possiblePositions = rugCoordinates.FindAll((Vector3 coord) =>
                    {
                        return(coord.x + newRugX < xLength && coord.z + newRugZ < zLength);
                    });

                    rugOrigin = SelectRandom(possiblePositions);
                    rugFits   = RugFits(rugOrigin, newRugX, newRugZ);
                }

                if (rugFits)
                {
                    // place at location
                    Rug     newRug = Instantiate(rugPrefab, rugOrigin, Quaternion.identity);
                    Vector3 scale  = new Vector3(newRugX, rugPrefab.transform.localScale.y, newRugZ);
                    newRug.transform.localScale = scale;
                    placedRugs.Add(newRug);

                    // Remove coords
                    RemoveRugCoords(rugOrigin, newRugX, newRugZ);
                    break;
                }
            }
        }
    }