com.watabou.utils.SystemTime Java Examples

The following examples show how to use com.watabou.utils.SystemTime. 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: Game.java    From YetAnotherPixelDungeon with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void onDrawFrame( GL10 gl ) {
	
	if (width == 0 || height == 0) {
		return;
	}
	
	SystemTime.tick();
	long rightNow = SystemTime.now;
	step = (now == 0 ? 0 : rightNow - now);
	now = rightNow;
	
	step();

	NoosaScript.get().resetCamera();
	GLES20.glScissor( 0, 0, width, height );
	GLES20.glClear( GLES20.GL_COLOR_BUFFER_BIT );
	draw();
}
 
Example #2
Source File: Game.java    From remixed-dungeon with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void onResume() {
    super.onResume();

    now = 0;

    SystemTime.tick();
    SystemTime.updateLastActionTime();

    view.onResume();

    Music.INSTANCE.resume();
    Sample.INSTANCE.resume();

    if (doOnResume != null) {
        Game.pushUiTask( () -> {
            doOnResume.run();
            doOnResume = null;
            }
        );
    }
}
 
Example #3
Source File: Game.java    From PD-classes with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void onDrawFrame( GL10 gl ) {
	
	if (width == 0 || height == 0) {
		return;
	}
	
	SystemTime.tick();
	long rightNow = SystemTime.now;
	step = (now == 0 ? 0 : rightNow - now);
	now = rightNow;
	
	step();

	NoosaScript.get().resetCamera();
	GLES20.glScissor( 0, 0, width, height );
	GLES20.glClear( GLES20.GL_COLOR_BUFFER_BIT );
	draw();
}
 
Example #4
Source File: Hero.java    From remixed-dungeon with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected boolean timeout() {
	if (SystemTime.now() - SystemTime.getLastActionTime() > Dungeon.moveTimeout()) {
		SystemTime.updateLastActionTime();
		spend(TIME_TO_REST);
		return true;
	}
	return false;
}
 
Example #5
Source File: PlayGamesButton.java    From remixed-dungeon with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void update() {
	super.update();
	if(SystemTime.now() - lastUpdatedTime > 1000) {
		lastUpdatedTime = SystemTime.now();
		updateStatus();
	}
}
 
Example #6
Source File: Hero.java    From remixed-dungeon with GNU General Public License v3.0 4 votes vote down vote up
@Override
public boolean act() {
	if(controlTargetId == getId()) {
		super.act();
	}

	if (paralysed) {
		curAction = null;
		spendAndNext(TICK);
		return false;
	}

	checkVisibleEnemies();

	if(controlTargetId != getId()) {
		curAction = null;
	}

	if (curAction == null) {

		if (restoreHealth) {
			if (isStarving() || hp() >= ht() || level().isSafe()) {
				restoreHealth = false;
			} else {
				spend(TIME_TO_REST);
				next();
				return false;
			}
		}

		if (Dungeon.realtime() || (controlTargetId != getId() && getControlTarget().curAction!=null) ) {
			if (!ready) {
				readyAndIdle();
			}
			spend(TICK);
			next();
		} else {
			readyAndIdle();
		}
		return false;

	} else {

		SystemTime.updateLastActionTime();

		restoreHealth = false;
		if(!Dungeon.realtime()) {
			busy();
		}

		if (curAction instanceof CharAction.Move) {

			return actMove((CharAction.Move) curAction);

		} else if (curAction instanceof CharAction.Interact) {

			return actInteract((CharAction.Interact) curAction);

		} else if (curAction instanceof CharAction.PickUp) {

			return actPickUp((CharAction.PickUp) curAction);

		} else if (curAction instanceof CharAction.OpenChest) {

			return actOpenChest((CharAction.OpenChest) curAction);

		} else if (curAction instanceof CharAction.Unlock) {

			return actUnlock((CharAction.Unlock) curAction);

		} else if (curAction instanceof CharAction.Descend) {

			return actDescend((CharAction.Descend) curAction);

		} else if (curAction instanceof CharAction.Ascend) {

			return actAscend((CharAction.Ascend) curAction);

		} else if (curAction instanceof CharAction.Attack) {

			return actAttack((CharAction.Attack) curAction);

		} else if (curAction instanceof CharAction.Cook) {

			return actCook((CharAction.Cook) curAction);

		}
	}
	return false;
}
 
Example #7
Source File: Dungeon.java    From remixed-dungeon with GNU General Public License v3.0 4 votes vote down vote up
public static void init() {
    SaveUtils.deleteLevels(heroClass);

    gameId = String.valueOf(SystemTime.now());

    LuaEngine.reset();
    Treasury.reset();

    setChallenges(RemixedDungeon.challenges());

    Scroll.initLabels();
    Potion.initColors();
    Wand.initWoods();
    Ring.initGems();

    Statistics.reset();
    Journal.reset();

    depth = 0;

    potionOfStrength = 0;
    scrollsOfUpgrade = 0;
    arcaneStyli = 0;
    dewVial = true;
    transmutation = Random.IntRange(6, 14);

    chapters = new HashSet<>();

    Ghost.Quest.reset();
    WandMaker.Quest.reset();
    Blacksmith.Quest.reset();
    Imp.Quest.reset();
    ScarecrowNPC.Quest.reset();
    AzuterronNPC.Quest.reset();
    CagedKobold.Quest.reset();
    PlagueDoctorNPC.Quest.reset();

    Room.shuffleTypes();

    hero = new Hero(difficulty);

    Badges.reset();

    heroClass.initHero(hero);

    hero.levelId = DungeonGenerator.getEntryLevel();

    realtime = RemixedDungeon.realtime();
    moveTimeoutIndex = RemixedDungeon.limitTimeoutIndex(RemixedDungeon.moveTimeout());
}
 
Example #8
Source File: Dungeon.java    From remixed-dungeon with GNU General Public License v3.0 3 votes vote down vote up
public synchronized static void save() {

        if (SystemTime.now() - lastSaveTimestamp < 1000) {
            return;
        }

        lastSaveTimestamp = SystemTime.now();

        saveAllImpl();
    }