File indexing completed on 2024-04-21 04:04:45

0001 /***************************************************************************
0002                           infantrysprite.h  -  description
0003                              -------------------
0004     begin                : 
0005     copyright            : (C) 2003-2007 by Gael de Chalendar
0006     email                : kleag@free.fr
0007  ***************************************************************************/
0008 
0009 /***************************************************************************
0010  *                                                                         *
0011  *   This program is free software; you can redistribute it and/or modify  *
0012  *   it under the terms of the GNU General Public License as published by  *
0013  *   the Free Software Foundation; either either version 2
0014    of the License, or (at your option) any later version.of the License, or     *
0015  *   (at your option) any later version.                                   *
0016  *                                                                         *
0017  *   You should have received a copy of the GNU General Public License
0018  *   along with this program; if not, write to the Free Software
0019  *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
0020  *   02110-1301, USA
0021  ***************************************************************************/
0022 
0023 #ifndef KSIRKINFANTRYSPRITE_H
0024 #define KSIRKINFANTRYSPRITE_H
0025 
0026 #include "armysprite.h"
0027 
0028 namespace Ksirk {
0029 
0030 namespace GameLogic
0031 {
0032   class Country;
0033 }
0034 
0035 /**
0036   * An InfantrySprite is an army sprite that represents 1 army
0037   * @author Gaƫl de Chalendar
0038   */
0039 class InfantrySprite : public ArmySprite
0040 {
0041 public:
0042   /**
0043     * This simplified constructor allows to create a new @ref InfantrySprite with
0044     * default values for svg pool id and skin elements names
0045     * @param zoom The current zoom factor
0046     * @param aBackGnd The background giving info about the world geometry and
0047     * access to the underlying QGraphicsScene
0048     * @param visibility Measures how much this sprite is visible. It gives its
0049     * Z value on the graphics scene.
0050     */
0051   InfantrySprite(double zoom,
0052                 BackGnd* aBackGnd,
0053                 unsigned int visibility = 200);
0054 
0055   /**
0056     * This constructor allows to create a new @ref AnimSprite whose images are
0057     * taken from the given file name with the given number of frames and
0058     * number of look directions
0059     * @param svgid The id of the SVG element from which to load images
0060     * @param aBackGnd The background giving info about the world geometry and
0061     * access to the underlying QGraphicsScene
0062     * @param nbFrames The number of different frames in this sprite animation, 
0063     * thus the number of columns in the sprite image
0064     * @param nbDirs The number of different views on the sprite, 
0065     * thus the number of rows in the sprite image
0066     * @param visibility Measures how much this sprite is visible. It gives its
0067     * Z value on the graphics scene.
0068     */
0069   InfantrySprite(const QString &svgid,
0070                   unsigned int width,
0071                   unsigned int height,
0072                   unsigned int nbFrames,
0073                   unsigned int nbDirs,
0074                   double zoom,
0075                   BackGnd* aBackGnd,
0076                   unsigned int visibility=200);
0077 
0078   /** The default destructor */
0079   ~InfantrySprite() override {}
0080 
0081   /**
0082     * This function chooses the approach mode of an infantry sprite towards its
0083     * destination:
0084     * if the distance between the origin and the destination is higher than half
0085     * the size of the map and if the origin and destination countries comunicate,
0086     * then the sprite should choose an approach by left or right, through the
0087     * edge of the map.
0088     */
0089   void setupTravel(GameLogic::Country* src, GameLogic::Country* dest, 
0090     const QPointF* dpi=nullptr) override;
0091 
0092   /**
0093     * Gets the number of armies represented by an infantry: 1
0094     * @return the number of armies represented by an infantry: 1
0095     */
0096   inline unsigned int nbArmies() const override {return m_nbArmies;}
0097 
0098 private:
0099   static const unsigned int m_nbArmies = 1;
0100 };
0101 
0102 }
0103 
0104 #endif