Android Studio,将离线游戏转换为在线游戏

Android Studio,将离线游戏转换为在线游戏,android,firebase,google-play,google-play-services,Android,Firebase,Google Play,Google Play Services,我做了一个离线问答游戏,向用户随机提问10个问题。这些问题取自我的firebase db,并保存在arraylist中。我的程序每次从arraylist中随机选取一个问题并显示该问题。这是我的一段代码 public void askQuestion(){ Random rnd=new Random(); int index = rnd.nextInt(questionList.size()); Info theQuestion=questionL

我做了一个离线问答游戏,向用户随机提问10个问题。这些问题取自我的firebase db,并保存在arraylist中。我的程序每次从arraylist中随机选取一个问题并显示该问题。这是我的一段代码

 public void askQuestion(){
        Random rnd=new Random();
        int index = rnd.nextInt(questionList.size());
        Info theQuestion=questionList.get(index);  
        question.setText(theQuestion.getQuestion());
        a.setText(theQuestion.getA());
        b.setText(theQuestion.getB());
        c.setText(theQuestion.getC());
        d.setText(theQuestion.getD());
        answer=theQuestion.getAnswer();
    }
//Info is the name of the object for my questions. questionList is an arraylist of type info where I keep the all questions I got from firebase.
这是我的问题

  • 我读到我应该使用google play服务在线制作游戏。有更好的方法吗?什么是最好的开始(链接将不胜感激)
  • 我可以在我的在线游戏中使用此活动,还是应该更改它?两个用户的随机性是否相同?我想问他们同样的问题
  • 两个用户的随机性是否相同

    从:

    如果使用相同的种子创建两个
    Random
    实例,并且为每个实例调用相同的方法序列,则它们将生成并返回相同的数字序列

    因此,只需确保创建的
    Random
    对象的初始值设定项在玩家之间相同:

    Random rnd=new Random(42);
    
    为了增加游戏的可重放性,您可以使用一个变化但可预测的值为随机化器添加种子。例如:实现当日游戏的一种简单方法是使用当日哈希代码为其种子:

    Calendar c = new GregorianCalendar(); // see http://stackoverflow.com/q/6850874
    c.set(Calendar.HOUR_OF_DAY, 0); //anything 0 - 23
    c.set(Calendar.MINUTE, 0);
    c.set(Calendar.SECOND, 0);
    c.set(Calendar.SECOND, 0);
    c.set(Calendar.MILLISECOND, 0);
    Date day = c.getTime(); //the midnight, that's the first second of the day.
    Random rnd=new Random(day.hashCode());
    

    请在每篇文章中只回答一个问题。我在下面回答了你最具体的问题。