private void SwapUnits(int pos1, int pos2) { playerButtons[pos1].Deselect(); playerButtons[pos2].Deselect(); PlayerChar temp = Units[pos1]; Units[pos1] = Units[pos2]; Units[pos2] = temp; }
public void PlayerUpdate(GameTime gameTime, Enemy enemy, PlayerChar attacker) { //count down on the attack timer and run endattack when it finishes length = length - gameTime.ElapsedGameTime.TotalSeconds; //run EndAttack when timer reaches zero if (length <= 0) { EndPlayerAttack(enemy, attacker); } }
/// <summary> /// resets the length (and damage, for the player) of a character's attack /// after they finish an attack /// </summary> /// <param name="character"> The character whose attack is reset</param> /// <param name="charType"> /// a hardcoded (subject to change) method to check which entity /// in the game needs their attack reset /// </param> public void ResetAttack(Unit character, string charType) { if (charType == "Player") { PlayerChar player = (PlayerChar)character; player.Atk.length = player.Atk.baseLength; player.Atk.damage = player.Atk.baseDamage; } else { Enemy enemy = (Enemy)character; enemy.Atk.length = enemy.Atk.baseLength; } }
public void EndPlayerAttack(Enemy attackTarget, PlayerChar attacker) { //may require an attack timer class and pause/unpause enums //damage the enemy attackTarget.Health = attackTarget.Health - attacker.Atk.damage; //set isAttacking to false attacker.IsAttacking = false; //add attack information to the battle log BattleLog.AddPlayerAttackEnd(attacker.Name, attackTarget.Name, attacker.Atk.damage); //reset attack timer ResetAttack(attacker, "Player"); }
public PlayerHandler(SpriteFont font, Game g) { //initializes the inventory of the player playerInv = new Inventory(g); //initializes the base units Units[0] = new PlayerChar(font, g, CharType.Heavy); Units[1] = new PlayerChar(font, g, CharType.Medium); Units[2] = new PlayerChar(font, g, CharType.Light); //initializes buttons for player controls for (int j = 0; j < playerButtons.Length; j++) { playerButtons[j] = new Button(g.Content.Load <Texture2D>(Config.PLAYER_BTN_NORMAL), g.Content.Load <Texture2D>(Config.PLAYER_BTN_HOVERED), g.Content.Load <Texture2D>(Config.PLAYER_BTN_CLICKED), new Rectangle(Config.PLAYER_BTN_X_POS + j * Config.PLAYER_BTN_SPACING, Config.PLAYER_BTN_Y_POS, Config.PLAYER_BTN_SIZE, Config.PLAYER_BTN_SIZE)); } //*Temporary* text = font; }
/// <summary> /// adds a string that informs the user that a player character has started their attack /// </summary> /// <param name="player"> The party member whose attack has been initiated </param> public static void AddPlayerAttackStart(PlayerChar player) { logQueue.Enqueue(player.Name + " is attacking the enemy!"); }