public override void LoadContents(ContentManager contents) { _sprite = contents.Load <Texture2D>(BULLET_PATH); _s_fire.LoadContents(contents, SOUND_FIRE); _s_fire.Play(); base.LoadContents(contents); }
protected void Hover(Vector2 position, Rectangle bounding) { if (CheckInsideUI(position, bounding)) { int a; a = (int)(255 * 0.75f); _bgColor = new Color((int)_bgColor.R, (int)_bgColor.G, (int)_bgColor.B, (int)a); } else { _bgColor = new Color((int)_bgColor.R, (int)_bgColor.G, (int)_bgColor.B, 255); } if (!_hoverBlockPlay && _hoverCanPlay) { // play sound _hoverEffect.Play(0.2f); _hoverBlockPlay = true; } }
public void Add(string type, Rectangle boundingBox) { if (type == Consts.TYPE_PAR_EXPLOSION) { _particles.Add(new ExplosionPar(boundingBox, 1.0f)); _explosion.Play(); } if (type == Consts.TYPE_PAR_FIRE) { _particles.Add(new FirePar(boundingBox, 5.0f)); } if (_particles.Count > 0) { _particles[_particles.Count - 1].LoadContents(_contents); } }
public override void Add(Sfs2X.Entities.User user, SFSObject data) { if (_bullets != null) { if (data.ContainsKey(Consts.X) && (data.ContainsKey(Consts.Y) && data.ContainsKey(Consts.GO_ID))) { int objectId = (int)data.GetDouble(Consts.GO_ID); if (!_bullets.ContainsKey(objectId)) { _bullets.Add((int)data.GetDouble(Consts.GO_ID), new Bullet((float)data.GetDouble(Consts.X), (float)data.GetDouble(Consts.Y), (ulong)objectId)); _bullets[objectId].LoadContents(_contents); _s_fire.Play(); } } } base.Add(user, data); }
public void ControllerUpdate(float deltaTime, ContentManager contents) { var direction = new Vector2((float)Math.Cos(MathHelper.ToRadians(90) - rotation), -(float)Math.Sin(MathHelper.ToRadians(90) - rotation)); if (Keyboard.GetState().IsKeyDown(Keys.A)) { rotation = 4.71f; tankPosition.X -= linearVelocity * deltaTime; } else if (Keyboard.GetState().IsKeyDown(Keys.D)) { rotation = 1.59f; tankPosition.X += linearVelocity * deltaTime; } else if (Keyboard.GetState().IsKeyDown(Keys.W)) { tankPosition.Y -= linearVelocity * deltaTime; rotation = 0f; } else if (Keyboard.GetState().IsKeyDown(Keys.S)) { tankPosition.Y += linearVelocity * deltaTime; rotation = 3.15f; } if (Keyboard.GetState().IsKeyDown(Keys.Space) && preKey.IsKeyUp(Keys.Space)) { sEff.Play(); Shoot(contents); } //test if (Keyboard.GetState().IsKeyDown(Keys.T) && preKey.IsKeyUp(Keys.T)) { isCollision = true; } preKey = Keyboard.GetState(); UpdateBullets(deltaTime); }
public override GameManager.GameState Update(float deltaTime) { if (Keyboard.GetState().IsKeyDown(Keys.Down) && prekey.IsKeyUp(Keys.Down)) { sE.Play(); state++; } if (Keyboard.GetState().IsKeyDown(Keys.Up) && prekey.IsKeyUp(Keys.Up)) { sE.Play(); state--; } prekey = Keyboard.GetState(); if (state == menuState.playButton) { if (colorPlayB.A == 255) { down = false; } if (colorPlayB.A == 0) { down = true; } if (down) { colorPlayB.A += 5; } else { colorPlayB.A -= 5; } } else { colorPlayB.A = 255; } if (state == menuState.exitButton) { if (colorExitB.A == 255) { down = false; } if (colorExitB.A == 0) { down = true; } if (down) { colorExitB.A += 3; } else { colorExitB.A -= 3; } } else { colorExitB.A = 255; } if (state == menuState.soundButton) { if (colorSoundB.A == 255) { down = false; } if (colorSoundB.A == 0) { down = true; } if (down) { colorSoundB.A += 3; } else { colorSoundB.A -= 3; } } else { colorSoundB.A = 255; } if ((int)state > 2) { state = menuState.playButton; } if ((int)state < 0) { state = menuState.soundButton; } return(GameManager.GameState.None); }