Пример #1
0
    //角色处于行走状态且玩家按下鼠标左键,设置目标坐标
    public static void mouse_click(Map[] map, Player[] player, Rectangle stage, MouseEventArgs e)
    {
        if (Player.status != Status.WALK)
        {
            return;
        }
        if (e.Button == MouseButtons.Left)
        {
            target_x = e.X - Map.get_map_sx(map, player, stage);
            target_y = e.Y - Map.get_map_sy(map, player, stage);

            flag_start_time = Comm.Time();
        }
        else if (e.Button == MouseButtons.Right)                 //鼠标右键弹出面板
        {
            StatusMenu.show();
            Task.block();
        }
    }
Пример #2
0
    //-----------------------------------------------------------------
    //        操控
    //-----------------------------------------------------------------
    public static void key_ctrl(Player[] player, Map[] map, Npc[] npc, KeyEventArgs e)
    {
        Player p = player[current_player];

        if (Player.status != Status.WALK)
        {
            return;
        }
        //切换角色
        if (e.KeyCode == Keys.Tab)
        {
            key_change_player(player);
        }

        /*       //是否转向                                      //先处理转向在处理行走
         *     if (e.KeyCode == Keys.Up && p.face != 4)
         *         p.face = 4;
         *     else if (e.KeyCode == Keys.Down && p.face != 1)
         *         p.face = 1;
         *     else if (e.KeyCode == Keys.Left && p.face != 2)
         *         p.face = 2;
         *     else if (e.KeyCode == Keys.Right && p.face != 3)
         *         p.face = 3;
         *     //间隔判定
         *     if (Comm.Time() - p.last_walk_time <= p.walk_interval)
         *         return;
         *     //移动处理
         *     if (e.KeyCode == Keys.Up&&Map.can_through(map,p.x,p.y-p.speed))                                   //加上判断目标位置是否可以通行
         *         p.y = p.y - p.speed;
         *     else if (e.KeyCode == Keys.Down && Map.can_through(map, p.x, p.y + p.speed))                                   //行走速度由speed控制
         *         p.y = p.y + p.speed;
         *     else if (e.KeyCode == Keys.Left && Map.can_through(map, p.x - p.speed, p.y))
         *         p.x = p.x - p.speed;
         *     else if (e.KeyCode == Keys.Right && Map.can_through(map, p.x + p.speed, p.y))
         *         p.x = p.x + p.speed;
         *     else return;
         *     //动画帧
         *     p.anm_frame = p.anm_frame + 1;
         *     if (p.anm_frame >= int.MaxValue) p.anm_frame = 0;     //超出上限的处理
         *     //时间
         *     p.last_walk_time = Comm.Time();
         */
        //行走
        if (e.KeyCode == Keys.Up)
        {
            walk(player, map, Comm.Direction.UP);
        }
        else if (e.KeyCode == Keys.Down)
        {
            walk(player, map, Comm.Direction.DOWN);
        }
        else if (e.KeyCode == Keys.Left)
        {
            walk(player, map, Comm.Direction.LEFT);
        }
        else if (e.KeyCode == Keys.Right)
        {
            walk(player, map, Comm.Direction.RIGHT);
        }
        else if (e.KeyCode == Keys.Escape)
        {
            StatusMenu.show();
            Task.block();
        }
        //npc碰撞
        npc_collision(player, map, npc, e);
    }