@ -6,11 +6,24 @@
# include "olcPGEX_QuickGUI.h"
# include "olcPGEX_QuickGUI.h"
# include "Textbox.h"
# include "Textbox.h"
Unit : : ~ Unit ( ) { } ;
LeftShifter : : ~ LeftShifter ( ) { } ;
RightShifter : : ~ RightShifter ( ) { } ;
BitRestorer : : ~ BitRestorer ( ) { } ;
MemorySwapper : : ~ MemorySwapper ( ) { } ;
Corrupter : : ~ Corrupter ( ) { } ;
MemoryAllocator : : ~ MemoryAllocator ( ) { } ;
RAMBank : : ~ RAMBank ( ) { } ;
MemoryGuard : : ~ MemoryGuard ( ) { } ;
Refresher : : ~ Refresher ( ) { } ;
Turret : : ~ Turret ( ) { } ;
_Platform : : ~ _Platform ( ) { } ;
std : : string LeftShifter : : unitName = " Left Shifter " ;
std : : string LeftShifter : : unitName = " Left Shifter " ;
std : : string LeftShifter : : unitDescription = " 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 , 6 } , { PROCEDURE , 1 } , { HEALTH , 4 } } ;
std : : vector < Memory > LeftShifter : : resourceCost = { { RANGE , 2 } , { ATKSPD , 2 } , { MOVESPD , 6 } , { PROCEDURE , 1 } , { HEALTH , 4 } } ;
LeftShifter : : LeftShifter ( PixelGameEngine * pge , vf2d pos , std : : map < Image , std : : unique_ptr < Renderable > > & IMAGES , bool friendly , bool moveable )
LeftShifter : : LeftShifter ( PixelGameEngine * pge , vf2d pos , std : : vecto r< 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 ) { }
: 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 ) {
void LeftShifter : : Attack ( Unit & victim , std : : vector < std : : shared_ptr < Unit > > & otherUnits ) {
victim < < = 1 ;
victim < < = 1 ;
@ -19,8 +32,8 @@ void LeftShifter::Attack(Unit&victim,std::vector<std::shared_ptr<Unit>>&otherUni
std : : string RightShifter : : unitName = " Right Shifter " ;
std : : string RightShifter : : unitName = " Right Shifter " ;
std : : string RightShifter : : unitDescription = " 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 , 6 } , { PROCEDURE , 1 } } ;
std : : vector < Memory > RightShifter : : resourceCost = { { HEALTH , 4 } , { RANGE , 2 } , { ATKSPD , 2 } , { MOVESPD , 6 } , { PROCEDURE , 1 } } ;
RightShifter : : RightShifter ( PixelGameEngine * pge , vf2d pos , std : : map < Image , std : : unique_pt r< Renderable > > & IMAGES , bool friendly , bool moveable )
RightShifter : : RightShifter ( PixelGameEngine * pge , vf2d pos , std : : vecto r< 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 ) { }
: 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 ) {
void RightShifter : : Attack ( Unit & victim , std : : vector < std : : shared_ptr < Unit > > & otherUnits ) {
victim > > = 1 ;
victim > > = 1 ;
@ -29,8 +42,8 @@ void RightShifter::Attack(Unit&victim,std::vector<std::shared_ptr<Unit>>&otherUn
std : : string BitRestorer : : unitName = " Bit Restorer " ;
std : : string BitRestorer : : unitName = " Bit Restorer " ;
std : : string BitRestorer : : unitDescription = " Randomly restores 1 missing bit to a target. " ;
std : : string BitRestorer : : unitDescription = " Randomly restores 1 missing bit to a target. " ;
std : : vector < Memory > BitRestorer : : resourceCost = { { PROCEDURE , 6 } , { RANGE , 1 } , { ATKSPD , 1 } , { MOVESPD , 2 } , { HEALTH , 2 } } ;
std : : vector < Memory > BitRestorer : : resourceCost = { { PROCEDURE , 6 } , { RANGE , 1 } , { ATKSPD , 1 } , { MOVESPD , 2 } , { HEALTH , 2 } } ;
BitRestorer : : BitRestorer ( PixelGameEngine * pge , vf2d pos , std : : map < Image , std : : unique_pt r< Renderable > > & IMAGES , bool friendly , bool moveable )
BitRestorer : : BitRestorer ( PixelGameEngine * pge , vf2d pos , std : : vecto r< Renderable > & IMAGES , bool friendly , bool moveable )
: Unit ( pge , 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 ) {
void BitRestorer : : Attack ( Unit & victim , std : : vector < std : : shared_ptr < Unit > > & otherUnits ) {
std : : vector < int > emptyMemoryPositions ;
std : : vector < int > emptyMemoryPositions ;
@ -71,8 +84,8 @@ void BitRestorer::AttemptToHealOtherAllies(std::vector<std::shared_ptr<Unit>>&ot
std : : string MemorySwapper : : unitName = " Memory Swapper " ;
std : : string MemorySwapper : : unitName = " Memory Swapper " ;
std : : string MemorySwapper : : unitDescription = " Flips the orientation of all bits of a target around. " ;
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 , 4 } } ;
std : : vector < Memory > MemorySwapper : : resourceCost = { { RANGE , 3 } , { ATKSPD , 1 } , { HEALTH , 3 } , { PROCEDURE , 3 } , { MOVESPD , 4 } } ;
MemorySwapper : : MemorySwapper ( PixelGameEngine * pge , vf2d pos , std : : map < Image , std : : unique_pt r< Renderable > > & IMAGES , bool friendly , bool moveable )
MemorySwapper : : MemorySwapper ( PixelGameEngine * pge , vf2d pos , std : : vecto r< Renderable > & IMAGES , bool friendly , bool moveable )
: Unit ( pge , 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 ;
autoAcquireFriendlyTarget = false ;
}
}
@ -115,8 +128,8 @@ void MemorySwapper::Attack(Unit&victim,std::vector<std::shared_ptr<Unit>>&otherU
std : : string Corrupter : : unitName = " Corrupter " ;
std : : string Corrupter : : unitName = " Corrupter " ;
std : : string Corrupter : : unitDescription = " Chooses a random bit and negates it on a target. " ;
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 , 8 } , { HEALTH , 4 } } ;
std : : vector < Memory > Corrupter : : resourceCost = { { ATKSPD , 3 } , { RANGE , 1 } , { PROCEDURE , 8 } , { MOVESPD , 8 } , { HEALTH , 4 } } ;
Corrupter : : Corrupter ( PixelGameEngine * pge , vf2d pos , std : : map < Image , std : : unique_pt r< Renderable > > & IMAGES , bool friendly , bool moveable )
Corrupter : : Corrupter ( PixelGameEngine * pge , vf2d pos , std : : vecto r< Renderable > & IMAGES , bool friendly , bool moveable )
: Unit ( pge , 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 ) {
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.
@ -127,8 +140,8 @@ void Corrupter::Attack(Unit&victim,std::vector<std::shared_ptr<Unit>>&otherUnits
std : : string MemoryAllocator : : unitName = " Memory Allocator " ;
std : : string MemoryAllocator : : unitName = " Memory Allocator " ;
std : : string MemoryAllocator : : unitDescription = " A unit that builds other units. " ;
std : : string MemoryAllocator : : unitDescription = " A unit that builds other units. " ;
std : : vector < Memory > MemoryAllocator : : resourceCost = { { RANGE , 1 } , { ATKSPD , 1 } , { MOVESPD , 2 } , { PROCEDURE , 1 } , { HEALTH , 1 } } ;
std : : vector < Memory > MemoryAllocator : : resourceCost = { { RANGE , 1 } , { ATKSPD , 1 } , { MOVESPD , 2 } , { PROCEDURE , 1 } , { HEALTH , 1 } } ;
MemoryAllocator : : MemoryAllocator ( PixelGameEngine * pge , vf2d pos , std : : map < Image , std : : unique_pt r< Renderable > > & IMAGES , bool friendly , bool moveable )
MemoryAllocator : : MemoryAllocator ( PixelGameEngine * pge , vf2d pos , std : : vecto r< Renderable > & IMAGES , bool friendly , bool moveable )
: Unit ( pge , 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 ;
isAllocator = true ;
}
}
@ -150,7 +163,7 @@ void MemoryAllocator::Update(PixelGameEngine*pge,std::map<Sound,std::unique_ptr<
}
}
}
}
void MemoryAllocator : : Draw ( TileTransformedView & game , std : : map < Image , std : : unique_pt r< Renderable > > & IMAGES ) {
void MemoryAllocator : : Draw ( TileTransformedView & game , std : : vecto r< Renderable > & IMAGES ) {
if ( IsBuilding ( ) ) {
if ( IsBuilding ( ) ) {
game . GetPGE ( ) - > SetDrawTarget ( img . Sprite ( ) ) ;
game . GetPGE ( ) - > SetDrawTarget ( img . Sprite ( ) ) ;
game . GetPGE ( ) - > Clear ( BLANK ) ;
game . GetPGE ( ) - > Clear ( BLANK ) ;
@ -159,12 +172,12 @@ void MemoryAllocator::Draw(TileTransformedView&game,std::map<Image,std::unique_p
game . DrawPartialRotatedDecal ( GetGhostPos ( ) , img . Decal ( ) , 0 , img . Sprite ( ) - > Size ( ) / 2 , { 0 , 0 } , { float ( img . Sprite ( ) - > width ) , float ( ( buildTime / CONSTANT : : UNIT_BUILD_TIME ) * img . Sprite ( ) - > height ) } , { 1 , 1 } , GetUnitColor ( ) / 3 ) ;
game . DrawPartialRotatedDecal ( GetGhostPos ( ) , img . Decal ( ) , 0 , img . Sprite ( ) - > Size ( ) / 2 , { 0 , 0 } , { float ( img . Sprite ( ) - > width ) , float ( ( buildTime / CONSTANT : : UNIT_BUILD_TIME ) * img . Sprite ( ) - > height ) } , { 1 , 1 } , GetUnitColor ( ) / 3 ) ;
game . DrawPartialRotatedDecal ( GetGhostPos ( ) + vf2d { 0.f , ( buildTime / CONSTANT : : UNIT_BUILD_TIME ) * buildTransformUnit - > GetImage ( ) . Sprite ( ) - > height } , buildTransformUnit - > GetImage ( ) . Decal ( ) , 0 , buildTransformUnit - > GetImage ( ) . Sprite ( ) - > Size ( ) / 2 , { 0.f , ( buildTime / CONSTANT : : UNIT_BUILD_TIME ) * buildTransformUnit - > GetImage ( ) . Sprite ( ) - > height } , { float ( buildTransformUnit - > GetImage ( ) . Sprite ( ) - > width ) , float ( buildTransformUnit - > GetImage ( ) . Sprite ( ) - > height - ( buildTime / CONSTANT : : UNIT_BUILD_TIME ) * buildTransformUnit - > GetImage ( ) . Sprite ( ) - > height ) } , { 1 , 1 } , GetUnitColor ( ) / 1.5f ) ;
game . DrawPartialRotatedDecal ( GetGhostPos ( ) + vf2d { 0.f , ( buildTime / CONSTANT : : UNIT_BUILD_TIME ) * buildTransformUnit - > GetImage ( ) . Sprite ( ) - > height } , buildTransformUnit - > GetImage ( ) . Decal ( ) , 0 , buildTransformUnit - > GetImage ( ) . Sprite ( ) - > Size ( ) / 2 , { 0.f , ( buildTime / CONSTANT : : UNIT_BUILD_TIME ) * buildTransformUnit - > GetImage ( ) . Sprite ( ) - > height } , { float ( buildTransformUnit - > GetImage ( ) . Sprite ( ) - > width ) , float ( buildTransformUnit - > GetImage ( ) . Sprite ( ) - > height - ( buildTime / CONSTANT : : UNIT_BUILD_TIME ) * buildTransformUnit - > GetImage ( ) . Sprite ( ) - > height ) } , { 1 , 1 } , GetUnitColor ( ) / 1.5f ) ;
if ( fmod ( buildTime , 1 ) > 0.5 ) {
if ( fmod ( buildTime , 1 ) > 0.5 ) {
game . DrawRotatedDecal ( GetGhostPos ( ) , IMAGES [ SELECTION_CIRCLE ] - > Decal ( ) , 0 , IMAGES [ SELECTION_CIRCLE ] - > Sprite ( ) - > Size ( ) / 2 , vf2d ( img . Sprite ( ) - > Size ( ) ) / IMAGES [ SELECTION_CIRCLE ] - > Sprite ( ) - > Size ( ) , { 0 , 202 , 217 } ) ;
game . DrawRotatedDecal ( GetGhostPos ( ) , IMAGES [ SELECTION_CIRCLE ] . Decal ( ) , 0 , IMAGES [ SELECTION_CIRCLE ] . Sprite ( ) - > Size ( ) / 2 , vf2d ( img . Sprite ( ) - > Size ( ) ) / IMAGES [ SELECTION_CIRCLE ] . Sprite ( ) - > Size ( ) , { 0 , 202 , 217 } ) ;
}
}
} else {
} else {
game . DrawRotatedDecal ( GetGhostPos ( ) , img . Decal ( ) , 0 , img . Sprite ( ) - > Size ( ) / 2 , { 1 , 1 } , GetUnitColor ( ) ) ;
game . DrawRotatedDecal ( GetGhostPos ( ) , img . Decal ( ) , 0 , img . Sprite ( ) - > Size ( ) / 2 , { 1 , 1 } , GetUnitColor ( ) ) ;
if ( IsSelected ( ) ) {
if ( IsSelected ( ) ) {
game . DrawRotatedDecal ( GetGhostPos ( ) , IMAGES [ SELECTION_CIRCLE ] - > Decal ( ) , 0 , IMAGES [ SELECTION_CIRCLE ] - > Sprite ( ) - > Size ( ) / 2 , vf2d ( img . Sprite ( ) - > Size ( ) ) / IMAGES [ SELECTION_CIRCLE ] - > Sprite ( ) - > Size ( ) , WHITE ) ;
game . DrawRotatedDecal ( GetGhostPos ( ) , IMAGES [ SELECTION_CIRCLE ] . Decal ( ) , 0 , IMAGES [ SELECTION_CIRCLE ] . Sprite ( ) - > Size ( ) / 2 , vf2d ( img . Sprite ( ) - > Size ( ) ) / IMAGES [ SELECTION_CIRCLE ] . Sprite ( ) - > Size ( ) , WHITE ) ;
}
}
}
}
}
}
@ -172,15 +185,15 @@ void MemoryAllocator::Draw(TileTransformedView&game,std::map<Image,std::unique_p
std : : string RAMBank : : unitName = " RAM Bank " ;
std : : string RAMBank : : unitName = " RAM Bank " ;
std : : string RAMBank : : unitDescription = " Allows for the construction of Memory Allocators. " ;
std : : string RAMBank : : unitDescription = " Allows for the construction of Memory Allocators. " ;
std : : vector < Memory > RAMBank : : resourceCost = { { PROCEDURE , 25 } , { HEALTH , 16 } } ;
std : : vector < Memory > RAMBank : : resourceCost = { { PROCEDURE , 25 } , { HEALTH , 16 } } ;
RAMBank : : RAMBank ( PixelGameEngine * pge , vf2d pos , std : : map < Image , std : : unique_pt r< Renderable > > & IMAGES , bool friendly )
RAMBank : : RAMBank ( PixelGameEngine * pge , vf2d pos , std : : vecto r< Renderable > & IMAGES , bool friendly )
: Unit ( pge , 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
, 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 ] ) {
img . Create ( IMAGES [ RAM_BANK ] - > Sprite ( ) - > width , IMAGES [ RAM_BANK ] - > Sprite ( ) - > height ) ;
img . Create ( IMAGES [ RAM_BANK ] . Sprite ( ) - > width , IMAGES [ RAM_BANK ] . Sprite ( ) - > height ) ;
pge - > SetDrawTarget ( img . Sprite ( ) ) ;
pge - > SetDrawTarget ( img . Sprite ( ) ) ;
pge - > Clear ( BLANK ) ;
pge - > Clear ( BLANK ) ;
pge - > DrawSprite ( { 0 , 0 } , IMAGES [ RAM_BANK ] - > Sprite ( ) ) ;
pge - > DrawSprite ( { 0 , 0 } , IMAGES [ RAM_BANK ] . Sprite ( ) ) ;
pge - > SetDrawTarget ( nullptr ) ;
pge - > SetDrawTarget ( nullptr ) ;
allocatorManager . colNormal = olc : : VERY_DARK_GREEN ;
allocatorManager . colNormal = olc : : VERY_DARK_GREEN ;
allocatorManager . colHover = olc : : GREEN ;
allocatorManager . colHover = olc : : GREEN ;
@ -188,7 +201,7 @@ RAMBank::RAMBank(PixelGameEngine*pge,vf2d pos,std::map<Image,std::unique_ptr<Ren
allocatorManager . colDisable = olc : : DARK_GREY ;
allocatorManager . colDisable = olc : : DARK_GREY ;
allocatorManager . colBorder = olc : : YELLOW ;
allocatorManager . colBorder = olc : : YELLOW ;
allocatorManager . colText = olc : : WHITE ;
allocatorManager . colText = olc : : WHITE ;
allocatorButton = new QuickGUI : : ImageButton ( allocatorManager , * IMAGES [ UNIT_ALLOCATOR ] , { 0.5f , 0.5f } , pos - vf2d { 8 , 48 } , { 20 , 20 } ) ;
allocatorButton = new QuickGUI : : ImageButton ( allocatorManager , IMAGES [ UNIT_ALLOCATOR ] , { 0.5f , 0.5f } , pos - vf2d { 8 , 48 } , { 20 , 20 } ) ;
}
}
void RAMBank : : Attack ( Unit & victim , std : : vector < std : : shared_ptr < Unit > > & otherUnits ) {
void RAMBank : : Attack ( Unit & victim , std : : vector < std : : shared_ptr < Unit > > & otherUnits ) {
@ -213,16 +226,16 @@ void RAMBank::Update(PixelGameEngine*pge,std::map<Sound,std::unique_ptr<Audio>>&
pge - > SetDrawTarget ( nullptr ) ;
pge - > SetDrawTarget ( nullptr ) ;
}
}
void RAMBank : : DrawHud ( TileTransformedView & game , std : : map < Image , std : : unique_pt r< Renderable > > & IMAGES ) {
void RAMBank : : DrawHud ( TileTransformedView & game , std : : vecto r< Renderable > & IMAGES ) {
if ( IsSelected ( ) ) {
if ( IsSelected ( ) ) {
allocatorManager . DrawDecal ( game ) ;
allocatorManager . DrawDecal ( game ) ;
}
}
}
}
void RAMBank : : Draw ( TileTransformedView & game , std : : map < Image , std : : unique_pt r< Renderable > > & IMAGES ) {
void RAMBank : : Draw ( TileTransformedView & game , std : : vecto r< Renderable > & IMAGES ) {
game . DrawRotatedDecal ( GetGhostPos ( ) , img . Decal ( ) , 0 , img . Sprite ( ) - > Size ( ) / 2 , { 1 , 1 } , GetUnitColor ( ) ) ;
game . DrawRotatedDecal ( GetGhostPos ( ) , img . Decal ( ) , 0 , img . Sprite ( ) - > Size ( ) / 2 , { 1 , 1 } , GetUnitColor ( ) ) ;
if ( IsSelected ( ) ) {
if ( IsSelected ( ) ) {
game . DrawRotatedDecal ( GetGhostPos ( ) , IMAGES [ SELECTION_CIRCLE ] - > Decal ( ) , 0 , IMAGES [ SELECTION_CIRCLE ] - > Sprite ( ) - > Size ( ) / 2 , vf2d ( img . Sprite ( ) - > Size ( ) ) / IMAGES [ SELECTION_CIRCLE ] - > Sprite ( ) - > Size ( ) , WHITE ) ;
game . DrawRotatedDecal ( GetGhostPos ( ) , IMAGES [ SELECTION_CIRCLE ] . Decal ( ) , 0 , IMAGES [ SELECTION_CIRCLE ] . Sprite ( ) - > Size ( ) / 2 , vf2d ( img . Sprite ( ) - > Size ( ) ) / IMAGES [ SELECTION_CIRCLE ] . Sprite ( ) - > Size ( ) , WHITE ) ;
}
}
}
}
@ -248,7 +261,7 @@ void RAMBank::UpdateGUIState(TileTransformedView&game,Resources&player_resources
allocatorButton - > Enable ( buttonEnabled ) ;
allocatorButton - > Enable ( buttonEnabled ) ;
}
}
bool RAMBank : : ClickHandled ( TileTransformedView & game , Resources & player_resources , std : : vector < std : : shared_ptr < Unit > > & units , std : : map < Image , std : : unique_pt r< Renderable > > & IMAGES ) {
bool RAMBank : : ClickHandled ( TileTransformedView & game , Resources & player_resources , std : : vector < std : : shared_ptr < Unit > > & units , std : : vecto r< Renderable > & IMAGES ) {
if ( allocatorButton - > bPressed ) {
if ( allocatorButton - > bPressed ) {
//First try to take one of each.
//First try to take one of each.
if ( player_resources . atkSpd > 0 & & player_resources . health > 0 & & player_resources . moveSpd > 0 & & player_resources . procedure > 0 & & player_resources . range > 0 ) {
if ( player_resources . atkSpd > 0 & & player_resources . health > 0 & & player_resources . moveSpd > 0 & & player_resources . procedure > 0 & & player_resources . range > 0 ) {
@ -285,8 +298,8 @@ bool RAMBank::ClickHandled(TileTransformedView&game,Resources&player_resources,s
std : : string _Platform : : unitName = " Platform " ;
std : : string _Platform : : unitName = " Platform " ;
std : : string _Platform : : unitDescription = " Anchored to the ground, this unit is an intermediate step for larger units. " ;
std : : string _Platform : : unitDescription = " Anchored to the ground, this unit is an intermediate step for larger units. " ;
std : : vector < Memory > _Platform : : resourceCost = { { HEALTH , 6 } } ;
std : : vector < Memory > _Platform : : resourceCost = { { HEALTH , 6 } } ;
_Platform : : _Platform ( PixelGameEngine * pge , vf2d pos , std : : map < Image , std : : unique_pt r< Renderable > > & IMAGES , bool friendly , bool moveable )
_Platform : : _Platform ( PixelGameEngine * pge , vf2d pos , std : : vecto r< Renderable > & IMAGES , bool friendly , bool moveable )
: Unit ( pge , _Platform : : resourceCost , pos , 24 , * IMAGES [ PLATFORM ] , CONSTANT : : ATTACKER_TARGET_COL , CONSTANT : : ATTACKER_ATTACK_COL , friendly , false ) {
: Unit ( pge , _Platform : : resourceCost , pos , 24 , IMAGES [ PLATFORM ] , CONSTANT : : ATTACKER_TARGET_COL , CONSTANT : : ATTACKER_ATTACK_COL , friendly , false ) {
isPlatform = true ;
isPlatform = true ;
}
}
@ -306,7 +319,7 @@ void _Platform::Update(PixelGameEngine*pge,std::map<Sound,std::unique_ptr<Audio>
}
}
}
}
void _Platform : : Draw ( TileTransformedView & game , std : : map < Image , std : : unique_pt r< Renderable > > & IMAGES ) {
void _Platform : : Draw ( TileTransformedView & game , std : : vecto r< Renderable > & IMAGES ) {
if ( IsBuilding ( ) ) {
if ( IsBuilding ( ) ) {
game . GetPGE ( ) - > SetDrawTarget ( img . Sprite ( ) ) ;
game . GetPGE ( ) - > SetDrawTarget ( img . Sprite ( ) ) ;
game . GetPGE ( ) - > Clear ( BLANK ) ;
game . GetPGE ( ) - > Clear ( BLANK ) ;
@ -315,12 +328,12 @@ void _Platform::Draw(TileTransformedView&game,std::map<Image,std::unique_ptr<Ren
game . DrawPartialRotatedDecal ( GetGhostPos ( ) , img . Decal ( ) , 0 , img . Sprite ( ) - > Size ( ) / 2 , { 0 , 0 } , { float ( img . Sprite ( ) - > width ) , float ( ( buildTime / CONSTANT : : UNIT_BUILD_TIME ) * img . Sprite ( ) - > height ) } , { 1 , 1 } , GetUnitColor ( ) / 3 ) ;
game . DrawPartialRotatedDecal ( GetGhostPos ( ) , img . Decal ( ) , 0 , img . Sprite ( ) - > Size ( ) / 2 , { 0 , 0 } , { float ( img . Sprite ( ) - > width ) , float ( ( buildTime / CONSTANT : : UNIT_BUILD_TIME ) * img . Sprite ( ) - > height ) } , { 1 , 1 } , GetUnitColor ( ) / 3 ) ;
game . DrawPartialRotatedDecal ( GetGhostPos ( ) + vf2d { 0.f , ( buildTime / CONSTANT : : UNIT_BUILD_TIME ) * buildTransformUnit - > GetImage ( ) . Sprite ( ) - > height } , buildTransformUnit - > GetImage ( ) . Decal ( ) , 0 , buildTransformUnit - > GetImage ( ) . Sprite ( ) - > Size ( ) / 2 , { 0.f , ( buildTime / CONSTANT : : UNIT_BUILD_TIME ) * buildTransformUnit - > GetImage ( ) . Sprite ( ) - > height } , { float ( buildTransformUnit - > GetImage ( ) . Sprite ( ) - > width ) , float ( buildTransformUnit - > GetImage ( ) . Sprite ( ) - > height - ( buildTime / CONSTANT : : UNIT_BUILD_TIME ) * buildTransformUnit - > GetImage ( ) . Sprite ( ) - > height ) } , { 1 , 1 } , GetUnitColor ( ) / 1.5f ) ;
game . DrawPartialRotatedDecal ( GetGhostPos ( ) + vf2d { 0.f , ( buildTime / CONSTANT : : UNIT_BUILD_TIME ) * buildTransformUnit - > GetImage ( ) . Sprite ( ) - > height } , buildTransformUnit - > GetImage ( ) . Decal ( ) , 0 , buildTransformUnit - > GetImage ( ) . Sprite ( ) - > Size ( ) / 2 , { 0.f , ( buildTime / CONSTANT : : UNIT_BUILD_TIME ) * buildTransformUnit - > GetImage ( ) . Sprite ( ) - > height } , { float ( buildTransformUnit - > GetImage ( ) . Sprite ( ) - > width ) , float ( buildTransformUnit - > GetImage ( ) . Sprite ( ) - > height - ( buildTime / CONSTANT : : UNIT_BUILD_TIME ) * buildTransformUnit - > GetImage ( ) . Sprite ( ) - > height ) } , { 1 , 1 } , GetUnitColor ( ) / 1.5f ) ;
if ( fmod ( buildTime , 1 ) > 0.5 ) {
if ( fmod ( buildTime , 1 ) > 0.5 ) {
game . DrawRotatedDecal ( GetGhostPos ( ) , IMAGES [ SELECTION_CIRCLE ] - > Decal ( ) , 0 , IMAGES [ SELECTION_CIRCLE ] - > Sprite ( ) - > Size ( ) / 2 , vf2d ( img . Sprite ( ) - > Size ( ) ) / IMAGES [ SELECTION_CIRCLE ] - > Sprite ( ) - > Size ( ) , { 0 , 202 , 217 } ) ;
game . DrawRotatedDecal ( GetGhostPos ( ) , IMAGES [ SELECTION_CIRCLE ] . Decal ( ) , 0 , IMAGES [ SELECTION_CIRCLE ] . Sprite ( ) - > Size ( ) / 2 , vf2d ( img . Sprite ( ) - > Size ( ) ) / IMAGES [ SELECTION_CIRCLE ] . Sprite ( ) - > Size ( ) , { 0 , 202 , 217 } ) ;
}
}
} else {
} else {
game . DrawRotatedDecal ( GetGhostPos ( ) , img . Decal ( ) , 0 , img . Sprite ( ) - > Size ( ) / 2 , { 1 , 1 } , GetUnitColor ( ) ) ;
game . DrawRotatedDecal ( GetGhostPos ( ) , img . Decal ( ) , 0 , img . Sprite ( ) - > Size ( ) / 2 , { 1 , 1 } , GetUnitColor ( ) ) ;
if ( IsSelected ( ) ) {
if ( IsSelected ( ) ) {
game . DrawRotatedDecal ( GetGhostPos ( ) , IMAGES [ SELECTION_CIRCLE ] - > Decal ( ) , 0 , IMAGES [ SELECTION_CIRCLE ] - > Sprite ( ) - > Size ( ) / 2 , vf2d ( img . Sprite ( ) - > Size ( ) ) / IMAGES [ SELECTION_CIRCLE ] - > Sprite ( ) - > Size ( ) , WHITE ) ;
game . DrawRotatedDecal ( GetGhostPos ( ) , IMAGES [ SELECTION_CIRCLE ] . Decal ( ) , 0 , IMAGES [ SELECTION_CIRCLE ] . Sprite ( ) - > Size ( ) / 2 , vf2d ( img . Sprite ( ) - > Size ( ) ) / IMAGES [ SELECTION_CIRCLE ] . Sprite ( ) - > Size ( ) , WHITE ) ;
}
}
}
}
}
}
@ -328,8 +341,8 @@ void _Platform::Draw(TileTransformedView&game,std::map<Image,std::unique_ptr<Ren
std : : string Refresher : : unitName = " Refresher " ;
std : : string Refresher : : unitName = " Refresher " ;
std : : string Refresher : : unitDescription = " Repairs missing bits to surrounding units. " ;
std : : string Refresher : : unitDescription = " Repairs missing bits to surrounding units. " ;
std : : vector < Memory > Refresher : : resourceCost = { { ATKSPD , 3 } , { RANGE , 1 } , { PROCEDURE , 8 } , { HEALTH , 4 } } ;
std : : vector < Memory > Refresher : : resourceCost = { { ATKSPD , 3 } , { RANGE , 1 } , { PROCEDURE , 8 } , { HEALTH , 4 } } ;
Refresher : : Refresher ( PixelGameEngine * pge , vf2d pos , std : : map < Image , std : : unique_pt r< Renderable > > & IMAGES , bool friendly , bool moveable )
Refresher : : Refresher ( PixelGameEngine * pge , vf2d pos , std : : vecto r< Renderable > & IMAGES , bool friendly , bool moveable )
: Unit ( pge , Refresher : : resourceCost , pos , 24 , * IMAGES [ REFRESHER ] , CONSTANT : : ATTACKER_TARGET_COL , CONSTANT : : ATTACKER_ATTACK_COL , friendly , false
: Unit ( pge , Refresher : : resourceCost , pos , 24 , IMAGES [ REFRESHER ] , CONSTANT : : ATTACKER_TARGET_COL , CONSTANT : : ATTACKER_ATTACK_COL , friendly , false
, true , false ) { }
, true , false ) { }
void Refresher : : Attack ( Unit & victim , std : : vector < std : : shared_ptr < Unit > > & otherUnits ) {
void Refresher : : Attack ( Unit & victim , std : : vector < std : : shared_ptr < Unit > > & otherUnits ) {
@ -353,8 +366,8 @@ void Refresher::Attack(Unit&victim,std::vector<std::shared_ptr<Unit>>&otherUnits
std : : string Turret : : unitName = " Turret " ;
std : : string Turret : : unitName = " Turret " ;
std : : string Turret : : unitDescription = " Automatically targets attack and movement speed memory ranges before others. " ;
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 } } ;
std : : vector < Memory > Turret : : resourceCost = { { ATKSPD , 4 } , { RANGE , 5 } , { HEALTH , 6 } , { PROCEDURE , 16 } } ;
Turret : : Turret ( PixelGameEngine * pge , vf2d pos , std : : map < Image , std : : unique_pt r< Renderable > > & IMAGES , bool friendly , bool moveable )
Turret : : Turret ( PixelGameEngine * pge , vf2d pos , std : : vecto r< Renderable > & IMAGES , bool friendly , bool moveable )
: Unit ( pge , Turret : : resourceCost , pos , 24 , * IMAGES [ TURRET ] , CONSTANT : : ATTACKER_TARGET_COL , CONSTANT : : ATTACKER_ATTACK_COL , friendly , false ) { }
: Unit ( pge , Turret : : resourceCost , pos , 24 , IMAGES [ TURRET ] , CONSTANT : : ATTACKER_TARGET_COL , CONSTANT : : ATTACKER_ATTACK_COL , friendly , false ) { }
void Turret : : Attack ( Unit & victim , std : : vector < std : : shared_ptr < Unit > > & otherUnits ) {
void Turret : : Attack ( Unit & victim , std : : vector < std : : shared_ptr < Unit > > & otherUnits ) {
if ( victim . GetMoveSpd ( ) > 0 ) {
if ( victim . GetMoveSpd ( ) > 0 ) {
@ -388,8 +401,8 @@ void Turret::Attack(Unit&victim,std::vector<std::shared_ptr<Unit>>&otherUnits){
std : : string MemoryGuard : : unitName = " Memory Guard " ;
std : : string MemoryGuard : : unitName = " Memory Guard " ;
std : : string MemoryGuard : : unitDescription = " Reduces the chance of bit modification for all surrounding units by 30% " ;
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 } } ;
std : : vector < Memory > MemoryGuard : : resourceCost = { { HEALTH , 10 } , { ATKSPD , 4 } , { RANGE , 4 } , { PROCEDURE , 12 } } ;
MemoryGuard : : MemoryGuard ( PixelGameEngine * pge , vf2d pos , std : : map < Image , std : : unique_pt r< Renderable > > & IMAGES , bool friendly , bool moveable )
MemoryGuard : : MemoryGuard ( PixelGameEngine * pge , vf2d pos , std : : vecto r< 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
: Unit ( pge , MemoryGuard : : resourceCost , pos , 24 , IMAGES [ MEMORY_GUARD ] , CONSTANT : : ATTACKER_TARGET_COL , CONSTANT : : ATTACKER_ATTACK_COL , friendly , false
, true , false ) { }
, true , false ) { }
void MemoryGuard : : Attack ( Unit & victim , std : : vector < std : : shared_ptr < Unit > > & otherUnits ) {
void MemoryGuard : : Attack ( Unit & victim , std : : vector < std : : shared_ptr < Unit > > & otherUnits ) {
@ -438,7 +451,7 @@ Unit::Unit(PixelGameEngine*pge,std::vector<Memory>memory,vf2d pos,float radius,R
targetingLine . Create ( 25 , 24 , false , false ) ;
targetingLine . Create ( 25 , 24 , false , false ) ;
}
}
void Unit : : DrawRangeIndicator ( PixelGameEngine * pge , TileTransformedView & game , std : : map < Image , std : : unique_pt r< Renderable > > & IMAGES ) {
void Unit : : DrawRangeIndicator ( PixelGameEngine * pge , TileTransformedView & game , std : : vecto r< Renderable > & IMAGES ) {
if ( ! CanInteractWithAllies ( ) & & ! CanInteractWithEnemies ( ) ) return ;
if ( ! CanInteractWithAllies ( ) & & ! CanInteractWithEnemies ( ) ) return ;
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 ) ;
@ -451,7 +464,7 @@ void Unit::DrawRangeIndicator(PixelGameEngine*pge,TileTransformedView&game,std::
} else {
} else {
col = { 0 , 196 , 0 } ;
col = { 0 , 196 , 0 } ;
}
}
game . DrawRotatedDecal ( GetGhostPos ( ) , IMAGES [ RANGE_INDICATOR ] - > Decal ( ) , 0 , IMAGES [ RANGE_INDICATOR ] - > Sprite ( ) - > Size ( ) / 2 , { totalRange / 12 , totalRange / 12 } , col ) ;
game . DrawRotatedDecal ( GetGhostPos ( ) , IMAGES [ RANGE_INDICATOR ] . Decal ( ) , 0 , IMAGES [ RANGE_INDICATOR ] . Sprite ( ) - > Size ( ) / 2 , { totalRange / 12 , totalRange / 12 } , col ) ;
} else
} else
if ( dist < range * 2 ) {
if ( dist < range * 2 ) {
@ -470,20 +483,20 @@ void Unit::DrawRangeIndicator(PixelGameEngine*pge,TileTransformedView&game,std::
}
}
}
}
uint8_t transparency = uint8_t ( ( 1.f - ( dist / ( range * 2 ) ) ) * 255 ) ;
uint8_t transparency = uint8_t ( ( 1.f - ( dist / ( range * 2 ) ) ) * 255 ) ;
game . DrawRotatedDecal ( GetGhostPos ( ) , IMAGES [ RANGE_INDICATOR ] - > Decal ( ) , 0 , IMAGES [ RANGE_INDICATOR ] - > Sprite ( ) - > Size ( ) / 2 , { totalRange / 12 , totalRange / 12 } , { col . r , col . g , col . b , transparency } ) ;
game . DrawRotatedDecal ( GetGhostPos ( ) , IMAGES [ RANGE_INDICATOR ] . Decal ( ) , 0 , IMAGES [ RANGE_INDICATOR ] . Sprite ( ) - > Size ( ) / 2 , { totalRange / 12 , totalRange / 12 } , { col . r , col . g , col . b , transparency } ) ;
}
}
}
}
void Unit : : Draw ( TileTransformedView & game , std : : map < Image , std : : unique_pt r< Renderable > > & IMAGES ) {
void Unit : : Draw ( TileTransformedView & game , std : : vecto r< Renderable > & IMAGES ) {
game . DrawRotatedDecal ( GetGhostPos ( ) , img . Decal ( ) , 0 , img . Sprite ( ) - > Size ( ) / 2 , { 1 , 1 } , GetUnitColor ( ) ) ;
game . DrawRotatedDecal ( GetGhostPos ( ) , img . Decal ( ) , 0 , img . Sprite ( ) - > Size ( ) / 2 , { 1 , 1 } , GetUnitColor ( ) ) ;
if ( IsSelected ( ) ) {
if ( IsSelected ( ) ) {
game . DrawRotatedDecal ( GetGhostPos ( ) , IMAGES [ SELECTION_CIRCLE ] - > Decal ( ) , 0 , IMAGES [ SELECTION_CIRCLE ] - > Sprite ( ) - > Size ( ) / 2 , vf2d ( img . Sprite ( ) - > Size ( ) ) / IMAGES [ SELECTION_CIRCLE ] - > Sprite ( ) - > Size ( ) , WHITE ) ;
game . DrawRotatedDecal ( GetGhostPos ( ) , IMAGES [ SELECTION_CIRCLE ] . Decal ( ) , 0 , IMAGES [ SELECTION_CIRCLE ] . Sprite ( ) - > Size ( ) / 2 , vf2d ( img . Sprite ( ) - > Size ( ) ) / IMAGES [ SELECTION_CIRCLE ] . Sprite ( ) - > Size ( ) , WHITE ) ;
}
}
}
}
void Unit : : DrawHud ( TileTransformedView & game , std : : map < Image , std : : unique_pt r< Renderable > > & IMAGES ) { }
void Unit : : DrawHud ( TileTransformedView & game , std : : vecto r< Renderable > & IMAGES ) { }
void Unit : : _DrawHud ( TileTransformedView & game , std : : map < Image , std : : unique_pt r< Renderable > > & IMAGES ) {
void Unit : : _DrawHud ( TileTransformedView & game , std : : vecto r< Renderable > & IMAGES ) {
DrawHud ( game , IMAGES ) ;
DrawHud ( game , IMAGES ) ;
int initialBarX = ghostPos . x - GetMemorySize ( ) / 2 * CONSTANT : : BAR_SQUARE_SIZE . x - CONSTANT : : BAR_SQUARE_SIZE . x / 2 ;
int initialBarX = ghostPos . x - GetMemorySize ( ) / 2 * CONSTANT : : BAR_SQUARE_SIZE . x - CONSTANT : : BAR_SQUARE_SIZE . x / 2 ;
int initialBarY = ghostPos . y - CONSTANT : : BAR_SQUARE_SIZE . y - img . Sprite ( ) - > height / 2 - 2 ;
int initialBarY = ghostPos . y - CONSTANT : : BAR_SQUARE_SIZE . y - img . Sprite ( ) - > height / 2 - 2 ;
@ -539,19 +552,19 @@ void Unit::_DrawHud(TileTransformedView&game,std::map<Image,std::unique_ptr<Rend
}
}
}
}
void Unit : : DrawUnitDamageStats ( PixelGameEngine * pge , TileTransformedView & game , std : : map < Image , std : : unique_pt r< Renderable > > & IMAGES ) {
void Unit : : DrawUnitDamageStats ( PixelGameEngine * pge , TileTransformedView & game , std : : vecto r< Renderable > & IMAGES ) {
if ( ! target . expired ( ) ) {
if ( ! target . expired ( ) ) {
geom2d : : line < float > lineToTarget ( pos , target . lock ( ) - > pos ) ;
geom2d : : line < float > lineToTarget ( pos , target . lock ( ) - > pos ) ;
lineToTarget . start = lineToTarget . rpoint ( GetUnitSize ( ) . x / 2 ) ;
lineToTarget . start = lineToTarget . rpoint ( GetUnitSize ( ) . x / 2 ) ;
lineToTarget . end = lineToTarget . rpoint ( lineToTarget . length ( ) - GetUnitSize ( ) . x / 4 ) ;
lineToTarget . end = lineToTarget . rpoint ( lineToTarget . length ( ) - GetUnitSize ( ) . x / 4 ) ;
util : : ApplyMatrixEffect ( game . GetPGE ( ) , targetingLine , * IMAGES [ TARGETING_LINE ] , IMAGES [ MATRIX ] ) ;
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 ) ;
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 ) ;
} else
} else
if ( targetLoc ! = CONSTANT : : UNSELECTED ) {
if ( targetLoc ! = CONSTANT : : UNSELECTED ) {
geom2d : : line < float > lineToTarget ( pos , targetLoc ) ;
geom2d : : line < float > lineToTarget ( pos , targetLoc ) ;
lineToTarget . start = lineToTarget . rpoint ( GetUnitSize ( ) . x / 2 ) ;
lineToTarget . start = lineToTarget . rpoint ( GetUnitSize ( ) . x / 2 ) ;
lineToTarget . end = lineToTarget . rpoint ( lineToTarget . length ( ) - GetUnitSize ( ) . x / 4 ) ;
lineToTarget . end = lineToTarget . rpoint ( lineToTarget . length ( ) - GetUnitSize ( ) . x / 4 ) ;
util : : ApplyMatrixEffect ( game . GetPGE ( ) , targetingLine , * IMAGES [ TARGETING_LINE ] , IMAGES [ MATRIX ] ) ;
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 , 0.6 } , CONSTANT : : MOVE_LINE_COL ) ;
game . DrawPartialRotatedDecal ( lineToTarget . upoint ( 0.5 ) , targetingLine . Decal ( ) , lineToTarget . vector ( ) . polar ( ) . y , { lineToTarget . length ( ) / 2 , 12 } , { lineShift * 10 , 0 } , { lineToTarget . length ( ) , 24 } , { 1 , 0.6 } , CONSTANT : : MOVE_LINE_COL ) ;
}
}
if ( ! appliedTarget . expired ( ) ) {
if ( ! appliedTarget . expired ( ) ) {
@ -559,7 +572,7 @@ void Unit::DrawUnitDamageStats(PixelGameEngine*pge,TileTransformedView&game,std:
lineToTarget . start = lineToTarget . rpoint ( GetUnitSize ( ) . x / 2 ) ;
lineToTarget . start = lineToTarget . rpoint ( GetUnitSize ( ) . x / 2 ) ;
lineToTarget . end = lineToTarget . rpoint ( lineToTarget . length ( ) - GetUnitSize ( ) . x / 4 ) ;
lineToTarget . end = lineToTarget . rpoint ( lineToTarget . length ( ) - GetUnitSize ( ) . x / 4 ) ;
if ( reloadTimer > 0 ) {
if ( reloadTimer > 0 ) {
util : : ApplyMatrixEffect ( game . GetPGE ( ) , attackingLine , * IMAGES [ ATTACKING_LINE ] , IMAGES [ MATRIX ] ) ;
util : : ApplyMatrixEffect ( game . GetPGE ( ) , attackingLine , IMAGES [ ATTACKING_LINE ] , IMAGES [ MATRIX ] ) ;
float reloadSpd = 1.f / ( GetAtkSpd ( ) / 2.f ) ;
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 + ( attackFailed ? - 0.3f : ( reloadTimer / reloadSpd ) * 0.25f ) } , attackFailed ? Pixel { 192 , 192 , 192 , 130 } : Pixel { attackingLineCol . r , attackingLineCol . g , attackingLineCol . b , uint8_t ( IsFriendly ( ) ? 200 : 160 ) } ) ;
game . DrawPartialRotatedDecal ( lineToTarget . upoint ( 0.5 ) , attackingLine . Decal ( ) , lineToTarget . vector ( ) . polar ( ) . y , { lineToTarget . length ( ) / 2 , 12 } , { lineShift * 30 , 0 } , { lineToTarget . length ( ) , 24 } , { 1 , 1 + ( attackFailed ? - 0.3f : ( reloadTimer / reloadSpd ) * 0.25f ) } , attackFailed ? Pixel { 192 , 192 , 192 , 130 } : Pixel { attackingLineCol . r , attackingLineCol . g , attackingLineCol . b , uint8_t ( IsFriendly ( ) ? 200 : 160 ) } ) ;
}
}
@ -572,11 +585,11 @@ 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 } , currentStat = = 0 ? Pixel { 192 , 64 , 64 , transparency } : Pixel { 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 {
game . DrawDecal ( this - > pos + downDisplayPos , IMAGES [ RED_X ] - > Decal ( ) , { 1 , 1 } , { 255 , 255 , 255 , transparency } ) ;
game . DrawDecal ( this - > pos + downDisplayPos , IMAGES [ RED_X ] . Decal ( ) , { 1 , 1 } , { 255 , 255 , 255 , transparency } ) ;
}
}
}
}
}
}
@ -639,7 +652,7 @@ void Unit::_RunAI(PixelGameEngine*pge){
RunAI ( 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 , std : : array < float , 5 > & resourceGainTimer , std : : vector < ResourceGainIcon > & resourceGainIcons , std : : map < Image , std : : unique_pt r< Renderable > > & IMAGES ) {
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 , std : : vector < ResourceGainIcon > & resourceGainIcons , std : : vecto r< Renderable > & IMAGES ) {
if ( ! target . expired ( ) ) {
if ( ! target . expired ( ) ) {
auto ptrTarget = target . lock ( ) ;
auto ptrTarget = target . lock ( ) ;
if ( ! InRange ( ptrTarget ) & & CanMove ( ) ) {
if ( ! InRange ( ptrTarget ) & & CanMove ( ) ) {
@ -684,7 +697,7 @@ void Unit::_Update(PixelGameEngine*pge,std::map<Sound,std::unique_ptr<Audio>>&SO
targetResource . procedure + + ;
targetResource . procedure + + ;
} break ;
} break ;
}
}
resourceGainIcons . push_back ( { IMAGES [ RESOURCE ] . get ( ) , attachedPoint . lock ( ) - > type , GetPos ( ) } ) ;
resourceGainIcons . emplace_back ( & IMAGES [ RESOURCE ] , attachedPoint . lock ( ) - > type , GetPos ( ) ) ;
}
}
}
}
@ -788,7 +801,7 @@ void Unit::SetPos(vf2d newPos){
pos = newPos ;
pos = newPos ;
}
}
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_pt r< Renderable > > & IMAGES ) {
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 : : vecto r< Renderable > & IMAGES ) {
if ( reloadTimer > 0 ) return ;
if ( reloadTimer > 0 ) return ;
std : : weak_ptr < Unit > finalTarget ;
std : : weak_ptr < Unit > finalTarget ;
if ( ! unit . expired ( ) ) {
if ( ! unit . expired ( ) ) {
@ -809,16 +822,16 @@ void Unit::AttemptAttack(std::weak_ptr<Unit>attacker,std::weak_ptr<Unit>unit,std
bool hadProcedure = finalTarget . lock ( ) - > GetProcedure ( ) > 0 ;
bool hadProcedure = finalTarget . lock ( ) - > GetProcedure ( ) > 0 ;
_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.
if ( hadAtkSpd & & finalTarget . lock ( ) - > GetAtkSpd ( ) = = 0 ) {
if ( hadAtkSpd & & finalTarget . lock ( ) - > GetAtkSpd ( ) = = 0 ) {
debuffIcons . emplace_back ( IMAGES [ RLD_ICON ] . get ( ) , IMAGES [ RED_X ] . get ( ) , finalTarget . lock ( ) - > GetPos ( ) - vf2d { util : : random ( 12 ) - 6 , 4 } ) ;
debuffIcons . emplace_back ( & IMAGES [ RLD_ICON ] , & IMAGES [ RED_X ] , finalTarget . lock ( ) - > GetPos ( ) - vf2d { util : : random ( 12 ) - 6 , 4 } ) ;
}
}
if ( hadMoveSpd & & finalTarget . lock ( ) - > GetMoveSpd ( ) = = 0 ) {
if ( hadMoveSpd & & finalTarget . lock ( ) - > GetMoveSpd ( ) = = 0 ) {
debuffIcons . emplace_back ( IMAGES [ SPD_ICON ] . get ( ) , IMAGES [ RED_X ] . get ( ) , finalTarget . lock ( ) - > GetPos ( ) - vf2d { util : : random ( 12 ) - 6 , 4 } ) ;
debuffIcons . emplace_back ( & IMAGES [ SPD_ICON ] , & IMAGES [ RED_X ] , finalTarget . lock ( ) - > GetPos ( ) - vf2d { util : : random ( 12 ) - 6 , 4 } ) ;
}
}
if ( hadRange & & finalTarget . lock ( ) - > GetRange ( ) = = 0 ) {
if ( hadRange & & finalTarget . lock ( ) - > GetRange ( ) = = 0 ) {
debuffIcons . emplace_back ( IMAGES [ RNG_ICON ] . get ( ) , IMAGES [ RED_X ] . get ( ) , finalTarget . lock ( ) - > GetPos ( ) - vf2d { util : : random ( 12 ) - 6 , 4 } ) ;
debuffIcons . emplace_back ( & IMAGES [ RNG_ICON ] , & IMAGES [ RED_X ] , finalTarget . lock ( ) - > GetPos ( ) - vf2d { util : : random ( 12 ) - 6 , 4 } ) ;
}
}
if ( hadProcedure & & finalTarget . lock ( ) - > GetProcedure ( ) = = 0 ) {
if ( hadProcedure & & finalTarget . lock ( ) - > GetProcedure ( ) = = 0 ) {
debuffIcons . emplace_back ( IMAGES [ PRC_ICON ] . get ( ) , IMAGES [ RED_X ] . get ( ) , finalTarget . lock ( ) - > GetPos ( ) - vf2d { util : : random ( 12 ) - 6 , 4 } ) ;
debuffIcons . emplace_back ( & IMAGES [ PRC_ICON ] , & IMAGES [ RED_X ] , finalTarget . lock ( ) - > GetPos ( ) - vf2d { util : : random ( 12 ) - 6 , 4 } ) ;
}
}
}
}
}
}
@ -931,7 +944,7 @@ Pixel Unit::GetUnitColor(){
}
}
}
}
bool Unit : : ClickHandled ( TileTransformedView & game , Resources & player_resources , std : : vector < std : : shared_ptr < Unit > > & units , std : : map < Image , std : : unique_pt r< Renderable > > & IMAGES ) {
bool Unit : : ClickHandled ( TileTransformedView & game , Resources & player_resources , std : : vector < std : : shared_ptr < Unit > > & units , std : : vecto r< Renderable > & IMAGES ) {
return false ;
return false ;
} ;
} ;