Пример #1
0
        private Object GetItemSource(LevelPiece.ItemType type)
        {
            GameObject result;

            switch (type)
            {
            case LevelPiece.ItemType.Rock:
                result = rockSource;
                break;

            case LevelPiece.ItemType.Coin:
                result = coinSource;
                break;

            case LevelPiece.ItemType.AccelerationWall:
                result = accWallSource;
                break;

            case LevelPiece.ItemType.Monster:
                result = monsterSource;
                break;

            case LevelPiece.ItemType.Saw:
                result = sawSource;
                break;

            default:
                result = new GameObject();
                break;
            }
            return(result);
        }
Пример #2
0
        private Transform CreatViewForItemType(LevelPiece.ItemType itemType)
        {
            switch (itemType)
            {
            case LevelPiece.ItemType.Rock:
                return(Instantiate(rockExample).transform);

                break;

            case LevelPiece.ItemType.Coin:
                return(Instantiate(coinExample).transform);

                break;

            case LevelPiece.ItemType.Saw:
                return(Instantiate(sawExample).transform);

                break;

            case LevelPiece.ItemType.Monster:
                return(Instantiate(monsterExample).transform);

                break;

            case LevelPiece.ItemType.AccelerationWall:
                return(Instantiate(accWallExample).transform);

                break;
            }
            return(Instantiate(rockExample).transform);
        }
Пример #3
0
        private void AddItemToCell(Transform cell, LevelPiece.ItemType itemType, float rotation)
        {
            Transform itemView = CreatViewForItemType(itemType);

            itemView.Rotate(0, 0, rotation);
            itemView.transform.SetParent(cell, false);
        }
Пример #4
0
        private void AddItemToListByType(LevelPiece.ItemType type)
        {
            GameObject cell = Instantiate(cellExample, cellExample.transform.position, cellExample.transform.rotation);

            cell.transform.SetParent(itemsList, false);
            CreatViewForItemType(type).SetParent(cell.transform, false);
            cell.GetComponent <Button>().onClick.AddListener(delegate
            {
                AddItemToGrid(type);
            });
        }
Пример #5
0
        private void AddItemToGrid(LevelPiece.ItemType type)
        {
            int x = GetSelectedX();
            int y = GetSelectedY();

            if (data.HasItemOfTypeAt(type, x, y))
            {
                return;
            }

            LevelPiece.Item newItem = new LevelPiece.Item();
            newItem.rotation = 0;
            newItem.type     = type;
            newItem.x        = x;
            newItem.y        = y;
            data.Add(newItem);

            AddItemToCell(currentCell, type, newItem.rotation);
        }