public Rectangle GetSpriteFrame(Character character) { var attackFrames = this.GetAnimationFrames(character); if ((attackFrames != 0) && ((character.State == State.YodaStrikePunch) || (character.State == State.WingedHorseKick) || (character.State == State.TeethOfTigerThrow))) { int animationFrames; switch (character.State) { case State.YodaStrikePunch: animationFrames = (int)Frames.YodaStrikePunch; break; case State.WingedHorseKick: animationFrames = (int)Frames.WingedHorseKick; break; case State.TeethOfTigerThrow: animationFrames = (int)Frames.TeethOfTigerThrow; break; default: animationFrames = 0; break; } return new Rectangle((this.FrameIndex % animationFrames) * 80, 140 * (int)character.State, 80, 140); } return new Rectangle(this.FrameIndex % ((character.State == State.Idle) ? (int)Frames.Idle : (int)Frames.Moving) * 80, 140 * (int)character.State, 80, 140); }
public void Hit(Character target) { var player = target as Player; var armor = player != null ? player.GetTotalArmor() : target.DefencePoints; var damage = this.Damage / armor; if (damage < this.Damage / 100d) { damage = this.Damage / 100d; } target.HealthPoints -= damage; if (target.HealthPoints <= 0) { target.RemoveLive(); target.HealthPoints = target.BaseHealthPoints; } }
private int GetAnimationFrames(Character character) { var attackFrames = (character is Player) ? this.PlayerAttackFrames : this.EnemyAttackFrames; if ((character.State == State.YodaStrikePunch) || (character.State == State.WingedHorseKick) || (character.State == State.TeethOfTigerThrow) || (attackFrames > 0)) { if ((attackFrames == 0) && ((character.State != State.Idle) || (character.State != State.Moving))) { switch (character.State) { case State.YodaStrikePunch: attackFrames = (int)Frames.YodaStrikePunch; break; case State.WingedHorseKick: attackFrames = (int)Frames.WingedHorseKick; break; case State.TeethOfTigerThrow: attackFrames = (int)Frames.TeethOfTigerThrow; break; default: attackFrames = 0; break; } } } if (character is Player) { this.PlayerAttackFrames = attackFrames; } else { this.EnemyAttackFrames = attackFrames; } return attackFrames; }