|
|
|
@ -186,7 +186,7 @@ void RAMBank::Update(PixelGameEngine*pge,std::map<Sound,std::unique_ptr<Audio>>& |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void RAMBank::Draw(TileTransformedView&game,std::map<Image,std::unique_ptr<Renderable>>&IMAGES){ |
|
|
|
|
game.DrawRotatedDecal(GetGhostPos(),img.Decal(),0,img.Sprite()->Size()/2,{1,1},friendly?Pixel{192,192,255}:Pixel{255,192,192}); |
|
|
|
|
game.DrawRotatedDecal(GetGhostPos(),img.Decal(),0,img.Sprite()->Size()/2,{1,1},GetUnitColor()); |
|
|
|
|
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); |
|
|
|
|
} |
|
|
|
@ -270,7 +270,7 @@ void Unit::DrawRangeIndicator(PixelGameEngine*pge,TileTransformedView&game,std:: |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void Unit::Draw(TileTransformedView&game,std::map<Image,std::unique_ptr<Renderable>>&IMAGES){ |
|
|
|
|
game.DrawRotatedDecal(ghostPos,img.Decal(),0,img.Sprite()->Size()/2,{1,1},friendly?Pixel{192,192,255}:Pixel{255,192,192}); |
|
|
|
|
game.DrawRotatedDecal(ghostPos,img.Decal(),0,img.Sprite()->Size()/2,{1,1},GetUnitColor()); |
|
|
|
|
if(IsSelected()){ |
|
|
|
|
game.DrawRotatedDecal(ghostPos,IMAGES[SELECTION_CIRCLE]->Decal(),0,IMAGES[SELECTION_CIRCLE]->Sprite()->Size()/2,vf2d(img.Sprite()->Size())/IMAGES[SELECTION_CIRCLE]->Sprite()->Size(),WHITE); |
|
|
|
|
} |
|
|
|
@ -338,6 +338,13 @@ void Unit::DrawUnitDamageStats(PixelGameEngine*pge,TileTransformedView&game,std: |
|
|
|
|
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); |
|
|
|
|
} else |
|
|
|
|
if(targetLoc!=CONSTANT::UNSELECTED){ |
|
|
|
|
geom2d::line<float>lineToTarget(pos,targetLoc); |
|
|
|
|
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,0.6},CONSTANT::MOVE_LINE_COL); |
|
|
|
|
} |
|
|
|
|
if(!appliedTarget.expired()){ |
|
|
|
|
geom2d::line<float>lineToTarget(pos,appliedTarget.lock()->pos); |
|
|
|
@ -435,6 +442,13 @@ void Unit::_Update(PixelGameEngine*pge,std::map<Sound,std::unique_ptr<Audio>>&SO |
|
|
|
|
float dist=geom2d::line<float>(pos,targetLoc).length(); |
|
|
|
|
if(dist>24){ |
|
|
|
|
SetPos(GetPos()+(targetLoc-pos).norm()*GetMoveSpd()*24*pge->GetElapsedTime()); |
|
|
|
|
} else { |
|
|
|
|
if(willAttachWhenReachingDestination&&!attachTarget.expired()){ |
|
|
|
|
attachedPoint=attachTarget; |
|
|
|
|
attachedPoint.lock()->attachedUnit=self_ptr; |
|
|
|
|
} |
|
|
|
|
willAttachWhenReachingDestination=false; |
|
|
|
|
targetLoc=CONSTANT::UNSELECTED; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -503,11 +517,13 @@ vf2d Unit::GetUnitSize(){ |
|
|
|
|
void Unit::SetTargetUnit(std::weak_ptr<Unit>target){ |
|
|
|
|
this->target=target; |
|
|
|
|
this->targetLoc=CONSTANT::UNSELECTED; |
|
|
|
|
willAttachWhenReachingDestination=false; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void Unit::SetTargetLocation(vf2d targetLoc){ |
|
|
|
|
this->target.reset(); |
|
|
|
|
this->targetLoc=targetLoc; |
|
|
|
|
willAttachWhenReachingDestination=false; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
bool Unit::InRange(std::shared_ptr<Unit>target){ |
|
|
|
@ -617,15 +633,15 @@ vf2d Unit::GetGhostPos(){ |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
bool Unit::IsMoveable(){ |
|
|
|
|
return moveable; |
|
|
|
|
return moveable&&attachedPoint.expired(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
bool Unit::CanInteractWithAllies(){ |
|
|
|
|
return friendlyInteractable; |
|
|
|
|
return friendlyInteractable&&attachedPoint.expired(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
bool Unit::CanInteractWithEnemies(){ |
|
|
|
|
return enemyInteractable; |
|
|
|
|
return enemyInteractable&&attachedPoint.expired(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
Renderable&Unit::GetImage(){ |
|
|
|
@ -638,4 +654,40 @@ std::weak_ptr<Unit>Unit::GetCurrentTarget(){ |
|
|
|
|
|
|
|
|
|
bool Unit::AutoAcquiresFriendlyTargets(){ |
|
|
|
|
return autoAcquireFriendlyTarget; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
bool Unit::CanMove(){ |
|
|
|
|
return moveSpd.size>0&&attachedPoint.expired(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void Unit::SetTargetCollectionPoint(std::weak_ptr<CollectionPoint>targetCP,std::weak_ptr<Unit>self_ptr){ |
|
|
|
|
SetTargetLocation(targetCP.lock()->pos); |
|
|
|
|
attachTarget=targetCP; |
|
|
|
|
willAttachWhenReachingDestination=true; |
|
|
|
|
this->self_ptr=self_ptr; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
Pixel Unit::GetUnitColor(){ |
|
|
|
|
Pixel col; |
|
|
|
|
if(!attachedPoint.expired()){ |
|
|
|
|
switch(attachedPoint.lock()->type){ |
|
|
|
|
case HEALTH:{ |
|
|
|
|
return CONSTANT::HEALTH_COLOR/2; |
|
|
|
|
}break; |
|
|
|
|
case RANGE:{ |
|
|
|
|
return CONSTANT::RANGE_COLOR/2; |
|
|
|
|
}break; |
|
|
|
|
case ATKSPD:{ |
|
|
|
|
return CONSTANT::ATKSPD_COLOR/2; |
|
|
|
|
}break; |
|
|
|
|
case MOVESPD:{ |
|
|
|
|
return CONSTANT::MOVESPD_COLOR/2; |
|
|
|
|
}break; |
|
|
|
|
case PROCEDURE:{ |
|
|
|
|
return CONSTANT::PROCEDURE_COLOR/2; |
|
|
|
|
}break; |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
return friendly?Pixel{192,192,255}:Pixel{255,192,192}; |
|
|
|
|
} |
|
|
|
|
} |