|
|
|
@ -7,7 +7,7 @@ |
|
|
|
|
#include "Textbox.h" |
|
|
|
|
|
|
|
|
|
std::string LeftShifter::unitName="Left Shifter"; |
|
|
|
|
std::string LeftShifter::unitDescription="Memory Shifts target memory 1 bit to the left."; |
|
|
|
|
std::string LeftShifter::unitDescription="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,LeftShifter::resourceCost,pos,12,*IMAGES[LEFT_SHIFTER],CONSTANT::ATTACKER_TARGET_COL,CONSTANT::ATTACKER_ATTACK_COL,friendly,moveable){} |
|
|
|
@ -17,7 +17,7 @@ void LeftShifter::Attack(Unit&victim,std::vector<std::shared_ptr<Unit>>&otherUni |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
std::string RightShifter::unitName="Right Shifter"; |
|
|
|
|
std::string RightShifter::unitDescription="Memory Shifts target memory 1 bit to the right."; |
|
|
|
|
std::string RightShifter::unitDescription="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,RightShifter::resourceCost,pos,12,*IMAGES[RIGHT_SHIFTER],CONSTANT::ATTACKER_TARGET_COL,CONSTANT::ATTACKER_ATTACK_COL,friendly,moveable){} |
|
|
|
@ -338,7 +338,7 @@ void Refresher::Attack(Unit&victim,std::vector<std::shared_ptr<Unit>>&otherUnits |
|
|
|
|
int attempts=0; |
|
|
|
|
while(attempts<maxAttempts){ |
|
|
|
|
int randomBit=rand()%u->GetMemorySize(); |
|
|
|
|
if(u->memory[randomBit]){ |
|
|
|
|
if(!u->memory[randomBit]){ |
|
|
|
|
u->memory[randomBit]=true; |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
@ -400,7 +400,7 @@ void MemoryGuard::Attack(Unit&victim,std::vector<std::shared_ptr<Unit>>&otherUni |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
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){ |
|
|
|
|
:pos(pos),radius(radius),ghostPos({-999999,-999999}),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++){ |
|
|
|
@ -637,7 +637,7 @@ void Unit::_RunAI(PixelGameEngine*pge){ |
|
|
|
|
RunAI(pge); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void Unit::_Update(PixelGameEngine*pge,std::map<Sound,std::unique_ptr<Audio>>&SOUNDS,Resources&player_resources,Resources&enemy_resources,std::vector<std::unique_ptr<Unit>>&queuedUnits){ |
|
|
|
|
void Unit::_Update(PixelGameEngine*pge,std::map<Sound,std::unique_ptr<Audio>>&SOUNDS,Resources&player_resources,Resources&enemy_resources,std::vector<std::unique_ptr<Unit>>&queuedUnits,std::array<float,5>&resourceGainTimer){ |
|
|
|
|
if(!target.expired()){ |
|
|
|
|
auto ptrTarget=target.lock(); |
|
|
|
|
if(!InRange(ptrTarget)&&CanMove()){ |
|
|
|
@ -668,18 +668,23 @@ void Unit::_Update(PixelGameEngine*pge,std::map<Sound,std::unique_ptr<Audio>>&SO |
|
|
|
|
switch(attachedPoint.lock()->type){ |
|
|
|
|
case HEALTH:{ |
|
|
|
|
targetResource.health++; |
|
|
|
|
resourceGainTimer[0]=2; |
|
|
|
|
}break; |
|
|
|
|
case RANGE:{ |
|
|
|
|
targetResource.range++; |
|
|
|
|
resourceGainTimer[3]=2; |
|
|
|
|
}break; |
|
|
|
|
case ATKSPD:{ |
|
|
|
|
targetResource.atkSpd++; |
|
|
|
|
resourceGainTimer[1]=2; |
|
|
|
|
}break; |
|
|
|
|
case MOVESPD:{ |
|
|
|
|
targetResource.moveSpd++; |
|
|
|
|
resourceGainTimer[2]=2; |
|
|
|
|
}break; |
|
|
|
|
case PROCEDURE:{ |
|
|
|
|
targetResource.procedure++; |
|
|
|
|
resourceGainTimer[4]=2; |
|
|
|
|
}break; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
@ -694,6 +699,7 @@ void Unit::_Update(PixelGameEngine*pge,std::map<Sound,std::unique_ptr<Audio>>&SO |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if(!InFogOfWar()){ |
|
|
|
|
ghostPos=pos; |
|
|
|
|
ghostMemory=memory; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -782,9 +788,6 @@ bool Unit::InRange(vf2d pos){ |
|
|
|
|
|
|
|
|
|
void Unit::SetPos(vf2d newPos){ |
|
|
|
|
pos=newPos; |
|
|
|
|
if(!InFogOfWar()){ |
|
|
|
|
ghostPos=pos; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void Unit::AttemptAttack(std::weak_ptr<Unit>attacker,std::weak_ptr<Unit>unit,std::vector<std::shared_ptr<Unit>>&otherUnits,std::vector<DebuffIcon>&debuffIcons,std::map<Image,std::unique_ptr<Renderable>>&IMAGES){ |
|
|
|
|