|
|
@ -1,70 +1,69 @@ |
|
|
|
#include "Unit.h" |
|
|
|
#include "Unit.h" |
|
|
|
#include "Constant.h" |
|
|
|
|
|
|
|
#include "olcUTIL_Geometry2D.h" |
|
|
|
#include "olcUTIL_Geometry2D.h" |
|
|
|
#include "TileManager.h" |
|
|
|
#include "TileManager.h" |
|
|
|
#include "util.h" |
|
|
|
#include "util.h" |
|
|
|
|
|
|
|
|
|
|
|
BasicUnit::BasicUnit(vf2d pos,std::map<Image,std::unique_ptr<Renderable>>&IMAGES,bool friendly,bool moveable) |
|
|
|
BasicUnit::BasicUnit(PixelGameEngine*pge,vf2d pos,std::map<Image,std::unique_ptr<Renderable>>&IMAGES,bool friendly,bool moveable) |
|
|
|
:Unit({ |
|
|
|
:Unit(pge,{ |
|
|
|
{HEALTH,4}, |
|
|
|
{HEALTH,4}, |
|
|
|
{RANGE,2}, |
|
|
|
{RANGE,2}, |
|
|
|
{ATKSPD,2}, |
|
|
|
{ATKSPD,2}, |
|
|
|
{MOVESPD,3}, |
|
|
|
{MOVESPD,3}, |
|
|
|
{PROCEDURE,1}, |
|
|
|
{PROCEDURE,1}, |
|
|
|
},pos,12,*IMAGES[VIRUS_IMG1],friendly,moveable){} |
|
|
|
},pos,12,*IMAGES[VIRUS_IMG1],WHITE,WHITE,friendly,moveable){} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void BasicUnit::Attack(Unit&victim,std::vector<std::shared_ptr<Unit>>&otherUnits){ |
|
|
|
void BasicUnit::Attack(Unit&victim,std::vector<std::shared_ptr<Unit>>&otherUnits){ |
|
|
|
victim<<=1; |
|
|
|
victim<<=1; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
BasicUnit2::BasicUnit2(vf2d pos,std::map<Image,std::unique_ptr<Renderable>>&IMAGES,bool friendly,bool moveable) |
|
|
|
BasicUnit2::BasicUnit2(PixelGameEngine*pge,vf2d pos,std::map<Image,std::unique_ptr<Renderable>>&IMAGES,bool friendly,bool moveable) |
|
|
|
:Unit({ |
|
|
|
:Unit(pge,{ |
|
|
|
{RANGE,2}, |
|
|
|
{RANGE,2}, |
|
|
|
{ATKSPD,2}, |
|
|
|
{ATKSPD,2}, |
|
|
|
{MOVESPD,3}, |
|
|
|
{MOVESPD,3}, |
|
|
|
{PROCEDURE,1}, |
|
|
|
{PROCEDURE,1}, |
|
|
|
{HEALTH,4}, |
|
|
|
{HEALTH,4}, |
|
|
|
},pos,12,*IMAGES[VIRUS_IMG1],friendly,moveable){} |
|
|
|
},pos,12,*IMAGES[VIRUS_IMG1],WHITE,WHITE,friendly,moveable){} |
|
|
|
|
|
|
|
|
|
|
|
void BasicUnit2::Attack(Unit&victim,std::vector<std::shared_ptr<Unit>>&otherUnits){ |
|
|
|
void BasicUnit2::Attack(Unit&victim,std::vector<std::shared_ptr<Unit>>&otherUnits){ |
|
|
|
victim>>=1; |
|
|
|
victim>>=1; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
LeftShifter::LeftShifter(vf2d pos,std::map<Image,std::unique_ptr<Renderable>>&IMAGES,bool friendly,bool moveable) |
|
|
|
LeftShifter::LeftShifter(PixelGameEngine*pge,vf2d pos,std::map<Image,std::unique_ptr<Renderable>>&IMAGES,bool friendly,bool moveable) |
|
|
|
:Unit({ |
|
|
|
:Unit(pge,{ |
|
|
|
{RANGE,2}, |
|
|
|
{RANGE,2}, |
|
|
|
{ATKSPD,2}, |
|
|
|
{ATKSPD,2}, |
|
|
|
{MOVESPD,3}, |
|
|
|
{MOVESPD,3}, |
|
|
|
{PROCEDURE,1}, |
|
|
|
{PROCEDURE,1}, |
|
|
|
{HEALTH,4}, |
|
|
|
{HEALTH,4}, |
|
|
|
},pos,12,*IMAGES[LEFT_SHIFTER],friendly,moveable){} |
|
|
|
},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){ |
|
|
|
void LeftShifter::Attack(Unit&victim,std::vector<std::shared_ptr<Unit>>&otherUnits){ |
|
|
|
victim<<=1; |
|
|
|
victim<<=1; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
RightShifter::RightShifter(vf2d pos,std::map<Image,std::unique_ptr<Renderable>>&IMAGES,bool friendly,bool moveable) |
|
|
|
RightShifter::RightShifter(PixelGameEngine*pge,vf2d pos,std::map<Image,std::unique_ptr<Renderable>>&IMAGES,bool friendly,bool moveable) |
|
|
|
:Unit({ |
|
|
|
:Unit(pge,{ |
|
|
|
{HEALTH,4}, |
|
|
|
{HEALTH,4}, |
|
|
|
{RANGE,2}, |
|
|
|
{RANGE,2}, |
|
|
|
{ATKSPD,2}, |
|
|
|
{ATKSPD,2}, |
|
|
|
{MOVESPD,3}, |
|
|
|
{MOVESPD,3}, |
|
|
|
{PROCEDURE,1}, |
|
|
|
{PROCEDURE,1}, |
|
|
|
},pos,12,*IMAGES[RIGHT_SHIFTER],friendly,moveable){} |
|
|
|
},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){ |
|
|
|
void RightShifter::Attack(Unit&victim,std::vector<std::shared_ptr<Unit>>&otherUnits){ |
|
|
|
victim>>=1; |
|
|
|
victim>>=1; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
BitRestorer::BitRestorer(vf2d pos,std::map<Image,std::unique_ptr<Renderable>>&IMAGES,bool friendly,bool moveable) |
|
|
|
BitRestorer::BitRestorer(PixelGameEngine*pge,vf2d pos,std::map<Image,std::unique_ptr<Renderable>>&IMAGES,bool friendly,bool moveable) |
|
|
|
:Unit({ |
|
|
|
:Unit(pge,{ |
|
|
|
{PROCEDURE,6}, |
|
|
|
{PROCEDURE,6}, |
|
|
|
{RANGE,1}, |
|
|
|
{RANGE,1}, |
|
|
|
{ATKSPD,1}, |
|
|
|
{ATKSPD,1}, |
|
|
|
{MOVESPD,1}, |
|
|
|
{MOVESPD,1}, |
|
|
|
{HEALTH,2}, |
|
|
|
{HEALTH,2}, |
|
|
|
},pos,12,*IMAGES[BIT_RESTORER],friendly,moveable,true,false){} |
|
|
|
},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){ |
|
|
|
void BitRestorer::Attack(Unit&victim,std::vector<std::shared_ptr<Unit>>&otherUnits){ |
|
|
|
std::vector<int>emptyMemoryPositions; |
|
|
|
std::vector<int>emptyMemoryPositions; |
|
|
@ -75,6 +74,7 @@ void BitRestorer::Attack(Unit&victim,std::vector<std::shared_ptr<Unit>>&otherUni |
|
|
|
} |
|
|
|
} |
|
|
|
if(emptyMemoryPositions.size()==0){ |
|
|
|
if(emptyMemoryPositions.size()==0){ |
|
|
|
//First see if we can find another damaged target, if we can, then we try healing them. Otherwise we exit.
|
|
|
|
//First see if we can find another damaged target, if we can, then we try healing them. Otherwise we exit.
|
|
|
|
|
|
|
|
appliedTarget.reset(); |
|
|
|
AttemptToHealOtherAllies(otherUnits); |
|
|
|
AttemptToHealOtherAllies(otherUnits); |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
@ -94,33 +94,36 @@ void BitRestorer::AttemptToHealOtherAllies(std::vector<std::shared_ptr<Unit>>&ot |
|
|
|
if(emptyMemoryPositions.size()!=0){ |
|
|
|
if(emptyMemoryPositions.size()!=0){ |
|
|
|
int randomBit=emptyMemoryPositions[rand()%emptyMemoryPositions.size()]; |
|
|
|
int randomBit=emptyMemoryPositions[rand()%emptyMemoryPositions.size()]; |
|
|
|
u->memory[randomBit]=u->ghostMemory[randomBit]=true; |
|
|
|
u->memory[randomBit]=u->ghostMemory[randomBit]=true; |
|
|
|
|
|
|
|
appliedTarget=u; |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
MemorySwapper::MemorySwapper(vf2d pos,std::map<Image,std::unique_ptr<Renderable>>&IMAGES,bool friendly,bool moveable) |
|
|
|
MemorySwapper::MemorySwapper(PixelGameEngine*pge,vf2d pos,std::map<Image,std::unique_ptr<Renderable>>&IMAGES,bool friendly,bool moveable) |
|
|
|
:Unit({ |
|
|
|
:Unit(pge,{ |
|
|
|
{RANGE,3}, |
|
|
|
{RANGE,3}, |
|
|
|
{ATKSPD,1}, |
|
|
|
{ATKSPD,1}, |
|
|
|
{HEALTH,3}, |
|
|
|
{HEALTH,3}, |
|
|
|
{PROCEDURE,3}, |
|
|
|
{PROCEDURE,3}, |
|
|
|
{MOVESPD,2}, |
|
|
|
{MOVESPD,2}, |
|
|
|
},pos,12,*IMAGES[MEMORY_SWAPPER],friendly,moveable,true){} |
|
|
|
},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){ |
|
|
|
void MemorySwapper::Attack(Unit&victim,std::vector<std::shared_ptr<Unit>>&otherUnits){ |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
Corrupter::Corrupter(vf2d pos,std::map<Image,std::unique_ptr<Renderable>>&IMAGES,bool friendly,bool moveable) |
|
|
|
Corrupter::Corrupter(PixelGameEngine*pge,vf2d pos,std::map<Image,std::unique_ptr<Renderable>>&IMAGES,bool friendly,bool moveable) |
|
|
|
:Unit({ |
|
|
|
:Unit(pge,{ |
|
|
|
{ATKSPD,3}, |
|
|
|
{ATKSPD,3}, |
|
|
|
{RANGE,1}, |
|
|
|
{RANGE,1}, |
|
|
|
{PROCEDURE,8}, |
|
|
|
{PROCEDURE,8}, |
|
|
|
{MOVESPD,4}, |
|
|
|
{MOVESPD,4}, |
|
|
|
{HEALTH,4}, |
|
|
|
{HEALTH,4}, |
|
|
|
},pos,12,*IMAGES[CORRUPTER],friendly,moveable){} |
|
|
|
},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){ |
|
|
|
void Corrupter::Attack(Unit&victim,std::vector<std::shared_ptr<Unit>>&otherUnits){ |
|
|
|
//Chooses a bit at random and corrupts it.
|
|
|
|
//Chooses a bit at random and corrupts it.
|
|
|
@ -128,27 +131,27 @@ void Corrupter::Attack(Unit&victim,std::vector<std::shared_ptr<Unit>>&otherUnits |
|
|
|
victim.memory[randomBit]=victim.ghostMemory[randomBit]=false; |
|
|
|
victim.memory[randomBit]=victim.ghostMemory[randomBit]=false; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
MemoryAllocator::MemoryAllocator(vf2d pos,std::map<Image,std::unique_ptr<Renderable>>&IMAGES,bool friendly,bool moveable) |
|
|
|
MemoryAllocator::MemoryAllocator(PixelGameEngine*pge,vf2d pos,std::map<Image,std::unique_ptr<Renderable>>&IMAGES,bool friendly,bool moveable) |
|
|
|
:Unit({ |
|
|
|
:Unit(pge,{ |
|
|
|
{RANGE,1}, |
|
|
|
{RANGE,1}, |
|
|
|
{ATKSPD,1}, |
|
|
|
{ATKSPD,1}, |
|
|
|
{MOVESPD,1}, |
|
|
|
{MOVESPD,1}, |
|
|
|
{PROCEDURE,1}, |
|
|
|
{PROCEDURE,1}, |
|
|
|
{HEALTH,1}, |
|
|
|
{HEALTH,1}, |
|
|
|
},pos,12,*IMAGES[UNIT_ALLOCATOR],friendly,true,false){} |
|
|
|
},pos,12,*IMAGES[UNIT_ALLOCATOR],CONSTANT::ATTACKER_TARGET_COL,CONSTANT::ATTACKER_ATTACK_COL,friendly,true,false){} |
|
|
|
|
|
|
|
|
|
|
|
void MemoryAllocator::Attack(Unit&victim,std::vector<std::shared_ptr<Unit>>&otherUnits){ |
|
|
|
void MemoryAllocator::Attack(Unit&victim,std::vector<std::shared_ptr<Unit>>&otherUnits){ |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
RAMBank::RAMBank(PixelGameEngine*pge,vf2d pos,std::map<Image,std::unique_ptr<Renderable>>&IMAGES,bool friendly) |
|
|
|
RAMBank::RAMBank(PixelGameEngine*pge,vf2d pos,std::map<Image,std::unique_ptr<Renderable>>&IMAGES,bool friendly) |
|
|
|
:Unit({ |
|
|
|
:Unit(pge,{ |
|
|
|
{RANGE,0}, |
|
|
|
{RANGE,0}, |
|
|
|
{ATKSPD,0}, |
|
|
|
{ATKSPD,0}, |
|
|
|
{MOVESPD,0}, |
|
|
|
{MOVESPD,0}, |
|
|
|
{PROCEDURE,25}, |
|
|
|
{PROCEDURE,25}, |
|
|
|
{HEALTH,16}, |
|
|
|
{HEALTH,16}, |
|
|
|
},pos,41,*IMAGES[RAM_BANK],friendly,false |
|
|
|
},pos,41,*IMAGES[RAM_BANK],WHITE,WHITE,friendly,false |
|
|
|
,false,false |
|
|
|
,false,false |
|
|
|
),randomOffset({util::random(128),util::random(128)}),matrixImg(*IMAGES[MATRIX]), |
|
|
|
),randomOffset({util::random(128),util::random(128)}),matrixImg(*IMAGES[MATRIX]), |
|
|
|
originalImg(*IMAGES[RAM_BANK]){ |
|
|
|
originalImg(*IMAGES[RAM_BANK]){ |
|
|
@ -163,7 +166,7 @@ void RAMBank::Attack(Unit&victim,std::vector<std::shared_ptr<Unit>>&otherUnits){ |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void RAMBank::Update(PixelGameEngine*pge){ |
|
|
|
void RAMBank::Update(PixelGameEngine*pge,std::map<Sound,std::unique_ptr<Audio>>&SOUNDS){ |
|
|
|
pge->SetDrawTarget(img.Sprite()); |
|
|
|
pge->SetDrawTarget(img.Sprite()); |
|
|
|
for(int y=0;y<img.Sprite()->height;y++){ |
|
|
|
for(int y=0;y<img.Sprite()->height;y++){ |
|
|
|
for(int x=0;x<img.Sprite()->width;x++){ |
|
|
|
for(int x=0;x<img.Sprite()->width;x++){ |
|
|
@ -173,6 +176,10 @@ void RAMBank::Update(PixelGameEngine*pge){ |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if(!soundStarted){ |
|
|
|
|
|
|
|
soundStarted=true; |
|
|
|
|
|
|
|
soundHandle=SOUNDS[Sound::HUM]->Play(GetPos(),0.4,0.4,true); |
|
|
|
|
|
|
|
} |
|
|
|
img.Decal()->Update(); |
|
|
|
img.Decal()->Update(); |
|
|
|
pge->SetDrawTarget(nullptr); |
|
|
|
pge->SetDrawTarget(nullptr); |
|
|
|
} |
|
|
|
} |
|
|
@ -184,8 +191,12 @@ void RAMBank::Draw(TileTransformedView&game,std::map<Image,std::unique_ptr<Rende |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
Unit::Unit(std::vector<Memory>memory,vf2d pos,float radius,Renderable&img,bool friendly,bool moveable,bool friendlyInteractable,bool enemyInteractable) |
|
|
|
void RAMBank::OnDeath(std::map<Sound,std::unique_ptr<Audio>>&SOUNDS){ |
|
|
|
:pos(pos),radius(radius),ghostPos(pos),img(img),friendly(friendly),moveable(moveable),friendlyInteractable(friendlyInteractable),enemyInteractable(enemyInteractable){ |
|
|
|
SOUNDS[Sound::HUM]->Stop(soundHandle); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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; |
|
|
|
int marker=0; |
|
|
|
for(Memory&mem:memory){ |
|
|
|
for(Memory&mem:memory){ |
|
|
|
for(int i=0;i<mem.size;i++){ |
|
|
|
for(int i=0;i<mem.size;i++){ |
|
|
@ -216,6 +227,9 @@ Unit::Unit(std::vector<Memory>memory,vf2d pos,float radius,Renderable&img,bool f |
|
|
|
} |
|
|
|
} |
|
|
|
marker+=mem.size; |
|
|
|
marker+=mem.size; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
attackingLine.Create(25,24,false,false); |
|
|
|
|
|
|
|
targetingLine.Create(25,24,false,false); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void Unit::DrawRangeIndicator(PixelGameEngine*pge,TileTransformedView&game,std::map<Image,std::unique_ptr<Renderable>>&IMAGES){ |
|
|
|
void Unit::DrawRangeIndicator(PixelGameEngine*pge,TileTransformedView&game,std::map<Image,std::unique_ptr<Renderable>>&IMAGES){ |
|
|
@ -317,6 +331,23 @@ void Unit::DrawHud(TileTransformedView&game,std::map<Image,std::unique_ptr<Rende |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void Unit::DrawUnitDamageStats(PixelGameEngine*pge,TileTransformedView&game,std::map<Image,std::unique_ptr<Renderable>>&IMAGES){ |
|
|
|
void Unit::DrawUnitDamageStats(PixelGameEngine*pge,TileTransformedView&game,std::map<Image,std::unique_ptr<Renderable>>&IMAGES){ |
|
|
|
|
|
|
|
if(!target.expired()){ |
|
|
|
|
|
|
|
geom2d::line<float>lineToTarget(pos,target.lock()->pos); |
|
|
|
|
|
|
|
lineToTarget.start=lineToTarget.rpoint(GetUnitSize().x/2); |
|
|
|
|
|
|
|
lineToTarget.end=lineToTarget.rpoint(lineToTarget.length()-GetUnitSize().x/4); |
|
|
|
|
|
|
|
util::ApplyMatrixEffect(game.GetPGE(),targetingLine,*IMAGES[TARGETING_LINE],IMAGES[MATRIX]); |
|
|
|
|
|
|
|
game.DrawPartialRotatedDecal(lineToTarget.upoint(0.5),targetingLine.Decal(),lineToTarget.vector().polar().y,{lineToTarget.length()/2,12},{lineShift*10,0},{lineToTarget.length(),24},{1,1},targetLineCol); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if(!appliedTarget.expired()){ |
|
|
|
|
|
|
|
geom2d::line<float>lineToTarget(pos,appliedTarget.lock()->pos); |
|
|
|
|
|
|
|
lineToTarget.start=lineToTarget.rpoint(GetUnitSize().x/2); |
|
|
|
|
|
|
|
lineToTarget.end=lineToTarget.rpoint(lineToTarget.length()-GetUnitSize().x/4); |
|
|
|
|
|
|
|
if(reloadTimer>0){ |
|
|
|
|
|
|
|
util::ApplyMatrixEffect(game.GetPGE(),attackingLine,*IMAGES[ATTACKING_LINE],IMAGES[MATRIX]); |
|
|
|
|
|
|
|
float reloadSpd=1.f/(GetAtkSpd()/2.f); |
|
|
|
|
|
|
|
game.DrawPartialRotatedDecal(lineToTarget.upoint(0.5),attackingLine.Decal(),lineToTarget.vector().polar().y,{lineToTarget.length()/2,12},{lineShift*30,0},{lineToTarget.length(),24},{1,1+(reloadTimer/reloadSpd)*0.25f},{attackingLineCol.r,attackingLineCol.g,attackingLineCol.b,uint8_t(IsFriendly()?200:160)}); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
float dist=geom2d::line<float>(game.ScreenToWorld(pge->GetMousePos()),GetGhostPos()).length(); |
|
|
|
float dist=geom2d::line<float>(game.ScreenToWorld(pge->GetMousePos()),GetGhostPos()).length(); |
|
|
|
float range=12*(GetRange()+1); |
|
|
|
float range=12*(GetRange()+1); |
|
|
|
|
|
|
|
|
|
|
@ -325,7 +356,7 @@ void Unit::DrawUnitDamageStats(PixelGameEngine*pge,TileTransformedView&game,std: |
|
|
|
auto DrawStatDown=[&](Marker&maxStat,int currentStat,vf2d pos,vf2d downDisplayPos,Image img,uint8_t transparency=255){ |
|
|
|
auto DrawStatDown=[&](Marker&maxStat,int currentStat,vf2d pos,vf2d downDisplayPos,Image img,uint8_t transparency=255){ |
|
|
|
if(maxStat.size>0){ |
|
|
|
if(maxStat.size>0){ |
|
|
|
if(currentStat!=maxStat.size){ |
|
|
|
if(currentStat!=maxStat.size){ |
|
|
|
game.DrawDecal(this->pos+pos,IMAGES[img]->Decal(),{1,1},{255,255,255,transparency}); |
|
|
|
game.DrawDecal(this->pos+pos,IMAGES[img]->Decal(),{1,1},currentStat==0?Pixel{192,64,64,transparency}:Pixel{255,255,255,transparency}); |
|
|
|
if(currentStat>0){ |
|
|
|
if(currentStat>0){ |
|
|
|
game.DrawDecal(this->pos+downDisplayPos,IMAGES[DOWN_ARROW]->Decal(),{1,1},{255,255,255,transparency}); |
|
|
|
game.DrawDecal(this->pos+downDisplayPos,IMAGES[DOWN_ARROW]->Decal(),{1,1},{255,255,255,transparency}); |
|
|
|
} else { |
|
|
|
} else { |
|
|
@ -337,15 +368,15 @@ void Unit::DrawUnitDamageStats(PixelGameEngine*pge,TileTransformedView&game,std: |
|
|
|
|
|
|
|
|
|
|
|
if(IsSelected()){ |
|
|
|
if(IsSelected()){ |
|
|
|
DrawStatDown(atkSpd,GetAtkSpd(),{-48-8,-24},{-48+8,-18},RLD); |
|
|
|
DrawStatDown(atkSpd,GetAtkSpd(),{-48-8,-24},{-48+8,-18},RLD); |
|
|
|
DrawStatDown(moveSpd,GetMoveSpd(),{-48-8,8},{-48+8,2},SPD); |
|
|
|
DrawStatDown(moveSpd,GetMoveSpd(),{-48-8,8},{-36+8,2},SPD); |
|
|
|
DrawStatDown(this->range,GetRange(),{8,-24},{36,-18},RNG); |
|
|
|
DrawStatDown(this->range,GetRange(),{8,-24},{20,-18},RNG); |
|
|
|
DrawStatDown(procedure,GetProcedure(),{8,8},{36,2},PRC); |
|
|
|
DrawStatDown(procedure,GetProcedure(),{8,8},{26,2},PRC); |
|
|
|
}else |
|
|
|
}else |
|
|
|
if(dist<range*2){ |
|
|
|
if(dist<range*2){ |
|
|
|
uint8_t transparency=uint8_t((1.f-(dist/(range*2)))*255); |
|
|
|
uint8_t transparency=uint8_t((1.f-(dist/(range*2)))*255); |
|
|
|
DrawStatDown(atkSpd,GetAtkSpd(),{-48-8,-24},{-48+8,-18},RLD,transparency); |
|
|
|
DrawStatDown(atkSpd,GetAtkSpd(),{-48-8,-24},{-48+8,-18},RLD,transparency); |
|
|
|
DrawStatDown(moveSpd,GetMoveSpd(),{-48-8,8},{-48+8,2},SPD,transparency); |
|
|
|
DrawStatDown(moveSpd,GetMoveSpd(),{-48-8,8},{-36+8,2},SPD,transparency); |
|
|
|
DrawStatDown(this->range,GetRange(),{8,-24},{26,-18},RNG,transparency); |
|
|
|
DrawStatDown(this->range,GetRange(),{8,-24},{20,-18},RNG,transparency); |
|
|
|
DrawStatDown(procedure,GetProcedure(),{8,8},{26,2},PRC,transparency); |
|
|
|
DrawStatDown(procedure,GetProcedure(),{8,8},{26,2},PRC,transparency); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -360,6 +391,8 @@ int Unit::GetBits(Marker&m){ |
|
|
|
return activeBits; |
|
|
|
return activeBits; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void Unit::OnDeath(std::map<Sound,std::unique_ptr<Audio>>&SOUNDS){} |
|
|
|
|
|
|
|
|
|
|
|
int Unit::GetHealth(){ |
|
|
|
int Unit::GetHealth(){ |
|
|
|
return GetBits(health); |
|
|
|
return GetBits(health); |
|
|
|
} |
|
|
|
} |
|
|
@ -390,7 +423,7 @@ void Unit::_RunAI(PixelGameEngine*pge){ |
|
|
|
RunAI(pge); |
|
|
|
RunAI(pge); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void Unit::_Update(PixelGameEngine*pge){ |
|
|
|
void Unit::_Update(PixelGameEngine*pge,std::map<Sound,std::unique_ptr<Audio>>&SOUNDS){ |
|
|
|
if(!target.expired()){ |
|
|
|
if(!target.expired()){ |
|
|
|
auto ptrTarget=target.lock(); |
|
|
|
auto ptrTarget=target.lock(); |
|
|
|
if(!InRange(ptrTarget)){ |
|
|
|
if(!InRange(ptrTarget)){ |
|
|
@ -413,8 +446,10 @@ void Unit::_Update(PixelGameEngine*pge){ |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
reloadTimer=std::max(0.f,reloadTimer-pge->GetElapsedTime()); |
|
|
|
reloadTimer=std::max(0.f,reloadTimer-pge->GetElapsedTime()); |
|
|
|
|
|
|
|
lineShift-=pge->GetElapsedTime(); |
|
|
|
|
|
|
|
if(lineShift<-25)lineShift+=25; |
|
|
|
|
|
|
|
|
|
|
|
Update(pge); |
|
|
|
Update(pge,SOUNDS); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
std::vector<bool> operator <<(Unit&u,const int n){ |
|
|
|
std::vector<bool> operator <<(Unit&u,const int n){ |
|
|
@ -511,12 +546,13 @@ void Unit::AttemptAttack(std::weak_ptr<Unit>attacker,std::weak_ptr<Unit>unit,std |
|
|
|
} |
|
|
|
} |
|
|
|
if(!finalTarget.expired()){ |
|
|
|
if(!finalTarget.expired()){ |
|
|
|
if(InRange(finalTarget.lock())){ |
|
|
|
if(InRange(finalTarget.lock())){ |
|
|
|
|
|
|
|
appliedTarget=finalTarget; |
|
|
|
_Attack(attacker,finalTarget,otherUnits); //Call the parent function first, followed by the child.
|
|
|
|
_Attack(attacker,finalTarget,otherUnits); //Call the parent function first, followed by the child.
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void Unit::Update(PixelGameEngine*pge){} |
|
|
|
void Unit::Update(PixelGameEngine*pge,std::map<Sound,std::unique_ptr<Audio>>&SOUNDS){} |
|
|
|
|
|
|
|
|
|
|
|
void Unit::Attacked(std::weak_ptr<Unit>attacker){} |
|
|
|
void Unit::Attacked(std::weak_ptr<Unit>attacker){} |
|
|
|
|
|
|
|
|
|
|
@ -574,4 +610,8 @@ Renderable&Unit::GetImage(){ |
|
|
|
|
|
|
|
|
|
|
|
std::weak_ptr<Unit>Unit::GetCurrentTarget(){ |
|
|
|
std::weak_ptr<Unit>Unit::GetCurrentTarget(){ |
|
|
|
return target; |
|
|
|
return target; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool Unit::AutoAcquiresFriendlyTargets(){ |
|
|
|
|
|
|
|
return autoAcquireFriendlyTarget; |
|
|
|
} |
|
|
|
} |