Fix minor bugs and levels. Ready to go. Final post-fix feature build.
This commit is contained in:
parent
a4439afc3f
commit
1a07786e7a
@ -143,6 +143,37 @@ void Scenario::RunAI(Resources&enemy_resources,std::vector<std::shared_ptr<Colle
|
||||
}
|
||||
}
|
||||
}
|
||||
if(!u->IsFriendly()&&u->IsPlatform()){
|
||||
std::array<UnitType,7>unitChoiceList={UnitType::RAMBank,UnitType::Refresher,UnitType::Refresher,UnitType::Turret,
|
||||
UnitType::Turret,UnitType::Turret,UnitType::MemoryGuard};
|
||||
std::array<std::vector<Memory>,7>unitResourceCostList={RAMBank::resourceCost,Refresher::resourceCost,Refresher::resourceCost,Turret::resourceCost,
|
||||
Turret::resourceCost,Turret::resourceCost,MemoryGuard::resourceCost};
|
||||
int randomIndex=rand()%unitChoiceList.size();
|
||||
UnitType buildUnit=unitChoiceList[randomIndex];
|
||||
|
||||
int totalCost=0;
|
||||
for(int i=0;i<unitResourceCostList[randomIndex].size();i++){
|
||||
totalCost+=unitResourceCostList[randomIndex][i].size;
|
||||
}
|
||||
if(totalCost<=availableMemory){
|
||||
#define Build(type) \
|
||||
case UnitType::type:{ \
|
||||
u->SetBuildUnit(8,std::make_shared<type>(game.GetPGE(),u->GetPos(),IMAGES,false),SOUNDS); \
|
||||
}break;
|
||||
switch(buildUnit){
|
||||
Build(RAMBank)
|
||||
Build(Refresher)
|
||||
Build(Turret)
|
||||
Build(MemoryGuard)
|
||||
}
|
||||
if(enemy_resources.health>0){enemy_resources.health=std::max(0,enemy_resources.health-totalCost);}else
|
||||
if(enemy_resources.atkSpd>0){enemy_resources.atkSpd=std::max(0,enemy_resources.atkSpd-totalCost);}else
|
||||
if(enemy_resources.moveSpd>0){enemy_resources.moveSpd=std::max(0,enemy_resources.moveSpd-totalCost);}else
|
||||
if(enemy_resources.range>0){enemy_resources.range=std::max(0,enemy_resources.range-totalCost);}else
|
||||
{enemy_resources.procedure=std::max(0,enemy_resources.procedure-totalCost);
|
||||
}
|
||||
}
|
||||
}
|
||||
switch(flags.difficulty){
|
||||
case 0:{
|
||||
unitBuildTimer=120;
|
||||
|
@ -727,6 +727,7 @@ void Unit::_Update(PixelGameEngine*pge,std::vector<std::unique_ptr<Audio>>&SOUND
|
||||
}
|
||||
|
||||
if(!attachedPoint.expired()){
|
||||
SetPos(attachedPoint.lock()->pos+vf2d{cos(float(attachedPoint.lock()->rot+PI/2))*16,sin(float(attachedPoint.lock()->rot+PI/2))*16});
|
||||
collectionTime-=pge->GetElapsedTime();
|
||||
if(collectionTime<=0){
|
||||
collectionTime=CONSTANT::COLLECTION_WAIT_TIME;
|
||||
@ -939,11 +940,26 @@ void Unit::Update(PixelGameEngine*pge,std::vector<std::unique_ptr<Audio>>&SOUNDS
|
||||
|
||||
void Unit::Attacked(std::weak_ptr<Unit>attacker){}
|
||||
|
||||
void Unit::_Attacked(std::weak_ptr<Unit>attacker){
|
||||
void Unit::_Attacked(std::weak_ptr<Unit>attacker,std::vector<std::shared_ptr<Unit>>&otherUnits){
|
||||
Attacked(attacker);
|
||||
if(attacker.lock()->IsFriendly()!=IsFriendly()&&CanInteractWithEnemies()){
|
||||
SetTargetUnit(attacker);
|
||||
}
|
||||
if(attacker.lock()->IsFriendly()!=IsFriendly()){
|
||||
for(auto&u:otherUnits){
|
||||
if(this!=u.get()&&!u->IsFriendly()&&u->GetCurrentTarget().expired()&&u->CanMove()&&!u->IsAllocator()){
|
||||
geom2d::line<float>distLine={GetPos(),u->GetPos()};
|
||||
if(distLine.length()<320){
|
||||
if(u->CanInteractWithEnemies()){
|
||||
u->SetTargetUnit(attacker);
|
||||
}else
|
||||
if(u->CanInteractWithAllies()){
|
||||
u->SetTargetLocation(GetPos());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Unit::_Attack(std::weak_ptr<Unit>attacker,std::weak_ptr<Unit>finalTarget,std::vector<std::shared_ptr<Unit>>&otherUnits,std::vector<std::unique_ptr<Audio>>&SOUNDS){
|
||||
@ -952,25 +968,12 @@ void Unit::_Attack(std::weak_ptr<Unit>attacker,std::weak_ptr<Unit>finalTarget,st
|
||||
float procChance=float(GetProcedure())/procedure.size;
|
||||
if(util::random(1)>=1-procChance){
|
||||
Attack(*finalTarget.lock(),otherUnits,SOUNDS);
|
||||
finalTarget.lock()->_Attacked(attacker);
|
||||
finalTarget.lock()->_Attacked(attacker,otherUnits);
|
||||
reloadTimer=1.f/(GetAtkSpd()/2.f);
|
||||
if(GetCurrentTarget().expired()&&!IsFriendly()){
|
||||
if(finalTarget.lock()->IsFriendly()!=IsFriendly()&&CanInteractWithEnemies()){
|
||||
SetTargetUnit(finalTarget);
|
||||
}
|
||||
for(auto&u:otherUnits){
|
||||
if(this!=u.get()&&!u->IsFriendly()&&u->GetCurrentTarget().expired()){
|
||||
geom2d::line<float>distLine={GetPos(),u->GetPos()};
|
||||
if(distLine.length()<200){
|
||||
if(u->CanInteractWithEnemies()){
|
||||
u->SetTargetUnit(finalTarget);
|
||||
}else
|
||||
if(u->CanInteractWithAllies()){
|
||||
u->SetTargetLocation(GetPos());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
reloadTimer=1.f/(GetAtkSpd()/2.f);
|
||||
|
@ -78,7 +78,7 @@ public:
|
||||
virtual void RunAI(PixelGameEngine*pge);
|
||||
void _RunAI(PixelGameEngine*pge);
|
||||
virtual void Attacked(std::weak_ptr<Unit>attacker);
|
||||
void _Attacked(std::weak_ptr<Unit>attacker);
|
||||
void _Attacked(std::weak_ptr<Unit>attacker,std::vector<std::shared_ptr<Unit>>&otherUnits);
|
||||
std::weak_ptr<Unit>GetCurrentTarget();
|
||||
void DrawUnitDamageStats(PixelGameEngine*pge,TileTransformedView&game,std::vector<std::unique_ptr<Renderable>>&IMAGES);
|
||||
bool AutoAcquiresFriendlyTargets();
|
||||
|
@ -215,307 +215,315 @@ void VirusAttack::InitializeLevelData(){
|
||||
}
|
||||
}
|
||||
#pragma endregion
|
||||
#pragma region Stage 5
|
||||
{
|
||||
//Stage 5 data.
|
||||
LevelName stage=STAGE5;
|
||||
levelData[stage].name=stage;
|
||||
levelData[stage].cameraStart={96,96};
|
||||
levelData[stage].worldZoom={1,1};
|
||||
levelData[stage].size={48,48};
|
||||
levelData[stage].levelColor=DARK_GREY;
|
||||
levelData[stage].bgm=Sound::BOSS1;
|
||||
levelData[stage].scenarioIndex=int(stage);
|
||||
levelData[stage].availableMemory=640;
|
||||
levelData[stage].player_starting_resources={5,5,5,5,5};
|
||||
levelData[stage].enemy_starting_resources={5,5,5,5,5};
|
||||
#pragma region Stage 5
|
||||
{
|
||||
std::vector<UnitData>&units=levelData[stage].unitPlacement;
|
||||
std::vector<CPData>&collectionPoints=levelData[stage].cpPlacement;
|
||||
//Stage 5 data.
|
||||
LevelName stage=STAGE5;
|
||||
levelData[stage].name=stage;
|
||||
levelData[stage].cameraStart={96,96};
|
||||
levelData[stage].worldZoom={1,1};
|
||||
levelData[stage].size={48,48};
|
||||
levelData[stage].levelColor=DARK_GREY;
|
||||
levelData[stage].bgm=Sound::BOSS1;
|
||||
levelData[stage].scenarioIndex=int(stage);
|
||||
levelData[stage].availableMemory=640;
|
||||
levelData[stage].player_starting_resources={5,5,5,5,5};
|
||||
levelData[stage].enemy_starting_resources={5,5,5,5,5};
|
||||
{
|
||||
std::vector<UnitData>&units=levelData[stage].unitPlacement;
|
||||
std::vector<CPData>&collectionPoints=levelData[stage].cpPlacement;
|
||||
|
||||
units.push_back({UnitType::RAMBank,vf2d{4*24,4*24},true});
|
||||
for(int i=0;i<5;i++){
|
||||
units.push_back({UnitType::MemoryAllocator,vf2d{4*24,6*24},true});
|
||||
}
|
||||
|
||||
collectionPoints.push_back(CPData{{8*24,1*24},0,MemoryType::HEALTH});
|
||||
collectionPoints.push_back(CPData{{10*24,1*24},0,MemoryType::HEALTH});
|
||||
collectionPoints.push_back(CPData{{32*24,12*24},0,MemoryType::HEALTH});
|
||||
collectionPoints.push_back(CPData{{20*24,32*24},0,MemoryType::HEALTH});
|
||||
collectionPoints.push_back(CPData{{9*24,1*24},0,MemoryType::PROCEDURE});
|
||||
collectionPoints.push_back(CPData{{1*24,7*24},-PI/2,MemoryType::PROCEDURE});
|
||||
collectionPoints.push_back(CPData{{16*24,16*24},0,MemoryType::PROCEDURE});
|
||||
collectionPoints.push_back(CPData{{36*24,1*24},-PI/2,MemoryType::PROCEDURE});
|
||||
collectionPoints.push_back(CPData{{1*24,3*24},-PI/2,MemoryType::RANGE});
|
||||
collectionPoints.push_back(CPData{{1*24,6*24},-PI/2,MemoryType::ATKSPD});
|
||||
collectionPoints.push_back(CPData{{1*24,11*24},-PI/2,MemoryType::MOVESPD});
|
||||
collectionPoints.push_back(CPData{{1*24,22*24},-PI/2,MemoryType::RANGE});
|
||||
collectionPoints.push_back(CPData{{6*24,16*24},-PI/2,MemoryType::ATKSPD});
|
||||
collectionPoints.push_back(CPData{{1*24,32*24},-PI/2,MemoryType::MOVESPD});
|
||||
collectionPoints.push_back(CPData{{(48-1)*24,(48-4)*24},PI/2,MemoryType::RANGE});
|
||||
collectionPoints.push_back(CPData{{(48-1)*24,(48-7)*24},PI/2,MemoryType::ATKSPD});
|
||||
collectionPoints.push_back(CPData{{(48-1)*24,(48-12)*24},PI/2,MemoryType::MOVESPD});
|
||||
collectionPoints.push_back(CPData{{(48-1)*24,(48-23)*24},PI/2,MemoryType::RANGE});
|
||||
collectionPoints.push_back(CPData{{(48-6)*24,(48-17)*24},PI/2,MemoryType::ATKSPD});
|
||||
collectionPoints.push_back(CPData{{(48-1)*24,(48-33)*24},PI/2,MemoryType::MOVESPD});
|
||||
|
||||
collectionPoints.push_back(CPData{{(48-8)*24,(48-2)*24},PI,MemoryType::HEALTH});
|
||||
collectionPoints.push_back(CPData{{(48-10)*24,(48-2)*24},PI,MemoryType::HEALTH});
|
||||
collectionPoints.push_back(CPData{{(48-32)*24,(48-13)*24},PI,MemoryType::HEALTH});
|
||||
collectionPoints.push_back(CPData{{(48-20)*24,(48-33)*24},PI,MemoryType::HEALTH});
|
||||
collectionPoints.push_back(CPData{{(48-9)*24,(48-2)*24},PI,MemoryType::PROCEDURE});
|
||||
collectionPoints.push_back(CPData{{(48-1)*24,(48-8)*24},PI/2,MemoryType::PROCEDURE});
|
||||
collectionPoints.push_back(CPData{{(48-16)*24,(48-17)*24},PI,MemoryType::PROCEDURE});
|
||||
collectionPoints.push_back(CPData{{(48-36)*24,(48-2)*24},PI/2,MemoryType::PROCEDURE});
|
||||
|
||||
for(int i=0;i<5;i++){
|
||||
units.push_back({UnitType::MemoryAllocator,vf2d{44*24,44*24},false});
|
||||
}
|
||||
units.push_back({UnitType::Turret,vf2d{42*24,42*24},false});
|
||||
units.push_back({UnitType::LeftShifter,vf2d{42*24,44*24},false});
|
||||
units.push_back({UnitType::LeftShifter,vf2d{42*24,44*24},false});
|
||||
units.push_back({UnitType::Corrupter,vf2d{42*24,44*24},false});
|
||||
units.push_back({UnitType::RightShifter,vf2d{42*24,44*24},false});
|
||||
units.push_back({UnitType::RightShifter,vf2d{45*24,41*24},false});
|
||||
units.push_back({UnitType::RAMBank,vf2d{44*24,44*24},false});
|
||||
}
|
||||
}
|
||||
#pragma endregion
|
||||
#pragma region Stage 6
|
||||
{
|
||||
//Stage 6 data.
|
||||
LevelName stage=STAGE6;
|
||||
levelData[stage].name=stage;
|
||||
levelData[stage].cameraStart={96,96};
|
||||
levelData[stage].worldZoom={1,1};
|
||||
levelData[stage].size={48,48};
|
||||
levelData[stage].levelColor=DARK_GREY;
|
||||
levelData[stage].bgm=Sound::BOSS1;
|
||||
levelData[stage].scenarioIndex=int(stage);
|
||||
levelData[stage].availableMemory=640;
|
||||
levelData[stage].player_starting_resources={5,5,5,5,5};
|
||||
levelData[stage].enemy_starting_resources={5,5,5,5,5};
|
||||
{
|
||||
std::vector<UnitData>&units=levelData[stage].unitPlacement;
|
||||
std::vector<CPData>&collectionPoints=levelData[stage].cpPlacement;
|
||||
|
||||
units.push_back({UnitType::RAMBank,vf2d{4*24,4*24},true});
|
||||
for(int i=0;i<5;i++){
|
||||
units.push_back({UnitType::MemoryAllocator,vf2d{4*24,6*24},true});
|
||||
}
|
||||
|
||||
std::vector<vf2d>positions={
|
||||
{{8,1},{10,1},{32,12},{20,32},{9,1},{1,7},{16,16}
|
||||
,{36,1},{1,3},{1,6},{1,11},{1,22},{6,16},{1,32}}
|
||||
};
|
||||
std::vector<MemoryType>types={
|
||||
{MemoryType::HEALTH,MemoryType::HEALTH,MemoryType::HEALTH,MemoryType::HEALTH,MemoryType::PROCEDURE,
|
||||
MemoryType::PROCEDURE,MemoryType::PROCEDURE,MemoryType::PROCEDURE,MemoryType::RANGE,
|
||||
MemoryType::ATKSPD,MemoryType::MOVESPD,MemoryType::RANGE,MemoryType::ATKSPD,MemoryType::MOVESPD,}
|
||||
};
|
||||
if(positions.size()!=types.size()){
|
||||
throw;
|
||||
}
|
||||
while(positions.size()>0){
|
||||
int randomIndex=rand()%positions.size();
|
||||
int randomIndex2=rand()%types.size();
|
||||
float finalDir=0;
|
||||
if(positions[randomIndex].x<levelData[stage].size.x/2){
|
||||
if(positions[randomIndex].y<positions[randomIndex].x){
|
||||
finalDir=0;
|
||||
}else{
|
||||
finalDir=-PI/2;
|
||||
}
|
||||
} else{
|
||||
if(positions[randomIndex].y>positions[randomIndex].x){
|
||||
finalDir=PI;
|
||||
}else{
|
||||
finalDir=PI/2;
|
||||
}
|
||||
units.push_back({UnitType::RAMBank,vf2d{4*24,4*24},true});
|
||||
for(int i=0;i<5;i++){
|
||||
units.push_back({UnitType::MemoryAllocator,vf2d{4*24,6*24},true});
|
||||
}
|
||||
collectionPoints.push_back(CPData{positions[randomIndex]*24,finalDir,types[randomIndex2]});
|
||||
collectionPoints.push_back(CPData{(levelData[stage].size-positions[randomIndex]-vf2d{1,1})*24,float(finalDir+PI),types[randomIndex2]});
|
||||
positions.erase(positions.begin()+randomIndex);
|
||||
types.erase(types.begin()+randomIndex2);
|
||||
}
|
||||
|
||||
for(int i=0;i<5;i++){
|
||||
units.push_back({UnitType::MemoryAllocator,vf2d{44*24,44*24},false});
|
||||
collectionPoints.push_back(CPData{{8*24,1*24},0,MemoryType::HEALTH});
|
||||
collectionPoints.push_back(CPData{{10*24,1*24},0,MemoryType::HEALTH});
|
||||
collectionPoints.push_back(CPData{{32*24,12*24},0,MemoryType::HEALTH});
|
||||
collectionPoints.push_back(CPData{{20*24,32*24},0,MemoryType::HEALTH});
|
||||
collectionPoints.push_back(CPData{{9*24,1*24},0,MemoryType::PROCEDURE});
|
||||
collectionPoints.push_back(CPData{{1*24,7*24},-PI/2,MemoryType::PROCEDURE});
|
||||
collectionPoints.push_back(CPData{{16*24,16*24},0,MemoryType::PROCEDURE});
|
||||
collectionPoints.push_back(CPData{{36*24,1*24},-PI/2,MemoryType::PROCEDURE});
|
||||
collectionPoints.push_back(CPData{{1*24,3*24},-PI/2,MemoryType::RANGE});
|
||||
collectionPoints.push_back(CPData{{1*24,6*24},-PI/2,MemoryType::ATKSPD});
|
||||
collectionPoints.push_back(CPData{{1*24,11*24},-PI/2,MemoryType::MOVESPD});
|
||||
collectionPoints.push_back(CPData{{1*24,22*24},-PI/2,MemoryType::RANGE});
|
||||
collectionPoints.push_back(CPData{{6*24,16*24},-PI/2,MemoryType::ATKSPD});
|
||||
collectionPoints.push_back(CPData{{1*24,32*24},-PI/2,MemoryType::MOVESPD});
|
||||
collectionPoints.push_back(CPData{{(48-1)*24,(48-4)*24},PI/2,MemoryType::RANGE});
|
||||
collectionPoints.push_back(CPData{{(48-1)*24,(48-7)*24},PI/2,MemoryType::ATKSPD});
|
||||
collectionPoints.push_back(CPData{{(48-1)*24,(48-12)*24},PI/2,MemoryType::MOVESPD});
|
||||
collectionPoints.push_back(CPData{{(48-1)*24,(48-23)*24},PI/2,MemoryType::RANGE});
|
||||
collectionPoints.push_back(CPData{{(48-6)*24,(48-17)*24},PI/2,MemoryType::ATKSPD});
|
||||
collectionPoints.push_back(CPData{{(48-1)*24,(48-33)*24},PI/2,MemoryType::MOVESPD});
|
||||
|
||||
collectionPoints.push_back(CPData{{(48-8)*24,(48-2)*24},PI,MemoryType::HEALTH});
|
||||
collectionPoints.push_back(CPData{{(48-10)*24,(48-2)*24},PI,MemoryType::HEALTH});
|
||||
collectionPoints.push_back(CPData{{(48-32)*24,(48-13)*24},PI,MemoryType::HEALTH});
|
||||
collectionPoints.push_back(CPData{{(48-20)*24,(48-33)*24},PI,MemoryType::HEALTH});
|
||||
collectionPoints.push_back(CPData{{(48-9)*24,(48-2)*24},PI,MemoryType::PROCEDURE});
|
||||
collectionPoints.push_back(CPData{{(48-1)*24,(48-8)*24},PI/2,MemoryType::PROCEDURE});
|
||||
collectionPoints.push_back(CPData{{(48-16)*24,(48-17)*24},PI,MemoryType::PROCEDURE});
|
||||
collectionPoints.push_back(CPData{{(48-36)*24,(48-2)*24},PI/2,MemoryType::PROCEDURE});
|
||||
|
||||
for(int i=0;i<5;i++){
|
||||
units.push_back({UnitType::MemoryAllocator,vf2d{44*24,44*24},false});
|
||||
}
|
||||
units.push_back({UnitType::Turret,vf2d{42*24,42*24},false});
|
||||
units.push_back({UnitType::LeftShifter,vf2d{42*24,44*24},false});
|
||||
units.push_back({UnitType::LeftShifter,vf2d{42*24,44*24},false});
|
||||
units.push_back({UnitType::Corrupter,vf2d{42*24,44*24},false});
|
||||
units.push_back({UnitType::RightShifter,vf2d{42*24,44*24},false});
|
||||
units.push_back({UnitType::RightShifter,vf2d{45*24,41*24},false});
|
||||
units.push_back({UnitType::RAMBank,vf2d{44*24,44*24},false});
|
||||
}
|
||||
units.push_back({UnitType::Refresher,vf2d{2*24,42*24},false});
|
||||
units.push_back({UnitType::MemoryGuard,vf2d{7*24,44*24},false});
|
||||
units.push_back({UnitType::LeftShifter,vf2d{2*24,44*24},false});
|
||||
units.push_back({UnitType::LeftShifter,vf2d{2*24,44*24},false});
|
||||
units.push_back({UnitType::Corrupter,vf2d{2*24,44*24},false});
|
||||
units.push_back({UnitType::RightShifter,vf2d{2*24,44*24},false});
|
||||
units.push_back({UnitType::RightShifter,vf2d{5*24,41*24},false});
|
||||
units.push_back({UnitType::RAMBank,vf2d{4*24,44*24},false});
|
||||
}
|
||||
}
|
||||
#pragma endregion
|
||||
#pragma endregion
|
||||
#pragma region Stage 6
|
||||
{
|
||||
//Stage 6 data.
|
||||
LevelName stage=STAGE6;
|
||||
levelData[stage].name=stage;
|
||||
levelData[stage].cameraStart={96,96};
|
||||
levelData[stage].worldZoom={1,1};
|
||||
levelData[stage].size={48,48};
|
||||
levelData[stage].levelColor=DARK_GREY;
|
||||
levelData[stage].bgm=Sound::BOSS1;
|
||||
levelData[stage].scenarioIndex=int(stage);
|
||||
levelData[stage].availableMemory=640;
|
||||
levelData[stage].player_starting_resources={5,5,5,5,5};
|
||||
levelData[stage].enemy_starting_resources={5,5,5,5,5};
|
||||
{
|
||||
std::vector<UnitData>&units=levelData[stage].unitPlacement;
|
||||
std::vector<CPData>&collectionPoints=levelData[stage].cpPlacement;
|
||||
|
||||
#pragma region Stage 7
|
||||
{
|
||||
//Stage 7 data.
|
||||
LevelName stage=STAGE7;
|
||||
levelData[stage].name=stage;
|
||||
levelData[stage].cameraStart={96,96};
|
||||
levelData[stage].worldZoom={1,1};
|
||||
levelData[stage].size={64,64};
|
||||
levelData[stage].levelColor=DARK_RED;
|
||||
levelData[stage].bgm=Sound::BOSS2;
|
||||
levelData[stage].scenarioIndex=int(stage);
|
||||
levelData[stage].availableMemory=960;
|
||||
levelData[stage].player_starting_resources={5,5,5,5,5};
|
||||
levelData[stage].enemy_starting_resources={5,5,5,5,5};
|
||||
units.push_back({UnitType::RAMBank,vf2d{4*24,4*24},true});
|
||||
for(int i=0;i<5;i++){
|
||||
units.push_back({UnitType::MemoryAllocator,vf2d{4*24,6*24},true});
|
||||
}
|
||||
|
||||
std::vector<vf2d>positions={
|
||||
{{8,1},{10,1},{32,12},{20,32},{9,1},{1,7},{16,16}
|
||||
,{36,1},{1,3},{1,6},{1,11},{1,22},{6,16},{1,32}}
|
||||
};
|
||||
std::vector<MemoryType>types={
|
||||
{MemoryType::HEALTH,MemoryType::HEALTH,MemoryType::HEALTH,MemoryType::HEALTH,MemoryType::PROCEDURE,
|
||||
MemoryType::PROCEDURE,MemoryType::PROCEDURE,MemoryType::PROCEDURE,MemoryType::RANGE,
|
||||
MemoryType::ATKSPD,MemoryType::MOVESPD,MemoryType::RANGE,MemoryType::ATKSPD,MemoryType::MOVESPD,}
|
||||
};
|
||||
if(positions.size()!=types.size()){
|
||||
throw;
|
||||
}
|
||||
while(positions.size()>0){
|
||||
int randomIndex=rand()%positions.size();
|
||||
int randomIndex2=rand()%types.size();
|
||||
float finalDir=0;
|
||||
if(positions[randomIndex].x<levelData[stage].size.x/2){
|
||||
if(positions[randomIndex].y<positions[randomIndex].x){
|
||||
finalDir=0;
|
||||
}else{
|
||||
finalDir=-PI/2;
|
||||
}
|
||||
} else{
|
||||
if(positions[randomIndex].y>positions[randomIndex].x){
|
||||
finalDir=PI;
|
||||
}else{
|
||||
finalDir=PI/2;
|
||||
}
|
||||
}
|
||||
collectionPoints.push_back(CPData{positions[randomIndex]*24,finalDir,types[randomIndex2]});
|
||||
collectionPoints.push_back(CPData{(levelData[stage].size-positions[randomIndex]-vf2d{1,1})*24,float(finalDir+PI),types[randomIndex2]});
|
||||
positions.erase(positions.begin()+randomIndex);
|
||||
types.erase(types.begin()+randomIndex2);
|
||||
}
|
||||
|
||||
for(int i=0;i<5;i++){
|
||||
units.push_back({UnitType::MemoryAllocator,vf2d{44*24,44*24},false});
|
||||
}
|
||||
units.push_back({UnitType::Refresher,vf2d{2*24,42*24},false});
|
||||
units.push_back({UnitType::MemoryGuard,vf2d{7*24,44*24},false});
|
||||
units.push_back({UnitType::LeftShifter,vf2d{2*24,44*24},false});
|
||||
units.push_back({UnitType::LeftShifter,vf2d{2*24,44*24},false});
|
||||
units.push_back({UnitType::Corrupter,vf2d{2*24,44*24},false});
|
||||
units.push_back({UnitType::RightShifter,vf2d{2*24,44*24},false});
|
||||
units.push_back({UnitType::RightShifter,vf2d{5*24,41*24},false});
|
||||
units.push_back({UnitType::RAMBank,vf2d{4*24,44*24},false});
|
||||
}
|
||||
}
|
||||
#pragma endregion
|
||||
#pragma region Stage 7
|
||||
{
|
||||
std::vector<UnitData>&units=levelData[stage].unitPlacement;
|
||||
std::vector<CPData>&collectionPoints=levelData[stage].cpPlacement;
|
||||
//Stage 7 data.
|
||||
LevelName stage=STAGE7;
|
||||
levelData[stage].name=stage;
|
||||
levelData[stage].cameraStart={96,96};
|
||||
levelData[stage].worldZoom={1,1};
|
||||
levelData[stage].size={64,64};
|
||||
levelData[stage].levelColor=DARK_RED;
|
||||
levelData[stage].bgm=Sound::BOSS2;
|
||||
levelData[stage].scenarioIndex=int(stage);
|
||||
levelData[stage].availableMemory=960;
|
||||
levelData[stage].player_starting_resources={5,5,5,5,5};
|
||||
levelData[stage].enemy_starting_resources={5,5,5,5,5};
|
||||
{
|
||||
std::vector<UnitData>&units=levelData[stage].unitPlacement;
|
||||
std::vector<CPData>&collectionPoints=levelData[stage].cpPlacement;
|
||||
|
||||
units.push_back({UnitType::RAMBank,vf2d{4*24,4*24},true});
|
||||
for(int i=0;i<5;i++){
|
||||
units.push_back({UnitType::MemoryAllocator,vf2d{4*24,6*24},true});
|
||||
}
|
||||
|
||||
std::vector<vf2d>positions={
|
||||
{{8,1},{10,1},{32,12},{20,32},{9,1},{1,7},{16,16}
|
||||
,{36,1},{1,3},{1,6},{1,11},{1,22},{6,16},{1,32}
|
||||
,{14,16},{27,29},{14,12},{7,36},{16,30},{22,19},{39,40}}
|
||||
};
|
||||
std::vector<MemoryType>types={
|
||||
{MemoryType::HEALTH,MemoryType::HEALTH,MemoryType::HEALTH,MemoryType::HEALTH,MemoryType::PROCEDURE,
|
||||
MemoryType::PROCEDURE,MemoryType::PROCEDURE,MemoryType::PROCEDURE,MemoryType::RANGE,
|
||||
MemoryType::ATKSPD,MemoryType::MOVESPD,MemoryType::RANGE,MemoryType::ATKSPD,MemoryType::MOVESPD,
|
||||
MemoryType::HEALTH,MemoryType::HEALTH,MemoryType::PROCEDURE,
|
||||
MemoryType::PROCEDURE,MemoryType::ATKSPD,MemoryType::MOVESPD,MemoryType::RANGE,}
|
||||
};
|
||||
if(positions.size()!=types.size()){
|
||||
throw;
|
||||
}
|
||||
while(positions.size()>0){
|
||||
int randomIndex=rand()%positions.size();
|
||||
int randomIndex2=rand()%types.size();
|
||||
float finalDir=0;
|
||||
if(positions[randomIndex].x<levelData[stage].size.x/2){
|
||||
if(positions[randomIndex].y<positions[randomIndex].x){
|
||||
finalDir=0;
|
||||
}else{
|
||||
finalDir=-PI/2;
|
||||
}
|
||||
} else{
|
||||
if(positions[randomIndex].y>positions[randomIndex].x){
|
||||
finalDir=PI;
|
||||
}else{
|
||||
finalDir=PI/2;
|
||||
}
|
||||
units.push_back({UnitType::RAMBank,vf2d{4*24,4*24},true});
|
||||
for(int i=0;i<5;i++){
|
||||
units.push_back({UnitType::MemoryAllocator,vf2d{4*24,6*24},true});
|
||||
}
|
||||
collectionPoints.push_back(CPData{positions[randomIndex]*24,finalDir,types[randomIndex2]});
|
||||
collectionPoints.push_back(CPData{(levelData[stage].size-positions[randomIndex]-vf2d{1,1})*24,float(finalDir+PI),types[randomIndex2]});
|
||||
positions.erase(positions.begin()+randomIndex);
|
||||
types.erase(types.begin()+randomIndex2);
|
||||
|
||||
std::vector<vf2d>positions={
|
||||
{{8,1},{10,1},{32,12},{20,32},{9,1},{1,7},{16,16}
|
||||
,{36,1},{1,3},{1,6},{1,11},{1,22},{6,16},{1,32}
|
||||
,{14,16},{27,29},{14,12},{7,36},{16,30},{22,19},{39,40}}
|
||||
};
|
||||
std::vector<MemoryType>types={
|
||||
{MemoryType::HEALTH,MemoryType::HEALTH,MemoryType::HEALTH,MemoryType::HEALTH,MemoryType::PROCEDURE,
|
||||
MemoryType::PROCEDURE,MemoryType::PROCEDURE,MemoryType::PROCEDURE,MemoryType::RANGE,
|
||||
MemoryType::ATKSPD,MemoryType::MOVESPD,MemoryType::RANGE,MemoryType::ATKSPD,MemoryType::MOVESPD,
|
||||
MemoryType::HEALTH,MemoryType::HEALTH,MemoryType::PROCEDURE,
|
||||
MemoryType::PROCEDURE,MemoryType::ATKSPD,MemoryType::MOVESPD,MemoryType::RANGE,}
|
||||
};
|
||||
if(positions.size()!=types.size()){
|
||||
throw;
|
||||
}
|
||||
while(positions.size()>0){
|
||||
int randomIndex=rand()%positions.size();
|
||||
int randomIndex2=rand()%types.size();
|
||||
float finalDir=0;
|
||||
if(positions[randomIndex].x<levelData[stage].size.x/2){
|
||||
if(positions[randomIndex].y<positions[randomIndex].x){
|
||||
finalDir=0;
|
||||
}else{
|
||||
finalDir=-PI/2;
|
||||
}
|
||||
} else{
|
||||
if(positions[randomIndex].y>positions[randomIndex].x){
|
||||
finalDir=PI;
|
||||
}else{
|
||||
finalDir=PI/2;
|
||||
}
|
||||
}
|
||||
collectionPoints.push_back(CPData{positions[randomIndex]*24,finalDir,types[randomIndex2]});
|
||||
collectionPoints.push_back(CPData{(levelData[stage].size-positions[randomIndex]-vf2d{1,1})*24,float(finalDir+PI),types[randomIndex2]});
|
||||
positions.erase(positions.begin()+randomIndex);
|
||||
types.erase(types.begin()+randomIndex2);
|
||||
}
|
||||
|
||||
units.push_back({UnitType::Turret,vf2d{52*24,52*24},false});
|
||||
units.push_back({UnitType::LeftShifter,vf2d{52*24,54*24},false});
|
||||
units.push_back({UnitType::LeftShifter,vf2d{52*24,54*24},false});
|
||||
units.push_back({UnitType::Corrupter,vf2d{52*24,54*24},false});
|
||||
units.push_back({UnitType::RightShifter,vf2d{52*24,54*24},false});
|
||||
units.push_back({UnitType::RightShifter,vf2d{55*24,51*24},false});
|
||||
units.push_back({UnitType::RAMBank,vf2d{54*24,54*24},false});
|
||||
units.push_back({UnitType::RAMBank,vf2d{54*24,54*24},false});
|
||||
|
||||
for(int i=0;i<5;i++){
|
||||
units.push_back({UnitType::MemoryAllocator,vf2d{54*24,54*24},false});
|
||||
}
|
||||
|
||||
units.push_back({UnitType::Turret,vf2d{53*24,22*24},false});
|
||||
units.push_back({UnitType::RAMBank,vf2d{54*24,24*24},false});
|
||||
for(int i=0;i<2;i++){
|
||||
units.push_back({UnitType::MemoryAllocator,vf2d{54*24,25*24},false});
|
||||
}
|
||||
units.push_back({UnitType::RightShifter,vf2d{53*24,24*24},false});
|
||||
units.push_back({UnitType::BitRestorer,vf2d{54*24,25*24},false});
|
||||
units.push_back({UnitType::RightShifter,vf2d{54*24,26*24},false});
|
||||
}
|
||||
|
||||
units.push_back({UnitType::Turret,vf2d{52*24,52*24},false});
|
||||
units.push_back({UnitType::LeftShifter,vf2d{52*24,54*24},false});
|
||||
units.push_back({UnitType::LeftShifter,vf2d{52*24,54*24},false});
|
||||
units.push_back({UnitType::Corrupter,vf2d{52*24,54*24},false});
|
||||
units.push_back({UnitType::RightShifter,vf2d{52*24,54*24},false});
|
||||
units.push_back({UnitType::RightShifter,vf2d{55*24,51*24},false});
|
||||
units.push_back({UnitType::RAMBank,vf2d{54*24,54*24},false});
|
||||
units.push_back({UnitType::RAMBank,vf2d{54*24,54*24},false});
|
||||
|
||||
for(int i=0;i<5;i++){
|
||||
units.push_back({UnitType::MemoryAllocator,vf2d{54*24,54*24},false});
|
||||
}
|
||||
|
||||
units.push_back({UnitType::Turret,vf2d{53*24,22*24},false});
|
||||
units.push_back({UnitType::RAMBank,vf2d{54*24,24*24},false});
|
||||
for(int i=0;i<2;i++){
|
||||
units.push_back({UnitType::MemoryAllocator,vf2d{54*24,25*24},false});
|
||||
}
|
||||
units.push_back({UnitType::RightShifter,vf2d{53*24,24*24},false});
|
||||
units.push_back({UnitType::BitRestorer,vf2d{54*24,25*24},false});
|
||||
units.push_back({UnitType::RightShifter,vf2d{54*24,26*24},false});
|
||||
}
|
||||
}
|
||||
#pragma endregion
|
||||
|
||||
|
||||
#pragma region Stage 8
|
||||
{
|
||||
//Stage 8 data.
|
||||
LevelName stage=STAGE8;
|
||||
levelData[stage].name=stage;
|
||||
levelData[stage].cameraStart={96,96};
|
||||
levelData[stage].worldZoom={1,1};
|
||||
levelData[stage].size={64,64};
|
||||
levelData[stage].levelColor=DARK_RED;
|
||||
levelData[stage].bgm=Sound::BOSS2;
|
||||
levelData[stage].scenarioIndex=int(stage);
|
||||
levelData[stage].availableMemory=1280;
|
||||
levelData[stage].player_starting_resources={5,5,5,5,5};
|
||||
levelData[stage].enemy_starting_resources={5,5,5,5,5};
|
||||
}
|
||||
#pragma endregion
|
||||
#pragma region Stage 8
|
||||
{
|
||||
std::vector<UnitData>&units=levelData[stage].unitPlacement;
|
||||
std::vector<CPData>&collectionPoints=levelData[stage].cpPlacement;
|
||||
//Stage 8 data.
|
||||
LevelName stage=STAGE8;
|
||||
levelData[stage].name=stage;
|
||||
levelData[stage].cameraStart={96,96};
|
||||
levelData[stage].worldZoom={1,1};
|
||||
levelData[stage].size={64,64};
|
||||
levelData[stage].levelColor=DARK_RED;
|
||||
levelData[stage].bgm=Sound::BOSS2;
|
||||
levelData[stage].scenarioIndex=int(stage);
|
||||
levelData[stage].availableMemory=1280;
|
||||
levelData[stage].player_starting_resources={5,5,5,5,5};
|
||||
levelData[stage].enemy_starting_resources={5,5,5,5,5};
|
||||
{
|
||||
std::vector<UnitData>&units=levelData[stage].unitPlacement;
|
||||
std::vector<CPData>&collectionPoints=levelData[stage].cpPlacement;
|
||||
|
||||
units.push_back({UnitType::RAMBank,vf2d{4*24,4*24},true});
|
||||
for(int i=0;i<5;i++){
|
||||
units.push_back({UnitType::MemoryAllocator,vf2d{4*24,6*24},true});
|
||||
}
|
||||
|
||||
std::vector<vf2d>positions={
|
||||
{{8,1},{10,1},{32,12},{20,32},{9,1},{1,7},{16,16}
|
||||
,{36,1},{1,3},{1,6},{1,11},{1,22},{6,16},{1,32}
|
||||
,{14,16},{27,29},{14,12},{7,36},{16,30},{22,19},{39,40}}
|
||||
};
|
||||
std::vector<MemoryType>types={
|
||||
{MemoryType::HEALTH,MemoryType::HEALTH,MemoryType::HEALTH,MemoryType::HEALTH,MemoryType::PROCEDURE,
|
||||
MemoryType::PROCEDURE,MemoryType::PROCEDURE,MemoryType::PROCEDURE,MemoryType::RANGE,
|
||||
MemoryType::ATKSPD,MemoryType::MOVESPD,MemoryType::RANGE,MemoryType::ATKSPD,MemoryType::MOVESPD,
|
||||
MemoryType::HEALTH,MemoryType::HEALTH,MemoryType::PROCEDURE,
|
||||
MemoryType::PROCEDURE,MemoryType::ATKSPD,MemoryType::MOVESPD,MemoryType::RANGE,}
|
||||
};
|
||||
if(positions.size()!=types.size()){
|
||||
throw;
|
||||
}
|
||||
while(positions.size()>0){
|
||||
int randomIndex=rand()%positions.size();
|
||||
int randomIndex2=rand()%types.size();
|
||||
float finalDir=0;
|
||||
if(positions[randomIndex].x<levelData[stage].size.x/2){
|
||||
if(positions[randomIndex].y<positions[randomIndex].x){
|
||||
finalDir=0;
|
||||
}else{
|
||||
finalDir=-PI/2;
|
||||
}
|
||||
} else{
|
||||
if(positions[randomIndex].y>positions[randomIndex].x){
|
||||
finalDir=PI;
|
||||
}else{
|
||||
finalDir=PI/2;
|
||||
}
|
||||
units.push_back({UnitType::RAMBank,vf2d{4*24,4*24},true});
|
||||
for(int i=0;i<5;i++){
|
||||
units.push_back({UnitType::MemoryAllocator,vf2d{4*24,6*24},true});
|
||||
}
|
||||
collectionPoints.push_back(CPData{positions[randomIndex]*24,finalDir,types[randomIndex2]});
|
||||
collectionPoints.push_back(CPData{(levelData[stage].size-positions[randomIndex]-vf2d{1,1})*24,float(finalDir+PI),types[randomIndex2]});
|
||||
positions.erase(positions.begin()+randomIndex);
|
||||
types.erase(types.begin()+randomIndex2);
|
||||
|
||||
std::vector<vf2d>positions={
|
||||
{{8,1},{10,1},{32,12},{20,32},{9,1},{1,7},{16,16}
|
||||
,{36,1},{1,3},{1,6},{1,11},{1,22},{6,16},{1,32}
|
||||
,{14,16},{27,29},{14,12},{7,36},{16,30},{22,19},{39,40}}
|
||||
};
|
||||
std::vector<MemoryType>types={
|
||||
{MemoryType::HEALTH,MemoryType::HEALTH,MemoryType::HEALTH,MemoryType::HEALTH,MemoryType::PROCEDURE,
|
||||
MemoryType::PROCEDURE,MemoryType::PROCEDURE,MemoryType::PROCEDURE,MemoryType::RANGE,
|
||||
MemoryType::ATKSPD,MemoryType::MOVESPD,MemoryType::RANGE,MemoryType::ATKSPD,MemoryType::MOVESPD,
|
||||
MemoryType::HEALTH,MemoryType::HEALTH,MemoryType::PROCEDURE,
|
||||
MemoryType::PROCEDURE,MemoryType::ATKSPD,MemoryType::MOVESPD,MemoryType::RANGE,}
|
||||
};
|
||||
if(positions.size()!=types.size()){
|
||||
throw;
|
||||
}
|
||||
while(positions.size()>0){
|
||||
int randomIndex=rand()%positions.size();
|
||||
int randomIndex2=rand()%types.size();
|
||||
float finalDir=0;
|
||||
if(positions[randomIndex].x<levelData[stage].size.x/2){
|
||||
if(positions[randomIndex].y<positions[randomIndex].x){
|
||||
finalDir=0;
|
||||
}else{
|
||||
finalDir=-PI/2;
|
||||
}
|
||||
} else{
|
||||
if(positions[randomIndex].y>positions[randomIndex].x){
|
||||
finalDir=PI;
|
||||
}else{
|
||||
finalDir=PI/2;
|
||||
}
|
||||
}
|
||||
collectionPoints.push_back(CPData{positions[randomIndex]*24,finalDir,types[randomIndex2]});
|
||||
collectionPoints.push_back(CPData{(levelData[stage].size-positions[randomIndex]-vf2d{1,1})*24,float(finalDir+PI),types[randomIndex2]});
|
||||
positions.erase(positions.begin()+randomIndex);
|
||||
types.erase(types.begin()+randomIndex2);
|
||||
}
|
||||
|
||||
|
||||
for(int i=0;i<2;i++){
|
||||
units.push_back({UnitType::MemoryAllocator,vf2d{53*24,53*24},false});
|
||||
}
|
||||
units.push_back({UnitType::Refresher,vf2d{56*24,56*24},false});
|
||||
units.push_back({UnitType::RAMBank,vf2d{54*24,54*24},false});
|
||||
|
||||
for(int i=0;i<5;i++){
|
||||
units.push_back({UnitType::MemoryAllocator,vf2d{39*24,35*24},false});
|
||||
}
|
||||
units.push_back({UnitType::Refresher,vf2d{43*24,52*24},false});
|
||||
units.push_back({UnitType::Turret,vf2d{44*24,52*24},false});
|
||||
units.push_back({UnitType::MemoryGuard,vf2d{40*24,35*24},false});
|
||||
units.push_back({UnitType::RAMBank,vf2d{40*24,36*24},false});
|
||||
units.push_back({UnitType::Turret,vf2d{37*24,57*24},false});
|
||||
units.push_back({UnitType::Turret,vf2d{42*24,57*24},false});
|
||||
|
||||
for(int i=0;i<2;i++){
|
||||
units.push_back({UnitType::MemoryAllocator,vf2d{10*24,53*24},false});
|
||||
}
|
||||
units.push_back({UnitType::RAMBank,vf2d{10*24,54*24},false});
|
||||
units.push_back({UnitType::Turret,vf2d{11*24,52*24},false});
|
||||
}
|
||||
|
||||
units.push_back({UnitType::Refresher,vf2d{52*24,52*24},false});
|
||||
units.push_back({UnitType::RAMBank,vf2d{54*24,54*24},false});
|
||||
|
||||
|
||||
for(int i=0;i<5;i++){
|
||||
units.push_back({UnitType::MemoryAllocator,vf2d{54*24,54*24},false});
|
||||
}
|
||||
|
||||
units.push_back({UnitType::RAMBank,vf2d{40*24,36*24},false});
|
||||
|
||||
units.push_back({UnitType::RAMBank,vf2d{10*24,54*24},false});
|
||||
}
|
||||
}
|
||||
#pragma endregion
|
||||
#pragma endregion
|
||||
}
|
||||
|
||||
bool VirusAttack::OnUserCreate(){
|
||||
@ -1294,7 +1302,7 @@ bool VirusAttack::OnUserUpdate(float fElapsedTime){
|
||||
|
||||
for(auto&u:units){
|
||||
u->Draw(gametv,IMAGES);
|
||||
if(u->IsGuarded()){
|
||||
if(u->IsGuarded()&&!u->InFogOfWar()){
|
||||
gametv.DrawDecal(u->GetPos()+vf2d{float(u->GetUnitSize().x/2),-float(u->GetUnitSize().y/2)}-vf2d{float(IMAGES[GUARD_ICON]->Sprite()->width),0.f}*0.375,IMAGES[GUARD_ICON]->Decal(),{0.375,0.375});
|
||||
}
|
||||
}
|
||||
@ -1383,9 +1391,16 @@ bool VirusAttack::OnUserUpdate(float fElapsedTime){
|
||||
#pragma endregion
|
||||
#pragma region COMPLETED
|
||||
case GameState::COMPLETED:{
|
||||
|
||||
DrawPartialDecal({0,0},GetScreenSize(),IMAGES[MATRIX]->Decal(),randomBackgroundOffset+gametv.GetWorldOffset()*(vf2d{32,32}/vf2d(GetScreenSize()))*gametv.GetWorldScale(),{32,32},Pixel{currentLevel->levelColor.r,currentLevel->levelColor.g,currentLevel->levelColor.b,164}/2);
|
||||
completedBox.Initialize("Thank you for playing Virus Attack!\n\nCompletion Time:"+std::to_string(gameSeconds)+" seconds\n\nHuge shoutout to the OLC community, javidx9 for the PGE, and all supporters!");
|
||||
completedBox.Initialize("Thank you for playing Virus Attack!\n\nCompletion Time:"+std::to_string(gameSeconds)+" seconds\n\nHuge shoutout to the OLC community, javidx9 for the PGE, and all supporters!\n\n\nPress [Escape] to return to the main menu.",{0,0},"Congratulations!",nullptr,{float(ScreenWidth()-2),1.f});
|
||||
completedBox.UpdateAndDraw({0,0},this,player_resources,IMAGES,GetTotalUsedMemory(),currentLevel->availableMemory);
|
||||
if(GetKey(ESCAPE).bPressed){
|
||||
state=GameState::MAIN_MENU;
|
||||
float titleScreenY=-200;
|
||||
float textOrientationY=0;
|
||||
float textOrientationX=0;
|
||||
levelToLoad=LevelName::STAGE1;
|
||||
}
|
||||
}break;
|
||||
#pragma endregion
|
||||
}
|
||||
|
File diff suppressed because one or more lines are too long
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user