Ejemplo n.º 1
0
  /** Get ready for a new game, given a letter list specification of the Boggle board. */
  public void newGame() {

    myBoard = BoggleBoardFactory.getBoard(myBoardSize);

    // set up views for new game
    if (myBoardSize == 4) {
      if (myBoardPanel != myBoardPanel4) {
        myBoardPanel = myBoardPanel4;
        getContentPane().remove(myBoardPanel5);
        getContentPane().add(myBoardPanel, BorderLayout.CENTER);
      }
    } else {
      if (myBoardPanel != myBoardPanel5) {
        myBoardPanel = myBoardPanel5;
        getContentPane().remove(myBoardPanel4);
        getContentPane().add(myBoardPanel, BorderLayout.CENTER);
      }
    }

    myBoardPanel.newGame();
    humanArea.setReady();
    computerArea.setReady();
    myBoardPanel.unHighlightAllDice();
    wordEntryField.setReady();
    ((JPanel) getContentPane()).revalidate();
    repaint();
  }
Ejemplo n.º 2
0
 @Override
 public void stop() {
   for (PlayerView player : m_players.values()) {
     player.showIdleAnimation();
     player.setDirection(MovementDirection.NONE);
   }
 }
Ejemplo n.º 3
0
  @Override
  public void onClick(View view) {
    switch (view.getId()) {
      case R.id.ib_lock:
        break;
      case R.id.ib_forward:
        mPlayerView.seek(10000);
        break;
      case R.id.ib_play:
        if (mPlayerView.isPlaying()) {
          mPlayerView.pause();
          ibPlay.setBackgroundResource(R.drawable.ic_play);
        } else {
          mPlayerView.play();
          ibPlay.setBackgroundResource(R.drawable.ic_pause);
        }
        break;

      case R.id.ib_backward:
        mPlayerView.seek(-10000);
        break;
      case R.id.ib_size:
        break;
      default:
        break;
    }
  }
Ejemplo n.º 4
0
  private void setPlayerPosition(PlayerView player, TileIndex index) {
    GridPosition position = m_tileManager.getGridPosition(index);
    int x = position.getLeft() + (m_tileManager.getGridElementWidth() - player.getWidth()) / 2;
    int y = position.getTop() + (m_tileManager.getGridElementHeight() - player.getHeight()) / 2;
    setWidgetTopHeight(player, y, Unit.PX, player.getHeight(), Unit.PX);
    setWidgetLeftWidth(player, x, Unit.PX, player.getWidth(), Unit.PX);

    GridPosition lastPosition = m_playersPositions.get(player);
    MovementDirection nextDirection = getMovementDirection(position, lastPosition);
    player.setDirection(nextDirection);
    m_playersPositions.put(player, position);
  }
Ejemplo n.º 5
0
  /** Let the computer player take its turn. */
  public void computerPlay() {
    computerArea.setName("Thinking!");
    computerArea.paintImmediately(computerArea.getVisibleRect());
    int minLength = myBoardSize == 4 ? 3 : 4;
    computerPlayer.findAllValidWords(myBoard, myLexicon, minLength);

    computerArea.setName("Computer");
    for (String s : computerPlayer) {
      computerArea.showWord(s, myFinder.cellsForWord(myBoard, s), computerPlayer);
    }
    myBoardPanel.unHighlightAllDice(); // leave board unhighlighted when
    // done
  }
Ejemplo n.º 6
0
  @Override
  public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
    if (fromUser && mPlayerView.canSeekable()) {
      mPlayerView.setTime(progress);
      setOverlayProgress();
    }

    SharedPreferences sp = getSharedPreferences("spTest", Context.MODE_PRIVATE);
    Log.d("===", "sp:" + sp.getBoolean("isAuto", true));
    if (!sp.getBoolean("isAuto", true)) {
      Log.d("===", "正在播放之前");
      if (mPlayerView.isPlaying() && isPlay) {
        Log.d("===", "正在播放");
        mPlayerView.pause();
        ibPlay.setBackgroundResource(R.drawable.ic_play);
        isPlay = false;
      }
    }
  }
Ejemplo n.º 7
0
 private int setOverlayProgress() {
   if (mPlayerView == null) {
     return 0;
   }
   int time = (int) mPlayerView.getTime();
   int length = (int) mPlayerView.getLength();
   boolean isSeekable = mPlayerView.canSeekable() && length > 0;
   ibFarward.setVisibility(isSeekable ? View.VISIBLE : View.GONE);
   ibBackward.setVisibility(isSeekable ? View.VISIBLE : View.GONE);
   sbVideo.setMax(length);
   sbVideo.setProgress(time);
   if (time >= 0) {
     tvTime.setText(millisToString(time, false));
   }
   if (length >= 0) {
     tvLength.setText(millisToString(length, false));
   }
   return time;
 }
Ejemplo n.º 8
0
  /** ClientEndServerFrames. */
  public static void ClientEndServerFrames() {
    int i;
    Entity ent;

    // calc the player views now that all pushing
    // and damage has been added
    for (i = 0; i < maxclients.value; i++) {
      ent = g_edicts[1 + i];
      if (!ent.inuse || null == ent.client) continue;
      PlayerView.ClientEndServerFrame(ent);
    }
  }
Ejemplo n.º 9
0
  /** Creates the Player's positions on the table (BoardView) */
  public void displayPlayers() {

    RelativeLayout players_left = (RelativeLayout) findViewById(R.id.players_left);
    RelativeLayout players_right = (RelativeLayout) findViewById(R.id.players_right);

    PlayerView player = new PlayerView(context);
    RelativeLayout.LayoutParams params;

    player = new PlayerView(context);
    params = (RelativeLayout.LayoutParams) player.getLayoutParams();
    params.addRule(CENTER_IN_PARENT, RelativeLayout.TRUE);
    params.addRule(ALIGN_PARENT_LEFT, RelativeLayout.TRUE);
    players_left.addView(player, params);
    playerViews.put(1, player);

    // Player 2
    player = new PlayerView(context);
    params = (RelativeLayout.LayoutParams) player.getLayoutParams();
    params.addRule(ALIGN_PARENT_TOP, RelativeLayout.TRUE);
    params.addRule(ALIGN_PARENT_LEFT, RelativeLayout.TRUE);
    players_left.addView(player, params);
    playerViews.put(2, player);

    // Player 3
    player = new PlayerView(context);
    params = (RelativeLayout.LayoutParams) player.getLayoutParams();
    params.addRule(CENTER_IN_PARENT, RelativeLayout.TRUE);
    params.addRule(ALIGN_PARENT_TOP, RelativeLayout.TRUE);
    players_left.addView(player, params);
    playerViews.put(3, player);

    // Player 4
    player = new PlayerView(context);
    params = (RelativeLayout.LayoutParams) player.getLayoutParams();
    params.addRule(ALIGN_PARENT_TOP, RelativeLayout.TRUE);
    params.addRule(CENTER_IN_PARENT, RelativeLayout.TRUE);
    addView(player, params);
    bringChildToFront(player);
    playerViews.put(4, player);

    // Player 5
    player = new PlayerView(context);
    params = (RelativeLayout.LayoutParams) player.getLayoutParams();
    params.addRule(CENTER_IN_PARENT, RelativeLayout.TRUE);
    params.addRule(ALIGN_PARENT_TOP, RelativeLayout.TRUE);
    players_right.addView(player, params);
    playerViews.put(5, player);

    // Player 6
    player = new PlayerView(context);
    params = (RelativeLayout.LayoutParams) player.getLayoutParams();
    params.addRule(ALIGN_PARENT_RIGHT, RelativeLayout.TRUE);
    params.addRule(ALIGN_PARENT_TOP, RelativeLayout.TRUE);
    players_right.addView(player, params);
    playerViews.put(6, player);

    // Player 7
    player = new PlayerView(context);
    params = (RelativeLayout.LayoutParams) player.getLayoutParams();
    params.addRule(CENTER_IN_PARENT, RelativeLayout.TRUE);
    params.addRule(ALIGN_PARENT_RIGHT, RelativeLayout.TRUE);
    players_right.addView(player, params);
    playerViews.put(7, player);
  }
Ejemplo n.º 10
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    mUrl = getIntent().getStringExtra("url");
    if (TextUtils.isEmpty(mUrl)) {
      Toast.makeText(this, "error:no url in intent!", Toast.LENGTH_SHORT).show();
      return;
    }
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    getWindow()
        .setFlags(
            WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);

    setContentView(R.layout.activity_player);

    mHandler = new Handler(this);
    isPlay = true;

    tvTitle = (TextView) findViewById(R.id.tv_title);
    tvTime = (TextView) findViewById(R.id.tv_time);
    tvLength = (TextView) findViewById(R.id.tv_length);
    sbVideo = (SeekBar) findViewById(R.id.sb_video);
    sbVideo.setOnSeekBarChangeListener(this);
    ibLock = (ImageButton) findViewById(R.id.ib_lock);
    ibLock.setOnClickListener(this);
    ibBackward = (ImageButton) findViewById(R.id.ib_backward);
    ibBackward.setOnClickListener(this);
    ibPlay = (ImageButton) findViewById(R.id.ib_play);
    ibPlay.setOnClickListener(this);
    ibFarward = (ImageButton) findViewById(R.id.ib_forward);
    ibFarward.setOnClickListener(this);
    ibSize = (ImageButton) findViewById(R.id.ib_size);
    ibSize.setOnClickListener(this);

    llOverlay = findViewById(R.id.ll_overlay);
    rlOverlayTitle = findViewById(R.id.rl_title);

    rlLoading = findViewById(R.id.rl_loading);
    tvBuffer = (TextView) findViewById(R.id.tv_buffer);
    // 使用步骤
    // 第一步 :通过findViewById或者new PlayerView()得到mPlayerView对象
    // mPlayerView= new PlayerView(PlayerActivity.this);
    mPlayerView = (PlayerView) findViewById(R.id.pv_video);

    // 第二步:设置参数,毫秒为单位
    mPlayerView.setNetWorkCache(20000);

    // 第三步:初始化播放器
    mPlayerView.initPlayer(mUrl);

    // 第四步:设置事件监听,监听缓冲进度等
    mPlayerView.setOnChangeListener(this);

    // 第五步:开始播放
    mPlayerView.start();

    // init view
    tvTitle.setText(mUrl);
    showLoading();
    hideOverlay();
  }
Ejemplo n.º 11
0
 @Override
 public void onPause() {
   hideOverlay();
   mPlayerView.stop();
   super.onPause();
 }
Ejemplo n.º 12
0
 @Override
 public void onConfigurationChanged(Configuration newConfig) {
   mPlayerView.changeSurfaceSize();
   super.onConfigurationChanged(newConfig);
 }
Ejemplo n.º 13
0
 @Override
 public void update(double progress) {
   for (PlayerView player : m_players.values()) {
     player.update(progress);
   }
 }