public void setView(DogMood mood) { if (mood.equals(DogMood.DIRTY)) { view.setDirty(); view.setSprite(DogMood.HAPPY); } else if (mood.equals(DogMood.BARKING)) { view.setSprite(mood); new Thread( new Runnable() { @Override public void run() { try { DogService.INSTANCE.playMusic(R.raw.hondschors, true); Thread.sleep(2500); } catch (InterruptedException e) { Log.e( "InterruptedException", "setBarking innerclass has thrown an InterruptedException: " + e.getMessage()); } DogService.INSTANCE.setBarking(false); DogService.INSTANCE.stopMusic(); } }) .start(); } else { view.setSprite(mood); } }
public Dog(Context c, DogView view) { this.view = view; x = ResourceManager.INSTANCE.getScreenWidth() / 2; y = (int) (ResourceManager.INSTANCE.getScreenHeight() - ResourceManager.INSTANCE.getPercentageLength(20, true)); view.setXY(x, y); setLastRefreshed(getTime()); }
public void playedWithDog(boolean gettingDirty) { if ((getTime() - getTimeLastEaten()) > THIRTYMINUTES) { DogService.INSTANCE.updateSatisfaction(15); } else { DogService.INSTANCE.updateSatisfaction(-5, 60); Toast.makeText( view.getContext(), "Pas op! Wacht met spelen tot 30 minuten nadat je hond gegeten heeft!", Toast.LENGTH_LONG) .show(); } if (Math.random() <= 0.75 && gettingDirty) { setDirty(true); // setView(DogMood.DIRTY); } // setView(DogMood.HAPPY); DogService.INSTANCE.setWantsToPlay(false); setTimeLastPlayed(new Date(getTime())); }
public void update() { view.setXY(x, y); view.setBackgroundColor(); checkUpdates(); randomBark(); }
public void setDirty() { view.setDirty(); }