public ActionResult DeleteConfirmed(int id)
        {
            FurniturePart furniturePart = db.FurnitureParts.Find(id);

            db.FurnitureParts.Remove(furniturePart);
            db.SaveChanges();
            return(RedirectToAction("Index", "Furnitures"));
        }
        // GET: FurnitureParts/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            FurniturePart furniturePart = db.FurnitureParts.Find(id);

            if (furniturePart == null)
            {
                return(HttpNotFound());
            }
            return(View(furniturePart));
        }
 public ActionResult Create(Furniture furniture, FurniturePart furnitureParts)
 {
     //If part Index not set??
     if (furnitureParts.FurnitureIndex == 0)
     {
         furnitureParts.FurnitureIndex     = furniture.FurnitureID;
         furnitureParts.FurniturePieceName = furniture.FurnitureName;
         return(View(furnitureParts));
     }
     else
     {
         //Redirect using TempData
         //TODO: MSG Adding another Part Failed.
         return(View("Index", "furnitures"));
     }
 }
        public ActionResult Create(string submit, Furniture furniture, [Bind(Include = "FurniturePartId,FurnitureIndex,PartName,PartCount,Width,Length,BoardThickness,partBoardFoot,PartNotes,PartImgUrl")] FurniturePart furniturePart)
        {
            switch (submit)
            {
            case "Add Another Part":
                if (ModelState.IsValid)
                {
                    furniturePart.FurniturePieceName = furniture.FurnitureName;     //Set Name and ID for Parts DB
                    furniturePart.FurnitureIndex     = furniture.FurnitureID;
                    furniturePart.partBoardFoot      = 0;
                    double BoardFoot = furniturePart.PartCount * ((furniturePart.Width * furniturePart.Length * furniturePart.BoardThickness) / 144);
                    BoardFoot = Math.Round(BoardFoot, 4);
                    furniturePart.partBoardFoot = BoardFoot;
                    db.FurnitureParts.Add(furniturePart);
                    db.SaveChanges();

                    return(RedirectToAction("create", "FurnitureParts", furniture));    //Returns Furniture for ID and Name
                }
                break;

            case "Finished":
                if (ModelState.IsValid)
                {
                    furniturePart.FurniturePieceName = furniture.FurnitureName;
                    furniturePart.FurnitureIndex     = furniture.FurnitureID;
                    double BoardFoot = furniturePart.PartCount * ((furniturePart.Width * furniturePart.Length * furniturePart.BoardThickness) / 144);
                    BoardFoot = Math.Round(BoardFoot, 4);
                    furniturePart.partBoardFoot = BoardFoot;
                    db.FurnitureParts.Add(furniturePart);
                    db.SaveChanges();
                    var id = furniturePart.FurnitureIndex;                         //FurnitureID = FurnitureIndex
                    return(RedirectToAction("Details", "Furnitures", new { id })); //Back to Furniture Details View
                }
                break;

            case "Cancel":
            {
                return(RedirectToAction("Index", "furnitures"));
            }

            default:
                break;
            }

            return(View(furniturePart));
        }
Beispiel #5
0
 private HousePassage GetFrontHousePassage(Vector3Int position, Orientation frontOrientation)
 {
     if (levelmanager.IsInRoom(position) && levelmanager.room[position.x, position.y, position.z] != null && levelmanager.room[position.x, position.y, position.z].type == HouseObject.Type.furniture)
     {
         FurniturePart furnitureInFront = (FurniturePart)levelmanager.room[position.x, position.y, position.z];
         if (furnitureInFront.canMoveFurniture)
         {
             foreach (HousePassage housePassage in furnitureInFront.allportails)
             {
                 if (housePassage.orientation == frontOrientation)
                 {
                     return(housePassage);
                 }
             }
         }
     }
     return(null);
 }
        public ActionResult Edit([Bind(Include = "FurniturePartId,FurnitureIndex,PartName,PartCount,Width,Length,BoardThickness,partBoardFoot,PartNotes,PartImgUrl")] FurniturePart furniturePart)
        {
            if (ModelState.IsValid)
            {
                db.Entry(furniturePart).State = EntityState.Modified;

                furniturePart.partBoardFoot = 0;
                double BoardFoot = furniturePart.PartCount * ((furniturePart.Width * furniturePart.Length * furniturePart.BoardThickness) / 144);
                BoardFoot = Math.Round(BoardFoot, 4);
                furniturePart.partBoardFoot = BoardFoot;


                db.SaveChanges();
                var id = furniturePart.FurnitureIndex;                         //FurnitureID = FurnitureIndex
                return(RedirectToAction("Details", "Furnitures", new { id })); //Back to Furniture Details View
            }
            return(View("Index", "Furnitures"));
        }
Beispiel #7
0
    public IEnumerator MoveCarpetIn(Vector3 carpetDirection)
    {
        Vector3Int currentPosition = new Vector3Int(allCarpetParts[allCarpetParts.Count - 1].position.x, (allCarpetParts[allCarpetParts.Count - 1].position.y),
                                                    (allCarpetParts[allCarpetParts.Count - 1].position.z));
        Vector3Int forwardPosition  = currentPosition + new Vector3Int((int)carpetDirection.x, (int)carpetDirection.y, (int)carpetDirection.z);
        Vector3Int downwardPosition = currentPosition + Vector3Int.down;
        Vector3    edgePos;

        while ((levelmanager.IsInRoom(forwardPosition) && levelmanager.room[forwardPosition.x, forwardPosition.y, forwardPosition.z] == null) ||
               (levelmanager.IsInRoom(downwardPosition) && levelmanager.room[downwardPosition.x, downwardPosition.y, downwardPosition.z] == null))
        {
            if (levelmanager.IsInRoom(downwardPosition) && levelmanager.room[downwardPosition.x, downwardPosition.y, downwardPosition.z] != null && levelmanager.room[downwardPosition.x, downwardPosition.y, downwardPosition.z].type == HouseObject.Type.carpetPart)
            {
                playerInput.Fail();
            }
            isRouling = true;
            Vector3    newPos;
            bool       isFalling = false;
            CarpetPart newCarpet;
            if (levelmanager.IsInRoom(downwardPosition) && levelmanager.room[downwardPosition.x, downwardPosition.y, downwardPosition.z] == null)
            {
                newCarpet          = Instantiate(fallingCarpetPartPrefab, downwardPosition, Quaternion.identity, carpetHolder);
                newCarpet.position = downwardPosition;
                newCarpet.type     = HouseObject.Type.carpetPart;
                allCarpetParts.Add(newCarpet);
                levelmanager.room[downwardPosition.x, downwardPosition.y, downwardPosition.z] = newCarpet;
                if (carpetDirection.x == 1)
                {
                    newCarpet.transform.rotation = Quaternion.Euler(0, 180, 0);
                }
                else if (carpetDirection.x == -1)
                {
                    newCarpet.transform.rotation = Quaternion.Euler(0, 0, 0);
                }
                else if (carpetDirection.z == 1)
                {
                    newCarpet.transform.rotation = Quaternion.Euler(0, 90, 0);
                }
                else if (carpetDirection.z == -1)
                {
                    newCarpet.transform.rotation = Quaternion.Euler(0, -90, 0);
                }
                newPos    = downwardPosition;
                edgePos   = Vector3.Lerp(currentPosition, downwardPosition, 0.5f);
                isFalling = true;
            }
            else if (levelmanager.IsInRoom(forwardPosition + Vector3Int.down) && levelmanager.room[forwardPosition.x, forwardPosition.y - 1, forwardPosition.z] == null)
            {
                Vector3Int nextDownPosition = forwardPosition + Vector3Int.down;
                newCarpet          = Instantiate(fallingCarpetPartPrefab, nextDownPosition, Quaternion.identity, carpetHolder);
                newCarpet.position = nextDownPosition;
                newCarpet.type     = HouseObject.Type.carpetPart;
                allCarpetParts.Add(newCarpet);
                levelmanager.room[nextDownPosition.x, nextDownPosition.y, nextDownPosition.z] = newCarpet;

                if (carpetDirection.x == 1)
                {
                    newCarpet.transform.rotation = Quaternion.Euler(0, 180, 0);
                }
                else if (carpetDirection.x == -1)
                {
                    newCarpet.transform.rotation = Quaternion.Euler(0, 0, 0);
                }
                else if (carpetDirection.z == 1)
                {
                    newCarpet.transform.rotation = Quaternion.Euler(0, 90, 0);
                }
                else if (carpetDirection.z == -1)
                {
                    newCarpet.transform.rotation = Quaternion.Euler(0, -90, 0);
                }
                newPos    = nextDownPosition;
                edgePos   = Vector3.Lerp(nextDownPosition + Vector3.up, nextDownPosition, 0.5f);
                isFalling = true;
            }
            else
            {
                newCarpet          = Instantiate(flatCarpetPartPrefab, forwardPosition, Quaternion.identity, carpetHolder);
                newCarpet.position = forwardPosition;
                newCarpet.type     = HouseObject.Type.carpetPart;
                allCarpetParts.Add(newCarpet);
                levelmanager.room[forwardPosition.x, forwardPosition.y, forwardPosition.z] = newCarpet;
                newPos = forwardPosition;

                if (carpetDirection.x == 1 || carpetDirection.x == -1)
                {
                    newCarpet.transform.rotation = Quaternion.Euler(0, 0, 0);
                }
                else if (carpetDirection.z == 1 || carpetDirection.z == -1)
                {
                    newCarpet.transform.rotation = Quaternion.Euler(0, 90, 0);
                }

                edgePos = Vector3.Lerp(currentPosition, forwardPosition, 0.5f);
            }
            float roulingTimer = 0;
            while (roulingTimer < carpetMovingSpeed)
            {
                newCarpet.transform.position = Vector3.Lerp(edgePos, newPos, roulingTimer / carpetMovingSpeed);
                if (isFalling)
                {
                    newCarpet.transform.localScale = new Vector3(1, Mathf.Lerp(0, 1, roulingTimer / carpetMovingSpeed), 1);
                }
                else
                {
                    newCarpet.transform.localScale = new Vector3(Mathf.Lerp(0, 1, roulingTimer / carpetMovingSpeed), 1, 1);
                }
                roulingTimer += Time.deltaTime;
                yield return(new WaitForEndOfFrame());
            }

            newCarpet.transform.localScale = Vector3.one;
            newCarpet.transform.position   = newPos;
            newCarpet.position             = new Vector3Int((int)newPos.x, (int)newPos.y, (int)newPos.z);

            currentPosition = new Vector3Int(allCarpetParts[allCarpetParts.Count - 1].position.x, (allCarpetParts[allCarpetParts.Count - 1].position.y),
                                             (allCarpetParts[allCarpetParts.Count - 1].position.z));
            forwardPosition  = currentPosition + new Vector3Int((int)carpetDirection.x, (int)carpetDirection.y, (int)carpetDirection.z);
            downwardPosition = currentPosition + Vector3Int.down;

            if (isFalling)
            {
                if (!(levelmanager.IsInRoom(downwardPosition) && levelmanager.room[downwardPosition.x, downwardPosition.y, downwardPosition.z] == null))
                {
                    newCarpet = Instantiate(flatCarpetPartPrefab, carpetHolder);
                    if (carpetDirection.x == 1 || carpetDirection.x == -1)
                    {
                        newCarpet.transform.rotation = Quaternion.Euler(0, 0, 0);
                    }
                    else if (carpetDirection.z == 1 || carpetDirection.z == -1)
                    {
                        newCarpet.transform.rotation = Quaternion.Euler(0, 90, 0);
                    }
                    edgePos      = currentPosition - carpetDirection * 0.5f;
                    newPos       = currentPosition;
                    roulingTimer = 0;
                    while (roulingTimer < carpetMovingSpeed)
                    {
                        newCarpet.transform.position   = Vector3.Lerp(edgePos, newPos, roulingTimer / carpetMovingSpeed);
                        newCarpet.transform.localScale = new Vector3(Mathf.Lerp(0, 1, roulingTimer / carpetMovingSpeed), 1, 1);
                        roulingTimer += Time.deltaTime;
                        yield return(new WaitForEndOfFrame());
                    }
                    newCarpet.transform.localScale = Vector3.one;
                    newCarpet.transform.position   = newPos;
                }
            }
        }
        isRouling = false;

        if (levelmanager.IsInRoom(forwardPosition) && levelmanager.room[forwardPosition.x, forwardPosition.y, forwardPosition.z] != null && levelmanager.room[forwardPosition.x, forwardPosition.y, forwardPosition.z].type == HouseObject.Type.furniture)
        {
            FurniturePart furnitureInFront = (FurniturePart)levelmanager.room[forwardPosition.x, forwardPosition.y, forwardPosition.z];
            foreach (HousePassage housePassage in furnitureInFront.allportails)
            {
                if (housePassage.orientation == endCarpetOrientation)
                {
                    housePassage.passage.PassCarpetRoomToHiddenSpace(hiddenSpaceCarpetPart);

                    carpetIsInHiddenSpace = true;
                }
            }
        }
    }