Example #1
0
    private void UpdateMouseHover()
    {
        if (GameManager.Instance.GameState != GameManager.GameStates.Playing)
        {
            if (currentMouseHoverBox)
            {
                currentMouseHoverBox.PoolRecycle();
            }
            lastFocusPos = null;
            return;
        }

        int[] pos = getClickPosition();
        if (lastFocusPos != null && pos != null && lastFocusPos[0] == pos[0] && lastFocusPos[1] == pos[1])
        {
            return;
        }
        else
        {
            if (pos != null)
            {
                lastFocusPos = pos;
                if (currentMouseHoverBox)
                {
                    currentMouseHoverBox.PoolRecycle();
                }
                currentMouseHoverBox = GameObjectPoolManager.Instance.Pool_MouseHoverBoxPool[turn].AllocateGameObject <MouseHoverBox>(transform);
                currentMouseHoverBox.transform.position = new Vector3((pos[0] - 3) * 1.5f, (pos[1] - 3) * 1.5f, -0.5f);
            }
        }
    }
Example #2
0
 private void UpdateMouseHover()
 {
     int[] pos = getClickPosition();
     if (lastFocusPos != null && pos != null && lastFocusPos[0] == pos[0] && lastFocusPos[1] == pos[1])
     {
         return;
     }
     else
     {
         if (pos != null)
         {
             lastFocusPos = pos;
             if (CurrentMouseHoverBox)
             {
                 CurrentMouseHoverBox.PoolRecycle();
             }
             CurrentMouseHoverBox = GameObjectPoolManager.Instance.PoolDict[GameObjectPoolManager.PrefabNames.MouseHoverBox].AllocateGameObject <MouseHoverBox>(ChessBoard);
             ((RectTransform)(CurrentMouseHoverBox.transform)).anchoredPosition = GetPiecePosByXY(pos);
             CurrentMouseHoverBox.ChangeColor(CurrentPlayerColor);
             ((RectTransform)(CurrentMouseHoverBox.transform)).sizeDelta = new Vector2(CellSize, CellSize);
         }
     }
 }