Пример #1
0
        public override void Paint()
        {
            if (Registers.gameState == GameState.Running)
            {
                GAME_ENGINE.SetColor(200, 50, 0);

                drawHere = Utils.Lerp2D(origin, dest, curTime / 2);
                GAME_ENGINE.FillRectangle(drawHere.X, drawHere.Y, 5, 5);
                GAME_ENGINE.DrawLine(origin, new Vector2f(drawHere.X + 2.5f, drawHere.Y + 2.5f), 5f);

                //Explode when ,missile has reached its destination
                if (Utils.Distance(drawHere, dest) <= 1)
                {
                    if (targetID <= gameManager.GetBuildings().Count - 1)
                    {
                        explM = new Explosion(gameManager, enemySpawner, this, drawHere, gameManager.GetBuildings()[targetID], 0);
                    }
                    Console.WriteLine(string.Format("Explosions #{0}", gameManager.explosions.Count));
                    enemySpawner.EMissileDetonate(this);
                    Dispose();
                }
                curTime += GAME_ENGINE.GetDeltaTime() / 2.5f;

                //Destroy missile when out of screen
                if (Utils.Distance(drawHere, new Vector2f(Alignment.X.Left, Alignment.Y.Up)) <= 0 && Utils.Distance(drawHere, new Vector2f(Alignment.X.Right, Alignment.Y.Down)) <= 0)
                {
                    enemySpawner.EMissileDetonate(this);
                    Dispose();
                }
            }
        }
 public override void Paint()
 {
     if (Registers.gameState == GameState.Running)
     {
         GAME_ENGINE.SetColor(128, 0, 128);
         GAME_ENGINE.FillRectangle(rec_launcher);
         GAME_ENGINE.FillRectangle(rec_launcherBase);
         GAME_ENGINE.SetColor(0, 0, 0);
     }
 }
Пример #3
0
        public override void Paint()
        {
            if (Registers.gameState == GameState.Running)
            {
                //Type = 0, friendly missile
                //Type = 1, enemy missile
                if (type == 0)
                {
                    GAME_ENGINE.SetColor(rda.Next(0, 255), rda.Next(0, 255), rda.Next(0, 255));
                    GAME_ENGINE.FillEllipse(rec_explosion);
                }
                else
                {
#if (DEBUG)
                    GAME_ENGINE.DrawBitmap(explosion_bmp, ExplosionLocationTopLeft);
#endif
                }

                duration -= GAME_ENGINE.GetDeltaTime() * 2.4f;
                if (nukeTown != null && nuked == false)
                {
                    List <Building> checkBuildings = gm.GetBuildings();
                    for (int i = 0; i < 6; i++)
                    {
                        if (i == 5)
                        {
                            Console.WriteLine(string.Format("Size: {0}", checkBuildings.Count));
                            i = 5;
                        }
                        if (checkBuildings[i] == null)
                        {
                            continue;
                        }
                        if (Utils.Distance(new Vector2f(checkBuildings[i].GetX() + checkBuildings[i].GetWidth() * 0.5f,
                                                        checkBuildings[i].GetY() + checkBuildings[i].GetHeight()), ExplosionLocation) < 40f)
                        {
                            Console.WriteLine(string.Format("Building hit! {0}", i));
                            nukeTown.Nuke();
                            nuked = true;
                            break;
                        }
                    }
                }
                if (type == 0)
                {
                    ExplosionCollision();
                }
                if (duration <= 0f)
                {
                    Dispose();
                }
            }
        }
Пример #4
0
        public override void Paint()
        {
            if (Registers.gameState == GameState.Running)
            {
                GAME_ENGINE.SetColor(0, 255, 0);

                drawHere = Utils.Lerp2D(orgin, dest, curTime);
                GAME_ENGINE.FillRectangle(drawHere.X, drawHere.Y, 5, 5);
                GAME_ENGINE.DrawLine(orgin, drawHere);
                if (Utils.Distance(drawHere, dest) <= 1)
                {
                    explM = new Explosion(gameManager, missileLauncher, this, drawHere);
                    Console.WriteLine(string.Format("Explosions #{0}", gameManager.explosions.Count));
                    missileLauncher.MissileDetonate(this);
                    Dispose();
                }
                curTime += GAME_ENGINE.GetDeltaTime() * 2f;

                if (misLocY <= 0)
                {
                    Dispose();
                }
            }
        }
        public override void Paint()
        {
            //If there's an error don't show anything else, in any class that needs to change values each frame and other drae functions
            if (Registers.gameState != GameState.Error)
            {
                GAME_ENGINE.SetBackgroundColor(0, 0, 0);
                GAME_ENGINE.SetColor(0, 0, 0);
                if (destroyedCities == 6)
                {
                    Registers.gameState = GameState.Stopped;
                }
                if (Registers.gameState == GameState.Paused)
                {
                    //Draw pause menu
                    //DISABLED as it hasn't been completed

                    /*int h = 0;
                     * for (int ij = 0; ij < ImageData.PauseMenu.Length; ij++)
                     * {
                     *  if (ImageData.PauseMenu[ij] == 0x00)
                     *  {
                     *      GAME_ENGINE.SetColor(255, 255, 255);
                     *      //GAME_ENGINE.FillRectangle(rec_landscape);
                     *  }
                     *  else
                     *  {
                     *      try
                     *      {
                     *          //Draw pixel based on color data in array
                     *          GAME_ENGINE.SetColor(ImageData.PauseMenu[ij], ImageData.PauseMenu[ij + 1], ImageData.PauseMenu[ij + 2]);
                     *          GAME_ENGINE.FillRectangle(rec_pausemenu);
                     *      }
                     *      catch (Exception e)
                     *      {
                     *          //This should NOT trigger, unless you f*cked something up
                     *          Console.WriteLine(string.Format("Okay, you f*cked something up {0}", e));
                     *          error_reason = new Exception($" {e}, Something ran into some problems which shouldn't happen");
                     *          Registers.gameState = GameState.Error;
                     *      }
                     *  }
                     *  rec_pausemenu.X += 8;
                     *  h++;
                     *  if (h >= 40)
                     *  {
                     *      Pausemenu_line++;
                     *      rec_pausemenu.Y += PausemenuScale;
                     *      rec_pausemenu.X = Registers.ScreenWidth * 0.5f - PausemenuScale;
                     *      h = 0;
                     *  }
                     *  //Console.WriteLine(string.Format("i: {0}, h: {1}, draw X: {2}", i, h, rec_pausemenu.X));
                     *  //Skip over other color data (G & B of RGB)
                     *  ij += 2;
                     * }*/
                }
                GAME_ENGINE.SetScale(8.5f, 8);
                GAME_ENGINE.DrawBitmap(landscape_bit, new Vector2f((float)(Registers.ScreenWidth * 0.5 - landscape_bit.GetWidth() * 4 - 0.025 * Registers.ScreenWidth), (float)(Registers.ScreenHeight * 0.5 - landscape_bit.GetHeight() * 4 + 0.46 * Registers.ScreenHeight)));
                GAME_ENGINE.SetScale(1, 1);

                GAME_ENGINE.SetColor(255, 255, 255);
                if (destroyedCities == 6)
                {
                    Registers.gameState = GameState.Stopped;
                    loseFont.SetHorizontalAlignment(Font.Alignment.Center);
                    loseFontMedium.SetHorizontalAlignment(Font.Alignment.Center);
                    GAME_ENGINE.SetColor(190, 0, 0);
                    GAME_ENGINE.DrawString(loseFont, "You lose", rec_lose);
                    GAME_ENGINE.DrawString(loseFontMedium, "Press Esc to exit", rec_exitText);
                    GAME_ENGINE.SetColor(0, 0, 0);
                }

                rec_landscape.X = LandscapeX;
                rec_landscape.Y = LandscapeY;
                rec_pausemenu.X = Registers.ScreenWidth * 0.5f - PausemenuScale;
                rec_pausemenu.Y = Registers.ScreenHeight * 0.5f - PausemenuScale;
                rec_crosshair.X = Registers.CrosshairX;
                rec_crosshair.Y = Registers.CrosshairY;


                GAME_ENGINE.DrawEllipse(rec_crosshair, 2);
                return;
            }
            GAME_ENGINE.SetBackgroundColor(200, 0, 30);
            GAME_ENGINE.SetColor(255, 255, 255);
            GAME_ENGINE.DrawString(errorFontM, "An Error has occured", rec_errorM);
            if (error_reason == null)
            {
                error_reason = new Exception("Error Screen triggered");
            }
            string err = error_reason.ToString();


            //GAME_ENGINE.DrawString(errorFont, string.Format("{0}", Regex.Replace(err, err_pattern, "")), rec_error);
            GAME_ENGINE.DrawString(errorFont, string.Format("{0}", err), rec_error);
            GAME_ENGINE.SetColor(0, 0, 0);
        }
Пример #6
0
        public override void Paint()
        {
            GAME_ENGINE.SetColor(0, 0, 0);
            GAME_ENGINE.SetColor(255, 215, 80);
            GAME_ENGINE.FillRectangle(700, 150, 501, 501);
            GAME_ENGINE.SetColor(0, 0, 0);
            GAME_ENGINE.DrawRectangle(700, 150, 502, 502);
            //1,1
            GAME_ENGINE.DrawBitmap(Orb, CurrentX1_1, CurrentY1_1, 0, 0, 100, 100);
            //1,2
            GAME_ENGINE.DrawBitmap(Orb, CurrentX1_2, CurrentY1_2, 100, 0, 100, 100);
            //1,3
            GAME_ENGINE.DrawBitmap(Orb, CurrentX1_3, CurrentY1_3, 200, 0, 100, 100);
            //1,4
            GAME_ENGINE.DrawBitmap(Orb, CurrentX1_4, CurrentY1_4, 300, 0, 100, 100);
            //1,5
            GAME_ENGINE.DrawBitmap(Orb, CurrentX1_5, CurrentY1_5, 400, 0, 100, 100);
            //2,1
            GAME_ENGINE.DrawBitmap(Orb, CurrentX2_1, CurrentY2_1, 0, 100, 100, 100);
            //2,2
            GAME_ENGINE.DrawBitmap(Orb, CurrentX2_2, CurrentY2_2, 100, 100, 100, 100);
            //2,3
            GAME_ENGINE.DrawBitmap(Orb, CurrentX2_3, CurrentY2_3, 200, 100, 100, 100);
            //2,4
            GAME_ENGINE.DrawBitmap(Orb, CurrentX2_4, CurrentY2_4, 300, 100, 100, 100);
            //2,5
            GAME_ENGINE.DrawBitmap(Orb, CurrentX2_5, CurrentY2_5, 400, 100, 100, 100);
            //3,1
            GAME_ENGINE.DrawBitmap(Orb, CurrentX3_1, CurrentY3_1, 0, 200, 100, 100);
            //3,2
            GAME_ENGINE.DrawBitmap(Orb, CurrentX3_2, CurrentY3_2, 100, 200, 100, 100);
            //3,3
            GAME_ENGINE.DrawBitmap(Orb, CurrentX3_3, CurrentY3_3, 200, 200, 100, 100);
            //3,4
            GAME_ENGINE.DrawBitmap(Orb, CurrentX3_4, CurrentY3_4, 300, 200, 100, 100);
            //3,5
            GAME_ENGINE.DrawBitmap(Orb, CurrentX3_5, CurrentY3_5, 400, 200, 100, 100);
            //4,1
            GAME_ENGINE.DrawBitmap(Orb, CurrentX4_1, CurrentY4_1, 0, 300, 100, 100);
            //4,2
            GAME_ENGINE.DrawBitmap(Orb, CurrentX4_2, CurrentY4_2, 100, 300, 100, 100);
            //4,3
            GAME_ENGINE.DrawBitmap(Orb, CurrentX4_3, CurrentY4_3, 200, 300, 100, 100);
            //4,4
            GAME_ENGINE.DrawBitmap(Orb, CurrentX4_4, CurrentY4_4, 300, 300, 100, 100);
            //4,5
            GAME_ENGINE.DrawBitmap(Orb, CurrentX4_5, CurrentY4_5, 400, 300, 100, 100);
            //5,1
            GAME_ENGINE.DrawBitmap(Orb, CurrentX5_1, CurrentY5_1, 0, 400, 100, 100);
            //5,2
            GAME_ENGINE.DrawBitmap(Orb, CurrentX5_2, CurrentY5_2, 100, 400, 100, 100);
            //5,3
            GAME_ENGINE.DrawBitmap(Orb, CurrentX5_3, CurrentY5_3, 200, 400, 100, 100);
            //5,4
            GAME_ENGINE.DrawBitmap(Orb, CurrentX5_4, CurrentY5_4, 300, 400, 100, 100);
            //5,5
            GAME_ENGINE.DrawBitmap(Orb, CurrentX5_5, CurrentY5_5, 400, 400, 100, 100);

            /*
             * GAME_ENGINE.SetColor(139, 0, 0);
             * GAME_ENGINE.DrawLine(xPositie + 2, yPositie, xPositie + 10, yPositie);
             * GAME_ENGINE.DrawLine(xPositie, yPositie + 2, xPositie, yPositie + 10);
             * GAME_ENGINE.DrawLine(xPositie - 2, yPositie, xPositie - 10, yPositie);
             * GAME_ENGINE.DrawLine(xPositie, yPositie - 2, xPositie, yPositie - 10);
             * GAME_ENGINE.SetColor(0, 0, 0);
             */
        }