public void Update(GameTime time) { var kbState = Keyboard.GetState(); // move to point var isAtPoint = Math.Abs(GameMathHelper.CalculateDistanceBetween(Props.Position, movingTo)) < 2f; if (!isAtPoint) { // look at point Props.Rotation = GameMathHelper.GetDirectionInRadians(Props.Position, movingTo); var force = GameMathHelper.UpdateVelocity( Props.Rotation, 5f); Props.AddForce(force); } else { if (waypointsQueue.Count == 0) { allWaypoints.Reverse(); waypointsQueue = new Queue <Vector2>(allWaypoints); } movingTo = waypointsQueue.Dequeue(); } }
public static void Draw(SpriteBatch sp) { //Health Bar sp.Draw(BarBackTexture, new Rectangle((int)Location.X, (int)Location.Y, BarLength, 25), Color.White); sp.Draw(TextureHelper.Blank(Color.Red), new Rectangle((int)Location.X, (int)Location.Y, (int)HLength, 25), Color.White); sp.DrawString(font, Game.PlayerManager.Health + "/" + Game.PlayerManager.MaxHealth, Location, Color.White, 0f, new Vector2(), 0.7f, SpriteEffects.None, 1f); //Mana Bar sp.Draw(BarBackTexture, new Rectangle((int)Location.X, (int)Location.Y + 50, BarLength, 25), Color.White); sp.Draw(TextureHelper.Blank(Color.Blue), new Rectangle((int)Location.X, (int)Location.Y + 50, (int)MLength, 25), Color.White); sp.DrawString(font, Game.PlayerManager.Mana + "/" + Game.PlayerManager.MaxMana, new Vector2(Location.X, Location.Y + 50), Color.White, 0f, new Vector2(), 0.7f, SpriteEffects.None, 1f); Rectangle BuffPosition = new Rectangle((int)Location.X, (int)Location.Y + 100, 30, 30); //Buffs foreach (Buff b in Game.PlayerCharacter.Buffs.CurrentBuffs) { if (b.Texture != null) { sp.Draw(b.Texture, BuffPosition, Color.White); sp.DrawString(font, GameMathHelper.FramesToStringTime(b.Duration), new Point(BuffPosition.X, BuffPosition.Bottom).ToVector2(), Color.White, 0f, new Vector2(), 0.5f, SpriteEffects.None, 1); if (MouseHandler.mousePosRect.Intersects(BuffPosition)) { string displayString = b.Name + "\n" + b.Description; Vector2 size = font.MeasureString(displayString) * 0.5f; sp.Draw(TextureHelper.Blank(Color.Black), new Rectangle(MouseHandler.mousePos.ToPoint(), size.ToPoint()), Color.White * 0.5f); sp.DrawString(font, displayString, MouseHandler.mousePos, Color.White, 0f, new Vector2(), 0.5f, SpriteEffects.None, 1); } BuffPosition.X += 10 + BuffPosition.Width; } } //Ability Bar sp.Draw(TextureHelper.Blank(Color.DarkOliveGreen), AbilityBarLocation, Color.White); sp.Draw(TextureHelper.Blank(Color.Turquoise), new Rectangle(AbilityBarLocation.Left, AbilityBarLocation.Y, AbilityBarLocation.Width / 4, AbilityBarLocation.Height), Color.White); // Q Ability sp.Draw(TextureHelper.Blank(Color.Pink), new Rectangle(AbilityBarLocation.Right - (AbilityBarLocation.Width / 4), AbilityBarLocation.Y, AbilityBarLocation.Width / 4, AbilityBarLocation.Height), Color.White); // E Ability if (Manager.Class.CooldownPercentage() < 1.0) { sp.Draw(TextureHelper.Blank(Color.Black), new Rectangle( AbilityBarLocation.Right - (AbilityBarLocation.Width / 4), // X AbilityBarLocation.Bottom - (int)(AbilityBarLocation.Height * Manager.Class.CooldownPercentage()), // Y AbilityBarLocation.Width / 4, // Width (int)(AbilityBarLocation.Height * Manager.Class.CooldownPercentage())), // Height Color.White * 0.5f); // E Ability Cover } }
public override void OnInventoryUse() { float original = Game.PlayerCharacter.terminalVelocity.X; if (Game.PlayerCharacter.Buffs.AddBuff(new SpeedBuff(1, GameMathHelper.TimeToFrames(10), Game.PlayerCharacter))) { Game.PlayerManager.Inventory.DeleteItem(this); } }
public Buff(string name, int dur, int lvl = 0, string desc = "", Action start = null, Action during = null, Action end = null, Texture2D texture = null) { Name = name + " " + GameMathHelper.NumToRomanNumeral(lvl); Duration = dur; Texture = texture; OnStart = start; During = during; OnEnd = end; Level = lvl; Description = desc; }
public void DrawItemInfo(SpriteBatch sp) { if (HoverItem != null) { if (HoverItem is ItemStack) { List <Item> stack = ((ItemStack)HoverItem).items; ItemInformation = new string[] { HoverItem.ID + " - " + HoverItem.Name + " (x" + stack.Count + ")", stack[0] is Weapon ? "Damage: " + ((Weapon)stack[0]).Damage.ToString() : "", stack[0] is Potion ? "Effect: " + ((Potion)stack[0]).EffectDescription : "", stack[0] is Potion ? "Duration: " + GameMathHelper.FramesToStringTime(((Potion)stack[0]).Duration) : "", "Description: " + HoverItem.Description }; } else { ItemInformation = new string[] { HoverItem.ID + " - " + HoverItem.Name, HoverItem is Weapon ? "Damage: " + ((Weapon)HoverItem).Damage.ToString() : "", HoverItem is Potion ? "Effect: " + ((Potion)HoverItem).EffectDescription : "", HoverItem is Potion ? "Duration: " + GameMathHelper.FramesToStringTime(((Potion)HoverItem).Duration) : "", "Description: " + HoverItem.Description }; } Point position = MouseHandler.mousePos.ToPoint(); SpriteFont font = Game.GameContent.Load <SpriteFont>(TextureHelper.Fonts.Default); float width = 0; foreach (string str in ItemInformation) { width = width < font.MeasureString(str).X ? (int)font.MeasureString(str).X : width; } width *= 0.7f; float yPos = position.Y + font.MeasureString(ItemInformation[0]).Y; for (int i = 0; i < ItemInformation.Length; i++) { if (ItemInformation[i].Length == 0) { continue; } sp.Draw(TextureHelper.Blank(Color.Black), new Vector2(position.X, yPos), new Rectangle(position.X, (int)yPos, (int)width, (int)font.MeasureString(ItemInformation[i]).Y), Color.White * TransparencyLevel); sp.DrawString(font, ItemInformation[i], new Vector2(position.X, yPos), Color.LightGray, 0f, new Vector2(), 0.7f, SpriteEffects.None, 1f); yPos += font.MeasureString(ItemInformation[i]).Y; } } }
private void WindEarth(AnimatedSprite target) { List <AnimatedSprite> sp = CollisionDetection.GetNearby(target.SpriteRectangle, 75); foreach (AnimatedSprite i in sp) { if (i != Game.PlayerCharacter) { i.Buffs.AddBuff(new WindyBuff(GameMathHelper.TimeToFrames(6), 2, i)); } } }
public BurningBuff(int dur, int lvl, AnimatedSprite target) : base("Burning", dur, lvl, "You're burning!", texture: TextureHelper.Blank(Color.Red)) { Target = target; OnStart = () => { if (timer == null) { timer = new TimerHelper( GameMathHelper.TimeToFrames(0.3f - (0.3f / 20f * (lvl - 1f))), () => { Target.AddHealthIgnoreInvincibility(-(1 + (lvl / 2))); } ); } }; OnEnd = () => { timer?.Delete(); timer = null; }; }
public RegenerationBuff(int dur, int lvl, AnimatedSprite target) : base("Regeneration", dur, lvl, "Your wounds are healing", texture: TextureHelper.Blank(Color.LightPink)) { Target = target; OnStart = () => { if (timer == null) { timer = new TimerHelper( GameMathHelper.TimeToFrames(0.3f - (0.3f / 20f * (lvl - 1f))), () => { Target.AddHealth(1 + (lvl / 2)); } ); } }; OnEnd = () => { timer?.Delete(); timer = null; }; }
public FrostbittenBuff(int dur, int lvl, AnimatedSprite target) : base("Frostbitten", dur, lvl, "You're really, really cold", texture: TextureHelper.Blank(Color.DarkBlue)) { Target = target; OnStart = () => { if (timer == null) { target.terminalVelocity.X -= lvl * 30; timer = new TimerHelper( GameMathHelper.TimeToFrames(1f - (1f / 100f * (lvl - 1f))), () => { Target.AddHealthIgnoreInvincibility(-(1 + (lvl))); } ); } }; OnEnd = () => { target.terminalVelocity.X = AnimatedSprite.DefaultTerminalVelocity.X; timer?.Delete(); timer = null; }; }
public CathedralRuinsFBoss() { maxBounds = new Rectangle(0, 0, 10000, 10000); ContentManager Content = Game.GameContent; BackgroundLayer = new MapObject[] { }; InteractableLayer = new MapInteractable[] { new MapInteractable(TextureHelper.Blank(Color.LightGreen), new Vector2(600, 2500), 50, 50, false, () => { List <AnimatedSprite> sp = CollisionDetection.GetNearby(new Rectangle(600, 2500, 50, 50), 100); foreach (AnimatedSprite i in sp) { i.Buffs.AddBuff(new RegenerationBuff(GameMathHelper.TimeToFrames(2), 10, i)); } }), new MapInteractable(TextureHelper.Blank(Color.Orange), new Vector2(500, 2800), 50, 50, false, () => { List <AnimatedSprite> sp = CollisionDetection.GetNearby(new Rectangle(500, 2800, 50, 50), 100); if (sp.Contains(Game.PlayerCharacter)) { Game.PlayerCharacter.Buffs.AddBuff(new AttackSpeedBuff(-1, 5)); sp.Clear(); } }), new MapInteractable(TextureHelper.Blank(Color.LightBlue), new Vector2(600, 2800), 50, 50, true, () => { List <AnimatedSprite> sp = CollisionDetection.GetNearby(new Rectangle(600, 2800, 50, 50), 100); if (sp.Contains(Game.PlayerCharacter)) { Game.PlayerCharacter.Buffs.AddBuff(new SpeedBuff(GameMathHelper.TimeToFrames(10), 2, Game.PlayerCharacter)); } }), new MapInteractable(TextureHelper.Blank(Color.White), new Vector2(700, 2800), 50, 50, true, () => { AnimatedSprite temp; temp = new AnimatedSprite(TextureHelper.Sprites.EnemySprite, 1, 1, 700, 2800, new BasicAI(Game.PlayerCharacter), new DefaultManager(10)); temp.AI.SupplyAI(temp); temp.Load(); temp.SpriteRectangle.Width = 50; temp.SpriteRectangle.Height = 50; RenderHandler.allCharacterSprites.Add(temp); }), new MapInteractable(TextureHelper.Blank(Color.DeepSkyBlue), new Vector2(800, 2800), 50, 50, true, () => { List <AnimatedSprite> sp = CollisionDetection.GetNearby(new Rectangle(800, 2800, 50, 50), 100); foreach (AnimatedSprite i in sp) { i.Buffs.AddBuff(new WindyBuff(GameMathHelper.TimeToFrames(10), 10, i)); } }) }; ActiveLayer = new MapObject[] { new MapObject(TextureHelper.Blank(Color.DarkGray), new Vector2(0, 0), 1600, 100), new MapObject(TextureHelper.Blank(Color.DarkGray), new Vector2(0, 0), 100, 500), new MapObject(TextureHelper.Blank(Color.DarkGray), new Vector2(0, 500), 800, 100), new MapObject(TextureHelper.Blank(Color.DarkGray), new Vector2(1200, 500), 500, 100), new MapObject(TextureHelper.Blank(Color.DarkGray), new Vector2(1600, 0), 100, 500), new MapObject(TextureHelper.Blank(Color.DarkGray), new Vector2(700, 600), 100, 1000), new MapObject(TextureHelper.Blank(Color.DarkGray), new Vector2(1200, 600), 100, 1000), new MapObject(TextureHelper.Blank(Color.DarkGray), new Vector2(0, 1600), 800, 100), new MapObject(TextureHelper.Blank(Color.DarkGray), new Vector2(1200, 1600), 600, 100), new MapObject(TextureHelper.Blank(Color.DarkGray), new Vector2(0, 1600), 100, 1500), new MapObject(TextureHelper.Blank(Color.DarkGray), new Vector2(1700, 1600), 100, 900), new MapObject(TextureHelper.Blank(Color.DarkGray), new Vector2(1700, 2800), 100, 300), new MapObject(TextureHelper.Blank(Color.DarkGray), new Vector2(0, 3100), 1800, 100), new MapObject(TextureHelper.Blank(Color.DarkGray), new Vector2(300, 2925), 1400, 50), new MapObject(TextureHelper.Blank(Color.DarkGray), new Vector2(100, 2600), 700, 50), new MapObject(TextureHelper.Blank(Color.DarkGray), new Vector2(1000, 2750), 400, 50), new MapObject(TextureHelper.Blank(Color.DarkGray), new Vector2(300, 2200), 1200, 50), new MapObject(TextureHelper.Blank(Color.DarkGray), new Vector2(1800, 2800), 800, 100), new MapObject(TextureHelper.Blank(Color.DarkGray), new Vector2(1800, 2400), 800, 100), new MapObject(TextureHelper.Blank(Color.DarkGray), new Vector2(2600, 2800), 100, 300), new MapObject(TextureHelper.Blank(Color.DarkGray), new Vector2(2600, 3100), 400, 100), new MapObject(TextureHelper.Blank(Color.DarkGray), new Vector2(3200, 3100), 400, 100), new MapObject(TextureHelper.Blank(Color.DarkGray), new Vector2(3600, 1200), 100, 2000), }; ForegroundLayer = new MapObject[] { }; }
public void StartAnimation(float rotateRate) { if (Visible) { return; } if (SwingCooldown > 0) { return; } if (MouseHandler.mousePos.X > Game.PlayerCharacter.SpriteRectangle.Center.X) { ItemLocation = () => { ItemRectangle.X = Game.PlayerCharacter.SpriteRectangle.Right; }; Game.PlayerCharacter.animate.Flipped = false; animate.Flipped = false; } else { ItemLocation = () => { ItemRectangle.X = Game.PlayerCharacter.SpriteRectangle.Left; }; Game.PlayerCharacter.animate.Flipped = true; animate.Flipped = true; } if (Game.PlayerManager.EquippedWeapon is Ranged) { if (animate.Flipped) { animate.Origin = new Vector2(animate.Texture.Width, animate.Texture.Height); animate.Angle = GameMathHelper.LookAtMouse(new Vector2(ItemRectangle.Right, ItemRectangle.Bottom)) - GameMathHelper.PIConstants.PI_45 + (float)Math.PI; } else { animate.Origin = new Vector2(0, animate.Texture.Height); animate.Angle = GameMathHelper.LookAtMouse(new Vector2(ItemRectangle.Left, ItemRectangle.Bottom)) + GameMathHelper.PIConstants.PI_45; } RotationRate = 0f; AngleCheck = () => { StopSwing = SwingCooldown <= 0; }; SwingCooldown = 0.3f - rotateRate; } else { if (animate.Flipped) { animate.Origin = new Vector2(animate.Texture.Width, animate.Texture.Height); RotationRate = -rotateRate; animate.Angle = GameMathHelper.PIConstants.PI_45; AngleCheck = () => { StopSwing = animate.Angle < -GameMathHelper.PIConstants.PI_45; }; } else { animate.Origin = new Vector2(0, animate.Texture.Height); RotationRate = rotateRate; animate.Angle = -GameMathHelper.PIConstants.PI_45; AngleCheck = () => { StopSwing = animate.Angle > GameMathHelper.PIConstants.PI_45; }; } } StopSwing = false; Visible = true; OnStart(); }
public WindyBuff(int dur, int lvl, AnimatedSprite target) : base("Windy", dur, lvl, "It's too windy to control!", texture: TextureHelper.Blank(Color.Tan)) { Random rand = new Random(); OnStart = () => { if (timer == null) { timer = new TimerHelper( GameMathHelper.TimeToFrames(1f - (1f / 20f * (lvl - 1f))), () => { int bounds = lvl * 300; int x = rand.Next(-bounds, bounds); int y = rand.Next(-bounds, bounds); if (y < 0 && target.North) { y = 0; } else if (y > 0 && target.South) { y = 0; } if (x > 0 && target.East) { x = 0; } else if (x < 0 && target.West) { x = 0; } if (y < -target.terminalVelocity.Y) { y = (int)-target.terminalVelocity.Y; } else if (y > target.terminalVelocity.Y) { y = (int)target.terminalVelocity.Y; } if (x < -target.terminalVelocity.X) { x = (int)-target.terminalVelocity.X; } else if (x > target.terminalVelocity.X) { x = (int)target.terminalVelocity.X; } target.velocity += new Vector2(x, y); } ); } }; OnEnd = () => { timer?.Delete(); timer = null; }; }
public override void ProjectileAction(AnimatedSprite source, AnimatedSprite target) { switch (spellType) { // Fire Attack case Caster.SpellType.FIRE: target.AddHealth(-Damage); // Fire + Ice if (target.Buffs.HasBuff(typeof(SlowBuff))) { target.Buffs.RemoveBuff(typeof(SlowBuff)); FireIce(target); } // Fire + Wind else if (target.Buffs.HasBuff(typeof(DamageReductionBuff))) { target.Buffs.RemoveBuff(typeof(DamageReductionBuff)); FireWind(target); } // Fire + Earth else if (target.Buffs.HasBuff(typeof(DefenseReductionBuff))) { target.Buffs.RemoveBuff(typeof(DefenseReductionBuff)); FireEarth(target); } else { target.Buffs.AddBuff(new BurningBuff(GameMathHelper.TimeToFrames(3), 1, target)); } break; // Ice Attack case Caster.SpellType.ICE: target.AddHealth(-Damage); // Fire + Ice if (target.Buffs.HasBuff(typeof(BurningBuff))) { target.Buffs.RemoveBuff(typeof(BurningBuff)); FireIce(target); } // Ice + Wind else if (target.Buffs.HasBuff(typeof(DamageReductionBuff))) { target.Buffs.RemoveBuff(typeof(DamageReductionBuff)); IceWind(target); } // Ice + Earth else if (target.Buffs.HasBuff(typeof(DefenseReductionBuff))) { target.Buffs.RemoveBuff(typeof(DefenseReductionBuff)); IceEarth(target); } else { target.Buffs.AddBuff(new SlowBuff(GameMathHelper.TimeToFrames(3), 2, target)); } break; // Wind Attack case Caster.SpellType.WIND: target.AddHealth(-Damage); // Fire + Wind if (target.Buffs.HasBuff(typeof(BurningBuff))) { target.Buffs.RemoveBuff(typeof(BurningBuff)); FireWind(target); } // Ice + Wind else if (target.Buffs.HasBuff(typeof(SlowBuff))) { target.Buffs.RemoveBuff(typeof(SlowBuff)); IceWind(target); } // Wind + Earth else if (target.Buffs.HasBuff(typeof(DefenseReductionBuff))) { target.Buffs.RemoveBuff(typeof(DefenseReductionBuff)); WindEarth(target); } else { target.Buffs.AddBuff(new DamageReductionBuff(GameMathHelper.TimeToFrames(3), 1, target)); } break; // Earth Attack case Caster.SpellType.EARTH: target.AddHealth(-Damage); // Fire + Earth if (target.Buffs.HasBuff(typeof(BurningBuff))) { target.Buffs.RemoveBuff(typeof(BurningBuff)); FireEarth(target); } // Ice + Earth else if (target.Buffs.HasBuff(typeof(SlowBuff))) { target.Buffs.RemoveBuff(typeof(SlowBuff)); IceEarth(target); } // Wind + Earth else if (target.Buffs.HasBuff(typeof(DamageReductionBuff))) { target.Buffs.RemoveBuff(typeof(DamageReductionBuff)); WindEarth(target); } else { target.Buffs.AddBuff(new DefenseReductionBuff(GameMathHelper.TimeToFrames(3), 1, target)); } break; default: target.AddHealth(-Damage); break; } Delete(); }