Ejemplo n.º 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();
            }
        }
    }
Ejemplo n.º 2
0
 void GetJump()
 {
     playerObj.GetJump();
 }
Ejemplo n.º 3
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)
        {
            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 (verticalDirection > 0.6)
        {
            Globals.isKeyUp   = true;
            Globals.isKeyDown = false;
        }
        else if (verticalDirection < -0.6)
        {
            Globals.isKeyUp   = false;
            Globals.isKeyDown = true;
        }
        else
        {
            Globals.isKeyUp   = false;
            Globals.isKeyDown = false;
        }



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

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

        //if (Input.GetKeyDown("Joystick1Button3"))
        //{
        //    if (IsCanControl()) _body.GetSkill2();
        //}

        //if (Input.GetKeyDown("Joystick1Button2"))
        //{
        //    if (IsCanControl()) _body.GetDodge1();
        //}



        //Debug.Log("手柄按钮控制!!");

        if (currentButton == "Joystick1Button0" || currentButton == "JoystickButton0")
        {
            //Debug.Log("Joystick1Button0 !!!!! ");
            if (Globals.IsHitPlotKuai)
            {
                return;
            }
            if (IsCanControl())
            {
                _body.GetAtk();
            }
            currentButton = "";
        }

        if (currentButton == "Joystick1Button1")
        {
            if (IsCanControl())
            {
                _body.GetJump();
            }
            currentButton = "";
        }

        if (currentButton == "Joystick1Button2")
        {
            if (IsCanControl())
            {
                _body.GetDodge1();
            }
            currentButton = "";
        }

        if (currentButton == "Joystick1Button3")
        {
            currentButton = "";
        }
    }