|
|
|
@ -8,8 +8,8 @@ |
|
|
|
|
|
|
|
|
|
Unit::~Unit(){}; |
|
|
|
|
|
|
|
|
|
void Unit::RandomHit(int chance,std::vector<std::unique_ptr<Audio>>&SOUNDS){ |
|
|
|
|
switch(rand()%chance){ |
|
|
|
|
void Unit::RandomHit(std::vector<std::unique_ptr<Audio>>&SOUNDS){ |
|
|
|
|
switch(rand()%3){ |
|
|
|
|
case 0:{SOUNDS[Sound::HIT1]->Play(GetPos(),1,0.6);}break; |
|
|
|
|
case 1:{SOUNDS[Sound::HIT2]->Play(GetPos(),1,0.6);}break; |
|
|
|
|
case 2:{SOUNDS[Sound::HIT3]->Play(GetPos(),1,0.6);}break; |
|
|
|
@ -24,7 +24,7 @@ LeftShifter::LeftShifter(PixelGameEngine*pge,vf2d pos,std::vector<std::unique_pt |
|
|
|
|
|
|
|
|
|
void LeftShifter::Attack(Unit&victim,std::vector<std::shared_ptr<Unit>>&otherUnits ,std::vector<std::unique_ptr<Audio>>&SOUNDS){ |
|
|
|
|
victim<<=1; |
|
|
|
|
RandomHit(6,SOUNDS); |
|
|
|
|
RandomHit(SOUNDS); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
std::string RightShifter::unitName="Right Shifter"; |
|
|
|
@ -35,7 +35,7 @@ RightShifter::RightShifter(PixelGameEngine*pge,vf2d pos,std::vector<std::unique_ |
|
|
|
|
|
|
|
|
|
void RightShifter::Attack(Unit&victim,std::vector<std::shared_ptr<Unit>>&otherUnits ,std::vector<std::unique_ptr<Audio>>&SOUNDS){ |
|
|
|
|
victim>>=1; |
|
|
|
|
RandomHit(6,SOUNDS); |
|
|
|
|
RandomHit(SOUNDS); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
std::string BitRestorer::unitName="Bit Restorer"; |
|
|
|
@ -124,7 +124,7 @@ void MemorySwapper::Attack(Unit&victim,std::vector<std::shared_ptr<Unit>>&otherU |
|
|
|
|
if(victim.atkSpd.index==9999999)victim.atkSpd.index=0; |
|
|
|
|
if(victim.moveSpd.index==9999999)victim.moveSpd.index=0; |
|
|
|
|
if(victim.procedure.index==9999999)victim.procedure.index=0; |
|
|
|
|
RandomHit(4,SOUNDS); |
|
|
|
|
RandomHit(SOUNDS); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
std::string Corrupter::unitName="Corrupter"; |
|
|
|
@ -137,7 +137,7 @@ void Corrupter::Attack(Unit&victim,std::vector<std::shared_ptr<Unit>>&otherUnits |
|
|
|
|
//Chooses a bit at random and corrupts it.
|
|
|
|
|
int randomBit=rand()%victim.memory.size(); |
|
|
|
|
if(victim.memory[randomBit]){ |
|
|
|
|
RandomHit(5,SOUNDS); |
|
|
|
|
RandomHit(SOUNDS); |
|
|
|
|
} |
|
|
|
|
victim.memory[randomBit]=false; |
|
|
|
|
} |
|
|
|
@ -990,14 +990,15 @@ bool Unit::IsAllocator(){ |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void Unit::SetBuildUnit(float buildTime,std::shared_ptr<Unit>finalUnit,std::vector<std::unique_ptr<Audio>>&SOUNDS){ |
|
|
|
|
this->buildTime=buildTime; |
|
|
|
|
this->buildTransformUnit=std::move(finalUnit); |
|
|
|
|
if(this->IsAllocator()){ |
|
|
|
|
SOUNDS[Sound::SMALLBUILD]->Play(GetPos()); |
|
|
|
|
} else |
|
|
|
|
if(this->IsPlatform()){ |
|
|
|
|
SOUNDS[Sound::BIGBUILD]->Play(GetPos()); |
|
|
|
|
} |
|
|
|
|
//Once the units start building they aren't considered allocators/platforms anymore, must do it before.
|
|
|
|
|
this->buildTime=buildTime; |
|
|
|
|
this->buildTransformUnit=std::move(finalUnit); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
bool Unit::IsBuilding(){ |
|
|
|
|