~ubuntu-branches/ubuntu/vivid/kapman/vivid-proposed

« back to all changes in this revision

Viewing changes to cell.h

  • Committer: Package Import Robot
  • Author(s): Jonathan Riddell
  • Date: 2012-12-07 17:37:19 UTC
  • Revision ID: package-import@ubuntu.com-20121207173719-5973b949kqub4zup
Tags: upstream-4.9.90
ImportĀ upstreamĀ versionĀ 4.9.90

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright 2007-2008 Thomas Gallinari <tg8187@yahoo.fr>
 
3
 * 
 
4
 * This program is free software; you can redistribute it and/or
 
5
 * modify it under the terms of the GNU General Public License as
 
6
 * published by the Free Software Foundation; either version 2 of 
 
7
 * the License, or (at your option) any later version.
 
8
 * 
 
9
 * This program is distributed in the hope that it will be useful,
 
10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
12
 * GNU General Public License for more details.
 
13
 * 
 
14
 * You should have received a copy of the GNU General Public License
 
15
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
16
 */
 
17
 
 
18
#ifndef CELL_H
 
19
#define CELL_H
 
20
 
 
21
#include <QtGlobal>
 
22
 
 
23
class Element;
 
24
 
 
25
/**
 
26
 * @brief This class represents a Cell of the Maze.
 
27
 */
 
28
class Cell {
 
29
 
 
30
        public:
 
31
 
 
32
                /** The Cell side size */
 
33
                static const qreal SIZE;
 
34
 
 
35
                /** The Cell possible types */
 
36
                enum Type {
 
37
                        WALL = 0,
 
38
                        CORRIDOR = 1,
 
39
                        GHOSTCAMP = 2
 
40
                };
 
41
 
 
42
        private:
 
43
 
 
44
                /** The Cell type */
 
45
                Type m_type;
 
46
 
 
47
                /** A reference on the Element that is on the Cell */
 
48
                Element* m_element;
 
49
 
 
50
                /** Cost used in A* pathfinding algorithm : lower is the cost, closer to the target Cell is this Cell */
 
51
                int m_cost;
 
52
 
 
53
                /** Parent node used in A* pathfinding algorithm : the Cell which enables to go to this Cell */
 
54
                Cell* m_parent;
 
55
 
 
56
        public:
 
57
 
 
58
                /**
 
59
                 * Creates a new Cell instance.
 
60
                 */
 
61
                Cell();
 
62
 
 
63
                /**
 
64
                 * Deletes the Cell instance.
 
65
                 */
 
66
                ~Cell();
 
67
 
 
68
                /**
 
69
                 * Gets the Cell type.
 
70
                 * @return the Cell type
 
71
                 */
 
72
                Type getType() const;
 
73
 
 
74
                /**
 
75
                 * Sets the Cell type.
 
76
                 * @param p_type the new type to set
 
77
                 */
 
78
                void setType(Type p_type);
 
79
 
 
80
                /**
 
81
                 * Gets the Element that is on the Cell.
 
82
                 * @return the Element that is on the Cell
 
83
                 */
 
84
                Element* getElement() const;
 
85
 
 
86
                /**
 
87
                 * Sets the Element that is on the Cell.
 
88
                 * @param p_element the Element to set on the Cell
 
89
                 */
 
90
                void setElement(Element* p_element);
 
91
 
 
92
                /**
 
93
                 * Gets the Cell cost for A* pathfinding algorithm.
 
94
                 * @return the Cell cost for A* pathfinding algorithm
 
95
                 */
 
96
                int getCost() const;
 
97
 
 
98
                /**
 
99
                 * Sets a cost for the Cell, for A* pathfinding algorithm.
 
100
                 * @param p_cost the cost of the Cell for A* pathfinding algorithm
 
101
                 */
 
102
                void setCost(const int p_cost);
 
103
 
 
104
                /**
 
105
                 * Gets the parent Cell of this Cell for A* pathfinding algorithm.
 
106
                 * @return the Cell parent for A* pathfinding algorithm
 
107
                 */
 
108
                Cell* getParent() const;
 
109
 
 
110
                /**
 
111
                 * Sets the parent Cell of this Cell for A* pathfinding algorithm.
 
112
                 * @param p_parent the parent of the Cell for A* pathfinding algorithm
 
113
                 */
 
114
                void setParent(Cell* p_parent);
 
115
};
 
116
 
 
117
#endif
 
118