public virtual void UpdateMenu(Game1 game) { if (game.newkeys.IsKeyDown(Keys.Down) && game.oldkeys.IsKeyUp(Keys.Down)) { items[currentItemX, currentItemY].SetIsHighlighted(false); ChangeCurrentItem(0, 1); items[currentItemX, currentItemY].SetIsHighlighted(true); sound.Play(click1); } if (game.newkeys.IsKeyDown(Keys.Up) && game.oldkeys.IsKeyUp(Keys.Up)) { items[currentItemX, currentItemY].SetIsHighlighted(false); ChangeCurrentItem(0, -1); items[currentItemX, currentItemY].SetIsHighlighted(true); sound.Play(click1); } if (game.newkeys.IsKeyDown(Keys.Left) && game.oldkeys.IsKeyUp(Keys.Left)) { items[currentItemX, currentItemY].SetIsHighlighted(false); ChangeCurrentItem(-1, 0); items[currentItemX, currentItemY].SetIsHighlighted(true); sound.Play(click1); } if (game.newkeys.IsKeyDown(Keys.Right) && game.oldkeys.IsKeyUp(Keys.Right)) { items[currentItemX, currentItemY].SetIsHighlighted(false); ChangeCurrentItem(1, 0); items[currentItemX, currentItemY].SetIsHighlighted(true); sound.Play(click1); } if (game.newkeys.IsKeyDown(Game1.fire) && game.oldkeys.IsKeyUp(Game1.fire)) { ActivateItem(game); } }
void IMapItem.UpdateSprite(Game1 game) { CollisionState result = CollisionDetector.PerPixelSprite(this, game.player, game.graphics); if (result == CollisionState.Hurtbox || result == CollisionState.Standard) { this.timer++; if (this.timer >= 3 * this.FRAME_OFFSET) { if (this.frameNum == numFrames - 1) { if (!this.recentlyActivated) { game.OpenSaveStationMenu(); this.recentlyActivated = true; dialUp.Play("dialUp"); } } else { this.frameNum++; } this.timer = 1; } } else { this.recentlyActivated = false; this.timer--; if (this.timer <= 0) { this.timer = 3 * this.FRAME_OFFSET; if (this.frameNum <= 0) { this.frameNum = 0; } else { this.frameNum--; } } } this.UpdateSprite(game.worldMap[game.currentRoom]); if (this.onScreen) { game.AddObjectToDraw(this); } else { game.RemoveObjectToDraw(this); } }
public Projectile(IProjectileData data, Directions direction, ISprite origin, Vector2 mapCoordinates, double worldX, double worldY, int frameNum, bool mirrorX, string cue, SoundFX effect) : base(worldX, worldY, data.GetTexture(), new Vector2((float)worldX - mapCoordinates.X, (float)worldY - mapCoordinates.Y), data.GetNumFrames(), frameNum, mirrorX) { Random rnd = new Random(); this.random = rnd.Next(); this.data = data; this.origin = origin; this.life = 0; this.damage = data.GetDamage(); this.direction = direction; effect.Play(StringConverter(cue)); }