Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #include "Powerup.h"
00026
00027 #include "Options.h"
00028 #include "Player.h"
00029 #include "libwiigui/gui.h"
00030
00031 extern Options *g_options;
00032 extern Player *g_players;
00033
00034 GuiSound *Powerup::defaultSound =
00035 new GuiSound(powerup_default_pcm, powerup_default_pcm_size, SOUND_PCM);
00036
00037
00038
00039
00040
00041
00042
00043
00044 bool Powerup::Initiate(u8 targetPlayer)
00045 {
00046 int slot;
00047 Powerup *powerup = NULL;
00048
00049 switch (GetTargetType())
00050 {
00051 case POWERUP_TARGET_ONE:
00052 {
00053 slot = g_players[targetPlayer].GetEffectQueueSlot();
00054 if (slot >= 0)
00055 {
00056 if (!powerup)
00057 powerup = GetInstance();
00058
00059 g_players[targetPlayer].QueueEffect(powerup, slot);
00060 StartEffect(targetPlayer);
00061 }
00062 break;
00063 }
00064
00065 case POWERUP_TARGET_ALL:
00066 {
00067 for (int i = 0; i < g_options->players; ++i)
00068 {
00069 slot = g_players[i].GetEffectQueueSlot();
00070 if (slot >= 0)
00071 {
00072 if (!powerup)
00073 powerup = GetInstance();
00074
00075 g_players[i].QueueEffect(powerup, slot);
00076 StartEffect(i);
00077 }
00078 }
00079 break;
00080 }
00081
00082 case POWERUP_TARGET_ALL_BUT_ONE:
00083 {
00084 for (int i = 0; i < g_options->players; ++i)
00085 {
00086 if (i != targetPlayer)
00087 {
00088 slot = g_players[i].GetEffectQueueSlot();
00089 if (slot >= 0)
00090 {
00091 if (!powerup)
00092 powerup = GetInstance();
00093
00094 g_players[i].QueueEffect(powerup, slot);
00095 StartEffect(i);
00096 }
00097 }
00098 }
00099 break;
00100 }
00101 }
00102
00103 if (powerup)
00104 {
00105 GetSound()->Play();
00106 powerup->startTime = gettime();
00107 }
00108
00109 return powerup != NULL;
00110 }
00111
00112 void Powerup::Terminate()
00113 {
00114 for (int i = 0; i < g_options->players; ++i)
00115 {
00116 if (g_players[i].RemoveEffect(this))
00117 StopEffect(i);
00118 }
00119
00120 delete this;
00121 }