public Item(GraphicsDeviceManager g, ContentManager c, int weapon, Vector2 startLoc, Vector2 playerDim) { graphics = g; content = c; dimensions = new Vector2(90, 120); loc = new Vector2(startLoc.X - playerDim.X / 2, startLoc.Y - playerDim.Y / 3); random = new Random(); if (weapon == 0) { LoadContent("Textures/ShortSwordWalk"); vitality = 0; dexterity = 0; intelligence = 0; strength = 0; critBonus = 0; critChance = 0; minDmg = 1f; maxDmg = 5f; statType = StatType.str; weaponType = WeaponType.slash; atkSpd = 1f; } animation = new SpriteAnimation(8, itemSpriteSheet, .45, new Rectangle((int)loc.X, (int)loc.Y, (int)dimensions.X, (int)dimensions.Y)); }
public void AddAnimation(string spriteName, int num, double time) { spriteSheet = content.Load<Texture2D>("Textures/" + spriteName); SpriteAnimation anim = new SpriteAnimation(num, spriteSheet, time, new Rectangle((int)loc.X, (int)loc.Y, (int)dimensions.X, (int)dimensions.Y)); animations.Add(anim); }
public void Initialize() { LoadContent(); pState = PlayerState.walking; currentDepth = 0; currentSpeed = Game1.screenWidth / 500; playerDimensions = new Vector2(60, 90); startLoc = new Vector2(Game1.screenWidth / 10, (float)(Game1.screenHeight / 1.33)) - playerDimensions / 2; armLoc = startLoc; armLoc.X -= playerDimensions.X / 2; primaryStats = new PStats(); secondaryStats = new SStats(); primaryStats.vitality = 10; primaryStats.strength = 10; primaryStats.dexterity = 10; primaryStats.intelligence = 10; secondaryStats.maxHealth = 20 + primaryStats.vitality * 10; secondaryStats.health = secondaryStats.maxHealth; secondaryStats.maxMana = 20 + primaryStats.intelligence * 10; secondaryStats.mana = secondaryStats.maxMana; currentItem = new Item(graphics, content, 0, startLoc, playerDimensions); secondaryStats.attack = currentItem.CalculateNextAttack(primaryStats.strength, primaryStats.intelligence, primaryStats.dexterity); secondaryStats.atkSpeed = currentItem.CalculateAtkSpd(primaryStats.dexterity); attackNum = 0; maxHealthBarLength = (int)Game1.screenWidth / 5; currentHealthBar = new Rectangle((int)Game1.screenWidth/20, (int)Game1.screenHeight/20, (int)Game1.screenWidth/5, (int)Game1.screenHeight/20); missingHealthBar = new Rectangle(currentHealthBar.Right, currentHealthBar.Y, 0, currentHealthBar.Height); loc = startLoc; walkAnimation = new SpriteAnimation(8, walkSheet, .45, new Rectangle((int)startLoc.X, (int)startLoc.Y, (int)playerDimensions.X, (int)playerDimensions.Y)); armWalkAnimation = new SpriteAnimation(8, armWalkSheet, .45, new Rectangle((int)armLoc.X, (int)armLoc.Y, (int)(playerDimensions.X * 1.5), (int)playerDimensions.Y)); attackAnimation = new SpriteAnimation(2, attackSheet, secondaryStats.atkSpeed, new Rectangle((int)startLoc.X, (int)startLoc.Y, (int)playerDimensions.X, (int)playerDimensions.Y)); }