Пример #1
0
        /// <summary>
        /// 把参数拼接成一条完整的握手消息
        /// </summary>
        /// <param name="type">此处只能为MsgType.Handshake</param>
        /// <param name="name">发送端</param>
        /// <param name="pw">授权码</param>
        /// <param name="ts">时间戳</param>
        /// <returns>完整的握手消息</returns>
        public static string MessageMaker(MsgType type, SendName name, string pw, string ts)
        {
            string accesscode = Md5_32(ts + Md5_32(pw));
            string strOut     = "{\"type\":\"Handshake\", \"name\":\"" + name + "\", \"msg\":\"" + accesscode + "\"}";

            return(strOut);
        }
Пример #2
0
 // sets cursor bool and gameobject to inactive
 void HideCursor()
 {
     SendName?.Invoke("");
     cursorHidden = true;
     CursorHidden?.Invoke();
     mainCursorImage.enabled = false;
 }
Пример #3
0
    // applies horizontal axis rounded to a positive or negative of the move distance
    void MoveHorizontal(float xInput)
    {
        if (cursorHidden == false && cursorCoroutine == null)
        {
            cursorCoroutine = StartCoroutine(CursorDelayRoutine());

            // saves starting position, moves
            Vector3 startingPosition = transform.position;
            Vector3 translation      = new Vector3((xInput > 0 ? 1 : -1) * cursorSearchDistance, 0, 0);
            transform.Translate(translation);

            // calls raycast search to read an object the cursor is over
            bool foundItem = RaycastSearch(startingPosition);

            // if no item was found (meaning it moved horizontally off the item screen, moves it to the top slot in the far row and activates UI graphic
            if (foundItem == false)
            {
                // activates the r and z icons and sets the main cursor to inactive
                if (xInput > 0)
                {
                    menuUIControl.ActivateRIcon();
                }
                else if (xInput < 0)
                {
                    menuUIControl.ActivateZIcon();
                }

                // hides cursor
                moveAudio.Play();
                SendName?.Invoke("");
                HideCursor();
                CursorHidden?.Invoke();
            }
        }
    }
Пример #4
0
    // raycasts the canvas object the cursor is over to determine how the cursor moves
    bool RaycastSearch(Vector3 position)
    {
        // moves pointer event data and fires a graphic raycast
        pointerEventData.position = Camera.main.WorldToScreenPoint(transform.position);
        List <RaycastResult> results = new List <RaycastResult>();

        graphicRaycaster.Raycast(pointerEventData, results);

        // if the raycast hits, saves current item, else returns cursor to starting position
        if (results.Count > 0)
        {
            if (results[0].gameObject.GetComponentInParent <MenuItem>() == true)
            {
                // stores reference to the item function
                currentItem = results[0].gameObject.GetComponentInParent <MenuItem>();

                // transforms cursor directly to the center of the found object, plays respective feedback
                transform.position = new Vector3
                                         (results[0].gameObject.transform.position.x, results[0].gameObject.transform.position.y, transform.position.z);
                moveAudio.Play();
                SendName?.Invoke(currentItem.itemName);
                return(true);
            }
            else if (results[0].gameObject.GetComponentInParent <MenuItem>() == false)
            {
                // returns cursor to previous transform position (effectively, it doesn't move)
                transform.position = position;
                return(false);
            }
        }
        else
        {
            // also reverts cursor position to check errors
            transform.position = position;
            return(false);
        }
        return(false);
    }