protected Ability(AbilityTypes type, Being being, TimeSpan cooldown, TimeSpan castTime, float manaCost, string iconFile) { Type = type; Being = being; FullCooldown = cooldown; ManaCost = manaCost; CastTime = castTime; DrawIcon = iconFile != ""; Texture = DrawIcon ? TextureCacheFactory.GetOnce($"Icons/{iconFile}.png") : null; DisabledTexture = DrawIcon ? TextureCacheFactory.GetOnce($"Icons/{iconFile}-grey.png") : null; }
public static void Initialize(GraphicsDevice graphicsDevice) { _witchTexture = TextureCacheFactory.GetOnce("HUD/witch-icon.png"); _aBtnTexture = TextureCacheFactory.GetOnce("HUD/a_button.png"); _bBtnTexture = TextureCacheFactory.GetOnce("HUD/b_button.png"); _xBtnTexture = TextureCacheFactory.GetOnce("HUD/x_button.png"); _yBtnTexture = TextureCacheFactory.GetOnce("HUD/y_button.png"); _rtBtnTexture = TextureCacheFactory.GetOnce("HUD/rt_button.png"); _rbBtnTexture = TextureCacheFactory.GetOnce("HUD/rb_button.png"); _healthBarBackColor = new Color(0.35f, 0.35f, 0.35f); }
private void SetTexture() { switch (Type) { case AbilityUpgradeType.DamageTaken: Texture = TextureCacheFactory.GetOnce("Icons/viking-shield.png"); return; case AbilityUpgradeType.DashDistance: Texture = TextureCacheFactory.GetOnce("Icons/charging-bull.png"); return; case AbilityUpgradeType.FireballDamage: case AbilityUpgradeType.FireballMana: Texture = TextureCacheFactory.GetOnce("Icons/fireball.png"); return; case AbilityUpgradeType.IceballCrit: case AbilityUpgradeType.IceballMana: Texture = TextureCacheFactory.GetOnce("Icons/ice-bolt.png"); return; case AbilityUpgradeType.HealthRegen: Texture = TextureCacheFactory.GetOnce("Icons/glass-heart.png"); return; case AbilityUpgradeType.ManaRegen: case AbilityUpgradeType.MaxMana: Texture = TextureCacheFactory.GetOnce("Icons/pentagram-rose.png"); return; case AbilityUpgradeType.LavaBlastDistance: Texture = TextureCacheFactory.GetOnce("Icons/lava_blast.png"); return; case AbilityUpgradeType.SprintSpeed: Texture = TextureCacheFactory.GetOnce("Icons/sprint.png"); return; case AbilityUpgradeType.MovementSpeed: Texture = TextureCacheFactory.GetOnce("Icons/walking-boot.png"); return; case AbilityUpgradeType.MaxHealth: Texture = TextureCacheFactory.GetOnce("Icons/health-normal.png"); return; default: throw new Exception("Unhandled upgrade type"); } }
public Zerd(Player player, List <Item> gear) : base(null, false) { Player = player; ChestTexture = TextureCacheFactory.GetOnce(gear.First(g => g.Type == ItemTypes.Robe).AnimationFile); FeetTexture = TextureCacheFactory.GetOnce(gear.First(g => g.Type == ItemTypes.Boots).AnimationFile); HandTexture = TextureCacheFactory.GetOnce(gear.First(g => g.Type == ItemTypes.Glove).AnimationFile); HeadTexture = TextureCacheFactory.GetOnce(gear.First(g => g.Type == ItemTypes.Hood).AnimationFile); gear.ForEach(i => { i.AbilityUpgrades.ForEach(a => player.AbilityUpgrades[a.Type] += a.Amount); i.SkillUpgrades.ForEach(s => { var skill = player.Skills.AllSkillTrees.SelectMany(t => t.Items).FirstOrDefault(item => item.Type == s.Type); if (skill != null) { skill.PointsSpent = Math.Min(skill.PointsSpent + s.UpgradeAmount, skill.MaxPoints); } }); }); Inventory = gear; X = Globals.Map.StartingPosition.X; Y = Globals.Map.StartingPosition.Y; X += (int)player.PlayerIndex % 2 == 0 ? 85 : -85; Y += (int)player.PlayerIndex < 2 ? -60 : 60; Health = GameplayConstants.ZerdStartingHealth; Health *= 1 + Inventory.SelectMany(i => i.AbilityUpgrades).Where(i => i.Type == AbilityUpgradeType.MaxHealth).Sum(i => i.Amount) / 100f; MaxHealth = Health; Mana = GameplayConstants.ZerdStartingMana; Mana *= 1 + Inventory.SelectMany(i => i.AbilityUpgrades).Where(i => i.Type == AbilityUpgradeType.MaxMana).Sum(i => i.Amount) / 100f; MaxMana = Mana; HealthRegen = GameplayConstants.ZerdStartingHealthRegen; ManaRegen = GameplayConstants.ZerdStartingManaRegen; Width = 64; Height = 64; HitboxSize = 0.7f; BaseSpeed = BootItem.Speed; CriticalChance = GameplayConstants.ZerdCritChance; TreasureChests = new List <TreasureChest>(); Keys = new List <Key>(); ZerdAnimations = ZerdAnimationHelpers.GetAnimations(); Stats = new Stats(); Abilities = new List <Ability> { new Dash(this), new Fireball(this), new Wand(this), new Iceball(this) }; }
public SkillTreeItem(SkillType type, string title, string description, int points, int row, int col, string file, SkillTreeItem parent = null, AbilityTypes ability = AbilityTypes.None) { Type = type; Row = row; Col = col; Title = title; MaxPoints = points; Description = description; Texture = TextureCacheFactory.GetOnce($"Icons/{file}"); Children = new List <SkillTreeItem>(); Parent = parent; parent?.Children.Add(this); Ability = ability; }
protected Item(ItemRarities rarity, ItemTypes type, string folder) { Rarity = rarity; Type = type; SkillUpgrades = new List <SkillUpgrade>(); AbilityUpgrades = new List <AbilityUpgrade>(); for (var i = 0; i < (int)rarity; i++) { AbilityUpgrades.Add(AbilityUpgradeHelper.GetRandomUpgrade(true)); } string iconName; switch (rarity) { case ItemRarities.Novice: iconName = "novice.png"; break; case ItemRarities.Apprentice: iconName = "apprentice.png"; break; case ItemRarities.Adept: iconName = "adept.png"; break; case ItemRarities.Master: iconName = "master.png"; break; case ItemRarities.Legendary: iconName = "legend.png"; break; default: throw new Exception("Unknown icon rarity"); } Texture = TextureCacheFactory.GetOnce($"Items/{folder}/{iconName}"); }
protected Entity(string file, bool cache) { Texture = string.IsNullOrWhiteSpace(file) ? null : cache?TextureCacheFactory.Get(file) : TextureCacheFactory.GetOnce(file); IsActive = true; }
public void InitializeMap(GraphicsDevice graphicsDevice, Rectangle clientBounds, MapSectionTypes?type = null) { _texture = TextureCacheFactory.GetOnce("Maps/Tiles.png"); _textureLocations = new Dictionary <TileTypes, Rectangle> { [TileTypes.Floor] = new Rectangle(128, 256, 64, 64), [TileTypes.Wall] = new Rectangle(0, 32, 64, 64), [TileTypes.SingleWall] = new Rectangle(320, 32, 64, 64) }; _mapSectionWidth = _textureLocations[TileTypes.Floor].Width * GameConstants.MapSectionSizeInTiles; _mapSectionHeight = _textureLocations[TileTypes.Floor].Height * GameConstants.MapSectionSizeInTiles; MapSection startSection = null; _sections = new MapSection[MapNumSectionsWide, MapNumSectionsTall]; if (type.HasValue) { for (var x = 0; x < MapNumSectionsWide; x++) { for (var y = 0; y < MapNumSectionsTall; y++) { _sections[x, y] = new MapSection(type.Value, new Rectangle(_mapSectionWidth * x, _mapSectionHeight * y, _mapSectionWidth, _mapSectionHeight), x, y); } } } else { // First surround the map in wall sections for (var x = 0; x < MapNumSectionsWide; x++) { var bottomY = MapNumSectionsTall - 1; _sections[x, 0] = new MapSection(MapSectionTypes.Wall, new Rectangle(_mapSectionWidth * x, _mapSectionHeight * 0, _mapSectionWidth, _mapSectionHeight), x, bottomY); _sections[x, bottomY] = new MapSection(MapSectionTypes.Wall, new Rectangle(_mapSectionWidth * x, _mapSectionHeight * bottomY, _mapSectionWidth, _mapSectionHeight), x, bottomY); } for (var y = 1; y < MapNumSectionsTall - 1; y++) { var rightX = MapNumSectionsWide - 1; _sections[0, y] = new MapSection(MapSectionTypes.Wall, new Rectangle(_mapSectionWidth * 0, _mapSectionHeight * y, _mapSectionWidth, _mapSectionHeight), rightX, y); _sections[rightX, y] = new MapSection(MapSectionTypes.Wall, new Rectangle(_mapSectionWidth * (rightX), _mapSectionHeight * y, _mapSectionWidth, _mapSectionHeight), rightX, y); } // Create the start var startingSectionX = Helpers.RandomIntInRange(1, MapNumSectionsWide - 2); var startingSectionY = Helpers.RandomIntInRange(1, MapNumSectionsWide - 2); StartingPosition = new Vector2(startingSectionX * _mapSectionWidth + _mapSectionHeight / 2, startingSectionY * _mapSectionHeight + _mapSectionHeight / 2); _sections[startingSectionX, startingSectionY] = new MapSection(MapSectionTypes.Start, new Rectangle(_mapSectionWidth * startingSectionX, _mapSectionHeight * startingSectionY, _mapSectionWidth, _mapSectionHeight), startingSectionX, startingSectionY); startSection = _sections[startingSectionX, startingSectionY]; // Create all of the other middle tiles for (var x = 1; x < MapNumSectionsWide - 1; x++) { for (var y = 1; y < MapNumSectionsTall - 1; y++) { if (_sections[x, y] == null) { _sections[x, y] = new MapSection(MapSectionTypes.Walled, new Rectangle(_mapSectionWidth * x, _mapSectionHeight * y, _mapSectionWidth, _mapSectionHeight), x, y); } } } // Create a maze var numVisited = 1; var stack = new List <(int, int)>(); (int X, int Y)currentSection = (startingSectionX, startingSectionY); while (numVisited < (MapNumSectionsTall - 2) * (MapNumSectionsWide - 2)) { var adjacentCells = GetAdjacentSections(currentSection.X, currentSection.Y, true); if (adjacentCells.Any()) { var randomNeighbor = adjacentCells[Globals.Random.Next(adjacentCells.Count)]; switch (randomNeighbor.Direction) { case CardinalDirection.Up: _sections[randomNeighbor.X, randomNeighbor.Y].DestroyWall(CardinalDirection.Down); _sections[currentSection.X, currentSection.Y].DestroyWall(CardinalDirection.Up); break; case CardinalDirection.Down: _sections[randomNeighbor.X, randomNeighbor.Y].DestroyWall(CardinalDirection.Up); _sections[currentSection.X, currentSection.Y].DestroyWall(CardinalDirection.Down); break; case CardinalDirection.Left: _sections[randomNeighbor.X, randomNeighbor.Y].DestroyWall(CardinalDirection.Right); _sections[currentSection.X, currentSection.Y].DestroyWall(CardinalDirection.Left); break; case CardinalDirection.Right: _sections[randomNeighbor.X, randomNeighbor.Y].DestroyWall(CardinalDirection.Left); _sections[currentSection.X, currentSection.Y].DestroyWall(CardinalDirection.Right); break; } stack.Add((currentSection.X, currentSection.Y)); currentSection = (randomNeighbor.X, randomNeighbor.Y); numVisited++; } else { // Set current section to the popped section from the stack currentSection = stack.Last(); stack.Remove(currentSection); } } } // Find the furthest cell from the start and spawn the boss there (if this is a real map) if (startSection != null) { var sectionsToVisit = new List <MapSection> { startSection }; var sections = new Dictionary <MapSection, int?> { [startSection] = 0 }; var bossSection = startSection; var maxDistance = 0; while (sectionsToVisit.Any()) { // Pop one var section = sectionsToVisit.Last(); sectionsToVisit.Remove(section); var adjacentCells = GetAdjacentSections(section.XPos, section.YPos, false); var distance = sections[section].Value + 1; foreach (var cell in adjacentCells) { var adjacentSection = _sections[cell.X, cell.Y]; // If we've already gotten to this cell in the same or less distance then ignore if (sections.Keys.Contains(adjacentSection) && sections[adjacentSection] <= distance) { continue; } // Process this section if we haven't already if (!sectionsToVisit.Contains(adjacentSection)) { sectionsToVisit.Add(adjacentSection); } sections[adjacentSection] = distance; if (distance > maxDistance) { maxDistance = distance; bossSection = adjacentSection; } } } bossSection.Type = MapSectionTypes.Boss; } // Tell the sections we are done making the map for (var x = 0; x < MapNumSectionsWide; x++) { for (var y = 0; y < MapNumSectionsTall; y++) { _sections[x, y].MapComplete(); } } }
public MainBackground() { _background = TextureCacheFactory.GetOnce("Backgrounds/sky.png"); _backgroundGreen = TextureCacheFactory.GetOnce("Backgrounds/sky-green.png"); _backgroundRed = TextureCacheFactory.GetOnce("Backgrounds/sky-red.png"); }