Exemple #1
0
    // Update is called once per frame
    protected override void Updates()
    {
        //用来响应按键
        bool J   = Input.GetKeyDown(KeyCode.J); //攻击
        bool K   = Input.GetKeyDown(KeyCode.K); //跳跃
        bool L   = Input.GetKeyDown(KeyCode.L); //冲刺
        bool A   = Input.GetKey(KeyCode.A);
        bool D   = Input.GetKey(KeyCode.D);
        bool Kup = Input.GetKeyUp(KeyCode.K);

        if (GetStatenum() < 2)//检查能否回气
        {
            health.setrecoverqi(true);
        }
        else
        {
            health.setrecoverqi(false);
        }

        if (A)
        {
            moves.moveleft();
        }

        if (D)
        {
            moves.moveright();
        }

        if (J)
        {
            attack.doattack("hack", 0.1700f, 0);
        }

        if (K)
        {
            jump.jump();
        }

        if (Kup)
        {
            jump.stopjump();
        }

        if (L)
        {
            if (move.isground())
            {
                dash.dash();
            }
        }
    }
Exemple #2
0
 public void jump()//跳跃消耗和速度
 {
     if (contral.GetStatenum() <= 2 && move.isground() && health.cando())
     {
         move.AddSpeed(0, jumpspeed);
         health.consumeqi(consume);
         health.setrecoverqi(false);
         jumping = true;
     }
 }
Exemple #3
0
    // Update is called once per frame
    protected override void Updates()
    {
        //用来响应按键
        float inputX = Input.GetAxis("Horizontal"); //让input的左右定义为a和s,
        bool  J      = Input.GetKeyDown(KeyCode.J); //攻击
        bool  K      = Input.GetKeyDown(KeyCode.K); //跳跃
        bool  L      = Input.GetKeyDown(KeyCode.L); //冲刺
        bool  A      = Input.GetKey(KeyCode.A);
        bool  D      = Input.GetKey(KeyCode.D);
        bool  Kup    = Input.GetKeyUp(KeyCode.K);

        if (A && D)
        {
            Setstatenum(0);
        }
        else if (A)//输入为左,即为负
        {
            if (GetStatenum() <= 1)
            {
                move.Turn(false); //向左转向 ,即为负  角色向左走
                Setstatenum(1);   //如果不是移动状态设置为移动状态
            }
            if (GetStatenum() <= 2)
            {
                move.moves(false);//如果不是技能状态,就可以移动    但是此状态下无法转向
            }
        }
        else if (D)//输入为右,即为正  角色向右走
        {
            if (GetStatenum() <= 1)
            {
                move.Turn(true); //向右转向
                Setstatenum(1);  //如果不是移动状态设置为移动状态
            }
            if (GetStatenum() <= 2)
            {
                move.moves(true);//如果不是技能状态,就可以移动    但是此状态下无法转向
            }
        }
        else //停止状态
        {
            Setstatenum(0);
        }

        if (J)
        {
            if (GetStatenum() <= 2)
            {
                if (health.cando(3))
                {
                    doit("hack", canAttack(0), 0.1700f);
                }
            }
        }

        if (K)
        {
            if (GetStatenum() <= 2 && move.isground() && health.cando(4))
            {
                move.AddSpeed(0, jumphigh);
                health.consumeqi(4);
            }
        }

        if (Kup && move.rispeed().y > 0.0001f && move.rispeed().y < jumphigh)
        {
            move.setY(0);
        }


        if (L)
        {
            if (move.isground())
            {
                dash.dash(this);
            }
        }


        if (GetStatenum() < 2)
        {
            health.setrecoverqi(true);
        }
        else
        {
            health.setrecoverqi(false);
        }
    }