//methods public Boolean DetectPlayers(Player player) { if (zombieAction != ZombieActions.Chase) { int rangeMultiplier = 4; Rectangle detectRange = new Rectangle( location.X - (((location.Width * rangeMultiplier * 2) / 2) - location.Width), location.Y - (((location.Height * rangeMultiplier) / 2) - location.Height), location.Width * rangeMultiplier * 2, location.Height * rangeMultiplier / 2); if (detectRange.Intersects(player.Location)) return true; } return false; }
private Boolean SingleKeyPress(Player p, Buttons b) { if(p.Controls.CurrentGPS.IsButtonDown(b) && p.Controls.PreviousGPS.IsButtonUp(b)) { return true; } else { return false; } }
private Boolean SingleKeyPress(Player p, Keys k) { if(p.Controls.CurrentKS.IsKeyDown(k) && p.Controls.PreviousKS.IsKeyDown(k)) { return true; } else { return false; } }
private void drawMedkitIcons(Player player) { int mkX = 77; if(player.PIndex == PlayerIndex.Two || player.PIndex == PlayerIndex.Four) mkX = 696; int mkY = 38; if(player.PIndex == PlayerIndex.Three || player.PIndex == PlayerIndex.Four) mkY = 431; int mkDir = -1; if(player.PIndex == PlayerIndex.Two || player.PIndex == PlayerIndex.Four) mkDir = 1; for(int i = 0; i < player.HealingItemsAmount; i++) { spriteBatch.Draw(GUIMedkit, new Rectangle(mkX + (16 * i * mkDir), mkY, GUIMedkit.Width, GUIMedkit.Height), Color.White); } }
private void drawHPBar(Player player) { int barX = 6; if(player.PIndex == PlayerIndex.Two || player.PIndex == PlayerIndex.Four) barX = 662; int barY = 63; if(player.PIndex == PlayerIndex.Three || player.PIndex == PlayerIndex.Four) barY = 428; //calculates bar size int percentHP = (player.HP * hpBarWidth / player.MaxHP); if(percentHP > hpBarWidth) { percentHP = hpBarWidth; } //draws the bar spriteBatch.Draw(GUIhpBARredside, new Rectangle(barX, barY, 1, 9), Color.White); spriteBatch.Draw(GUIhpBARred, new Rectangle(barX + 1, barY, percentHP, 9), Color.White); spriteBatch.Draw(GUIhpBARgrey, new Rectangle(percentHP + barX + 1, barY, hpBarWidth - percentHP, 9), Color.White); if(percentHP >= hpBarWidth) spriteBatch.Draw(GUIhpBARredside, new Rectangle(hpBarWidth + barX + 1, barY, 1, 9), Color.White); else spriteBatch.Draw(GUIhpBARgreyside, new Rectangle(hpBarWidth + barX + 1, barY, 1, 9), Color.White); }
private void drawAmmoClips(Player player) { int ammoX = 89; if(player.PIndex == PlayerIndex.Two || player.PIndex == PlayerIndex.Four) ammoX = 696; int ammoY = 50; if(player.PIndex == PlayerIndex.Three || player.PIndex == PlayerIndex.Four) ammoY = 443; int ammoDir = -1; if(player.PIndex == PlayerIndex.Two || player.PIndex == PlayerIndex.Four) ammoDir = 1; if(player.Items.Count > 0) { int ammoClipsUserHasLeft = 0; foreach(Item item in player.Items) { if(item.GetType() == typeof(AmmoItem)) ammoClipsUserHasLeft++; } for(int i = 0; i < ammoClipsUserHasLeft; i++) { spriteBatch.Draw(GUIAmmo, new Rectangle(ammoX + (16 * i * ammoDir), ammoY, GUIAmmo.Width, GUIAmmo.Height), Color.White); } } }
private void drawAmmo(Player player) { int ammoX = 106; if(player.PIndex == PlayerIndex.Two || player.PIndex == PlayerIndex.Four) ammoX = 632; int ammoY = 5; if(player.PIndex == PlayerIndex.Three || player.PIndex == PlayerIndex.Four) ammoY = 441; int width = GUIAmmoClipEmpty.Width; int height = GUIAmmoClipEmpty.Height; SpriteEffects rotate = SpriteEffects.None; if(player.PIndex == PlayerIndex.Two) rotate = SpriteEffects.FlipHorizontally; else if(player.PIndex == PlayerIndex.Three) rotate = SpriteEffects.FlipVertically; else if(player.PIndex == PlayerIndex.Four) rotate = SpriteEffects.FlipHorizontally | SpriteEffects.FlipVertically; int ammoDir = 1; if(player.PIndex == PlayerIndex.Three || player.PIndex == PlayerIndex.Four) ammoDir = 0; //empty clip spriteBatch.Draw(GUIAmmoClipEmpty, new Rectangle(ammoX, ammoY, width, height), new Rectangle(0, 0, width, height), Color.White, 0, Vector2.Zero, rotate, 0); if(player.CurrentClip != null) { int ammoLeft = 0; if(player.CurrentClip.ClipCapacity != 0) { ammoLeft = (player.CurrentClip.Current * height / player.CurrentClip.ClipCapacity); } //full/partially full clip spriteBatch.Draw(GUIAmmoClipFull, new Vector2(ammoX, ammoY + (height - ammoLeft) * ammoDir), new Rectangle(0, height - ammoLeft, width, ammoLeft), Color.White, 0, Vector2.Zero, 1, rotate, 0); } }