Beispiel #1
0
    /// <summary>
    /// called when we want to add something to a cell
    /// (add a image on top of a cell)
    /// </summary>
    private void AddToCell(int x, int y, ushort id, bool duplicate = true)
    {
        CellsBehaviour _cell = GridManager.Instance.GetCell(x, y);

        if (!duplicate && _cell.OtherWithSameId(id))
        {
            return;
        }

        /*
         * InsideCell inside = new InsideCell
         * {
         *  cell = _cell.transform,
         *  posCell = new Point(x, y),
         * };
         * insideCellList.Add(inside);
         */

        GameObject newCell = Instantiate(prefabsCellInside, Vector3.zero, Quaternion.identity, _cell.GetParentCell());

        newCell.GetComponent <RectTransform>().ResetPos();
        newCell.GetComponent <RectTransform>().ResetScale();
        newCell.SetActive(true);

        _cell.AddToCell(newCell, x, y, id);
    }
Beispiel #2
0
    /// <summary>
    /// the player clic on this case
    /// </summary>
    public void ClickOnCase(int x, int y, bool fromClick = true, bool fromEndRound = false)
    {
        if (played && x == lastClicked.x && y == lastClicked.y)
        {
            if (!clickedOnce)
            {
                clickedOnce = true;
                ClickButDoHover(x, y);
                return;
            }

            if (IsAlreadyClicked(x, y))
            {
                Debug.Log("here we have already clicked on that one !");
                return;
            }



            Debug.Log("we click on the same !!!!");
            GridManager.Instance.ClearListLast();

            GridManager.Instance.SetSpells(this, GetSpellSelected().spellType, GetSpellSelected().levelSpell, x, y, 0);   //0 = definitif
            GridManager.Instance.ClearListLast(true);

            GameLoop.Instance.cursor.AddToCell(x, y, "PlayerClicked");

            CellsBehaviour _cell = GridManager.Instance.GetCell(x, y);
            _cell.isClicked = true;



            //finish round only if not already finished
            if (!fromEndRound)
            {
                GameLoop.Instance.FinishRound();
            }
            return;
        }

        if (!GridManager.Instance.IsSameTypeCellAndPlayer(x, y, GetRealIndexNumber(0)))
        {
            //if we have clicked one time, don't reset !!
            //only if we are on over
            if (clickedOnce && !fromClick)
            {
                return;
            }

            //Debug.Log("can't click !! here reset last move");

            GridManager.Instance.ClearListLast();
            lastClicked = new Point(-1, -1);
            clickedOnce = false;
            return;
        }
        clickedOnce = false;

        ClickButDoHover(x, y);
    }
Beispiel #3
0
    /// <summary>
    /// here fill a case, and update his UI
    /// </summary>
    /// <param name="x"></param>
    /// <param name="y"></param>
    /// <param name="data"></param>
    public void FillCase(int x, int y, ushort data)
    {
        gridData[x, y] = data;
        CellsBehaviour cellBehave = GetCell(x, y);

        cellBehave.Init(x, y, GridDatas.Instance.GetCellsByData(data));
    }
Beispiel #4
0
    public void OverCase(CellsBehaviour cell, bool hover)
    {
        if (hover)
        {
            posOfCursors.ActiveAllChild(false);

            //Debug.Log("change scale");
            cursors[indexCursor].obj.transform.SetParent(cell.GetParentCell());
            cursors[indexCursor].obj.GetComponent <RectTransform>().ResetPos();
            cursors[indexCursor].obj.GetComponent <RectTransform>().ResetScale();
            cursors[indexCursor].obj.SetActive(true);
        }
        else
        {
            cursors[indexCursor].obj.SetActive(false);
            cursors[indexCursor].obj.transform.SetParent(posOfCursors);
        }
    }
Beispiel #5
0
    /// <summary>
    /// called to delete something inside a cell
    /// </summary>
    private void DeleteCell(int x, int y, ushort id, bool all = false)
    {
        CellsBehaviour _cell = GridManager.Instance.GetCell(x, y);

        _cell.DeleteToCell(x, y, id, all);


        /*
         *
         *
         * InsideCell inside = new InsideCell
         * {
         *  cell = _cell.transform,
         *  posCell = new Point(x, y),
         * };
         * insideCellList.Remove(inside);
         */
    }
Beispiel #6
0
    public void DeleteAllInCell(int x, int y)
    {
        CellsBehaviour _cell = GridManager.Instance.GetCell(x, y);

        _cell.DeleteAllInCell(x, y);
    }
Beispiel #7
0
    /// <summary>
    /// the player is over this case
    /// </summary>
    public void HoverCase(int x, int y, CellsBehaviour cell, bool hover)
    {
        //Debug.Log("[editor] over " + x + ", " + y);

        GameLoop.Instance.cursor.OverCase(cell, hover);
    }
Beispiel #8
0
 /// <summary>
 /// the player is over this case
 /// </summary>
 public void HoverCase(int x, int y, CellsBehaviour cell, bool hover)
 {
     cursor.OverCase(cell, hover);
     currentPlayingPlayer.HoverCase(x, y, hover);
 }
Beispiel #9
0
    /// <summary>
    /// here if we already clicked here, do nothing
    /// </summary>
    private bool IsAlreadyClicked(int x, int y)
    {
        CellsBehaviour _cell = GridManager.Instance.GetCell(x, y);

        return(_cell.isClicked);
    }