예제 #1
0
 public void SetElement(string name, int price, FurnitureItem.ItemTheme theme, FurnitureItem.ItemCategory category, params Tile[] tile)
 {
     itemData             = new FurnitureItem(name, price, theme, category, 0, tile);
     priceText.text       = itemData.Price.ToString();
     this.thumnail.sprite = itemData.Tiles[0].sprite;
     this.thumnail.SetNativeSize();
     Debug.Log(itemData.ToString());
 }
예제 #2
0
        public void RemoveItem(FurnitureItem item)
        {
            var cartItem = FindByFurnitureItem(item);

            if (cartItem != null)
            {
                _cartItems.Remove(cartItem);
            }
        }
예제 #3
0
        public void AddItem(FurnitureItem item)
        {
            var cartItem = FindByFurnitureItem(item);

            if (cartItem != null)
            {
                cartItem.Count++;
            }
            else
            {
                _cartItems.Add(new CartItem {
                    Item = item
                });
            }
        }
예제 #4
0
    public bool PutTile(FurnitureItem item, int spriteSelect)
    {
        Ray ray = MainCamera.ScreenPointToRay(Input.mousePosition);
        // get the collision point of the ray with the z = 0 plane
        Vector3    worldPoint = ray.GetPoint(-ray.origin.z / ray.direction.z);
        Vector3Int CellPosition;

        switch (CheckTileTypeAndPosition(worldPoint, out CellPosition))
        {
        case TileType.FLOOR:
            FurnitureTilemap.SetTile(CellPosition, item.Tiles[spriteSelect]);
            break;

        case TileType.LWALL:
            FurnitureTilemap.SetTile(CellPosition, item.Tiles[spriteSelect]);
            break;

        case TileType.RWALL:
            FurnitureTilemap.SetTile(CellPosition, item.Tiles[spriteSelect]);
            break;
        }
        return(true);
    }
예제 #5
0
        private CartItem FindByFurnitureItem(FurnitureItem item)
        {
            var furnitureItem = _cartItems.FirstOrDefault(x => x.Item.Equals(item));

            return(furnitureItem);
        }
예제 #6
0
    IEnumerator UpdateFurnitureArrangement(FurnitureItem furnitureItem)
    {
        Debug.Log(furnitureItem.Name + "ArrangeMent start");
        Vector3Int CellPosition, PrevCellPosition = new Vector3Int(100, 100, 0);

        while (true)
        {
            Ray ray = MainCamera.ScreenPointToRay(Input.mousePosition);
            // get the collision point of the ray with the z = 0 plane
            Vector3 worldPoint = ray.GetPoint(-ray.origin.z / ray.direction.z);

            TileType PresentTileType = CheckTileTypeAndPosition(worldPoint, out CellPosition);

            switch (furnitureItem.Category)
            {
            case FurnitureItem.ItemCategory.FLOOR_FURNITURE:    //이미 설치되어 있었다면 맨 처음에는 그 위치에 있을 것, 마지막 터치(마우스) 위치를 기준으로 체크 버튼을 누르면 확정 다른 타일과 충돌 처리 해야 함
                if (PresentTileType == TileType.FLOOR)
                {
                    FollowTilemap.SetTile(PrevCellPosition, null);
                    FollowTilemap.SetTile(CellPosition, furnitureItem.Tiles[furnitureItem.MainTileNum]);
                    PrevCellPosition = CellPosition;
                }
                else
                {
                    FollowTilemap.SetTile(PrevCellPosition, furnitureItem.Tiles[furnitureItem.MainTileNum]);
                }
                break;

            case FurnitureItem.ItemCategory.FLOOR_TILE:    //마우스가 지나가는 위치에는 모두 설치 되돌리기 키 없음, 회전 없음 이미 설치된 것 고려하지 않음
                if (PresentTileType == TileType.FLOOR)
                {
                    FloorTilemap.SetTile(CellPosition, furnitureItem.Tiles[0]);
                }
                break;

            case FurnitureItem.ItemCategory.WALL_FURNITURE:    //이미 설치된 것 고려 O,회전 버튼 없음 대신 왼쪽벽 오른쪽벽 감지 후 자동 선택, 회수 버튼은 있음
                if (PresentTileType == TileType.LWALL)
                {
                    FollowTilemap.SetTile(PrevCellPosition, null);
                    FollowTilemap.SetTile(CellPosition, furnitureItem.Tiles[0]);
                    PrevCellPosition = CellPosition;
                }
                else if (PresentTileType == TileType.RWALL)
                {
                    FollowTilemap.SetTile(PrevCellPosition, null);
                    FollowTilemap.SetTile(CellPosition, furnitureItem.Tiles[1]);
                    PrevCellPosition = CellPosition;
                }

                break;

            case FurnitureItem.ItemCategory.WALL_PAPER:    //마우스가 지나가는 위치에 모두 설치 되돌리기 키 없음, 회전 없음, 이미 설치된 것 고려하지 않음, 왼쪽벽 오른쪽벽 감지 후 자동 선택
                if (PresentTileType == TileType.LWALL)
                {
                    WallTilemap.SetTile(CellPosition, furnitureItem.Tiles[0]);
                }
                else if (PresentTileType == TileType.RWALL)
                {
                    WallTilemap.SetTile(CellPosition, furnitureItem.Tiles[1]);
                }
                break;

            default:
                Debug.LogError("없는 타입의 타일입니다");
                break;
            }

            yield return(null);

            if (UpdateFurnitureArrangementBreak)
            {
                Debug.Log("EndArrangement");
                UpdateFurnitureArrangementBreak = false;
                if (furnitureItem.Category == FurnitureItem.ItemCategory.FLOOR_FURNITURE || furnitureItem.Category == FurnitureItem.ItemCategory.WALL_FURNITURE)
                {
                    FurnitureTilemap.SetTile(PrevCellPosition, furnitureItem.Tiles[furnitureItem.MainTileNum]);
                    furnitureItem.position = PrevCellPosition;
                    FollowTilemap.ClearAllTiles();
                }

                break;
            }
        }
    }
예제 #7
0
 public void StartFurnitureArrangement(FurnitureItem furnitureItem)
 {
     presentCoroutine = StartCoroutine(UpdateFurnitureArrangement(furnitureItem));
 }
예제 #8
0
 public void SetElement(FurnitureItem item, GameObject panel)
 {
     this.item       = item;
     thumnail.sprite = item.Tiles[0].sprite;
     this.panel      = panel;
 }
예제 #9
0
    public void OnCreateInWorkStation(List <ItemInfo> materials, int id, int amo)
    {
        foreach (var material in materials)
        {
            MaterialItemManager finditem = null;
            bool isZreo = false;
            foreach (var dataItem in data.CURMATERIALITELIST)
            {
                if (material.ID == dataItem.ITEMINFO.ID)
                {
                    dataItem.ITEMINFO.AMOUNTNUMBER -= material.AMOUNTNUMBER;
                    data.BAGSPACE -= material.AMOUNTNUMBER;
                    if (dataItem.ITEMINFO.AMOUNTNUMBER <= 0)
                    {
                        finditem = dataItem;
                        isZreo   = true;
                    }
                }
            }
            if (isZreo)
            {
                data.CURMATERIALITELIST.Remove(finditem);
            }
        }

        foreach (var workstationItem in workStationItemList)
        {
            bool isHave = false;
            if (workstationItem.ID == id)
            {
                if (workstationItem.SORT != "가구" && workstationItem.SORT != "재료")
                {
                    foreach (var item in data.CURPRODUCTIONITEMLIST)
                    {
                        if (item.ID == workstationItem.ID)
                        {
                            isHave = true;
                            item.ITEMINFO.AMOUNTNUMBER += amo;
                        }
                    }
                    if (!isHave)
                    {
                        Debug.Log("제작물");

                        var temp = new ProductionObjInfo(workstationItem);
                        if (amo >= 2)
                        {
                            temp.ITEMINFO.AMOUNTNUMBER = amo;
                        }
                        data.CURPRODUCTIONITEMLIST.Add(temp);
                    }
                }
                else if (workstationItem.SORT == "가구")
                {
                    foreach (var item in data.CURFURNITUREITEMLIST)
                    {
                        if (item.ITEMINFO.ID == workstationItem.ID)
                        {
                            isHave = true;
                            item.ITEMINFO.AMOUNTNUMBER += amo;
                        }
                    }
                    if (!isHave)
                    {
                        Debug.Log("가구");
                        var temp = new FurnitureItem();
                        temp.Initialization(workstationItem.ITEMINFO);
                        if (amo >= 2)
                        {
                            temp.ITEMINFO.AMOUNTNUMBER = amo;
                        }
                        data.CURFURNITUREITEMLIST.Add(temp);
                    }
                }
                else if (workstationItem.SORT == "재료")
                {
                    foreach (var item in data.CURMATERIALITELIST)
                    {
                        if (item.ITEMINFO.ID == workstationItem.ID)
                        {
                            isHave = transform;
                            item.ITEMINFO.AMOUNTNUMBER += amo;
                        }
                    }
                    if (!isHave)
                    {
                        var temp = new MaterialItemManager();
                        Debug.Log(workstationItem.ITEMINFO.ICON_INDEX);
                        temp.Initialization(workstationItem.ITEMINFO);
                        if (amo >= 2)
                        {
                            temp.ITEMINFO.AMOUNTNUMBER = amo;
                        }
                        data.CURMATERIALITELIST.Add(temp);
                    }
                }
            }
        }
        data.BAGSPACE += amo;
        changeData?.Invoke(data);
    }
예제 #10
0
    // Start is called before the first frame update
    void Start()
    {
        string[,] result = CsvLoader.LoadCsvBy2DimensionArray("Csv/My_Paradise_Shop");

        int[] ElementCnt = { 0, 0, 0, 0 };
        int   select     = 0;

        for (int i = 0; i < result.GetLength(0); ++i)
        {
            if (result[i, 0] == "거실")
            {
                select = 0;
            }
            else if (result[i, 0] == "주방")
            {
                select = 1;
            }
            else if (result[i, 0] == "침실")
            {
                select = 2;
            }
            else if (result[i, 0] == "욕실")
            {
                select = 3;
            }


            if (int.TryParse(result[i, 7], out int s))
            {
                GameObject go = Instantiate(ShopElement, ScrollRect[select].content.transform);
                go.GetComponent <RectTransform>().anchoredPosition = new Vector3(0, -Gap * ElementCnt[select], 0);

                if (Resources.Load("Tile/Furniture/" + result[i, 3]) is Tile)
                {
                    List <Tile> tiles = new List <Tile>();
                    for (int j = 3; j < 7; ++j)
                    {
                        if (Resources.Load("Tile/Furniture/" + result[i, j]) is Tile)
                        {
                            tiles.Add(Resources.Load("Tile/Furniture/" + result[i, j]) as Tile);
                        }
                        else
                        {
                            break;
                        }
                    }
                    go.GetComponent <ShopElement>().SetElement(result[i, 2], s,
                                                               FurnitureItem.StringToItemTheme(result[i, 0]),
                                                               FurnitureItem.StringToItemCategory(result[i, 1]),
                                                               tiles.ToArray());
                }
                else
                {
                    Debug.Log(result[i, 3] + ": Can't loading");
                }
                ++ElementCnt[select];
            }
        }
        for (int i = 0; i < 4; ++i)
        {
            ScrollRect[i].content.GetComponent <RectTransform>().sizeDelta = new Vector2(ScrollRect[i].content.GetComponent <RectTransform>().sizeDelta.x, Gap * ElementCnt[i]);
        }
    }