E:/Eigene Dateien/Eigene Projekte/c0re/Field.cpp

Go to the documentation of this file.
00001 /*
00002         This file is part of c0re.
00003 
00004         c0re is a multiplayer RTS on a hexagonal map with an evolving unit concept.
00005     Copyright (C) 2007 Stephan Hofmann
00006 
00007     c0re is free software: you can redistribute it and/or modify
00008     it under the terms of the GNU General Public License as published by
00009     the Free Software Foundation, either version 3 of the License, or
00010     (at your option) any later version.
00011 
00012     This program is distributed in the hope that it will be useful,
00013     but WITHOUT ANY WARRANTY; without even the implied warranty of
00014     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015     GNU General Public License for more details.
00016 
00017     You should have received a copy of the GNU General Public License
00018     along with this program.  If not, see <http://www.gnu.org/licenses/>.
00019 */
00020 
00021 #include "Field.h"
00022 
00023 #include "system.h"
00024 #include <GL/gl.h>
00025 #include <GL/glu.h>
00026 
00027 int Field::s_selectedFieldID = -1;
00028 Object* Field::shadowTexture = 0;
00029 
00030 Field::Field()
00031 {
00032         unit = 0;
00033         size = 1.0;
00034         isVisible = true;
00035         isSettleRange = false;
00036 }
00037 
00038 Field::~Field()
00039 {
00040 
00041 }
00042 
00043 int Field::render(Vector3d p_pos, double p_deltasize)
00044 {
00045         int ret = 0;
00046 
00047         ret = Object::render(p_pos, p_deltasize);
00048         if (!isVisible)
00049                 ret += shadowTexture->render(p_pos, p_deltasize);
00050         
00051         return ret;
00052 }
00053 
00054 int Field::renderChild(Vector3d p_pos, Level* p_level, double p_deltasize)
00055 {
00056         int ret = 0;
00057 
00058         if (isVisible && (unit != 0))
00059         {
00060                 unit->render(p_pos, p_level, p_deltasize);
00061         }
00062 
00063         return ret;
00064 }
00065 
00066 int Field::select(std::string p_filename)
00067 {
00068         int ret = 0;
00069         textureName = p_filename;
00070 
00071         int pos = (int)p_filename.rfind(".");
00072 
00073         if (isSettleRange)
00074                 loadAndBind(p_filename.insert(pos, "-settlerange"));
00075         else if (energy > 10)
00076                 loadAndBind(p_filename.insert(pos, "-full"));
00077         else if (energy > 5)
00078                 loadAndBind(p_filename.insert(pos, "-medium"));
00079         else if (energy > 0 )
00080                 loadAndBind(p_filename.insert(pos, "-low"));
00081         else
00082                 loadAndBind(p_filename.insert(pos, "-dead"));
00083         return 0;
00084 }
00085 
00086 Field* Field::getField()
00087 {
00088         return this;
00089 }

Generated on Tue Jul 17 22:02:22 2007 for C0re by  doxygen 1.5.2