src/tron/zone/zEffector.cpp

Go to the documentation of this file.
00001 /*
00002 
00003 *************************************************************************
00004 
00005 ArmageTron -- Just another Tron Lightcycle Game in 3D.
00006 Copyright (C) 2000  Manuel Moos (manuel@moosnet.de)
00007 
00008 **************************************************************************
00009 
00010 This program is free software; you can redistribute it and/or
00011 modify it under the terms of the GNU General Public License
00012 as published by the Free Software Foundation; either version 2
00013 of the License, or (at your option) any later version.
00014 
00015 This program is distributed in the hope that it will be useful,
00016 but WITHOUT ANY WARRANTY; without even the implied warranty of
00017 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00018 GNU General Public License for more details.
00019 
00020 You should have received a copy of the GNU General Public License
00021 along with this program; if not, write to the Free Software
00022 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
00023   
00024 ***************************************************************************
00025 
00026 */
00027 
00028 #include "zEffector.h"
00029 #include "tRandom.h"
00030 #include "gGame.h"
00031 
00032 
00033 void zEffector::apply(gVectorExtra<ePlayerNetID *> &d_calculatedTargets)
00034 {
00035     if (count == -1 || count > 0) {
00036         effect(d_calculatedTargets);
00037         /*
00038         tOutput asdf;
00039         asdf.SetTemplateParameter(1, tString("33"));
00040         asdf.SetTemplateParameter(2, tString("bibibi"));
00041         asdf.Append(message);
00042         sn_ConsoleOut(asdf);
00043         */
00044         if (count > 0)
00045             count --;
00046     }
00047 }
00048 
00049 void
00050 zEffector::setMessage(tString unformated)
00051 {/*
00052                                               tString res;
00053                                               for (size_t i=0; i< unformated.Size(); i++)
00054                                                 {
00055                                                   char c = unformated(i);
00056                                                   if (c != '\\')
00057                                                 res += c;
00058                                                   else if (i < unformated.Size())
00059                                                 {
00060                                                   switch (unformated(i+1))
00061                                                     {
00062                                                     case 'n':
00063                                                       res += '\n';
00064                                                       i++;
00065                                                       break;
00066                                                     case '1':
00067                                                       res += '\1';
00068                                                       i++;
00069                                                       break;
00070                                                     default:
00071                                                       res += '\\';
00072                                                       break;
00073                                                     }
00074                                                 }
00075                                                 }
00076 
00077                                               message = res;
00078                                              */
00079     message << unformated;
00080     /*
00081     message.Append( unformated );
00082     message << unformated.c_str();
00083     message.Append( unformated.c_str());
00084     */
00085 }
00086 
00087 void zEffectorWin::effect(gVectorExtra<ePlayerNetID *> &d_calculatedTargets)
00088 {
00089     // BOP
00090     static const char* message="$player_win_instant";
00091     // EOP
00092 
00093     gVectorExtra<ePlayerNetID *>::iterator iter;
00094     for(iter = d_calculatedTargets.begin();
00095             iter != d_calculatedTargets.end();
00096             ++iter)
00097     {
00098         sg_DeclareWinner((*iter)->CurrentTeam(), message );
00099     }
00100 }
00101 
00102 void zEffectorDeath::effect(gVectorExtra<ePlayerNetID *> &d_calculatedTargets)
00103 {
00104     gVectorExtra<ePlayerNetID *>::iterator iter;
00105     for(iter = d_calculatedTargets.begin();
00106             iter != d_calculatedTargets.end();
00107             ++iter)
00108     {
00109         static_cast<gCycle *>((*iter)->Object())->Kill();
00110     }
00111 }
00112 
00113 //
00114 //
00115 //
00116 
00117 void zEffectorPoint::effect(gVectorExtra<ePlayerNetID *> &d_calculatedTargets)
00118 {
00119     gVectorExtra<ePlayerNetID *>::iterator iter;
00120     for(iter = d_calculatedTargets.begin();
00121             iter != d_calculatedTargets.end();
00122             ++iter)
00123     {
00124         //      (*iter)->AddScore(d_score, tOutput(), "$player_lose_suicide");
00125         (*iter)->AddScore(d_score, tOutput(), message);
00126     }
00127 }
00128 
00129 //
00130 //
00131 //
00132 
00133 void zEffectorCycleRubber::effect(gVectorExtra<ePlayerNetID *> &d_calculatedTargets)
00134 {
00135     gVectorExtra<ePlayerNetID *>::iterator iter;
00136     for(iter = d_calculatedTargets.begin();
00137             iter != d_calculatedTargets.end();
00138             ++iter)
00139     {
00140         static_cast<gCycle *>((*iter)->Object())->SetRubber(0.0);
00141     }
00142 }
00143 
00144 
00145 //
00146 //
00147 //
00148 
00149 void zEffectorCycleBrake::effect(gVectorExtra<ePlayerNetID *> &d_calculatedTargets)
00150 {
00151     gVectorExtra<ePlayerNetID *>::iterator iter;
00152     for(iter = d_calculatedTargets.begin();
00153             iter != d_calculatedTargets.end();
00154             ++iter)
00155     {
00156         static_cast<gCycle *>((*iter)->Object())->SetBrakingReservoir(1.0);
00157     }
00158 }
00159 
00160 //
00161 //
00162 //
00163 
00164 void zEffectorCycleAcceleration::effect(gVectorExtra<ePlayerNetID *> &d_calculatedTargets)
00165 {
00166     gVectorExtra<ePlayerNetID *>::iterator iter;
00167     for(iter = d_calculatedTargets.begin();
00168             iter != d_calculatedTargets.end();
00169             ++iter)
00170     {
00171         static_cast<gCycle *>((*iter)->Object())->AddZoneAcceleration(acceleration.GetOffset());
00172     }
00173 }
00174 
00175 //
00176 //
00177 //
00178 
00179 void zEffectorSpawnPlayer::effect(gVectorExtra<ePlayerNetID *> &d_calculatedTargets)
00180 {
00181     gVectorExtra<ePlayerNetID *>::iterator iter;
00182     for(iter = d_calculatedTargets.begin();
00183             iter != d_calculatedTargets.end();
00184             ++iter)
00185     {
00186         sg_RespawnPlayer(grid, arena, (*iter));
00187     }
00188 }
00189 
00190 void zEffectorSetting::effect(gVectorExtra<ePlayerNetID *> &d_calculatedTargets)
00191 {
00192     std::stringstream ss;
00193     ss << settingName  << " " << settingValue;
00194     tConfItemBase::LoadAll(ss);
00195 
00196 }
00197 
00198 

Generated on Sat Mar 15 22:56:12 2008 for Armagetron Advanced by  doxygen 1.5.4