Beispiel #1
0
    private static void initializeFloor()
    /* Create the grid of floor squares. */
    {
        // Create the grid.
        foreach (int xIdx in Enumerable.Range(0, numGridSquaresWide))
        {
            foreach (int yIdx in Enumerable.Range(0, numGridSquaresDeep))
            {
                Vector2 gridIndices = new Vector2(xIdx, yIdx);
                bool    isSacred    = yIdx == 0;
                PrefabInstantiator.P.CreateFloorSquare(gridIndices, isSacred: isSacred);
            }
        }

        // Stain all but the starting unstained rows, 1 extra turn of stain per row you move back.
        foreach (int xIdx in Enumerable.Range(0, numGridSquaresWide))
        {
            foreach (int yIdx in Enumerable.Range(0, numGridSquaresDeep - startingUnstainedRows))
            {
                Vector2     gridIndices = new Vector2(xIdx, yIdx);
                FloorSquare floorSquare = floorSquaresMap[gridIndices];
                int         stainTurns  = numGridSquaresDeep - startingUnstainedRows - yIdx;
                floorSquare.addStainTurns(stainTurns);
            }
        }
    }
    public override int getCostToPlay()

    /* Use this card's normal cost, except double it if any of the squares it will be on are
     *  stained.
     *
     * See getCostToPlay on base class Card.
     */
    {
        Vector2 mouseDownSquare = (Vector2)TrialLogic.mouseDownGridIndices;
        Vector2 mouseUpSquare   = (Vector2)TrialLogic.mouseUpGridIndices;

        int costToPlace = iumCost;

        foreach (Vector2 square in getSquaresToPlaceOn(mouseDownSquare, mouseUpSquare))
        {
            if (TrialLogic.floorSquaresMap.ContainsKey(square))
            {
                FloorSquare floorSquare = TrialLogic.floorSquaresMap[square];
                if (floorSquare.isStained())
                {
                    costToPlace *= 2;
                    break;
                }
            }
        }

        return(costToPlace);
    }
    public override void cardAction()
    /* See cardAction on base class Card. */
    {
        Vector2     gridIndices = (Vector2)TrialLogic.mouseDownGridIndices;
        FloorSquare floorSquare = TrialLogic.floorSquaresMap[gridIndices];

        floorSquare.addStainTurns(-floorSquare.numTurnsStained);
    }
Beispiel #4
0
    public void destroy()
    /* Remove this Block from the grid, applying any onDestroy effects. */
    {
        // If this Block has any onDestroy effects, run them.
        if (blockType == BlockType.RED)
        {
            destroyNeighboringMass();
        }

        FloorSquare floorSquare = TrialLogic.floorSquaresMap[gridIndices];

        floorSquare.addStainTurns(1);

        TrialLogic.placedBlocks.Remove(gridIndices);

        EventLog.LogEvent($"Was destroyed at {gridIndices}.");

        Destroy(gameObject);
    }
Beispiel #5
0
    public override int getCostToPlay()

    /* Use this card's normal cost, except double it if the targeted square is stained.
     *
     * See getCostToPlay on base class Card.
     */
    {
        int costToPlace = iumCost;

        Vector2     gridIndices = (Vector2)TrialLogic.mouseDownGridIndices;
        FloorSquare floorSquare = TrialLogic.floorSquaresMap[gridIndices];

        if (floorSquare.isStained())
        {
            costToPlace *= 2;
        }

        return(costToPlace);
    }
    /* 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);
    }
Beispiel #7
0
    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);
    }
Beispiel #10
0
    void OnMouseUp()
    {
        if (TrialLogic.isGameplayUserInputsFrozen)
        {
            return;
        }

        // Store which square was clicked up on.
        TrialLogic.mouseUpGridIndices = null;
        Ray        ray = Camera.main.ScreenPointToRay(Input.mousePosition);
        RaycastHit hit;

        if (Physics.Raycast(ray, out hit))
        {
            FloorSquare floorSquare = hit.transform.gameObject.GetComponent <FloorSquare>();
            Block       block       = hit.transform.gameObject.GetComponent <Block>();
            if (floorSquare != null)
            {
                TrialLogic.mouseUpGridIndices = floorSquare.gridIndices;
            }
            else if (block != null)
            {
                TrialLogic.mouseUpGridIndices = block.gridIndices;
            }
        }

        if (String.IsNullOrEmpty(TrialLogic.selectedCardId))
        {
            return;
        }
        Card selectedCard = TrialLogic.trialDeck[TrialLogic.selectedCardId].card;

        selectedCard.playCard();

        TrialLogic.mouseDownGridIndices = null;
        TrialLogic.mouseUpGridIndices   = null;
    }