Unity之快捷键组合

#region 快捷键

    bool isDown = false;
    KeyCode currentKey;
    void Update()
    {
        // 普通奖
        if (Input.GetKey(KeyCode.LeftControl) && Input.GetKey(KeyCode.Keypad0))
        {
            if (isDown)
                return;
            isDown = true;
            Debug.LogError("CTRL + 0 普通奖");
        }

        //幸运送次数 幸运座位,在正常中奖的前提下,多送1--11个动物 (恭喜发财)
        if (Input.GetKey(KeyCode.LeftControl) && Input.GetKey(KeyCode.Keypad1))
        {
            if (isDown)
                return;
            isDown = true;
            Debug.LogError("CTRL + 1 幸运送次数");
        }

        //送颜色(同颜色中奖)
        if (Input.GetKey(KeyCode.LeftControl) && Input.GetKey(KeyCode.Keypad2))
        {
            if (isDown)
                return;
            isDown = true;
            Debug.LogError("CTRL + 2 送颜色");
        }
        //送动物(同动物中奖)
        if (Input.GetKey(KeyCode.LeftControl) && Input.GetKey(KeyCode.Keypad3))
        {
            if (isDown)
                return;
            isDown = true;
            Debug.LogError("CTRL + 3 送动物");
        }
        //送彩金
        if (Input.GetKey(KeyCode.LeftControl) && Input.GetKey(KeyCode.Keypad4))
        {
            if (isDown)
                return;
            isDown = true;
            Debug.LogError("CTRL + 4 送彩金");
        }
        //幸运彩金
        if (Input.GetKey(KeyCode.LeftControl) && Input.GetKey(KeyCode.Keypad5))
        {
            if (isDown)
                return;
            isDown = true;
            Debug.LogError("CTRL + 5 幸运彩金");
        }

        //幸运送颜色
        if (Input.GetKey(KeyCode.LeftControl) && Input.GetKey(KeyCode.Keypad6))
        {
            if (isDown)
                return;
            isDown = true;
            Debug.LogError("CTRL + 6 幸运送颜色");
        }
        //幸运送动物
        if (Input.GetKey(KeyCode.LeftControl) && Input.GetKey(KeyCode.Keypad7))
        {
            if (isDown)
                return;
            isDown = true;
            Debug.LogError("CTRL + 7 幸运送动物");
        }
        //幸运大满贯
        if (Input.GetKey(KeyCode.LeftControl) && Input.GetKey(KeyCode.Keypad8))
        {
            if (isDown)
                return;
            isDown = true;
            Debug.LogError("CTRL + 8 幸运大满贯");
        }

        //棒棒糖(送灯)
        if (Input.GetKey(KeyCode.LeftControl) && Input.GetKey(KeyCode.Keypad9))
        {
            if (isDown)
                return;
            isDown = true;
            Debug.LogError("CTRL + 9 棒棒糖(送灯)");
        }

        //超级大乐透
        if (Input.GetKey(KeyCode.LeftAlt) && Input.GetKey(KeyCode.Keypad0))
        {
            if (isDown)
                return;
            isDown = true;
            Debug.LogError("ALt + 0 棒棒糖(送灯)");
        }

        //抬起键
        if (Input.GetKeyUp(KeyCode.LeftControl) || Input.GetKeyUp(KeyCode.RightControl) || Input.GetKeyUp(KeyCode.LeftAlt)) {
            isDown = false;
            Debug.LogError("抬起");
        }

    }
        #endregion

发布了70 篇原创文章 · 获赞 68 · 访问量 10万+

猜你喜欢

转载自blog.csdn.net/Rose_Girls/article/details/51638959
今日推荐