本文整理汇总了C#中Microsoft.Xna.Framework.GameTime.getSeconds方法的典型用法代码示例。如果您正苦于以下问题:C# GameTime.getSeconds方法的具体用法?C# GameTime.getSeconds怎么用?C# GameTime.getSeconds使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.Xna.Framework.GameTime
的用法示例。
在下文中一共展示了GameTime.getSeconds方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Update
public override void Update(GameTime gameTime)
{
float seconds = gameTime.getSeconds(Hero.HERO_TIMESCALE);
base.Update(gameTime);
if(!hero.Alive && bombs.Count > 0)
bombs.Clear();
}
示例2: Update
public override void Update(GameTime gameTime)
{
float seconds = gameTime.getSeconds(Hero.HERO_TIMESCALE);
if (bursting)
{
timeInBurst += seconds;
if (timeInBurst >= BURST_DURATION)
{
moveSpeedMultiplier = 1f;
burstRecharge = 0;
bursting = false;
}
}
else if (burstRecharge < BURST_COOLDOWN)
{
burstRecharge += seconds*hero.powerupCooldownModifier;
}
if (Hero.HERO_TIMESCALE > 0f)
{
switch (hero.direction)
{
case Direction.Up:
leftBoosterOffset = new Vector2(-6, 12);
rightBoosterOffset = new Vector2(6, 12);
boosterAngle = (float)Math.PI / 2;
break;
case Direction.Down:
leftBoosterOffset = new Vector2(6, -12);
rightBoosterOffset = new Vector2(-6, -12);
boosterAngle = (float)Math.PI * 3 / 2;
break;
case Direction.Left:
leftBoosterOffset = new Vector2(12, 6);
rightBoosterOffset = new Vector2(12, -6);
boosterAngle = 0;
break;
case Direction.Right:
leftBoosterOffset = new Vector2(-12, -6);
rightBoosterOffset = new Vector2(-12, 6);
boosterAngle = (float)Math.PI;
break;
}
}
leftBooster.angle = boosterAngle;
rightBooster.angle = boosterAngle;
if (seconds > 0)
{
leftBooster.Update(gameTime);
rightBooster.Update(gameTime);
}
Vector2 nextHeroPos = hero.position + hero.movement; //use next frame's hero position to stick the particle emitter to the hero better
leftBooster.position = nextHeroPos + leftBoosterOffset;
rightBooster.position = nextHeroPos + rightBoosterOffset;
}
示例3: Update
public void Update(GameTime gameTime)
{
actionTimer += gameTime.getSeconds();
if (actionTimer >= directionTimes[actionIndex])
{
actionIndex = (actionIndex + 1) % actionCount;
actionTimer = 0;
}
}
示例4: Update
public override void Update(GameTime gameTime)
{
float seconds = gameTime.getSeconds(Hero.HERO_TIMESCALE);
bombTimer += seconds * hero.powerupCooldownModifier;
for(int i = 0; i < bombs.Count; i++)
{
Bomb b = bombs[i];
b.Update(gameTime);
if(b.timeAlive >= b.timeToExplode)
{
bombs.RemoveAt(i);
i--;
}
}
}
示例5: Update
public override void Update(GameTime gameTime)
{
float seconds = gameTime.getSeconds();
Vector2 scrollTarget;
if (Vector2.Distance(targetEntity.position, otherEntity.position) <= MaxDistanceBetweenEntities)
{
Vector2 centerBetween = Vector2.Lerp(targetEntity.position, otherEntity.position, 0.5f);
scrollTarget = centerBetween;
}
else
{
Vector2 unitVectorBetween = (otherEntity.position - targetEntity.position);
unitVectorBetween.Normalize();
Vector2 maxDistanceFromTargetEntityTowardsOther = targetEntity.position + (unitVectorBetween * (MaxDistanceBetweenEntities / 2));
scrollTarget = maxDistanceFromTargetEntityTowardsOther;
}
scrollCameraToTarget(scrollTarget, seconds);
}
示例6: Update
public override void Update(GameTime gameTime)
{
if (!hero.Alive)
{
toRemove = true;
return;
}
if (activated) {
float seconds = gameTime.getSeconds(Hero.HERO_TIMESCALE);
if (timer < ADRENALINE_TIME) {
hero.powerupCooldownModifier *= modifier;
timer += seconds;
}
else {
toRemove = true;
}
adrenalineEmitter.position = hero.position; //updates particle emitter
adrenalineEmitter.Update(gameTime);
}
}
示例7: Update
public override void Update(GameTime gameTime)
{
if (!hero.Alive)
{
toRemove = true;
return;
}
if (activated)
{
float seconds = gameTime.getSeconds(Hero.HERO_TIMESCALE);
if (secsPassed < BOOST_SECS)
{
secsPassed += seconds;
hero.globalMoveSpeedMultiplier *= SPEED_BOOST;
}
else
toRemove = true;
speedEmitter.position = hero.position; //updates particle emitter
speedEmitter.Update(gameTime);
}
}
示例8: Update
public void Update(GameTime gameTime, bool collide)
{
active = collide;
switch (hero.direction)
{
case Direction.Up:
position.X = hero.position.X;
position.Y = hero.position.Y - offset;
break;
case Direction.Down:
position.X = hero.position.X;
position.Y = hero.position.Y + offset;
break;
case Direction.Left:
position.X = hero.position.X - offset;
position.Y = hero.position.Y;
break;
case Direction.Right:
position.X = hero.position.X + offset;
position.Y = hero.position.Y;
break;
}
updateCurrentLevelAndTile();
float seconds = gameTime.getSeconds(Hero.HERO_TIMESCALE);
if (active)
foreach (Enemy e in RetroGame.getLevels()[levelX, levelY].enemies)
if (hitbox.intersects(e.hitbox))
{
e.hitBy(hero, damagePerSecond * seconds);
}
flameEmitter.position = position;
flameEmitter.active = collide;
flameEmitter.Update(gameTime);
base.Update(gameTime);
}
示例9: Update
public override void Update(GameTime gameTime)
{
float seconds = gameTime.getSeconds(Hero.HERO_TIMESCALE);
base.Update(gameTime);
if (!hero.Alive)
return;
if (bombs.Count > 0)
{
tickTimer += seconds;
for(tickStage = 0; tickStage < TICK_STAGE_TIMES.Length; tickStage++) //terribly ugly loop... oh well
{
if (bombs[0].timeAlive < TICK_STAGE_TIMES[tickStage])
break;
}
tickStage--;
Console.WriteLine("timealive=" + bombs[0].timeAlive + " stage=" + tickStage);
tickInterval = TICK_INTERVALS[tickStage];
if (tickTimer >= tickInterval)
{
tickTimer = 0;
SoundManager.PlaySoundOnce("BombTick", playInReverseDuringReverse: true);
}
}
}
示例10: Update
public override void Update(GameTime gameTime)
{
float seconds = gameTime.getSeconds();
scrolling = false;
scrollCamera(seconds);
}
示例11: Update
public override void Update(GameTime gameTime)
{
float seconds = gameTime.getSeconds(Hero.HERO_TIMESCALE);
if (hero.Alive)
{
if (bursting)
{
leftBoosterFiring.active = true;
rightBoosterFiring.active = true;
leftBoosterIdle.active = false;
rightBoosterIdle.active = false;
}
else
{
leftBoosterIdle.active = true;
rightBoosterIdle.active = true;
leftBoosterFiring.active = false;
rightBoosterFiring.active = false;
}
}
else
{
leftBoosterIdle.active = false;
rightBoosterIdle.active = false;
leftBoosterFiring.active = false;
rightBoosterFiring.active = false;
}
if (bursting)
{
float speed = hero.movement.Length();
leftBoosterFiring.valueToDeath = BOOSTER_LENGTH * (1 + speed / (Hero.MOVE_SPEED * seconds));
rightBoosterFiring.valueToDeath = BOOSTER_LENGTH * (1 + speed / (Hero.MOVE_SPEED * seconds));
hero.globalMoveSpeedMultiplier *= moveSpeedMultiplier;
}
if (burstRecharge >= BURST_COOLDOWN)
{
leftBoosterIdle.valueToDeath = 12;
rightBoosterIdle.valueToDeath = 12;
leftBoosterIdle.startColor = BOOST_IDLE_RECHARGED_COLOR;
rightBoosterIdle.startColor = BOOST_IDLE_RECHARGED_COLOR;
}
else
{
leftBoosterIdle.valueToDeath = 10;
rightBoosterIdle.valueToDeath = 10;
leftBoosterIdle.startColor = BOOST_IDLE_NOT_RECHARGED_COLOR;
rightBoosterIdle.startColor = BOOST_IDLE_NOT_RECHARGED_COLOR;
}
base.Update(gameTime);
leftBoosterFiring.angle = boosterAngle;
rightBoosterFiring.angle = boosterAngle;
if (seconds > 0)
{
leftBoosterFiring.Update(gameTime);
rightBoosterFiring.Update(gameTime);
}
Vector2 nextHeroPos = hero.position + hero.movement; //use next frame's hero position to stick the particle emitter to the hero better
leftBoosterFiring.position = nextHeroPos + leftBoosterOffset;
rightBoosterFiring.position = nextHeroPos + rightBoosterOffset;
}
示例12: Update
public static void Update(GameTime gameTime)
{
float seconds = gameTime.getSeconds();
bool coop = RetroGame.NUM_PLAYERS == 2;
int newPosition;
if (!coop)
{
currentSoloHighscore.score = RetroGame.Score;
for (newPosition = currentHighscorePosition; newPosition > 0; newPosition--)
{
if (currentSoloHighscore.score >= highscoresSolo[newPosition - 1].score)
continue;
break;
}
if (newPosition != currentHighscorePosition)
{
if (currentHighscorePosition < HIGHSCORE_COUNT)
highscoresSolo.RemoveAt(currentHighscorePosition);
else
highscoresSolo.RemoveAt(HIGHSCORE_COUNT - 1);
highscoresSolo.Insert(newPosition, currentSoloHighscore);
currentHighscorePosition = newPosition;
}
}
else
{
currentCoopHighscore.score = RetroGame.Score;
for (newPosition = currentHighscorePosition; newPosition > 0; newPosition--)
{
if (currentCoopHighscore.score >= highscoresCoop[newPosition - 1].score)
continue;
break;
}
if (newPosition != currentHighscorePosition)
{
if (currentHighscorePosition < HIGHSCORE_COUNT)
highscoresCoop.RemoveAt(currentHighscorePosition);
else
highscoresCoop.RemoveAt(HIGHSCORE_COUNT - 1);
highscoresCoop.Insert(newPosition, currentCoopHighscore);
currentHighscorePosition = newPosition;
}
}
currentHighscoreColorInterp += seconds * currentHighscoreColorInterpModifier * CURRENT_HIGHSCORE_COLOR_SPEED;
if (currentHighscoreColorInterp > 1 || currentHighscoreColorInterp < 0)
{
currentHighscoreColorInterpModifier *= -1;
currentHighscoreColorInterp = MathHelper.Clamp(currentHighscoreColorInterp, 0, 1);
}
currentHighscoreColor = Color.Lerp(CURRENT_HIGHSCORE_REGULAR_COLOR, CURRENT_HIGHSCORE_HIGHLIGHTED_COLOR, currentHighscoreColorInterp);
}
示例13: UpdateReverse
public static void UpdateReverse(GameTime gameTime)
{
float seconds = gameTime.getSeconds();
secsSinceLastRetroPort = 0;
bool isNewFrame = false;
int RETROPORT_FRAMES = histories.Count;
float framePerc = currentFrame / RETROPORT_FRAMES;
float frameVelocity = getFrameVelocity(framePerc);
float oldFrame = currentFrame;
currentFrame += frameVelocity * seconds;
if ((int)currentFrame != (int)oldFrame)
isNewFrame = true;
int frameIndex = RETROPORT_FRAMES - (int)currentFrame - 1;
float interpolation = currentFrame - (int)currentFrame;
History currentHistory = null;
History nextHistory = null;
if (frameIndex >= 0)
{
currentHistory = histories.ElementAt(frameIndex);
}
else
{
CancelRevert();
return;
}
if (frameIndex > 0)
{
nextHistory = histories.ElementAt(frameIndex - 1);
}
foreach (IReversible reversible in currentHistory.mementos.Keys)
{
IMemento nextFrame = null;
if (nextHistory != null && nextHistory.mementos.ContainsKey(reversible))
nextFrame = nextHistory.mementos[reversible];
currentHistory.mementos[reversible].Apply(interpolation, isNewFrame, nextFrame);
}
currentHistory.retroGameMemento.Apply(interpolation, isNewFrame, (nextHistory != null) ? nextHistory.retroGameMemento : null);
currentHistory.riotGuardWallMemento.Apply(interpolation, isNewFrame, (nextHistory != null) ? nextHistory.riotGuardWallMemento : null);
currentHistory.soundManagerMemento.Apply(interpolation, isNewFrame, (nextHistory != null) ? nextHistory.soundManagerMemento : null);
LevelManagerScreen topScreen = RetroGame.TopLevelManagerScreen;
topScreen.currentEffect = Effects.RewindDistortion;
topScreen.currentEffect.CurrentTechnique = topScreen.currentEffect.Techniques["DistortRight"];
topScreen.currentEffect.Parameters["waveFrequency"].SetValue(DISTORTION_WAVE_FREQUENCY);
topScreen.currentEffect.Parameters["granularity"].SetValue(DISTORTION_WAVE_GRANULARITY);
topScreen.currentEffect.Parameters["waveOffset"].SetValue(DISTORTION_WAVE_OFFSET);
waveAmplitude = 2 * frameVelocity / FRAME_VELOCITY_MAX;
topScreen.currentEffect.Parameters["waveAmplitude"].SetValue((DISTORTION_WAVE_AMPLITUDE_BASE * waveAmplitude) - DISTORTION_WAVE_OFFSET);
phaseOffset = framePerc * 2;
topScreen.currentEffect.Parameters["phaseOffset"].SetValue(phaseOffset);
topScreen.drawEffects = true;
}
示例14: UpdateForward
public static void UpdateForward(GameTime gameTime)
{
float seconds = gameTime.getSeconds();
secsSinceLastRetroPort += seconds;
History history = new History();
foreach (IReversible reversible in registeredReversibles)
{
history.mementos[reversible] = reversible.GenerateMementoFromCurrentFrame();
}
history.retroGameMemento = RetroGame.GenerateMementoFromCurrentFrame();
history.riotGuardWallMemento = RiotGuardWall.GenerateMementoFromCurrentFrame();
history.soundManagerMemento = SoundManager.GenerateMementoFromCurrentFrame();
histories.Enqueue(history);
if (secsSinceLastRetroPort >= RETROPORT_BASE_SECS)
{
LastHistory = histories.Dequeue();
}
else
{
LastHistory = null;
}
}
示例15: Update
public override void Update(GameTime gameTime)
{
float seconds = gameTime.getSeconds();
if (SoundManager.TargetVolume != BACKGROUND_MUSIC_VOLUME)
SoundManager.SetMusicVolume(BACKGROUND_MUSIC_VOLUME);
UpdateControls(bindings, gameTime);
arrowDistance += seconds * ARROW_DISTANCE_VELOCITY * arrowVelocityModifier;
if(arrowDistance >= ARROW_DISTANCE_MAX || arrowDistance <= ARROW_DISTANCE_MIN)
arrowVelocityModifier *= -1;
if (bindingsMenuInstructionsNotifyTime < BINDINGS_INSTRUCTIONS_NOTIFY_TIME)
{
bindingsMenuInstructionsNotifyTime += seconds;
}
bindingsMenuInstructionsColor = Color.Lerp(bindingsMenuInstructionsError ? BINDINGS_INSTRUCTIONS_ERROR_COLOR : BINDINGS_INSTRUCTIONS_NOTIFY_COLOR, BINDINGS_INSTRUCTIONS_IDLE_COLOR, bindingsMenuInstructionsNotifyTime / BINDINGS_INSTRUCTIONS_NOTIFY_TIME);
}