// Update uppdaterar trianglens rotation och placering på planet // samt tillkallar Alive() metoden för att titta om spelaren lever private void Update() { Alive(); CheckKeyInput(); color = ButtonSeries.GetSelectedColor(3); for (int i = 0; i < 3; i++) { pointTriangle[i].X = (xPlanePos); pointTriangle[i].Y = (yPlanePos); if (i > 0) { pointTriangle[i].X += (spaceshipSize * ToFloat(xCircle[i - 1])); pointTriangle[i].Y += (spaceshipSize * ToFloat(yCircle[i - 1])); } if (i < 2) { pointLine[i].X = (xPlanePos); pointLine[i].Y = (yPlanePos); } if (i == 1) { pointLine[i].X += (spaceshipSize * ToFloat(xLine[i])); pointLine[i].Y += (spaceshipSize * ToFloat(yLine[i])); } } }
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]); } } } }
public override void Update() { ButtonSeries.UpdateSeries(4); ButtonSeries.UpdateSeries(5); ButtonSeries.UpdateSeries(6); ButtonSeries.UpdateSeries(7); }
public void DrawUI() { Raylib.DrawText("SCORE:", 30, 28, 35, ButtonSeries.GetSelectedColor(3)); Raylib.DrawText(Spaceship.GetSpaceshipScore(1).ToString(), 180, 28, 35, ButtonSeries.GetSelectedColor(3)); Raylib.DrawText("PAUSE [P]", 800, 28, 35, ButtonSeries.GetSelectedColor(3)); UserInterfaceKey.DrawAll(); }
// metod som uppdaterar skottets position private void Update() { color = ButtonSeries.GetSelectedColor(3); lazerSpeed -= 15; x = ((Math.Cos(v) * lazerSpeed) + OriginX); y = ((Math.Sin(v) * lazerSpeed) + OriginY); rect.x = ToFloat(x); rect.y = ToFloat(y); }
public ScatterAsteroidSubMissile(Vector2 location, Color color, int hp) : base(location, color) { asteroidMoveSpeed = 0.5 * ButtonSeries.GetSelectedMultiplier(2); this.hp = hp; asteroidColor = color; originX = location.X; originY = location.Y; followShip = random.Next(0, spaceshipList.Count); }
private void Draw() { Raylib.DrawRectangle((int)keyPosition.X, (int)keyPosition.Y, (int)keyRectangle.width, (int)keyRectangle.height, rectangleColorInt); if (highlightKey && ButtonSeries.GetSelectedButtonID(3) == 0) { Raylib.DrawRectangle((int)keyPosition.X, (int)keyPosition.Y, (int)keyRectangle.width, (int)keyRectangle.height, highlightColor2); } else if (highlightKey) { Raylib.DrawRectangle((int)keyPosition.X, (int)keyPosition.Y, (int)keyRectangle.width, (int)keyRectangle.height, highlightColor1); } Raylib.DrawText(keyText, (int)keyPosition.X + 15, (int)keyPosition.Y + 7, 50, textColor); }
public MissileScatterAsteroidMissile() { rectangle.width = rectangle.height = 200; centerOfRect = new Vector2(rectangle.width / 2, rectangle.width / 2); asteroidColor = lightPink; asteroidMoveSpeed = 0.3 * ButtonSeries.GetSelectedMultiplier(2); hp = worth = 800; followShip = random.Next(0, spaceshipList.Count); }
public ScatterAsteroid() { rectangle.width = rectangle.height = 120; centerOfRect = new Vector2(rectangle.width / 2, rectangle.width / 2); asteroidColor = Color.PURPLE; asteroidMoveSpeed = 0.7 * ButtonSeries.GetSelectedMultiplier(2); hp = worth = 400; followShip = random.Next(0, spaceshipList.Count); }
public MissileAsteroid() { rectangle.width = rectangle.height = 70; centerOfRect = new Vector2(rectangle.width / 2, rectangle.width / 2); asteroidColor = Color.DARKGRAY; asteroidMoveSpeed = 1 * ButtonSeries.GetSelectedMultiplier(2); hp = worth = 200; followShip = random.Next(0, spaceshipList.Count); }
private void Update() { rectangleColorInt = ButtonSeries.GetSelectedColor(colorInt); if (ButtonSeries.GetSelectedButtonID(3) == 0) { textColor = Color.BLACK; } if (Raylib.IsKeyDown(key)) { highlightKey = true; } else { highlightKey = false; } }
public LimitScreen() { side = random.Next(1, 5); switch (side) { case 1: rectangle.x = 0; rectangle.y = 0; rectangle.width = 500; rectangle.height = 1000; break; case 2: rectangle.x = 500; rectangle.y = 0; rectangle.width = 500; rectangle.height = 1000; break; case 3: rectangle.x = 0; rectangle.y = 0; rectangle.width = 1000; rectangle.height = 500; break; case 4: rectangle.x = 0; rectangle.y = 500; rectangle.width = 1000; rectangle.height = 500; break; } activeTime = 200 * (int)ButtonSeries.GetSelectedMultiplier(2); limitList.Add(this); }
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(); }
public new void Draw() { Raylib.DrawRectangleGradientV(300, 300, 400, 400, ButtonSeries.GetSelectedColor(3), new Color(0, 0, 0, 0)); Button.DrawAll(6); Raylib.DrawText("Pause", 410, 330, 60, Color.BLACK); }
public override void Update() { ButtonSeries.UpdateSeries(2); }