/// <summary> /// Shoot method with starting conditions to compensate for network delay /// </summary> /// <param name="target">Where is bulet traveling to</param> /// <param name="shootOrgin">Where shot was fired</param> /// <param name="shootRotation">How was weapon rotated during shoot</param> public void Shoot(Vector2f target, Vector2f shootOrgin, float shootRotation, Player player, bool sendToServer) { if (Ammo != 0 && Reloading != true && ShootTimer.ElapsedTime.AsMilliseconds() > AttackSpeed) { ShootTimer.Restart(); // maybe figure out how to make this Vector2f -> Vector2 -> Vector2f mess cleaner later const float projectileSpeed = 10f; Vector2 normalizedTarget = new Vector2(target.X, target.Y); normalizedTarget = Vector2.Normalize(normalizedTarget); Vector2f myTarget = new Vector2f(normalizedTarget.X, normalizedTarget.Y); Projectile bullet = new Projectile(myTarget * projectileSpeed, ProjectileSprite, shootOrgin, shootRotation); Projectiles.Add(bullet); ChangeAmmo(-1); Sound sound = ResourceHolderFacade.GetInstance().Sounds.Get(SoundIdentifier.GenericGun); sound.Volume = ResourceHolderFacade.GetInstance().CurrentVolume.GetVolume(); sound.Play(); if (sendToServer) { var shootEventData = new ShootEventData(player.ToDTO(), target, this.Position, this.Rotation); //GameState.GetInstance().ConnectionManager.Connection.SendAsync("ShootEventServer", shootEventData); GameState.GetInstance().ConnectionManagerProxy.Connection.SendAsync("ShootEventServer", shootEventData); } } }
public CustomText(uint textSize) { this.Font = ResourceHolderFacade.GetInstance().Fonts.Get(FontIdentifier.PixelatedSmall); this.CharacterSize = textSize; this.OutlineThickness = 2; this.OutlineColor = Color.Black; this.Origin = new Vector2f(-5, -15f); }
public Button() { normalTexture = TextureHolder.GetInstance().Get(TextureIdentifier.ButtonDefault); selectedTexture = TextureHolder.GetInstance().Get(TextureIdentifier.ButtonSelected); pressedTexture = TextureHolder.GetInstance().Get(TextureIdentifier.ButtonClicked); sprite = new Sprite(); text = new Text(string.Empty, ResourceHolderFacade.GetInstance().Fonts.Get(FontIdentifier.PixelatedSmall), 16); sprite.Texture = normalTexture; var bounds = sprite.GetLocalBounds(); text.Position = new Vector2f(bounds.Width / 2, bounds.Height / 2); }
public static PowerupFlyweight GetFlyweight(TextureIdentifier textureIdentifier, IPowerUpStrategy strategy) { String key = getKey(textureIdentifier, strategy); if (_powerupFlyweights.ContainsKey(key)) { //OurLogger.Log($"Reusing flyweight {key}"); GameApplication.defaultLogger.LogMessage(10, $"Reusing flyweight {key}"); return(_powerupFlyweights[key]); } else { //OurLogger.Log($"Creating new flyweight {key}"); GameApplication.defaultLogger.LogMessage(10, $"Creating flyweight {key}"); PowerupFlyweight powerupFlyweight = new PowerupFlyweight(ResourceHolderFacade.GetInstance().Textures.Get(textureIdentifier), strategy); _powerupFlyweights.Add(key, powerupFlyweight); return(_powerupFlyweights[key]); } }