|
|
|
@ -10,7 +10,7 @@ std::string LeftShifter::unitName="Left Shifter"; |
|
|
|
|
std::string LeftShifter::unitDescription="Memory Shifts target memory 1 bit to the left."; |
|
|
|
|
std::vector<Memory> LeftShifter::resourceCost={{RANGE,2},{ATKSPD,2},{MOVESPD,3},{PROCEDURE,1},{HEALTH,4}}; |
|
|
|
|
LeftShifter::LeftShifter(PixelGameEngine*pge,vf2d pos,std::map<Image,std::unique_ptr<Renderable>>&IMAGES,bool friendly,bool moveable) |
|
|
|
|
:Unit(pge,UnitType::LeftShifter,LeftShifter::resourceCost,pos,12,*IMAGES[LEFT_SHIFTER],CONSTANT::ATTACKER_TARGET_COL,CONSTANT::ATTACKER_ATTACK_COL,friendly,moveable){} |
|
|
|
|
:Unit(pge,LeftShifter::resourceCost,pos,12,*IMAGES[LEFT_SHIFTER],CONSTANT::ATTACKER_TARGET_COL,CONSTANT::ATTACKER_ATTACK_COL,friendly,moveable){} |
|
|
|
|
|
|
|
|
|
void LeftShifter::Attack(Unit&victim,std::vector<std::shared_ptr<Unit>>&otherUnits){ |
|
|
|
|
victim<<=1; |
|
|
|
@ -20,7 +20,7 @@ std::string RightShifter::unitName="Right Shifter"; |
|
|
|
|
std::string RightShifter::unitDescription="Memory Shifts target memory 1 bit to the right."; |
|
|
|
|
std::vector<Memory> RightShifter::resourceCost={{HEALTH,4},{RANGE,2},{ATKSPD,2},{MOVESPD,3},{PROCEDURE,1}}; |
|
|
|
|
RightShifter::RightShifter(PixelGameEngine*pge,vf2d pos,std::map<Image,std::unique_ptr<Renderable>>&IMAGES,bool friendly,bool moveable) |
|
|
|
|
:Unit(pge,UnitType::RightShifter,RightShifter::resourceCost,pos,12,*IMAGES[RIGHT_SHIFTER],CONSTANT::ATTACKER_TARGET_COL,CONSTANT::ATTACKER_ATTACK_COL,friendly,moveable){} |
|
|
|
|
:Unit(pge,RightShifter::resourceCost,pos,12,*IMAGES[RIGHT_SHIFTER],CONSTANT::ATTACKER_TARGET_COL,CONSTANT::ATTACKER_ATTACK_COL,friendly,moveable){} |
|
|
|
|
|
|
|
|
|
void RightShifter::Attack(Unit&victim,std::vector<std::shared_ptr<Unit>>&otherUnits){ |
|
|
|
|
victim>>=1; |
|
|
|
@ -30,7 +30,7 @@ std::string BitRestorer::unitName="Bit Restorer"; |
|
|
|
|
std::string BitRestorer::unitDescription="Randomly restores 1 missing bit to a target."; |
|
|
|
|
std::vector<Memory> BitRestorer::resourceCost={{PROCEDURE,6},{RANGE,1},{ATKSPD,1},{MOVESPD,1},{HEALTH,2}}; |
|
|
|
|
BitRestorer::BitRestorer(PixelGameEngine*pge,vf2d pos,std::map<Image,std::unique_ptr<Renderable>>&IMAGES,bool friendly,bool moveable) |
|
|
|
|
:Unit(pge,UnitType::BitRestorer,BitRestorer::resourceCost,pos,12,*IMAGES[BIT_RESTORER],CONSTANT::HEALER_TARGET_COL,CONSTANT::HEALER_ATTACK_COL,friendly,moveable,true,false){} |
|
|
|
|
:Unit(pge,BitRestorer::resourceCost,pos,12,*IMAGES[BIT_RESTORER],CONSTANT::HEALER_TARGET_COL,CONSTANT::HEALER_ATTACK_COL,friendly,moveable,true,false){} |
|
|
|
|
|
|
|
|
|
void BitRestorer::Attack(Unit&victim,std::vector<std::shared_ptr<Unit>>&otherUnits){ |
|
|
|
|
std::vector<int>emptyMemoryPositions; |
|
|
|
@ -72,19 +72,43 @@ std::string MemorySwapper::unitName="Memory Swapper"; |
|
|
|
|
std::string MemorySwapper::unitDescription="Flips the orientation of all bits of a target around."; |
|
|
|
|
std::vector<Memory> MemorySwapper::resourceCost={{RANGE,3},{ATKSPD,1},{HEALTH,3},{PROCEDURE,3},{MOVESPD,2}}; |
|
|
|
|
MemorySwapper::MemorySwapper(PixelGameEngine*pge,vf2d pos,std::map<Image,std::unique_ptr<Renderable>>&IMAGES,bool friendly,bool moveable) |
|
|
|
|
:Unit(pge,UnitType::MemorySwapper,MemorySwapper::resourceCost,pos,12,*IMAGES[MEMORY_SWAPPER],CONSTANT::ATTACKER_TARGET_COL,CONSTANT::ATTACKER_ATTACK_COL,friendly,moveable,true){ |
|
|
|
|
:Unit(pge,MemorySwapper::resourceCost,pos,12,*IMAGES[MEMORY_SWAPPER],CONSTANT::ATTACKER_TARGET_COL,CONSTANT::ATTACKER_ATTACK_COL,friendly,moveable,true){ |
|
|
|
|
autoAcquireFriendlyTarget=false; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void MemorySwapper::Attack(Unit&victim,std::vector<std::shared_ptr<Unit>>&otherUnits){ |
|
|
|
|
|
|
|
|
|
std::vector<bool>oldMemory=victim.memory; |
|
|
|
|
for(int i=0;i<oldMemory.size();i++){ |
|
|
|
|
victim.memory[i]=victim.ghostMemory[i]=oldMemory[oldMemory.size()-i-1]; |
|
|
|
|
} |
|
|
|
|
std::vector<Marker*>order; |
|
|
|
|
for(int i=0;i<5;i++){ |
|
|
|
|
int lowestInd=999999; |
|
|
|
|
Marker*lowest; |
|
|
|
|
if(victim.health.index<lowestInd){lowest=&victim.health;lowestInd=lowest->index;} |
|
|
|
|
if(victim.range.index<lowestInd){lowest=&victim.range;lowestInd=lowest->index;} |
|
|
|
|
if(victim.atkSpd.index<lowestInd){lowest=&victim.atkSpd;lowestInd=lowest->index;} |
|
|
|
|
if(victim.moveSpd.index<lowestInd){lowest=&victim.moveSpd;lowestInd=lowest->index;} |
|
|
|
|
if(victim.procedure.index<lowestInd){lowest=&victim.procedure;lowestInd=lowest->index;} |
|
|
|
|
|
|
|
|
|
order.push_back(lowest); |
|
|
|
|
lowest->index=9999999; |
|
|
|
|
} |
|
|
|
|
std::reverse(order.begin(),order.end()); |
|
|
|
|
int i=0; |
|
|
|
|
int marker=0; |
|
|
|
|
while(marker<oldMemory.size()){ |
|
|
|
|
order[i]->index=marker; |
|
|
|
|
marker+=order[i]->size; |
|
|
|
|
i++; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
std::string Corrupter::unitName="Corrupter"; |
|
|
|
|
std::string Corrupter::unitDescription="Chooses a random bit and negates it on a target."; |
|
|
|
|
std::vector<Memory> Corrupter::resourceCost={{ATKSPD,3},{RANGE,1},{PROCEDURE,8},{MOVESPD,4},{HEALTH,4}}; |
|
|
|
|
Corrupter::Corrupter(PixelGameEngine*pge,vf2d pos,std::map<Image,std::unique_ptr<Renderable>>&IMAGES,bool friendly,bool moveable) |
|
|
|
|
:Unit(pge,UnitType::Corrupter,Corrupter::resourceCost,pos,12,*IMAGES[CORRUPTER],CONSTANT::ATTACKER_TARGET_COL,CONSTANT::ATTACKER_ATTACK_COL,friendly,moveable){} |
|
|
|
|
:Unit(pge,Corrupter::resourceCost,pos,12,*IMAGES[CORRUPTER],CONSTANT::ATTACKER_TARGET_COL,CONSTANT::ATTACKER_ATTACK_COL,friendly,moveable){} |
|
|
|
|
|
|
|
|
|
void Corrupter::Attack(Unit&victim,std::vector<std::shared_ptr<Unit>>&otherUnits){ |
|
|
|
|
//Chooses a bit at random and corrupts it.
|
|
|
|
@ -96,7 +120,7 @@ std::string MemoryAllocator::unitName="Memory Allocator"; |
|
|
|
|
std::string MemoryAllocator::unitDescription="A unit that builds other units."; |
|
|
|
|
std::vector<Memory> MemoryAllocator::resourceCost={{RANGE,1},{ATKSPD,1},{MOVESPD,1},{PROCEDURE,1},{HEALTH,1}}; |
|
|
|
|
MemoryAllocator::MemoryAllocator(PixelGameEngine*pge,vf2d pos,std::map<Image,std::unique_ptr<Renderable>>&IMAGES,bool friendly,bool moveable) |
|
|
|
|
:Unit(pge,UnitType::MemoryAllocator,MemoryAllocator::resourceCost,pos,12,*IMAGES[UNIT_ALLOCATOR],CONSTANT::ATTACKER_TARGET_COL,CONSTANT::ATTACKER_ATTACK_COL,friendly,true,false){ |
|
|
|
|
:Unit(pge,MemoryAllocator::resourceCost,pos,12,*IMAGES[UNIT_ALLOCATOR],CONSTANT::ATTACKER_TARGET_COL,CONSTANT::ATTACKER_ATTACK_COL,friendly,true,false){ |
|
|
|
|
isAllocator=true; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -141,7 +165,7 @@ std::string RAMBank::unitName="RAM Bank"; |
|
|
|
|
std::string RAMBank::unitDescription="Allows for the construction of Memory Allocators."; |
|
|
|
|
std::vector<Memory> RAMBank::resourceCost={{RANGE,0},{ATKSPD,0},{MOVESPD,0},{PROCEDURE,25},{HEALTH,16}}; |
|
|
|
|
RAMBank::RAMBank(PixelGameEngine*pge,vf2d pos,std::map<Image,std::unique_ptr<Renderable>>&IMAGES,bool friendly) |
|
|
|
|
:Unit(pge,UnitType::RAMBank,RAMBank::resourceCost,pos,41,*IMAGES[RAM_BANK],WHITE,WHITE,friendly,false |
|
|
|
|
:Unit(pge,RAMBank::resourceCost,pos,41,*IMAGES[RAM_BANK],WHITE,WHITE,friendly,false |
|
|
|
|
,false,false |
|
|
|
|
),randomOffset({util::random(128),util::random(128)}),matrixImg(*IMAGES[MATRIX]), |
|
|
|
|
originalImg(*IMAGES[RAM_BANK]){ |
|
|
|
@ -250,8 +274,56 @@ bool RAMBank::ClickHandled(TileTransformedView&game,Resources&player_resources,s |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
Unit::Unit(PixelGameEngine*pge,UnitType type,std::vector<Memory>memory,vf2d pos,float radius,Renderable&img,Pixel targetLineColor,Pixel attackingLineColor,bool friendly,bool moveable,bool friendlyInteractable,bool enemyInteractable) |
|
|
|
|
:pos(pos),type(type),radius(radius),ghostPos(pos),img(img),targetLineCol(targetLineColor),attackingLineCol(attackingLineColor),friendly(friendly),moveable(moveable),friendlyInteractable(friendlyInteractable),enemyInteractable(enemyInteractable){ |
|
|
|
|
std::string _Platform::unitName="Corrupter"; |
|
|
|
|
std::string _Platform::unitDescription="Chooses a random bit and negates it on a target."; |
|
|
|
|
std::vector<Memory> _Platform::resourceCost={{ATKSPD,3},{RANGE,1},{PROCEDURE,8},{MOVESPD,4},{HEALTH,4}}; |
|
|
|
|
_Platform::_Platform(PixelGameEngine*pge,vf2d pos,std::map<Image,std::unique_ptr<Renderable>>&IMAGES,bool friendly,bool moveable) |
|
|
|
|
:Unit(pge,_Platform::resourceCost,pos,24,*IMAGES[PLATFORM],CONSTANT::ATTACKER_TARGET_COL,CONSTANT::ATTACKER_ATTACK_COL,friendly,moveable){} |
|
|
|
|
|
|
|
|
|
void _Platform::Attack(Unit&victim,std::vector<std::shared_ptr<Unit>>&otherUnits){}; |
|
|
|
|
|
|
|
|
|
std::string Refresher::unitName="Refresher"; |
|
|
|
|
std::string Refresher::unitDescription="Repairs missing bits for all surrounding units."; |
|
|
|
|
std::vector<Memory> Refresher::resourceCost={{ATKSPD,3},{RANGE,1},{PROCEDURE,8},{MOVESPD,4},{HEALTH,4}}; |
|
|
|
|
Refresher::Refresher(PixelGameEngine*pge,vf2d pos,std::map<Image,std::unique_ptr<Renderable>>&IMAGES,bool friendly,bool moveable) |
|
|
|
|
:Unit(pge,Refresher::resourceCost,pos,24,*IMAGES[REFRESHER],CONSTANT::ATTACKER_TARGET_COL,CONSTANT::ATTACKER_ATTACK_COL,friendly,moveable){} |
|
|
|
|
|
|
|
|
|
void Refresher::Attack(Unit&victim,std::vector<std::shared_ptr<Unit>>&otherUnits){ |
|
|
|
|
//Chooses a bit at random and corrupts it.
|
|
|
|
|
int randomBit=rand()%victim.memory.size(); |
|
|
|
|
victim.memory[randomBit]=victim.ghostMemory[randomBit]=false; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
std::string Turret::unitName="Turret"; |
|
|
|
|
std::string Turret::unitDescription="Automatically targets attack and movement speed memory ranges before others."; |
|
|
|
|
std::vector<Memory> Turret::resourceCost={{ATKSPD,4},{RANGE,5},{HEALTH,6},{PROCEDURE,16}}; |
|
|
|
|
Turret::Turret(PixelGameEngine*pge,vf2d pos,std::map<Image,std::unique_ptr<Renderable>>&IMAGES,bool friendly,bool moveable) |
|
|
|
|
:Unit(pge,Turret::resourceCost,pos,24,*IMAGES[TURRET],CONSTANT::ATTACKER_TARGET_COL,CONSTANT::ATTACKER_ATTACK_COL,friendly,moveable){} |
|
|
|
|
|
|
|
|
|
void Turret::Attack(Unit&victim,std::vector<std::shared_ptr<Unit>>&otherUnits){ |
|
|
|
|
//Chooses a bit at random and corrupts it.
|
|
|
|
|
int randomBit=rand()%victim.memory.size(); |
|
|
|
|
victim.memory[randomBit]=victim.ghostMemory[randomBit]=false; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
std::string MemoryGuard::unitName="Memory Guard"; |
|
|
|
|
std::string MemoryGuard::unitDescription="Reduces the chance of bit modification for all surrounding units by 30%"; |
|
|
|
|
std::vector<Memory> MemoryGuard::resourceCost={{HEALTH,10},{ATKSPD,4},{RANGE,4},{PROCEDURE,12}}; |
|
|
|
|
MemoryGuard::MemoryGuard(PixelGameEngine*pge,vf2d pos,std::map<Image,std::unique_ptr<Renderable>>&IMAGES,bool friendly,bool moveable) |
|
|
|
|
:Unit(pge,MemoryGuard::resourceCost,pos,24,*IMAGES[MEMORY_GUARD],CONSTANT::ATTACKER_TARGET_COL,CONSTANT::ATTACKER_ATTACK_COL,friendly,false |
|
|
|
|
,true,false){} |
|
|
|
|
|
|
|
|
|
void MemoryGuard::Attack(Unit&victim,std::vector<std::shared_ptr<Unit>>&otherUnits){ |
|
|
|
|
target.reset(); //Doesn't acquire a target.
|
|
|
|
|
for(auto&u:otherUnits){ |
|
|
|
|
if(IsFriendly()==u->IsFriendly()&&InRange(u.get())){ |
|
|
|
|
u->SetGuardTime(3); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
Unit::Unit(PixelGameEngine*pge,std::vector<Memory>memory,vf2d pos,float radius,Renderable&img,Pixel targetLineColor,Pixel attackingLineColor,bool friendly,bool moveable,bool friendlyInteractable,bool enemyInteractable) |
|
|
|
|
:pos(pos),radius(radius),ghostPos(pos),img(img),targetLineCol(targetLineColor),attackingLineCol(attackingLineColor),friendly(friendly),moveable(moveable),friendlyInteractable(friendlyInteractable),enemyInteractable(enemyInteractable){ |
|
|
|
|
int marker=0; |
|
|
|
|
for(Memory&mem:memory){ |
|
|
|
|
for(int i=0;i<mem.size;i++){ |
|
|
|
@ -545,6 +617,7 @@ void Unit::_Update(PixelGameEngine*pge,std::map<Sound,std::unique_ptr<Audio>>&SO |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
reloadTimer=std::max(0.f,reloadTimer-pge->GetElapsedTime()); |
|
|
|
|
guardTime=std::max(0.f,guardTime-pge->GetElapsedTime()); |
|
|
|
|
lineShift-=pge->GetElapsedTime(); |
|
|
|
|
if(lineShift<-25)lineShift+=25; |
|
|
|
|
|
|
|
|
@ -793,4 +866,16 @@ void Unit::SetBuildUnit(float buildTime,std::unique_ptr<Unit>finalUnit){ |
|
|
|
|
|
|
|
|
|
bool Unit::IsBuilding(){ |
|
|
|
|
return buildTime>0; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void Unit::SetGuardTime(float time){ |
|
|
|
|
guardTime=time; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
bool Unit::IsGuarded(){ |
|
|
|
|
return guardTime>0; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void Unit::SaveMemory(){ |
|
|
|
|
savedMemory=memory; |
|
|
|
|
} |