예제 #1
0
    private void SwapFunctionality(BoardSpaceStruct space, ICard card)
    {
        //attempting to swap with empty space
        if (card == null)
        {
            return;
        }
        //check for same space swap
        if (SelectedSpace.x == space.x && SelectedSpace.y == space.y)
        {
            return;
        }

        else
        {
            //Checks for valid swap
            if (manager.gameModel.canSwap(SelectedSpace.x, SelectedSpace.y, space.x, space.y))
            {
                manager.gameModel.SwapCards(0, SelectedSpace.x, SelectedSpace.y, space.x, space.y);
                manager.updateBoard();
                SelectedSpace.setOutlineColor(0);
                movemade      = new GameMove(SelectedSpace.x, SelectedSpace.y, space.x, space.y);
                SelectedSpace = null;
                FindObjectOfType <buttonManager>().Deselect();
                swapflag = false;
                manager.switchState();
            }
        }
    }
예제 #2
0
    public void SelectSpaceFunctionality(BoardSpaceStruct space, ICard card)
    {
        bool deselected = false;

        if (SelectedSpace != null)
        {
            SelectedSpace.setOutlineColor(0);

            //Deselect selected space
            if (SelectedSpace.x == space.x && space.y == SelectedSpace.y)
            {
                SelectedSpace = null;
                deselected    = true;
                onSpaceDeselect(space, manager.gameModel);
            }
        }

        if (!deselected)
        {
            SelectedSpace = space;
            space.setOutlineColor(1);
            if (SelectedCard != null)
            {
                SelectedCard.setOutlineColor(0);
                SelectedCard = null;
            }
            onSpaceSelect(SelectedSpace, manager.gameModel);
        }
    }
예제 #3
0
    public void SelectHandFunctionality(HandCardStruct cardspace)
    {
        bool deselected = false;

        cardspace.setOutlineColor(1);

        if (SelectedCard != null)
        {
            SelectedCard.setOutlineColor(0);

            if (SelectedCard.pos == cardspace.pos)
            {
                SelectedCard = null;
                deselected   = true;
            }
        }

        if (!deselected)
        {
            SelectedCard = cardspace;
            cardspace.setOutlineColor(1);
            if (SelectedSpace != null)
            {
                SelectedSpace.setOutlineColor(0);
                SelectedSpace = null;
                FindObjectOfType <buttonManager>().Deselect();
            }
        }
    }
예제 #4
0
 // Use this for initialization
 void Awake()
 {
     manager       = FindObjectOfType <ModelManager>();
     SelectedSpace = null;
     SelectedCard  = null;
     movemade      = null;
     swapflag      = false;
 }
예제 #5
0
    private IEnumerator displayOutline(BoardSpaceStruct s, float time)
    {
        s.setOutlineColor(2);

        yield return(new WaitForSeconds(time));

        s.setOutlineColor(0);
    }
예제 #6
0
    public void onSelect(BoardSpaceStruct space, IGame model)
    {
        peekButton.SetActive(false);
        swapButton.SetActive(true);

        if (model.canRemove(0, space.x, space.y))
        {
            removeButton.SetActive(true);
        }

        if (!space.isFaceup())
        {
            peekButton.SetActive(true);
        }
    }
예제 #7
0
 public void CancelActions()
 {
     swapflag = false;
     if (SelectedSpace != null)
     {
         SelectedSpace.setOutlineColor(0);
     }
     if (SelectedCard != null)
     {
         SelectedCard.setOutlineColor(0);
     }
     SelectedSpace = null;
     SelectedCard  = null;
     FindObjectOfType <buttonManager>().Deselect();
 }
예제 #8
0
    //Gets all the board spaces at this row
    public BoardSpaceStruct[] GetCardSet()
    {
        var ret = new BoardSpaceStruct[5];

        switch (direction)
        {
        case Direction.Row:
        {
            ret = (from x in FindObjectsOfType <BoardSpaceStruct>() where x.y == this.depthnumber select x).ToArray();
            break;
        }

        case Direction.Column:
        {
            ret = (from x in FindObjectsOfType <BoardSpaceStruct>() where x.x == this.depthnumber select x).ToArray();
            break;
        }

        case Direction.Diagonal:
        {
            if (depthnumber == 0)
            {
                ret = (from x in FindObjectsOfType <BoardSpaceStruct>() where x.x == x.y select x).ToArray();
            }
            else if (depthnumber == 1)
            {
                ret = (from x in FindObjectsOfType <BoardSpaceStruct>() where x.x + x.y == ret.Length - 1 select x).ToArray();
            }
            else
            {
                throw new System.Exception("Yo dawg what are you doin");
            }
            break;
        }
        }
        return(ret);
    }
예제 #9
0
 public void onDeselect(BoardSpaceStruct space, IGame model)
 {
     Deselect();
 }