2019-07-23 14:54:05 +02:00
using Base ;
using System ;
using System.Collections.Generic ;
using System.Drawing ;
using System.Drawing.Drawing2D ;
using System.IO ;
using System.Linq ;
using System.Windows.Forms ;
using System.Globalization ;
namespace LaptopSimulator2015.Levels
{
class Lvl1 : Level
{
static Image _installer ;
public string installerHeader
{
get {
switch ( CultureInfo . CurrentUICulture . Name . Split ( '-' ) [ 0 ] )
{
case "de" :
return "Speichererweiterer 2.0" ;
default :
return "RAM Installer 2.0" ;
}
}
}
public string installerText
{
get {
switch ( CultureInfo . CurrentUICulture . Name . Split ( '-' ) [ 0 ] )
{
case "de" :
return "Vielen Dank dass sie sich entschieden haben, mit unserem super sicherem Speichererweiterer ihren RAM zu erweitern.\r\n\r\nIhr Computer wird es ihnen danken!" ;
default :
return "Thank you for deciding to download RAM Installer 2.0 from our secure download servers. Please wait a second while we install your RAM.\r\n\r\nYour Computer is about to run a whole lot smoother!" ;
}
}
}
public Image installerIcon
{
get {
if ( _installer = = null )
{
string __installer = "iVBORw0KGgoAAAANSUhEUgAAAIAAAACACAYAAADDPmHLAAAABGdBTUEAALGPC/xhBQAAREVJREFUeF7tnQd4XPWZ7jcbsiR7yb27Calbks3d7G6SvSkLoYMJMRhwwzZylats2apWt/qoazS9997UR73ZlnsvYINNMQ6QAqSTZEM6fPf9/mdGGskjF5Yk4Oj/PO8zo9FIU37v186cc+avZtfsml2z67pe74PeD33glltu+duMjIy/zyvP+1RxcfGn12ZlfXTOnDk38e9i9+H7zq7rYN1QUFBws96uv8vb6k4LR8OqjoGu3s7B6NHOoeiTbQM959v6ep8J9UTPBqLRE972ziGrP2xSW53ZMoVm7uackn/E/2BTzK730Prr9IL0m33tvuUdA23WvrGe04O7+18f2jNIg+OD1L9rkHp3DlJ0bJC6Rgapc2iQ2gcHqXVgkMJ9gxTsGaRAdJA8HX1v2EPdz+rckVCz3rl5/dbtn8X/5uwwu96l6/2yZtnnWnvCVb1j3YeH9gz8bnjvILFwHfAHaGDXAPXF4Hcz/OFB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o8L8F2o9y7AdwK+E/Cd5G91kq81jJrfjprfhpofJCeARYe6kwOPKwnsS7RHUt9gFzkB3IGxzmVUk9uEGd/YQh7Ueg8i3gPwXoD3miFEvBfgvY5q8jmryQ/wfg+M4MU0YCh+4mMf+7uv4HXO7jeQbBUUpN/c2m1/qrPPjaYNwHuhHifAO5HOHaj3DjR7dtR8G+DbKdBqR4PnRORHyB2OIPoj5PC5REOYHDprlIb3DL+KyPYMjw/n4HomIFvx8zPTwSeqPWQjl7aSXCbM+RYNuayQCWUAqd4N8G5EvNuOWu+oIg+ge92QBybwQ
Stream s = new MemoryStream ( Convert . FromBase64String ( __installer ) ) ;
_installer = Image . FromStream ( s ) ;
s . Close ( ) ;
}
return _installer ;
}
}
public int LevelNumber = > 1 ;
public int gameClock = > 17 ;
public Panel desktopIcon { get ; set ; }
2019-07-27 20:57:23 +02:00
public int installerProgressSteps = > 500 ;
2019-07-23 14:54:05 +02:00
2019-07-27 20:57:23 +02:00
List < Vector2 > invadersAliens = new List < Vector2 > ( ) ;
List < Vector2 > invadersBullets = new List < Vector2 > ( ) ;
Vector2 invadersPlayer ;
uint minigamePrevTime = 0 ;
2019-07-23 14:54:05 +02:00
bool invadersCanShoot = true ;
2019-08-01 22:42:35 +02:00
double speedMod = 5 ;
2019-07-23 14:54:05 +02:00
2019-08-01 22:42:35 +02:00
public void gameTick ( Graphics e , Panel minigamePanel , Timer minigameTimer , uint minigameTime )
2019-07-23 14:54:05 +02:00
{
2019-08-01 22:42:35 +02:00
BufferedGraphics buffer = BufferedGraphicsManager . Current . Allocate ( e , new Rectangle ( 0 , 0 , minigamePanel . Width , minigamePanel . Height ) ) ;
Graphics g = buffer . Graphics ;
2019-07-23 14:54:05 +02:00
try
{
g . Clear ( Color . Black ) ;
for ( int i = 0 ; i < invadersAliens . Count ; i + + )
{
2019-07-27 20:57:23 +02:00
g . FillRectangle ( new SolidBrush ( Color . Red ) , new Rectangle ( invadersAliens [ i ] . toPoint ( ) , new Size ( 10 , 10 ) ) ) ;
2019-07-23 14:54:05 +02:00
}
for ( int i = 0 ; i < invadersBullets . Count ; i + + )
{
2019-07-27 20:57:23 +02:00
g . FillRectangle ( new SolidBrush ( Color . White ) , new Rectangle ( invadersBullets [ i ] . toPoint ( ) , new Size ( 5 , 5 ) ) ) ;
2019-07-23 14:54:05 +02:00
}
2019-07-27 20:57:23 +02:00
g . FillRectangle ( new SolidBrush ( Color . Green ) , new Rectangle ( invadersPlayer . toPoint ( ) , new Size ( 10 , 10 ) ) ) ;
2019-07-23 14:54:05 +02:00
Random random = new Random ( ) ;
2019-07-27 20:57:23 +02:00
if ( minigameTime ! = minigamePrevTime )
2019-07-23 14:54:05 +02:00
{
2019-07-27 20:57:23 +02:00
minigamePrevTime = minigameTime ;
if ( random . Next ( 0 , 100000 ) < minigameTime + 1300 )
invadersAliens . Add ( new Vector2 ( minigamePanel . Width , random . Next ( minigamePanel . Height - 10 ) ) ) ;
2019-07-23 14:54:05 +02:00
for ( int i = 0 ; i < invadersAliens . Count ; i + + )
{
2019-08-01 22:42:35 +02:00
invadersAliens [ i ] . X - = 1.2 ;
2019-07-27 20:57:23 +02:00
if ( invadersPlayer . distanceFromSquared ( invadersAliens [ i ] ) < 100 | invadersAliens [ i ] . X < 0 )
2019-07-23 14:54:05 +02:00
{
2019-07-27 20:57:23 +02:00
throw new Exception ( "The VM was shut down to prevent damage to your Machine." , new Exception ( "0717750f-3508-4bc2-841e-f3b077c676fe" ) ) ;
2019-07-23 14:54:05 +02:00
}
}
2019-08-26 14:12:51 +02:00
invadersCanShoot = invadersCanShoot | ! Input . Action ;
2019-07-27 20:57:23 +02:00
List < Vector2 > aliensToRemove = new List < Vector2 > ( ) ;
List < Vector2 > bulletsToRemove = new List < Vector2 > ( ) ;
2019-07-23 14:54:05 +02:00
for ( int i = 0 ; i < invadersBullets . Count ; i + + )
{
2019-07-27 20:57:23 +02:00
invadersBullets [ i ] . X + = 4 ;
2019-07-23 14:54:05 +02:00
for ( int j = 0 ; j < invadersAliens . Count ; j + + )
{
2019-07-27 20:57:23 +02:00
if ( invadersBullets [ i ] . distanceFromSquared ( invadersAliens [ j ] + new Vector2 ( 2.5f , 2.5f ) ) < 56.25f )
2019-07-23 14:54:05 +02:00
{
2019-07-27 20:57:23 +02:00
aliensToRemove . Add ( invadersAliens [ j ] ) ;
bulletsToRemove . Add ( invadersBullets [ i ] ) ;
2019-07-23 14:54:05 +02:00
}
}
2019-07-27 20:57:23 +02:00
if ( invadersBullets [ i ] . X > minigamePanel . Width )
bulletsToRemove . Add ( invadersBullets [ i ] ) ;
2019-07-23 14:54:05 +02:00
}
2019-07-27 20:57:23 +02:00
invadersAliens = invadersAliens . Except ( aliensToRemove . Distinct ( ) ) . Distinct ( ) . ToList ( ) ;
invadersBullets = invadersBullets . Except ( bulletsToRemove . Distinct ( ) ) . Distinct ( ) . ToList ( ) ;
2019-08-01 22:42:35 +02:00
speedMod + = 0.1 ;
speedMod = Math . Max ( Math . Min ( speedMod , 5 ) , 1 ) ;
2019-08-25 16:21:07 +02:00
if ( Input . Up )
2019-08-01 22:42:35 +02:00
invadersPlayer . Y - = speedMod ;
2019-08-25 16:21:07 +02:00
if ( Input . Left )
2019-08-01 22:42:35 +02:00
invadersPlayer . X - = speedMod ;
2019-08-25 16:21:07 +02:00
if ( Input . Down )
2019-08-01 22:42:35 +02:00
invadersPlayer . Y + = speedMod ;
2019-08-25 16:21:07 +02:00
if ( Input . Right )
2019-08-01 22:42:35 +02:00
invadersPlayer . X + = speedMod ;
2019-08-25 16:21:07 +02:00
if ( Input . Action & invadersCanShoot )
2019-07-23 14:54:05 +02:00
{
2019-08-25 16:21:07 +02:00
invadersBullets . Add ( new Vector2 ( 0 , 2.5 ) + invadersPlayer ) ;
2019-07-23 14:54:05 +02:00
invadersCanShoot = false ;
2019-08-01 22:42:35 +02:00
speedMod - - ;
2019-07-23 14:54:05 +02:00
}
}
2019-08-01 22:42:35 +02:00
buffer . Render ( ) ;
buffer . Dispose ( ) ;
2019-07-23 14:54:05 +02:00
}
2019-07-27 20:57:23 +02:00
catch ( Exception ex ) { if ( ex . InnerException ? . Message = = "0717750f-3508-4bc2-841e-f3b077c676fe" ) throw new Exception ( ex . Message ) ; else Console . WriteLine ( ex . ToString ( ) ) ; }
2019-07-23 14:54:05 +02:00
}
2019-07-27 20:57:23 +02:00
public void initGame ( Graphics g , Panel minigamePanel , Timer minigameTimer )
2019-07-23 14:54:05 +02:00
{
2019-07-27 20:57:23 +02:00
invadersPlayer = new Vector2 ( minigamePanel . Width / 4 , minigamePanel . Height / 2 ) ;
invadersPlayer . bounds_wrap = true ;
invadersPlayer . bounds = new Rectangle ( - 10 , - 10 , minigamePanel . Width + 10 , minigamePanel . Height + 10 ) ;
invadersAliens = new List < Vector2 > ( ) ;
invadersBullets = new List < Vector2 > ( ) ;
minigamePrevTime = 0 ;
2019-07-23 14:54:05 +02:00
invadersCanShoot = true ;
2019-08-01 22:42:35 +02:00
speedMod = 5 ;
2019-07-23 14:54:05 +02:00
}
}
}