Java Code Examples for com.watabou.noosa.Game#addToScene()

The following examples show how to use com.watabou.noosa.Game#addToScene() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SociologistNPC.java    From remixed-dungeon with GNU General Public License v3.0 6 votes vote down vote up
public boolean interact(Char hero) {

        Game.addToScene(new WndOptions(this.name,
                Game.getVar(R.string.SociologistNPC_Hi),
                Game.getVar(R.string.Wnd_Button_Yes), Game.getVar(R.string.Wnd_Button_No)
        ) {

            @Override
            public void onSelect(int index) {
                if (index == 0) {
                    String[] requiredPermissions = {Manifest.permission.INTERNET};
                    Game.instance().doPermissionsRequest(SociologistNPC.this, requiredPermissions);
                }
            }
        });
        return true;
    }
 
Example 2
Source File: StartScene.java    From remixed-dungeon with GNU General Public License v3.0 6 votes vote down vote up
private void selectDifficulty() {

        WndOptions difficultyOptions = new WndOptions(Game.getVar(R.string.StartScene_DifficultySelect), Utils.EMPTY_STRING,
                Game.getVar(RemixedDungeon.donated() > 0 ? R.string.StartScene_DifficultyEasyNoAds : R.string.StartScene_DifficultyEasy),
                Game.getVar(RemixedDungeon.donated() > 0 ? R.string.StartScene_DifficultyNormalWithSavesNoAds : R.string.StartScene_DifficultyNormalWithSaves),
                Game.getVar(R.string.StartScene_DifficultyNormal),
                Game.getVar(R.string.StartScene_DifficultyExpert)) {
            @Override
            public void onSelect(final int index) {

                if (index < 2 && EuConsent.getConsentLevel() < EuConsent.NON_PERSONALIZED) {
                    Game.addToScene(new WndEuConsent() {
                        @Override
                        public void done() {
                            startNewGame(index);
                        }
                    });
                    return;
                }

                startNewGame(index);
            }
        };

        add(difficultyOptions);
    }
 
Example 3
Source File: WndModSelect.java    From remixed-dungeon with GNU General Public License v3.0 6 votes vote down vote up
private void onDelete(String name) {

		File modDir = FileSystem.getExternalStorageFile(name);

		if (modDir.exists() && modDir.isDirectory()) {
			FileSystem.deleteRecursive(modDir);
		}

		if (RemixedDungeon.activeMod().equals(name)) {
			SaveUtils.deleteGameAllClasses();
			SaveUtils.copyAllClassesFromSlot(ModdingMode.REMIXED);
			RemixedDungeon.activeMod(ModdingMode.REMIXED);
			RemixedDungeon.instance().doRestart();
		}

		if (getParent() != null) {
			hide();
		}
		Game.addToScene(new WndModSelect());
	}
 
Example 4
Source File: WndModSelect.java    From remixed-dungeon with GNU General Public License v3.0 5 votes vote down vote up
protected void onSelect(String option) {

		Mods.ModDesc desc = modsList.get(option);
		if (!option.equals(ModdingMode.REMIXED) || desc.needUpdate) {

			if (desc.needUpdate) {
				FileSystem.deleteRecursive(FileSystem.getExternalStorageFile(desc.name));
				selectedMod = desc.name;
				downloadTo = FileSystem.getExternalStorageFile(selectedMod + ".zip").getAbsolutePath();
				desc.needUpdate = false;

				Game.execute(new DownloadTask(new DownloadProgressWindow(Utils.format("Downloading %s", selectedMod),this),
						desc.url,
						downloadTo));

				return;
			}
		}

		String prevMod = RemixedDungeon.activeMod();

		if (option.equals(prevMod)) {
			return;
		}

		if (getParent() != null) {
			hide();
		}
		Game.addToScene(new WndModDescription(option, prevMod));
	}
 
Example 5
Source File: QuickSlot.java    From remixed-dungeon with GNU General Public License v3.0 5 votes vote down vote up
static public void selectSlotFor(Item item) {
    objectForSlot = item;
    prompt = new Toast(Game.getVar(R.string.QuickSlot_SelectSlot)) {
        @Override
        protected void onClose() {
            Game.scene().remove(this);
            objectForSlot = null;

        }
    };
    prompt.camera = uiCamera;
    prompt.setPos((uiCamera.width - prompt.width()) / 2, uiCamera.height - 60);

    Game.addToScene(prompt);
}
 
Example 6
Source File: BadgesList.java    From remixed-dungeon with GNU General Public License v3.0 5 votes vote down vote up
public boolean onClick( float x, float y ) {
	if (inside( x, y )) {
		Sample.INSTANCE.play( Assets.SND_CLICK, 0.7f, 0.7f, 1.2f );
		Game.addToScene( new WndBadge( badge ) );
		return true;
	} else {
		return false;
	}
}
 
Example 7
Source File: WndSurvey.java    From remixed-dungeon with GNU General Public License v3.0 5 votes vote down vote up
public WndSurvey(final JSONObject survey) {
    super();

    String lang = RemixedDungeon.uiLanguage();

    if (!survey.has(lang)) {
        lang = "en";
    }

    try {
        String surveyId = survey.getString("survey_id");

        if (Preferences.INSTANCE.getString(SURVEY_TAKEN, Utils.EMPTY_STRING).equals(surveyId)) {
            Game.addToScene(new WndMessage(Game.getVar(R.string.SociologistNPC_AlreadyTaken)));
            super.hide();
            return;
        }
        Preferences.INSTANCE.put(SURVEY_TAKEN, surveyId);
        this.survey = survey.getJSONArray(lang);
    } catch (JSONException e) {
        this.survey = new JSONArray();
    }

    question = 0;

    //Title text
    questionText = PixelScene.createMultiline(Utils.EMPTY_STRING, GuiProperties.mediumTitleFontSize());
    questionText.hardlight(TITLE_COLOR);
    questionText.maxWidth(WIDTH - GAP);
    questionText.x = GAP;
    questionText.y = GAP;
    add(questionText);

    answers = new Component();
    add(answers);
    resize(WIDTH, (int) (questionText.bottom() + GAP));
    NextQuestion();
}
 
Example 8
Source File: WndStory.java    From remixed-dungeon with GNU General Public License v3.0 5 votes vote down vote up
public static void showChapter( int id ) {
	
	if (Dungeon.chapters.contains( id )) {
		return;
	}
	
	String text = CHAPTERS.get( id );
	if (text != null) {
		WndStory wnd = new WndStory( text );
		
		Game.addToScene( wnd );
		
		Dungeon.chapters.add( id );
	}
}
 
Example 9
Source File: WndSaveSlotSelect.java    From remixed-dungeon with GNU General Public License v3.0 5 votes vote down vote up
private void showActionResult(final boolean res) {
    refreshWindow();

    if (res) {
        Game.addToScene(new WndMessage("ok!"));
    } else {
        Game.addToScene(new WndMessage("something went wrong..."));
    }
}
 
Example 10
Source File: PixelScene.java    From remixed-dungeon with GNU General Public License v3.0 5 votes vote down vote up
public static void showBadge(Badges.Badge badge) {
	if(!(Game.scene() instanceof GameScene)) {
		return;
	}
	
	if (uiCamera != null && !Game.isPaused()) {
		BadgeBanner banner = BadgeBanner.show(badge.image);
		banner.camera = uiCamera;
		banner.x = align(banner.camera,
				(banner.camera.width - banner.width) / 2);
		banner.y = align(banner.camera,
				(banner.camera.height - banner.height) / 3);
		Game.addToScene(banner);
	}
}
 
Example 11
Source File: WndStory.java    From remixed-dungeon with GNU General Public License v3.0 4 votes vote down vote up
public static void showCustomStory( @NotNull String text ) {
		Game.addToScene( new WndStory( text ) );
}
 
Example 12
Source File: WndRanking.java    From remixed-dungeon with GNU General Public License v3.0 4 votes vote down vote up
private void reportError() {
	hide();
	Game.addToScene( new WndError( Game.getVar(R.string.WndRanking_Error) + "\n" + error ) );
}
 
Example 13
Source File: WndRanking.java    From remixed-dungeon with GNU General Public License v3.0 4 votes vote down vote up
public StatsTab() {
	super();
	
	Hero hero = Dungeon.hero;
	String heroClass = hero.className();

	HeroSpriteDef heroSprite = HeroSpriteDef.createHeroSpriteDef(hero);

	IconTitle title = new IconTitle();
	title.icon( heroSprite.avatar() );
	title.label( Utils.format( Game.getVar(R.string.WndRanking_StaTitle), hero.lvl(), heroClass ).toUpperCase( Locale.ENGLISH ) );
	title.setRect( 0, 0, WIDTH, 0 );
	title.color(0xCC33FF);
	add( title );
	
	float pos = title.bottom();
	
	if (Dungeon.getChallenges() > 0) {
		RedButton btnCatalogus = new RedButton( Game.getVar(R.string.WndRanking_StaChallenges) ) {
			@Override
			protected void onClick() {
				Game.addToScene( new WndChallenges(Dungeon.getChallenges(), false ) );
			}
		};
		btnCatalogus.setRect( 0, pos + GAP, btnCatalogus.reqWidth() + 2, btnCatalogus.reqHeight() + 2 );
		add( btnCatalogus );
		
		pos = btnCatalogus.bottom();
	}
	
	pos += GAP + GAP;
	
	pos = statSlot( this, difficultyToText(hero.getDifficulty()), Utils.EMPTY_STRING, pos );
	
	pos += GAP;
	
	pos = statSlot( this, Game.getVar(R.string.WndRanking_StaStr), Integer.toString( hero.effectiveSTR() ), pos );
	pos = statSlot( this, Game.getVar(R.string.WndRanking_StaHealth), Integer.toString( hero.ht() ), pos );
	
	pos += GAP;
	
	pos = statSlot( this, Game.getVar(R.string.WndRanking_StaDuration), Integer.toString( (int)Statistics.duration ), pos );
	
	pos += GAP;
	
	pos = statSlot( this, Game.getVar(R.string.WndRanking_StaDepth), Integer.toString( Statistics.deepestFloor ), pos );
	pos = statSlot( this, Game.getVar(R.string.WndRanking_StaEnemies), Integer.toString( Statistics.enemiesSlain ), pos );
	pos = statSlot( this, Game.getVar(R.string.WndRanking_StaGold), Integer.toString( Statistics.goldCollected ), pos );
	
	pos += GAP;
	
	pos = statSlot( this, Game.getVar(R.string.WndRanking_StaFood), Integer.toString( Statistics.foodEaten ), pos );
	pos = statSlot( this, Game.getVar(R.string.WndRanking_StaAlchemy), Integer.toString( Statistics.potionsCooked ), pos );
	pos = statSlot( this, Game.getVar(R.string.WndRanking_StaAnkhs), Integer.toString( Statistics.ankhsUsed ), pos );
}
 
Example 14
Source File: WndRanking.java    From remixed-dungeon with GNU General Public License v3.0 4 votes vote down vote up
@Override
protected void onClick() {
	Game.addToScene( new WndItem( null, item ) );
}
 
Example 15
Source File: WndModDescription.java    From remixed-dungeon with GNU General Public License v3.0 4 votes vote down vote up
public void onBackPressed() {
	hide();
	Game.addToScene(new WndModSelect());
}
 
Example 16
Source File: PlayGamesButton.java    From remixed-dungeon with GNU General Public License v3.0 4 votes vote down vote up
@Override
protected void onClick() {
	Game.addToScene(new WndPlayGames());
}
 
Example 17
Source File: WndPlayGames.java    From remixed-dungeon with GNU General Public License v3.0 4 votes vote down vote up
public WndPlayGames() {

        boolean playGamesConnected = Game.instance().playGames.isConnected();
        resizeLimited(120);

        Text listTitle = PixelScene.createMultiline(Game.getVar(R.string.WndPlayGames_Title), GuiProperties.mediumTitleFontSize());
        listTitle.hardlight(TITLE_COLOR);
        listTitle.maxWidth(width - GAP * 2);
        listTitle.x = (width - listTitle.width()) / 2;
        listTitle.y = y;

        add(listTitle);

        y += listTitle.height() + GAP;

        CheckBox usePlayGames = new CheckBox(Game.getVar(R.string.WndPlayGames_Use),
                Preferences.INSTANCE.getBoolean(Preferences.KEY_USE_PLAY_GAMES, false)
                && Game.instance().playGames.isConnected()
                )
        {
            @Override
            public void checked(boolean value) {
                super.checked(value);

                if (value) {
                    Game.instance().playGames.connectExplicit();
                    Game.addToScene(new WndMessage(Game.getVar(R.string.WndPlayGames_Connecting)));
                } else {
                    Game.instance().playGames.disconnect();
                }

                hide();
            }
        };

        addButton(usePlayGames);

        if (!playGamesConnected) {
            resize(width, y);
            return;
        }

        addButton(new RedButton(Game.getVar(R.string.WndPlayGames_Show_Badges)) {
            @Override
            protected void onClick() {
                super.onClick();
                Game.instance().playGames.showBadges();
            }
        });

        addButton(new RedButton(Game.getVar(R.string.WndPlayGames_Show_Leaderboards)) {
            @Override
            protected void onClick() {
                super.onClick();
                Game.instance().playGames.showLeaderboard();
            }
        });

        addButton(new RedButton(Game.getVar(R.string.WndPlayGames_BackupProgress)) {
            @Override
            protected void onClick() {
                super.onClick();
                Game.instance().playGames.backupProgress(new ResultHandler());
            }
        });

        addButton(new RedButton(Game.getVar(R.string.WndPlayGames_RestoreProgress)) {
            @Override
            protected void onClick() {
                super.onClick();
                Game.instance().playGames.restoreProgress(new ResultHandler());
            }
        });

        resize(width, y);
    }
 
Example 18
Source File: WndPlayGames.java    From remixed-dungeon with GNU General Public License v3.0 4 votes vote down vote up
ResultHandler() {
    working = new WndMessage(Game.getVar(R.string.WndPlayGames_WorkInCloud));
    Game.addToScene(working);
}
 
Example 19
Source File: SociologistNPC.java    From remixed-dungeon with GNU General Public License v3.0 4 votes vote down vote up
private void reportError() {
    Game.addToScene(new WndError(Game.getVar(R.string.SociologistNPC_DownloadError)));
}
 
Example 20
Source File: ServiceManNPC.java    From remixed-dungeon with GNU General Public License v3.0 4 votes vote down vote up
@Override
public boolean interact(final Char hero) {

    if (EuConsent.getConsentLevel() < EuConsent.NON_PERSONALIZED) {
        Game.addToScene(new WndEuConsent() {
            @Override
            public void done() {
                AdsUtils.initRewardVideo();
            }
        });
        return true;
    }

    getSprite().turnTo(getPos(), hero.getPos());

    if (!Util.isConnectedToInternet()) {
        GameScene.show(new WndQuest(this, Game.getVar(R.string.ServiceManNPC_NoConnection)));
        return true;
    }

    if (filmsSeen >= getLimit()) {
        GameScene.show(new WndQuest(this, Utils.format(Game.getVar(R.string.ServiceManNPC_Limit_Reached), getLimit())));
        return true;
    }

    Game.instance().runOnUiThread(() ->
    {
        boolean result = Ads.isRewardVideoReady();
        RemixedDungeon.pushUiTask(() -> {
                    if (result) {
                        GameScene.show(new WndMovieTheatre(this, filmsSeen, getLimit(), getReward()));
                    } else {
                        say(Game.getVar(R.string.ServiceManNPC_NotReady));
                    }
                }
        );

    });

    return true;
}