示例#1
0
        public void Init()
        {
            var d3dDevice = D3DDevice.Instance.Device;

            drawer2D = new Drawer2D();

            #region configurarSprites

            CustomSprite sprite = new CustomSprite();
            sprite.Bitmap = new CustomBitmap(GameModel.mediaDir + "\\sprites\\emoji.png", D3DDevice.Instance.Device);
            var textureSize = sprite.Bitmap.Size;
            sprite.Position = new TGCVector2(FastMath.Max(D3DDevice.Instance.Width - textureSize.Width / 0.75f, 0), 0);
            sprites.Add(sprite);

            CustomSprite plantas = new CustomSprite();
            plantas.Bitmap   = new CustomBitmap(GameModel.mediaDir + "\\sprites\\PLANTAS.png", D3DDevice.Instance.Device);
            textureSize      = plantas.Bitmap.Size;
            plantas.Position = new TGCVector2(0, FastMath.Max(D3DDevice.Instance.Height - textureSize.Height, 0));
            sprites.Add(plantas);

            CustomSprite girasol = new CustomSprite();
            girasol.Bitmap   = new CustomBitmap(GameModel.mediaDir + "\\sprites\\girasol.png", D3DDevice.Instance.Device);
            girasol.Position = new TGCVector2(30, 30);
            sprites.Add(girasol);

            CustomSprite zombie = new CustomSprite();
            zombie.Bitmap   = new CustomBitmap(GameModel.mediaDir + "\\sprites\\zombie.png", D3DDevice.Instance.Device);
            zombie.Position = new TGCVector2(30, 100);
            sprites.Add(zombie);

            GOD.Bitmap   = new CustomBitmap(GameModel.mediaDir + "\\sprites\\GOD.png", D3DDevice.Instance.Device);
            GOD.Position = new TGCVector2(FastMath.Max(D3DDevice.Instance.Width - 60, 0), 0);
            #endregion

            #region texto
            //Crear texto 2, especificando color, alineacion, posicion, tamano y fuente.
            soles          = new TgcText2D();
            soles.Text     = "" + GameLogic.cantidadEnergia;
            soles.Color    = Color.GreenYellow;
            soles.Align    = TgcText2D.TextAlign.LEFT;
            soles.Position = new Point(100, 40);
            soles.Size     = new Size(100, 10);
            soles.changeFont(new Font("Console", 25, FontStyle.Bold | FontStyle.Italic));


            zombies          = new TgcText2D();
            zombies.Text     = "" + GameLogic.cantidadZombiesMuertos;
            zombies.Color    = Color.LawnGreen;
            zombies.Align    = TgcText2D.TextAlign.LEFT;
            zombies.Position = new Point(100, 110);
            zombies.Size     = new Size(100, 10);
            zombies.changeFont(new Font("Console", 25, FontStyle.Bold | FontStyle.Italic));
            #endregion
        }
        public static void Init(string mediaDir)
        {
            WIDTH  = D3DDevice.Instance.Width;
            HEIGHT = D3DDevice.Instance.Height;

            MediaDir = mediaDir;

            InventoryItems    = new List <ItemSprite>();
            CraftingItems     = new List <ItemSprite>();
            SelectedItemIndex = 0;


            sonido = new TgcStaticSound();
            sonido.loadSound(SoundsManager.Instance().mediaDir + "Sounds\\grab.wav", SoundsManager.Instance().sound);

            drawer = new Drawer2D();

            //Main Menu
            Logo        = new CustomSprite();
            Logo.Bitmap = new CustomBitmap(MediaDir + "logo_subnautica.png", D3DDevice.Instance.Device);
            var spriteSize = Logo.Bitmap.Size;

            Logo.Position = new TGCVector2(WIDTH / 2 - spriteSize.Width / 2, Round(HEIGHT * 0.2f) - spriteSize.Height / 2);

            Start          = new TgcText2D();
            Start.Text     = "Start";
            Start.Align    = TgcText2D.TextAlign.LEFT;
            Start.Position = new Point(Round(WIDTH * 0.45f), Round(HEIGHT * 0.7f));
            Start.Size     = new Size(300, 100);
            Start.changeFont(new Font("Calibri", 35, FontStyle.Bold));
            Start.Color = Color.White;

            Instruccion          = new TgcText2D();
            Instruccion.Text     = "Instructions";
            Instruccion.Align    = TgcText2D.TextAlign.LEFT;
            Instruccion.Position = new Point(Round(WIDTH * 0.45f), Round(HEIGHT * 0.75f));
            Instruccion.Size     = new Size(300, 100);
            Instruccion.changeFont(new Font("Calibri", 35, FontStyle.Bold));
            Instruccion.Color = Color.White;

            Exit          = new TgcText2D();
            Exit.Text     = "Exit";
            Exit.Align    = TgcText2D.TextAlign.LEFT;
            Exit.Position = new Point(Round(WIDTH * 0.45f), Round(HEIGHT * 0.8f));
            Exit.Size     = new Size(300, 100);
            Exit.changeFont(new Font("Calibri", 35, FontStyle.Bold));
            Exit.Color = Color.White;


            instrucciones = new List <TgcText2D>();

            TgcText2D instruccionesItem = new TgcText2D();

            instruccionesItem.Text     = "- Press A S D W to move";
            instruccionesItem.Align    = TgcText2D.TextAlign.LEFT;
            instruccionesItem.Position = new Point(Round(WIDTH * 0.2f), Round(HEIGHT * 0.4f));
            instruccionesItem.Size     = new Size(WIDTH - 200, 100);
            instruccionesItem.changeFont(new Font("Calibri", 25, FontStyle.Bold));
            instruccionesItem.Color = Color.White;
            instrucciones.Add(instruccionesItem);

            instruccionesItem          = new TgcText2D();
            instruccionesItem.Text     = "- Press O to go inside/outside the ship";
            instruccionesItem.Align    = TgcText2D.TextAlign.LEFT;
            instruccionesItem.Position = new Point(Round(WIDTH * 0.2f), Round(HEIGHT * 0.45f));
            instruccionesItem.Size     = new Size(WIDTH - 200, 100);
            instruccionesItem.changeFont(new Font("Calibri", 25, FontStyle.Bold));
            instruccionesItem.Color = Color.White;
            instrucciones.Add(instruccionesItem);

            instruccionesItem          = new TgcText2D();
            instruccionesItem.Text     = "- Press I to show/hide the inventory";
            instruccionesItem.Align    = TgcText2D.TextAlign.LEFT;
            instruccionesItem.Position = new Point(Round(WIDTH * 0.2f), Round(HEIGHT * 0.5f));
            instruccionesItem.Size     = new Size(WIDTH - 200, 100);
            instruccionesItem.changeFont(new Font("Calibri", 25, FontStyle.Bold));
            instruccionesItem.Color = Color.White;
            instrucciones.Add(instruccionesItem);

            instruccionesItem          = new TgcText2D();
            instruccionesItem.Text     = "- Press P to enter developer mode";
            instruccionesItem.Align    = TgcText2D.TextAlign.LEFT;
            instruccionesItem.Position = new Point(Round(WIDTH * 0.2f), Round(HEIGHT * 0.55f));
            instruccionesItem.Size     = new Size(WIDTH - 200, 100);
            instruccionesItem.changeFont(new Font("Calibri", 25, FontStyle.Bold));
            instruccionesItem.Color = Color.White;
            instrucciones.Add(instruccionesItem);

            instruccionesItem          = new TgcText2D();
            instruccionesItem.Text     = "- Collect as many items as you can by clicking on them";
            instruccionesItem.Align    = TgcText2D.TextAlign.LEFT;
            instruccionesItem.Position = new Point(Round(WIDTH * 0.2f), Round(HEIGHT * 0.6f));
            instruccionesItem.Size     = new Size(WIDTH - 200, 100);
            instruccionesItem.changeFont(new Font("Calibri", 25, FontStyle.Bold));
            instruccionesItem.Color = Color.White;
            instrucciones.Add(instruccionesItem);

            instruccionesItem          = new TgcText2D();
            instruccionesItem.Text     = "- Be careful with the shark! In order to kill it, you must have a weapon";
            instruccionesItem.Align    = TgcText2D.TextAlign.LEFT;
            instruccionesItem.Position = new Point(Round(WIDTH * 0.2f), Round(HEIGHT * 0.65f));
            instruccionesItem.Size     = new Size(WIDTH - 200, 100);
            instruccionesItem.changeFont(new Font("Calibri", 25, FontStyle.Bold));
            instruccionesItem.Color = Color.White;
            instrucciones.Add(instruccionesItem);

            instruccionesItem          = new TgcText2D();
            instruccionesItem.Text     = "- To get a weapon, go to the inventory and trade it for items";
            instruccionesItem.Align    = TgcText2D.TextAlign.LEFT;
            instruccionesItem.Position = new Point(Round(WIDTH * 0.2f), Round(HEIGHT * 0.7f));
            instruccionesItem.Size     = new Size(WIDTH - 200, 100);
            instruccionesItem.changeFont(new Font("Calibri", 25, FontStyle.Bold));
            instruccionesItem.Color = Color.White;
            instrucciones.Add(instruccionesItem);

            instruccionesItem          = new TgcText2D();
            instruccionesItem.Text     = "- To recover oxygen, go inside the ship or the ocean's surface";
            instruccionesItem.Align    = TgcText2D.TextAlign.LEFT;
            instruccionesItem.Position = new Point(Round(WIDTH * 0.2f), Round(HEIGHT * 0.75f));
            instruccionesItem.Size     = new Size(WIDTH - 200, 100);
            instruccionesItem.changeFont(new Font("Calibri", 25, FontStyle.Bold));
            instruccionesItem.Color = Color.White;
            instrucciones.Add(instruccionesItem);

            instruccionesItem          = new TgcText2D();
            instruccionesItem.Text     = "Press Enter to go back to the menu";
            instruccionesItem.Align    = TgcText2D.TextAlign.LEFT;
            instruccionesItem.Position = new Point(Round(WIDTH * 0.2f), Round(HEIGHT * 0.8f));
            instruccionesItem.Size     = new Size(WIDTH - 200, 100);
            instruccionesItem.changeFont(new Font("Calibri", 25, FontStyle.Bold));
            instruccionesItem.Color = Color.White;
            instrucciones.Add(instruccionesItem);

            SelectedText = Start;

            //Gameplay
            HealthBar          = new CustomSprite();
            HealthBar.Bitmap   = new CustomBitmap(MediaDir + "bar_health.png", D3DDevice.Instance.Device);
            spriteSize         = HealthBar.Bitmap.Size;
            HealthBar.Position = new TGCVector2(WIDTH / 2 - spriteSize.Width / 2, Round(HEIGHT * 0.85f));

            OxygenBar          = new CustomSprite();
            OxygenBar.Bitmap   = new CustomBitmap(MediaDir + "bar_oxygen.png", D3DDevice.Instance.Device);
            OxygenBar.Position = HealthBar.Position + new TGCVector2(0, 25 + spriteSize.Height);



            //Inventory
            OverlayInv          = new CustomSprite();
            OverlayInv.Bitmap   = new CustomBitmap(MediaDir + "overlay_inv.png", D3DDevice.Instance.Device);
            spriteSize          = OverlayInv.Bitmap.Size;
            OverlayInv.Position = new TGCVector2(WIDTH / 2 - spriteSize.Width / 2, HEIGHT / 2 - spriteSize.Height / 2);

            //Load item background preset to be used on every item sprite
            ItemBackgroundPreset        = new CustomSprite();
            ItemBackgroundPreset.Bitmap = new CustomBitmap(MediaDir + "item_placeholder2.png", D3DDevice.Instance.Device);
            spriteSize = ItemBackgroundPreset.Bitmap.Size;

            //10 items per line
            for (int j = 1; j <= MAX_INVENTORY_ITEMS / 10; j++)
            {
                for (int i = 0; i <= 9; i++)
                {
                    var item = new ItemSprite();

                    item.background        = new CustomSprite();
                    item.background.Bitmap = ItemBackgroundPreset.Bitmap;
                    var xoffset = 45 + i * spriteSize.Width * 1.5f;
                    var yoffset = 25 + j * spriteSize.Height * 1.5f;
                    item.background.Position = OverlayInv.Position + new TGCVector2(xoffset, yoffset);
                    item.background.Color    = Color.CadetBlue;

                    item.amount       = new TgcText2D();
                    item.amount.Align = TgcText2D.TextAlign.LEFT;
                    item.amount.Text  = "";
                    var xpos = Round(item.background.Position.X + spriteSize.Width / 3);
                    var ypos = Round(item.background.Position.Y + spriteSize.Height / 2);
                    item.amount.Position = new Point(xpos, ypos);
                    item.amount.Size     = new Size(50, 15);
                    item.amount.changeFont(new Font("Calibri", 15, FontStyle.Bold));
                    item.amount.Color = Color.White;

                    item.icon          = new CustomSprite();
                    item.icon.Position = item.background.Position;

                    InventoryItems.Add(item);
                }
            }

            //Crafting
            OverlayCraft          = new CustomSprite();
            OverlayCraft.Bitmap   = new CustomBitmap(MediaDir + "overlay_craft.png", D3DDevice.Instance.Device);
            OverlayCraft.Position = OverlayInv.Position;

            for (int i = 0; i < MAX_CRAFTING_ITEMS; i++)
            {
                var item = new ItemSprite();

                item.background        = new CustomSprite();
                item.background.Bitmap = ItemBackgroundPreset.Bitmap;
                var xoffset = 45 + i * spriteSize.Width * 1.5f;
                var yoffset = Round(OverlayCraft.Bitmap.Size.Height * 0.8f);
                item.background.Position = OverlayCraft.Position + new TGCVector2(xoffset, yoffset);
                item.background.Color    = Color.CadetBlue;

                item.amount      = new TgcText2D();
                item.amount.Text = "";

                item.icon          = new CustomSprite();
                item.icon.Position = item.background.Position;

                CraftingItems.Add(item);
            }


            //GameOver
            GameOver          = new TgcText2D();
            GameOver.Text     = "GAME OVER";
            GameOver.Align    = TgcText2D.TextAlign.LEFT;
            GameOver.Position = new Point(Round(WIDTH * 0.28f), Round(HEIGHT * 0.4f));
            GameOver.Size     = new Size(750, 500);
            GameOver.changeFont(new Font("Calibri", 100, FontStyle.Bold));
            GameOver.Color = Color.Red;

            GameOverSubtitle          = new TgcText2D();
            GameOverSubtitle.Text     = "Press Enter to exit";
            GameOverSubtitle.Align    = TgcText2D.TextAlign.LEFT;
            GameOverSubtitle.Position = new Point(Round(WIDTH * 0.4f), Round(HEIGHT * 0.7f));
            GameOverSubtitle.Size     = new Size(350, 200);
            GameOverSubtitle.changeFont(new Font("Calibri", 30, FontStyle.Bold));
            GameOverSubtitle.Color = Color.Red;


            //Win
            YouWin          = new TgcText2D();
            YouWin.Text     = "YOU WIN!";
            YouWin.Align    = TgcText2D.TextAlign.LEFT;
            YouWin.Position = new Point(Round(WIDTH * 0.3f), Round(HEIGHT * 0.4f));
            YouWin.Size     = new Size(750, 500);
            YouWin.changeFont(new Font("Calibri", 100, FontStyle.Bold));
            YouWin.Color = Color.Green;

            YouWinSubtitle          = new TgcText2D();
            YouWinSubtitle.Text     = "Press Enter to exit";
            YouWinSubtitle.Align    = TgcText2D.TextAlign.LEFT;
            YouWinSubtitle.Position = new Point(Round(WIDTH * 0.4f), Round(HEIGHT * 0.7f));
            YouWinSubtitle.Size     = new Size(350, 200);
            YouWinSubtitle.changeFont(new Font("Calibri", 30, FontStyle.Bold));
            YouWinSubtitle.Color = Color.Green;
        }
示例#3
0
 /// <summary>
 ///     Draws a sprite on the screen.
 /// </summary>
 /// <param name="sprite">The sprite.</param>
 public void DrawSprite(CustomSprite sprite)
 {
     DxSprite.Transform = sprite.TransformationMatrix.ToMatrix();
     DxSprite.Draw(sprite.Bitmap.D3dTexture, sprite.SrcRect, TGCVector3.Empty, TGCVector3.Empty, sprite.Color);
 }