Exemplo n.º 1
0
    // Update is called once per frame
    void Update()
    {
        if (DraggableObject.IsPlayerDraggingObject() && selected == this)
        {
            OnRelease();
            selected = null;
        }
        x = tile.x;
        y = tile.y;

        // This is ugly but it will work for now!
        if (selected != this)
        {
            Unmark();
            if (selected != null)
            {
                selected.MarkNeighbors(new Color(0, 1, 0));
            }
        }
        else
        {
            if (IsTileOccupated(tile))
            {
                OnRelease();
                selected = null;
            }
        }
    }
Exemplo n.º 2
0
    void OnMouseOver()
    {
        if (PauseMenu.PAUSED)
        {
            return;
        }
        if (!Game.BOARD.Contains(tile))
        {
            return;
        }
        if (DraggableObject.IsPlayerDraggingObject())
        {
            return;
        }
        if (IsTileOccupated(tile))
        {
            return;
        }

        if (btnSelect.Check() == InputStates.InputState.JustPressed)
        {
            if (selected == null)
            {
                OnSelect();
                selected = this;
            }
            else if (selected != this)
            {
                if ((Math.Abs((int)selected.x - (int)x) == 1 && selected.y == y) || (Math.Abs((int)selected.y - (int)y) == 1 && selected.x == x))
                {
                    if (!IsTileOccupated(selected.tile))
                    {
                        //Debug.Log("§§-§§");
                        //Debug.Log("> T1: " + new Vector2(x, y));
                        //Debug.Log("> T2: " + new Vector2(selected.x, selected.y));
                        GameBoard.GAME_BOARD.AddTile(selected.tile, x, y);
                        GameBoard.GAME_BOARD.AddTile(tile, selected.x, selected.y);
                        GameBoard.GAME_BOARD.Build();
                        selected.OnRelease();
                        OnRelease();
                        selected = null;
                    }
                }
                else
                {
                    selected.OnRelease();
                    OnSelect();
                    selected = this;
                }
            }
            else
            {
                OnRelease();
                selected = null;
            }
        }
    }