public override void Update() { Spaceship.UpdateAll(); Lazer.UpdateAll(); Asteroid.UpdateAll(); LimitScreen.UpdateAll(); }
protected override void CollisionWithLine(int asteroidIndex) { for (int index = lazerList.Count - 1; index > -1; index--) { // om skott krockar med astroid if (Raylib.CheckCollisionCircleRec(asteroidList[asteroidIndex].GetCirclePos, asteroidList[asteroidIndex].GetAsteroidHitboxSize, lazerList[index].GetRect)) { // - skott dmg && ta bort skott && + score för spaceship asteroidList[asteroidIndex].Hp -= lazerList[index].GetDamage; Spaceship.AddToScore(lazerList[index].GetID, lazerList[index].GetDamage); Lazer.RemoceInstanceOfLine(index); // om hp efter -dmg >=0 ta bort astroid också if (asteroidList[asteroidIndex].Hp <= 0) { for (int i = 0; i < 3 * ButtonSeries.GetSelectedMultiplier(2); i++) { ScatterAsteroidSubMissile scatterAsteroidSubMissile = new ScatterAsteroidSubMissile(asteroidList[asteroidIndex].GetCirclePos, Color.PINK, 100); } asteroidList.Remove(asteroidList[asteroidIndex]); } } } }
// hämtar in lista med skott // syftet med metoden är att checka om ett skott(Line) kolliderar med en asteroid protected virtual void CollisionWithLine(int asteroidIndex) { // för varje instans av Lazer tittar om kollision med astroid; for (int index = lazerList.Count - 1; index > -1; index--) { // om skott krockar med astroid if (Raylib.CheckCollisionCircleRec(asteroidList[asteroidIndex].GetCirclePos, asteroidList[asteroidIndex].GetAsteroidHitboxSize, lazerList[index].GetRect)) { // - skott dmg && ta bort skott && + score för spaceship asteroidList[asteroidIndex].Hp -= lazerList[index].GetDamage; // om hp efter -dmg >=0 ta bort astroid också if (asteroidList[asteroidIndex].Hp <= 0) { // lägger till poäng för asteroid Spaceship.AddToScore(lazerList[index].GetID, asteroidList[asteroidIndex].worth); // tar bort instans av astroid asteroidList.Remove(asteroidList[asteroidIndex]); } // tar bort skott(index) Lazer.RemoceInstanceOfLine(index); } } }
public override void Draw() { Spaceship.DrawAll(); Lazer.DrawAll(); Asteroid.DrawAll(); }
public override void Update() { userInterface.UpdateUI(); spaceShipScore = Spaceship.GetSpaceshipScore(1); switch (createdSpaceShip) { case 0: { if (!regularSpaceship.IsSpaceshipAlive) { this.isGameOn = false; } else if (regularSpaceship.Shoot()) { Lazer lazer = new Lazer ( regularSpaceship.TriangleX, regularSpaceship.TriangleY, regularSpaceship.TriangleV, regularSpaceship.TriangleR, regularSpaceship.Damage, regularSpaceship.GetID ); } } break; case 1: { if (!scoutSpaceship.IsSpaceshipAlive) { this.isGameOn = false; } else if (scoutSpaceship.Shoot()) { Lazer lazer = new Lazer ( scoutSpaceship.TriangleX, scoutSpaceship.TriangleY, scoutSpaceship.TriangleV, scoutSpaceship.TriangleR, scoutSpaceship.Damage, scoutSpaceship.GetID ); } } break; case 2: { if (!heavySpaceship.IsSpaceshipAlive) { this.isGameOn = false; } else if (heavySpaceship.Shoot()) { Lazer lazer = new Lazer ( heavySpaceship.TriangleX, heavySpaceship.TriangleY, heavySpaceship.TriangleV, heavySpaceship.TriangleR, heavySpaceship.Damage, heavySpaceship.GetID ); } } break; case 3: { if (!sniperSpaceship.IsSpaceshipAlive) { this.isGameOn = false; } else if (sniperSpaceship.Shoot()) { Lazer lazer = new Lazer ( sniperSpaceship.TriangleX, sniperSpaceship.TriangleY, sniperSpaceship.TriangleV, sniperSpaceship.TriangleR, sniperSpaceship.Damage, sniperSpaceship.GetID ); } } break; } if (time[0] >= 10 * (4 - ButtonSeries.GetSelectedMultiplier(2))) { Asteroid asteroid = new Asteroid(); time[0] = 0; } else { time[0]++; } if (spaceShipScore >= 2000) { wave = 2; if (time[1] == 600) { MissileAsteroid missileAsteroid = new MissileAsteroid(); time[1] = 0; } else { time[1]++; } } if (spaceShipScore >= 4000) { wave = 3; if (time[2] == 1000) { ScatterAsteroid scatterAsteroid = new ScatterAsteroid(); time[2] = 0; } else { time[2]++; } } if (spaceShipScore >= 6000) { wave = 4; if (time[3] == 2000) { MissileScatterAsteroid missileScatterAsteroid = new MissileScatterAsteroid(); time[3] = 0; } else { time[3]++; } } if (spaceShipScore >= 8000 && ButtonSeries.GetSelectedButtonID(4) == 0) { wave = 5; if (time[4] == 2000) { LimitScreen limitScreen = new LimitScreen(); time[4] = 0; } else { time[4]++; } } if (spaceShipScore >= 10000) { if (ButtonSeries.GetSelectedButtonID(4) == 0) { wave = 6; } else { wave = 5; } if (time[5] == 4000) { MissileScatterAsteroidMissile missileScatterAsteroidMissile = new MissileScatterAsteroidMissile(); time[5] = 0; } else { time[5]++; } } if (spaceShipScore >= 20000) { if (time[6] == 0) { time[6] = 20000 - spaceShipScore / 10; } else { time[6]--; } if (ButtonSeries.GetSelectedButtonID(2) == 4) { wave = 7; } else { wave = 6; } int t = time[6]; switch (t) { case 1: { for (int i = 0; i < 200; i++) { Asteroid asteroid = new Asteroid(); } } break; case 2000: { for (int i = 0; i < 3; i++) { MissileAsteroid missileAsteroid = new MissileAsteroid(); } } break; case 4000: { for (int i = 0; i < 5; i++) { ScatterAsteroid scatterAsteroid = new ScatterAsteroid(); } } break; case 6000: { for (int i = 0; i < 3; i++) { MissileScatterAsteroid missileScatterAsteroid = new MissileScatterAsteroid(); } } break; case 8000: { for (int i = 0; i < 4; i++) { MissileScatterAsteroidMissile missileScatterAsteroidMissile = new MissileScatterAsteroidMissile(); } } break; } } base.Update(); }