@ -5,67 +5,42 @@
# include "DebuffIcon.h"
# include "DebuffIcon.h"
# include "olcPGEX_QuickGUI.h"
# include "olcPGEX_QuickGUI.h"
std : : vector < Memory > BasicUnit : : resourceCost = { { HEALTH , 4 } , { RANGE , 2 } , { ATKSPD , 2 } , { MOVESPD , 3 } , { PROCEDURE , 1 } } ;
BasicUnit : : BasicUnit ( PixelGameEngine * pge , 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 ( pge , {
: Unit ( pge , BasicUnit : : resourceCost , pos , 12 , * IMAGES [ VIRUS_IMG1 ] , WHITE , WHITE , friendly , moveable ) { }
{ HEALTH , 4 } ,
{ RANGE , 2 } ,
{ ATKSPD , 2 } ,
{ MOVESPD , 3 } ,
{ PROCEDURE , 1 } ,
} , 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 ;
}
}
std : : vector < Memory > BasicUnit2 : : resourceCost = { { RANGE , 2 } , { ATKSPD , 2 } , { MOVESPD , 3 } , { PROCEDURE , 1 } , { HEALTH , 4 } } ;
BasicUnit2 : : BasicUnit2 ( PixelGameEngine * pge , 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 ( pge , {
: Unit ( pge , BasicUnit2 : : resourceCost , pos , 12 , * IMAGES [ VIRUS_IMG1 ] , WHITE , WHITE , friendly , moveable ) { }
{ RANGE , 2 } ,
{ ATKSPD , 2 } ,
{ MOVESPD , 3 } ,
{ PROCEDURE , 1 } ,
{ HEALTH , 4 } ,
} , 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 ;
}
}
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 )
LeftShifter : : LeftShifter ( PixelGameEngine * pge , vf2d pos , std : : map < Image , std : : unique_ptr < Renderable > > & IMAGES , bool friendly , bool moveable )
: Unit ( pge , {
: Unit ( pge , LeftShifter : : resourceCost , pos , 12 , * IMAGES [ LEFT_SHIFTER ] , CONSTANT : : ATTACKER_TARGET_COL , CONSTANT : : ATTACKER_ATTACK_COL , friendly , moveable ) { }
{ RANGE , 2 } ,
{ ATKSPD , 2 } ,
{ MOVESPD , 3 } ,
{ PROCEDURE , 1 } ,
{ HEALTH , 4 } ,
} , 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 ;
}
}
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 )
RightShifter : : RightShifter ( PixelGameEngine * pge , vf2d pos , std : : map < Image , std : : unique_ptr < Renderable > > & IMAGES , bool friendly , bool moveable )
: Unit ( pge , {
: Unit ( pge , RightShifter : : resourceCost , pos , 12 , * IMAGES [ RIGHT_SHIFTER ] , CONSTANT : : ATTACKER_TARGET_COL , CONSTANT : : ATTACKER_ATTACK_COL , friendly , moveable ) { }
{ HEALTH , 4 } ,
{ RANGE , 2 } ,
{ ATKSPD , 2 } ,
{ MOVESPD , 3 } ,
{ PROCEDURE , 1 } ,
} , 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 ;
}
}
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 )
BitRestorer : : BitRestorer ( PixelGameEngine * pge , vf2d pos , std : : map < Image , std : : unique_ptr < Renderable > > & IMAGES , bool friendly , bool moveable )
: Unit ( pge , {
: Unit ( pge , BitRestorer : : resourceCost , pos , 12 , * IMAGES [ BIT_RESTORER ] , CONSTANT : : HEALER_TARGET_COL , CONSTANT : : HEALER_ATTACK_COL , friendly , moveable , true , false ) { }
{ PROCEDURE , 6 } ,
{ RANGE , 1 } ,
{ ATKSPD , 1 } ,
{ MOVESPD , 1 } ,
{ HEALTH , 2 } ,
} , 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 ;
@ -103,14 +78,9 @@ void BitRestorer::AttemptToHealOtherAllies(std::vector<std::shared_ptr<Unit>>&ot
}
}
}
}
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 )
MemorySwapper : : MemorySwapper ( PixelGameEngine * pge , vf2d pos , std : : map < Image , std : : unique_ptr < Renderable > > & IMAGES , bool friendly , bool moveable )
: Unit ( pge , {
: Unit ( pge , MemorySwapper : : resourceCost , pos , 12 , * IMAGES [ MEMORY_SWAPPER ] , CONSTANT : : ATTACKER_TARGET_COL , CONSTANT : : ATTACKER_ATTACK_COL , friendly , moveable , true ) {
{ RANGE , 3 } ,
{ ATKSPD , 1 } ,
{ HEALTH , 3 } ,
{ PROCEDURE , 3 } ,
{ MOVESPD , 2 } ,
} , pos , 12 , * IMAGES [ MEMORY_SWAPPER ] , CONSTANT : : ATTACKER_TARGET_COL , CONSTANT : : ATTACKER_ATTACK_COL , friendly , moveable , true ) {
autoAcquireFriendlyTarget = false ;
autoAcquireFriendlyTarget = false ;
}
}
@ -118,14 +88,9 @@ void MemorySwapper::Attack(Unit&victim,std::vector<std::shared_ptr<Unit>>&otherU
}
}
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 )
Corrupter : : Corrupter ( PixelGameEngine * pge , vf2d pos , std : : map < Image , std : : unique_ptr < Renderable > > & IMAGES , bool friendly , bool moveable )
: Unit ( pge , {
: Unit ( pge , Corrupter : : resourceCost , pos , 12 , * IMAGES [ CORRUPTER ] , CONSTANT : : ATTACKER_TARGET_COL , CONSTANT : : ATTACKER_ATTACK_COL , friendly , moveable ) { }
{ ATKSPD , 3 } ,
{ RANGE , 1 } ,
{ PROCEDURE , 8 } ,
{ MOVESPD , 4 } ,
{ HEALTH , 4 } ,
} , 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.
@ -133,14 +98,9 @@ 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 ;
}
}
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 )
MemoryAllocator : : MemoryAllocator ( PixelGameEngine * pge , vf2d pos , std : : map < Image , std : : unique_ptr < Renderable > > & IMAGES , bool friendly , bool moveable )
: Unit ( pge , {
: Unit ( pge , MemoryAllocator : : resourceCost , pos , 12 , * IMAGES [ UNIT_ALLOCATOR ] , CONSTANT : : ATTACKER_TARGET_COL , CONSTANT : : ATTACKER_ATTACK_COL , friendly , true , false ) {
{ RANGE , 1 } ,
{ ATKSPD , 1 } ,
{ MOVESPD , 1 } ,
{ PROCEDURE , 1 } ,
{ HEALTH , 1 } ,
} , pos , 12 , * IMAGES [ UNIT_ALLOCATOR ] , CONSTANT : : ATTACKER_TARGET_COL , CONSTANT : : ATTACKER_ATTACK_COL , friendly , true , false ) {
isAllocator = true ;
isAllocator = true ;
}
}
@ -148,14 +108,9 @@ void MemoryAllocator::Attack(Unit&victim,std::vector<std::shared_ptr<Unit>>&othe
}
}
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 )
RAMBank : : RAMBank ( PixelGameEngine * pge , vf2d pos , std : : map < Image , std : : unique_ptr < Renderable > > & IMAGES , bool friendly )
: Unit ( pge , {
: Unit ( pge , RAMBank : : resourceCost , pos , 41 , * IMAGES [ RAM_BANK ] , WHITE , WHITE , friendly , false
{ RANGE , 0 } ,
{ ATKSPD , 0 } ,
{ MOVESPD , 0 } ,
{ PROCEDURE , 25 } ,
{ HEALTH , 16 } ,
} , 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 ] ) {
@ -733,11 +688,11 @@ bool Unit::IsMoveable(){
}
}
bool Unit : : CanInteractWithAllies ( ) {
bool Unit : : CanInteractWithAllies ( ) {
return friendlyInteractable & & attachedPoint . expired ( ) ;
return friendlyInteractable & & attachedPoint . expired ( ) & & buildTime < = 0 ;
}
}
bool Unit : : CanInteractWithEnemies ( ) {
bool Unit : : CanInteractWithEnemies ( ) {
return enemyInteractable & & attachedPoint . expired ( ) ;
return enemyInteractable & & attachedPoint . expired ( ) & & buildTime < = 0 ;
}
}
Renderable & Unit : : GetImage ( ) {
Renderable & Unit : : GetImage ( ) {
@ -753,7 +708,7 @@ bool Unit::AutoAcquiresFriendlyTargets(){
}
}
bool Unit : : CanMove ( ) {
bool Unit : : CanMove ( ) {
return moveSpd . size > 0 & & attachedPoint . expired ( ) ;
return moveSpd . size > 0 & & attachedPoint . expired ( ) & & buildTime < = 0 ;
}
}
void Unit : : SetTargetCollectionPoint ( std : : weak_ptr < CollectionPoint > targetCP , std : : weak_ptr < Unit > self_ptr ) {
void Unit : : SetTargetCollectionPoint ( std : : weak_ptr < CollectionPoint > targetCP , std : : weak_ptr < Unit > self_ptr ) {
@ -795,5 +750,10 @@ bool Unit::ClickHandled(TileTransformedView&game,Resources&player_resources,std:
void Unit : : UpdateGUIState ( TileTransformedView & game , Resources & player_resources ) { } ;
void Unit : : UpdateGUIState ( TileTransformedView & game , Resources & player_resources ) { } ;
bool Unit : : IsAllocator ( ) {
bool Unit : : IsAllocator ( ) {
return isAllocator ;
return isAllocator & & attachedPoint . expired ( ) & & buildTime < = 0 ;
}
void Unit : : SetBuildUnit ( float buildTime , std : : unique_ptr < Unit > finalUnit ) {
this - > buildTime = buildTime ;
this - > buildTransformUnit = std : : move ( finalUnit ) ;
}
}