Skip to content

Commit

Permalink
Fixed powerup offset. Fixed boss laser spawn
Browse files Browse the repository at this point in the history
  • Loading branch information
HansenDJ committed Apr 4, 2022
1 parent 44d71a4 commit 166474e
Show file tree
Hide file tree
Showing 8 changed files with 39 additions and 34 deletions.
7 changes: 3 additions & 4 deletions Game/Characters/Character.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,10 @@ public class Character

public int colliderBoxWidth = 0;

// Height offset for collider box
public int offsetColliderHeight = 30;

// Width offset for collider box
public int offsetColliderWidth = 10;
public int offsetColliderWidth = 0;
// Height offset for collider box
public int offsetColliderHeight = 0;

public int offsetH = 0;

Expand Down
File renamed without changes
1 change: 1 addition & 0 deletions Game/Laser/Weapon.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ public class Weapon : Character
{
public static int reloadTime = 0;
public int laserID;
public int randomBossWeaponY = 0;
public bool location = false;
public int powerUpShot = 0;
public int speed = 25;
Expand Down
4 changes: 2 additions & 2 deletions Game/Player.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ public class Player : Character
public static int moveIncrementL;
public static int moveIncrementR;
private readonly int playerXRange = VideoService.scrnWidth - VideoService.scrnWidth / 5;
private readonly int offsetH = 14;
private readonly int offsetW = 18;
public int offsetH = 14;
public int offsetW = 18;


// SETS player constants
Expand Down
2 changes: 2 additions & 0 deletions Game/Powerup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ public static void ReduceEffectTime()
isExplosiveShot = false;
isShielded = false;
isCoins = false;
// Player.offsetW = 30;
// Player.offsetH = 10;
}
}
public static void IsHealthHit2Effect()
Expand Down
28 changes: 11 additions & 17 deletions Game/Services/CurrencyHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,30 +25,24 @@ public static int CheckMoney()
{
if (money < 100) return 1;

if (money >= 100 && money < 500) return 2;
else if (money >= 100 && money < 500) return 2;

if (money >= 500 && money < 1000) return 3;
else if (money >= 500 && money < 1000) return 3;

if (money >= 1000 && money < 1500) return 4;
else if (money >= 1000 && money < 1500) return 4;

if (money >= 1500 && money < 2000) return 5;
else if (money >= 1500 && money < 2000) return 5;

if (money >= 2000 && money < 3000) return 6;
else if (money >= 2000 && money < 3000) return 6;

if (money >= 3000 && money < 4000) return 7;
else if (money >= 3000 && money < 4000) return 7;

if (money >= 4000 && money < 5000) return 8;
else if (money >= 4000 && money < 5000) return 8;

if (money <= 5000 && money < 10000)
{
return 9;
}
if (money >= 10000)
{
return 10;
}
else if (money >= 5000 && money < 10000) return 9;

Console.WriteLine("ERROR:Money is negative!");
return 11;
else if (money >= 10000) return 10;

else return 11;
}
}
21 changes: 16 additions & 5 deletions Game/Services/VideoService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ public class VideoService
{
public static int scrnWidth = 1400;
public static int scrnHeight = 850;
Random rnd = new Random();

// public static double FullPrimaryScreenWidth { get; }
// public static double FullPrimaryScreenHeight { get; }
Expand Down Expand Up @@ -43,7 +44,6 @@ public static void DrawPowerUpList(List<PowerUpGraphic> powerups)
{
DrawTexture(powerups[i].GetCharTexture(),powerups[i].x,powerups[i].y,Color.WHITE);
DrawColliderBox(powerups[i]);

}
}

Expand Down Expand Up @@ -100,10 +100,18 @@ public static void DrawEnemyWeapons(int index_enemy, List<Enemy> enemyToDraw, Li

if (!enemyWeaponsToDraw[i_weaponEnemy].location && enemyWeaponsToDraw[i_weaponEnemy].laserID == enemyToDraw[index_enemy].enemyID)
{
enemyWeaponsToDraw[i_weaponEnemy].SetX(enemyToDraw[index_enemy].x);
enemyWeaponsToDraw[i_weaponEnemy].SetY(enemyToDraw[index_enemy].y + enemyToDraw[index_enemy].GetColliderBoxHeight() / 2);
DrawCharacter(enemyWeaponsToDraw[i_weaponEnemy]);
DrawColliderBox(enemyWeaponsToDraw[i_weaponEnemy]);
if (enemyToDraw[index_enemy].levelOfEnemy == 100)
{
enemyWeaponsToDraw[i_weaponEnemy].SetX(enemyToDraw[index_enemy].x - 50);
enemyWeaponsToDraw[i_weaponEnemy].SetY(enemyToDraw[index_enemy].y + enemyWeaponsToDraw[i_weaponEnemy].randomBossWeaponY);
}
else
{
enemyWeaponsToDraw[i_weaponEnemy].SetX(enemyToDraw[index_enemy].x);
enemyWeaponsToDraw[i_weaponEnemy].SetY(enemyToDraw[index_enemy].y + enemyToDraw[index_enemy].GetColliderBoxHeight() / 2);
DrawCharacter(enemyWeaponsToDraw[i_weaponEnemy]);
DrawColliderBox(enemyWeaponsToDraw[i_weaponEnemy]);
}

enemyWeaponsToDraw[i_weaponEnemy].location = true;
}
Expand Down Expand Up @@ -153,8 +161,11 @@ public static void DrawPlayer(Player player)
DrawTexture(player.GetCharTexture(), player.x, player.y, WHITE);
if (Powerup.isShielded)
{
player.SetOffsetColliderWidth(0);
player.SetOffsetColliderHeight(0);
DrawColliderBox(player);
}
DrawColliderBox(player);

}

Expand Down
10 changes: 4 additions & 6 deletions Game/SpawnDestroy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -646,9 +646,8 @@ private void EnemyBossShot(Enemy enemy, Weapon enemyWeaponToCreate)
enemyWeaponToCreate.speed = rnd.Next(6,15);
enemyWeaponToCreate.strength = 50;
enemyWeaponToCreate.SetCharTexture(ImageService.laser8Texture);
enemyWeaponToCreate.SetX(enemy.x - 50);
enemyWeaponToCreate.SetY(enemy.y + rnd.Next(50, enemy.GetColliderBoxHeight() - 50));
enemyWeaponToCreate.location = true;
enemyWeaponToCreate.randomBossWeaponY = rnd.Next(50, enemy.GetColliderBoxHeight() - 50);

// enemyWeaponToCreate.enemyIndex = enemyI;
// enemy.laserIndex = enemyWeaponToCreate.enemyIndex;

Expand Down Expand Up @@ -820,7 +819,8 @@ public void ClearMap()
public void SetRandomPowerUp(int chance, Enemy enemy)
{
getPowerUp = rnd.Next(1,25);
if(getPowerUp * chance <= 5){
if(getPowerUp * chance <= 5)
{
setPowerUp = rnd.Next(1,4);
PowerUpGraphic powerup = new PowerUpGraphic();
switch (setPowerUp)
Expand All @@ -838,8 +838,6 @@ public void SetRandomPowerUp(int chance, Enemy enemy)

powerup.ID = setPowerUp;

powerup.SetOffsetColliderWidth(enemy.offsetW);
powerup.SetOffsetColliderHeight(enemy.offsetH);
powerup.SetX(enemy.x + enemy.GetColliderBoxWidth());
powerup.SetY(enemy.y + enemy.GetColliderBoxHeight());

Expand Down

0 comments on commit 166474e

Please sign in to comment.