示例#1
0
    void ShouBing()
    {
        //var values = Enum.GetValues(typeof(KeyCode));//存储所有的按键
        //for (int x = 0; x < values.Length; x++)
        //{
        //    if (Input.GetKeyDown((KeyCode)values.GetValue(x)))
        //    {
        //        currentButton = values.GetValue(x).ToString();//遍历并获取当前按下的按键
        //        print("手柄按键  " + currentButton);
        //    }
        //}
        //detectPressedKeyOrButton();

        //float hl = Input.GetAxis("Horizontal_L");
        //float vl = Input.GetAxis("Vertical_L");

        //print("  hl "+hl);
        //print("  vl " + vl);



        horizontalDirection = Input.GetAxis(HORIZONTAL);

        verticalDirection = Input.GetAxis(VERTICAL);

        if (horizontalDirection > 0.8 || horizontalDirection < -0.8)
        {
            IsInShoubing = true;
        }

        if (verticalDirection > 0.6)
        {
            IsInShoubing      = true;
            Globals.isKeyUp   = true;
            Globals.isKeyDown = false;
        }
        else if (verticalDirection < -0.6)
        {
            IsInShoubing      = true;
            Globals.isKeyUp   = false;
            Globals.isKeyDown = true;
        }
        else
        {
            if (IsInShoubing)
            {
                Globals.isKeyUp   = false;
                Globals.isKeyDown = false;
            }
        }



        //if (Input.GetKeyDown(KeyCode.Joystick1Button3) && Globals.isKeyUp)
        //{
        //    //if (IsCanControl()) _body.GetSkill1();
        //    //print("技能释放---------   right ");

        //    ObjectEventDispatcher.dispatcher.dispatchEvent(new UEvent(EventTypeName.RELEASE_SKILL, "center"), this);
        //    return;
        //}
        if (Input.GetKeyDown(KeyCode.Joystick1Button3) && Globals.isKeyUp)
        {
            //if (IsCanControl()) _body.GetSkill1();
            //print("技能释放---------  up");
            ObjectEventDispatcher.dispatcher.dispatchEvent(new UEvent(EventTypeName.RELEASE_SKILL, "up"), this);
            return;
        }

        if (Input.GetKeyDown(KeyCode.Joystick1Button3) && Globals.isKeyDown)
        {
            //if (IsCanControl()) _body.GetSkill1();
            //print("技能释放---------  down");
            ObjectEventDispatcher.dispatcher.dispatchEvent(new UEvent(EventTypeName.RELEASE_SKILL, "down"), this);
            return;
        }

        if (Input.GetKeyDown(KeyCode.Joystick1Button3))
        {
            //if (IsCanControl()) _body.GetSkill1();
            //print("技能释放---------   center");
            ObjectEventDispatcher.dispatcher.dispatchEvent(new UEvent(EventTypeName.RELEASE_SKILL, "center"), this);
            return;
        }



        if (IsInShoubing)
        {
            if (horizontalDirection > 0)
            {
                if (IsCanControl())
                {
                    _body.RunRight(horizontalDirection);
                }
            }
            else if (horizontalDirection < 0)
            {
                if (IsCanControl())
                {
                    _body.RunLeft(horizontalDirection);
                }
            }
            else
            {
                if (IsCanControl() && !Globals.isXNBtn)
                {
                    _body.ReSetLR();
                }
            }
        }

        //print("verticalDirection    " + verticalDirection);


        if (Input.GetKeyDown(KeyCode.Joystick1Button5))
        {
            //if (IsCanControl()) _body.GetSkill1();
            //print("技能释放---------   center");
            //ObjectEventDispatcher.dispatcher.dispatchEvent(new UEvent(EventTypeName.RELEASE_SKILL, "center"), this);

            if (IsCanControl())
            {
                _body.Gedang();
            }
            return;
        }


        if (Input.GetKeyDown(KeyCode.Joystick1Button0))
        {
            if (Globals.IsHitPlotKuai)
            {
                return;
            }
            //print(">>>>>>>>>>>???????  JJJJJJJ  Globals.isKeyUp    "+ Globals.isKeyUp);
            if (IsCanControl())
            {
                _body.GetAtk();
            }
        }
        if (Input.GetKeyDown(KeyCode.Joystick1Button1))
        {
            if (IsCanControl())
            {
                _body.GetJump();
            }
        }

        if (Input.GetKeyDown(KeyCode.Joystick1Button2) || Input.GetKeyDown(KeyCode.Joystick1Button7))
        {
            if (IsCanControl())
            {
                _body.GetDodge1();
            }
        }
    }
示例#2
0
    void NewKey()
    {
        //ShouBing();

        if (Input.GetKeyDown(KeyCode.U) && Input.GetKey(KeyCode.D))
        {
            //if (IsCanControl()) _body.GetSkill1();
            //print("技能释放---------   right ");

            ObjectEventDispatcher.dispatcher.dispatchEvent(new UEvent(EventTypeName.RELEASE_SKILL, "center"), this);
            return;
        }
        if (Input.GetKeyDown(KeyCode.U) && Input.GetKey(KeyCode.W))
        {
            //if (IsCanControl()) _body.GetSkill1();
            //print("技能释放---------  up");
            ObjectEventDispatcher.dispatcher.dispatchEvent(new UEvent(EventTypeName.RELEASE_SKILL, "up"), this);
            return;
        }

        if (Input.GetKeyDown(KeyCode.U) && Input.GetKey(KeyCode.S))
        {
            //if (IsCanControl()) _body.GetSkill1();
            //print("技能释放---------  down");
            ObjectEventDispatcher.dispatcher.dispatchEvent(new UEvent(EventTypeName.RELEASE_SKILL, "down"), this);
            return;
        }

        if (Input.GetKeyDown(KeyCode.U))
        {
            //if (IsCanControl()) _body.GetSkill1();
            //print("技能释放---------   center");
            ObjectEventDispatcher.dispatcher.dispatchEvent(new UEvent(EventTypeName.RELEASE_SKILL, "center"), this);
            return;
        }



        if (Input.GetKeyDown(KeyCode.I) && Input.GetKey(KeyCode.W))
        {
            ObjectEventDispatcher.dispatcher.dispatchEvent(new UEvent(EventTypeName.DIU_FEIDAO, "up"), this);
            return;
        }

        if (Input.GetKeyDown(KeyCode.I) && Input.GetKey(KeyCode.S))
        {
            ObjectEventDispatcher.dispatcher.dispatchEvent(new UEvent(EventTypeName.DIU_FEIDAO, "down"), this);
            return;
        }

        if (Input.GetKeyDown(KeyCode.I))
        {
            //print("i");
            ObjectEventDispatcher.dispatcher.dispatchEvent(new UEvent(EventTypeName.DIU_FEIDAO, ""), this);
            return;
        }



        if (Input.GetKeyDown(KeyCode.W))
        {
            //print("   W----upupupupupup!!! ");
            Globals.isKeyUp = true;
        }

        if (Input.GetKeyDown(KeyCode.S))
        {
            Globals.isKeyDown = true;
        }

        if (Input.GetKeyUp(KeyCode.W))
        {
            Globals.isKeyUp = false;
        }

        if (Input.GetKeyUp(KeyCode.S))
        {
            Globals.isKeyDown = false;
        }

        if (Input.GetKeyUp(KeyCode.T))
        {
            _body.GetSit2();
        }

        if (Input.GetKey(KeyCode.A))
        {
            if (IsCanControl())
            {
                _body.RunLeft(-1f);
            }
        }
        else if (Input.GetKey(KeyCode.D))
        {
            if (IsCanControl())
            {
                _body.RunRight(1f);
            }
        }
        else
        {
            if (IsCanControl() && !Globals.isXNBtn)
            {
                _body.ReSetLR();
            }
        }

        /*if (Input.GetKeyUp(KeyCode.A))
         * {
         *  if (IsCanControl() && !Globals.isXNBtn) _body.ReSetLR();
         * }
         *
         * if (Input.GetKeyUp(KeyCode.D))
         * {
         *
         *  if (IsCanControl() && !Globals.isXNBtn) _body.ReSetLR();
         * }*/

        if (Input.GetKeyDown(KeyCode.H))
        {
            //if (IsCanControl()) _body.GetSkill1();
            //print("技能释放---------   center");
            //ObjectEventDispatcher.dispatcher.dispatchEvent(new UEvent(EventTypeName.RELEASE_SKILL, "center"), this);

            if (IsCanControl())
            {
                _body.Gedang();
            }
            return;
        }

        if (Input.GetKeyDown(KeyCode.J))
        {
            if (Globals.IsHitPlotKuai)
            {
                return;
            }
            //print(">>>>>>>>>>>???????  JJJJJJJ  Globals.isKeyUp    "+ Globals.isKeyUp);
            if (IsCanControl())
            {
                _body.GetAtk();
            }
        }
        if (Input.GetKeyDown(KeyCode.K))
        {
            if (IsCanControl())
            {
                _body.GetJump();
            }
        }

        if (Input.GetKeyDown(KeyCode.U))
        {
            //if (IsCanControl()) _body.GetSkill1();
        }

        if (Input.GetKeyDown(KeyCode.I))
        {
            if (IsCanControl())
            {
                _body.GetSkill2();
            }
        }

        if (Input.GetKeyDown(KeyCode.L))
        {
            if (IsCanControl())
            {
                _body.GetDodge1();
            }
        }
    }