예제 #1
0
파일: Tile.cs 프로젝트: euming/FotP
    public Tile myOriginal;     //  when we clone, we want to keep track of the original.

    //	figure out which slot I should be in, and put myself there.
    void AutoAssignToSlot()
    {
        GameState gs = GameState.GetCurrentGameState();
        TileShop  ts = gs.tileShop;

        //	am I already in a valid slot? if so, bail
        if (mySlot != null)             //	we already are in a slot
        //	is this the slot that we are supposed to be in anyway?
        {
            if (isValidSlot(mySlot))
            {
                //	if so, then don't do anything else because we have already successfully "autoassigned" to this slot
                return;
            }
            mySlot.removeChild(this.gameObject);                //	remove this from the slot
        }

        //	first get the bar according to the shop Row index
        Bar bar = ts.barList[shopRow];

        foreach (int colIdx in shopCol)
        {
            BarSlot slot = bar.barSlotList[colIdx];
            if (slot.isEmpty())
            {
                slot.addChild(this.gameObject);
                break;  //	we're done
            }
        }
    }
예제 #2
0
파일: Tile.cs 프로젝트: euming/FotP
    //	see if this slot is one of the valid slots we have designated in the Unity data properties.
    public bool isValidSlot(BarSlot testSlot)
    {
        GameState gs = GameState.GetCurrentGameState();
        TileShop  ts = gs.tileShop;

        Bar bar = ts.barList[shopRow];

        foreach (int colIdx in shopCol)
        {
            BarSlot slot = bar.barSlotList[colIdx];
            if (slot == testSlot)
            {
                return(true);
            }
        }
        return(false);
    }