/* PUBLIC API */ public GameObject CreateBlock(BlockType blockType, Vector2 gridIndices) /* Create a Block. * * :param BlockType blockType: One of [ "mass", "blue", "yellow", "red" ] * :param Vector2 gridIndices: The square in which to put the block ((0, 0) is the bottom-left). * * :returns GameObject blockObj: */ { Vector3 position = FloorSquare.getGridSquareCenter(gridIndices); GameObject blockObj = Instantiate(blockPrefab, position, Quaternion.identity); Block block = blockObj.GetComponent <Block>(); block.blockType = blockType; block.gridIndices = gridIndices; return(blockObj); }
public void shift(Vector2 newGridIndices) /* Move this block to a new square. * * :param Vector2 newGridIndices: */ { // Reposition this block visually. Vector3 currentPosition = transform.position; Vector3 newPosition = FloorSquare.getGridSquareCenter(newGridIndices); newPosition.y = currentPosition.y; transform.position = newPosition; // Update the trial's knowledge of this block's placement. TrialLogic.placedBlocks[newGridIndices] = TrialLogic.placedBlocks[gridIndices]; TrialLogic.placedBlocks.Remove(gridIndices); // Reset this block's stored grid indices. gridIndices = newGridIndices; }
public GameObject CreateFloorSquare(Vector2 gridIndices, bool isSacred = false) /* Create a FloorSquare. * * :param Vector2 gridIndices: Which square of the grid this object is ((0, 0) is the bottom-left). * * :returns GameObject floorSquareObj: */ { Vector3 position = FloorSquare.getGridSquareCenter(gridIndices); GameObject floorSquareObj = Instantiate(floorSquarePrefab, position, Quaternion.identity); FloorSquare floorSquare = floorSquareObj.GetComponent <FloorSquare>(); floorSquare.gridIndices = gridIndices; floorSquare.isSacred = isSacred; floorSquare.numTurnsStained = 0; TrialLogic.floorSquaresMap[gridIndices] = floorSquare; return(floorSquareObj); }
public GameObject CreatePointer(Vector2 gridIndices, string text = null) /* Create a Pointer. * * :param Vector2 gridIndices: The square over which to point the pointer ((0, 0) is the * bottom-left). * * :returns GameObject pointerObj: */ { Vector3 position = FloorSquare.getGridSquareCenter(gridIndices); position.y = 1; GameObject pointerObj = Instantiate(pointerPrefab, position, Quaternion.identity); Pointer pointer = pointerObj.GetComponent <Pointer>(); pointer.text = text; return(pointerObj); }