//Misc methods private int CalculateDamage(IndividualPokemon user, IndividualPokemon target, float randomMultiplier, bool crit = false, float extraModifier = 1) { //Calculates the damange this move will do float modifier = CalculateDamageModifier(user, target, crit) * randomMultiplier * extraModifier; //Choose the appropriate attack/defense stats float attack = user.attack; float defense = target.defense; if (moveCategory == MoveCategory.special) { attack = user.spAttack; defense = target.spDefense; } //Do the calculations float damageUnrounded = ((2f * user.level + 10) / 250) * (attack / defense) * power + 2; damageUnrounded *= modifier; int damage = (int)damageUnrounded; //Always do atleast 1 damage, unless the multiplier is zero if (damage == 0 && modifier != 0f) { damage = 1; } return(damage); }
//Misc methods private void PlayerSwitchIn(IndividualPokemon pokemon) { //Switches the given pokemon in for the player playerPokemon = pokemon; //TODO: Change sprite, play animation }
private void EnemySwitchIn(IndividualPokemon pokemon) { //Switches the given pokemon in for the enemy enemyPokemon = pokemon; //TODO: Change sprite, play animation }
public void Use(IndividualPokemon user, IndividualPokemon target) { //Uses the move //Throw an error if not enough PP if (currentPP <= 0) { throw new NotEnoughPPException(); } //Use the move currentPP--; entry.Use(user, target); }
//Interface public override void Use(IndividualPokemon user, IndividualPokemon target) { //Deals damage to the target based on the damage formula //Determine the random multiplier float randMult = RandomBetween(MIN_RAND_MULTIPLIER, MAX_RAND_MULTIPLIER); //TODO: Determine if it's a crit bool crit = false; //Determine how much damage to deal int damage = CalculateDamage(user, target, randMult, crit); //Deal the damage target.ChangeHP(damage * -1); }
public bool CreateIndividualPokemon(IndividualPokemonCreate model) { var entity = new IndividualPokemon { IndividualPokemonName = model.IndividualPokemonName, PokemonID = model.PokemonID, UserID = _userID, TeamID = model.TeamID }; using (var ctx = new ApplicationDbContext()) { ctx.IndividualPokemonDb.Add(entity); return(ctx.SaveChanges() == 1); } }
private IEnumerator ExecuteCommand(BattleCommand command) { //Actually execute the command executingCommand = true; //Determine which set of display objects to use BattlePokemonDisplay userDisplay = playerDisplay; ScrollingTextbox userTextbox = playerTextbox; BattlePokemonDisplay targetDisplay = enemyDisplay; if (command.userPokemon == enemyPokemon) { userTextbox = enemyTextbox; userDisplay = enemyDisplay; targetDisplay = playerDisplay; } //Display the command text userTextbox.text = command.text; //Execute the move if (command.commandType == BattleCommandType.useMove) { IndividualPokemon user = command.userPokemon; IndividualPokemon target = command.targetPokemon; IndividualPokemonMove move = user.GetMove(command.moveToUse); //Start the command's animation float waitTime = userDisplay.GenericMoveAnimation(move.entry.genericAnimationID); yield return(new WaitForSecondsOrSkip(waitTime)); //Use the move user.GetMove(command.moveToUse).Use(user, target); //Start flashing targetDisplay.TakeDamage(); } executingCommand = false; yield return(null); }
private IndividualPokemon GenerateTestMissingno(int level) { //Generates a missingno to be used for testing purposes //Set each IV to 15 PokemonStats ivs = new PokemonStats(); for (int i = 0; i < PokemonStats.NUM_STATS; i++) { ivs[(PokemonStatID)i] = 15; } //Give it tackle List <IndividualPokemonMove> moves = new List <IndividualPokemonMove>(); moves.Add(new IndividualPokemonMove(new DexID("", 1))); //Create the pokemon IndividualPokemon pokemon = new IndividualPokemon(new DexID("", 0), ivs, moves, level); return(pokemon); }
//Abstract methods public abstract void Use(IndividualPokemon user, IndividualPokemon target);
//Interface public void SendOut(IndividualPokemon pokemon) { //TODO: Start the send-out animation }