コード例 #1
0
 protected Player()
 {
     walking = new TgcStaticSound();
     walking.loadSound(SoundsManager.Instance().mediaDir + "Sounds\\walking.wav", SoundsManager.Instance().sound);
     colision = new TgcStaticSound();
     colision.loadSound(SoundsManager.Instance().mediaDir + "Sounds\\colision.wav", SoundsManager.Instance().sound);
     gameOver = new TgcStaticSound();
     gameOver.loadSound(SoundsManager.Instance().mediaDir + "Sounds\\gameover.wav", SoundsManager.Instance().sound);
 }
コード例 #2
0
 public Shark(TgcMesh mesh) : base(mesh, meshLookDir)
 {
     this.vida = 500;
     necesitaArmaParaInteractuar = true;
     agarrarEfecto = new TgcStaticSound();
     agarrarEfecto.loadSound(SoundsManager.Instance().mediaDir + "Sounds\\stab.wav", SoundsManager.Instance().sound);
     soundWin = new TgcStaticSound();
     soundWin.loadSound(SoundsManager.Instance().mediaDir + "Sounds\\win.wav", SoundsManager.Instance().sound);
 }
コード例 #3
0
 public Entity(TgcMesh mesh, TGCVector3 defaultLookDir)
 {
     if (!necesitaArmaParaInteractuar)
     {
         agarrarEfecto = new TgcStaticSound();
         agarrarEfecto.loadSound(SoundsManager.Instance().mediaDir + "Sounds\\grab.wav", SoundsManager.Instance().sound);
     }
     this.mesh           = mesh;
     this.defaultLookDir = defaultLookDir;
 }
コード例 #4
0
        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;
        }