//走一步 public void walk(Map[] map, Comm.Direction direction, bool isblock) { //转向 face = direction; //间隔判定 if (Comm.Time() - last_walk_time <= walk_interval) { return; } //行走 //up if (direction == Comm.Direction.UP && (!isblock || Map.can_through(map, x, y - speed))) { y = y - speed; } //down else if (direction == Comm.Direction.DOWN && (!isblock || Map.can_through(map, x, y + speed))) { y = y + speed; } //right else if (direction == Comm.Direction.LEFT && (!isblock || Map.can_through(map, x - speed, y))) { x = x - speed; } //left else if (direction == Comm.Direction.RIGHT && (!isblock || Map.can_through(map, x + speed, y))) { x = x + speed; } //动画帧 walk_frame = walk_frame + 1; if (walk_frame >= int.MaxValue) { walk_frame = 0; } //时间 last_walk_time = Comm.Time(); }
public static void walk(Player[] player, Map[] map, Comm.Direction direction) { Player p = player[current_player]; //转向 p.face = (int)direction; //间隔判定 if (Comm.Time() - p.last_walk_time <= p.walk_interval) { return; } //行走 //up if (direction == Comm.Direction.UP && Map.can_through(map, p.x, p.y - p.speed)) { p.y = p.y - p.speed; } //down else if (direction == Comm.Direction.DOWN && Map.can_through(map, p.x, p.y + p.speed)) { p.y = p.y + p.speed; } //right else if (direction == Comm.Direction.LEFT && Map.can_through(map, p.x - p.speed, p.y)) { p.x = p.x - p.speed; } //left else if (direction == Comm.Direction.RIGHT && Map.can_through(map, p.x + p.speed, p.y)) { p.x = p.x + p.speed; } //动画帧 p.anm_frame = p.anm_frame + 1; if (p.anm_frame >= int.MaxValue) { p.anm_frame = 0; } //时间 p.last_walk_time = Comm.Time(); return; }