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); }
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); }
private void AddItemToCell(Transform cell, LevelPiece.ItemType itemType, float rotation) { Transform itemView = CreatViewForItemType(itemType); itemView.Rotate(0, 0, rotation); itemView.transform.SetParent(cell, false); }
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); }); }
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); }