コード例 #1
0
        public override void Init()
        {
            int W   = D3DDevice.Instance.Width;
            int H   = D3DDevice.Instance.Height;
            int x0  = W / 2;
            int y0  = H / 2;
            int dy  = 80;
            int dy2 = dy;
            int dx  = 200;

            drawer2D = new Drawer2D();

            backgroundSprite          = new CustomSprite();
            backgroundSprite.Bitmap   = new CustomBitmap(MediaDir + "\\Bitmaps\\youWin.png", D3DDevice.Instance.Device);
            backgroundSprite.Position = new TGCVector2(W * 0.1f, H * 0.2f);
            backgroundSprite.Scaling  = new TGCVector2(1, 1);

            gui.Create(MediaDir);
            gui.InitDialog(false, false);

            //gui.InsertMenuItem(ID_CLOSE, "Cerrar", "close.png", x0, y0, MediaDir, dx, dy);
            //gui.InsertButton(ID_CLOSE, "Salir", x0 - 150, y0 + 250, dx, dy, Color.DarkRed);

            winSound.loadSound(MediaDir + "\\Sounds\\win.wav", DirectSound.DsDevice);
        }
コード例 #2
0
        public override void Init()
        {
            int W = D3DDevice.Instance.Width;
            int H = D3DDevice.Instance.Height;

            collectedItems = new List <ItemModel>();

            text          = new TgcText2D();
            text.Text     = "INVENTARIO";
            text.Color    = Color.White;
            text.Align    = TgcText2D.TextAlign.RIGHT;
            text.Position = new Point(300, 40);
            text.Size     = new Size(300, 100);
            text.changeFont(new Font("TimesNewRoman", 25, FontStyle.Bold));

            noUseShipHelmText.Text     = "Acercate a la proa";
            noUseShipHelmText.Color    = Color.Red;
            noUseShipHelmText.Align    = TgcText2D.TextAlign.RIGHT;
            noUseShipHelmText.Position = new Point((W / 2) - 180, (H / 2) - 5);
            noUseShipHelmText.Size     = new Size(300, 100);
            noUseShipHelmText.changeFont(new Font("TimesNewRoman", 14));

            gui.Create(MediaDir);
            gui.InitDialog(false, false);
        }
コード例 #3
0
        /// <summary>
        /// Dialog que muestra todas las categorias de texturas disponibles que hay.
        /// Al hacer clic te abre un segundo Dialog con las texturas dentro de esa categoria.
        /// </summary>
        public void TextureGroupDlg(DXGui gui)
        {
            // Inicio un dialogo modalless
            gui.InitDialog(false, false);

            int W = GuiController.Instance.Panel3d.Width;
            int H = GuiController.Instance.Panel3d.Height;

            int x0 = 20;
            int y0 = 50;
            int dy = 500;
            int dx = W - 40;
            int r  = 250;

            gui.InsertFrame("Seleccione la categoría", x0, y0, dx, dy, Color.FromArgb(192, 192, 192), frameBorder.redondeado);

            //int sdx = 400;
            //int sdy = 120;
            //gui.InsertKinectScrollButton(0, "scroll_left.png", x0 + 40, y0 + dy - sdy - 50, sdx, sdy);
            //gui.InsertKinectScrollButton(1, "scroll_right.png", x0 + 40 + sdx + 20, y0 + dy - sdy - 50, sdx, sdy);
            gui_item cancel_btn = gui.InsertKinectCircleButton(1, "Cancel", "cancel.png", W - gui.KINECT_BUTTON_SIZE_X - 40,
                                                               y0 + 20, gui.KINECT_BUTTON_SIZE_X);

            cancel_btn.scrolleable = false;      // fijo el boton de cancelar

            //Crear un boton por cada grupo de textura
            for (int i = 0; i < grupos.Count; i++)
            {
                Group g = grupos[i];
                gui.InsertKinectCircleButton(g.guiId, g.name, g.iconPath, x0 + 50 + i * (r + 20), y0 + 160, r);
            }
        }
コード例 #4
0
        /// <summary>
        /// Dialog que muestra todas las texturas dentro de una categoria especifica.
        /// Al seleccionar una textura la aplica a todos los mesh que tenga esa categoria
        /// </summary>
        public void TextureDlg(DXGui gui, int groupId)
        {
            // Inicio un dialogo modalless
            gui.InitDialog(false, false);

            int W = GuiController.Instance.Panel3d.Width;
            int H = GuiController.Instance.Panel3d.Height;

            int x0  = -20;
            int y0  = 0;
            int dy  = 520;
            int dx  = W + 40;
            int tdx = 250;
            int tdy = 200;

            gui.InsertFrame("Seleccione la textura", x0, y0, dx, dy, Color.FromArgb(192, 192, 192), frameBorder.sin_borde);
            int sdx = 500;
            int sdy = 120;

            gui.InsertKinectScrollButton(0, "scroll_left.png", x0 + 40, y0 + dy - sdy - 50, sdx, sdy);
            gui.InsertKinectScrollButton(1, "scroll_right.png", x0 + 40 + sdx + 20, y0 + dy - sdy - 50, sdx, sdy);
            gui_item cancel_btn = gui.InsertKinectCircleButton(1, "Cancel", "cancel.png", W - gui.KINECT_BUTTON_SIZE_X - 40,
                                                               y0 + dy - gui.KINECT_BUTTON_SIZE_X - 50, gui.KINECT_BUTTON_SIZE_X);

            cancel_btn.scrolleable = false;      // fijo el boton de cancelar

            //Buscar grupo con ese id de gui
            selectedGroup = null;
            foreach (Group g in grupos)
            {
                if (g.guiId == groupId)
                {
                    selectedGroup = g;
                    break;
                }
            }


            //Crear un boton por cada textura dentro de este grupo
            for (int i = 0; i < selectedGroup.textures.Count; i++)
            {
                Texture t = selectedGroup.textures[i];
                gui.InsertKinectTileButton(t.guiId, (i + 1).ToString(), t.path, x0 + 50 + i * (tdx + 50), y0 + 100, tdx, tdy);
            }
        }
コード例 #5
0
        public override void Init()
        {
            text = new TgcText2D();

            text.Text     = "CRAFTEO";
            text.Color    = Color.White;
            text.Align    = TgcText2D.TextAlign.RIGHT;
            text.Position = new Point(300, 40);
            text.Size     = new Size(300, 100);
            text.changeFont(new Font("TimesNewRoman", 25, FontStyle.Bold));

            gui.Create(MediaDir);
            gui.InitDialog(false, false);

            CreateInterface();

            craftSound.loadSound(MediaDir + "\\Sounds\\craft.wav", DirectSound.DsDevice);
        }
コード例 #6
0
        public override void Init()
        {
            drawer2D = new Drawer2D();

            //Crear Sprite
            backgroundSprite        = new CustomSprite();
            backgroundSprite.Bitmap = new CustomBitmap(MediaDir + "\\Bitmaps\\main3.jpg", D3DDevice.Instance.Device);

            text          = new TgcText2D();
            text.Text     = "CARIBBEAN´S DEATH";
            text.Color    = Color.Red;
            text.Align    = TgcText2D.TextAlign.RIGHT;
            text.Position = new Point(D3DDevice.Instance.Width - 500, 100);
            text.Size     = new Size(300, 100);
            text.changeFont(new Font("TimesNewRoman", 25, FontStyle.Bold | FontStyle.Italic));

            //Ubicarlo centrado en la pantalla
            var textureSize = backgroundSprite.Bitmap.Size;

            backgroundSprite.Position = new TGCVector2(0, 0);
            backgroundSprite.Scaling  = new TGCVector2(0.75f, 0.35f);

            gui.Create(MediaDir);

            // menu principal
            gui.InitDialog(false, false);
            int W   = D3DDevice.Instance.Width;
            int H   = D3DDevice.Instance.Height;
            int x0  = W - 200;
            int y0  = H - 300;
            int dy  = 80;
            int dy2 = dy;
            int dx  = 200;

            gui.InsertMenuItem(ID_NUEVA_PARTIDA, "  Jugar", "play.png", x0, y0, MediaDir, dx, dy);
            gui.InsertMenuItem(ID_CONTROLES, "  Controles", "navegar.png", x0, y0 += dy2, MediaDir, dx, dy);
            gui.InsertMenuItem(ID_APP_EXIT, "  Salir", "salir.png", x0, y0        += dy2, MediaDir, dx, dy);

            music          = new TgcMp3Player();
            music.FileName = MediaDir + "\\Sounds\\mainMenuMusic.mp3";
            music.play(true);
        }
コード例 #7
0
        public override void Init()
        {
            int W   = D3DDevice.Instance.Width;
            int H   = D3DDevice.Instance.Height;
            int x0  = W / 2;
            int y0  = H / 2;
            int dy  = 80;
            int dy2 = dy;
            int dx  = 200;

            drawer2D = new Drawer2D();

            backgroundSprite          = new CustomSprite();
            backgroundSprite.Bitmap   = new CustomBitmap(MediaDir + "\\Bitmaps\\noteView.PNG", D3DDevice.Instance.Device);
            backgroundSprite.Position = new TGCVector2(W * 0.2f, H * 0.2f);
            backgroundSprite.Scaling  = new TGCVector2(0.75f, 0.35f);

            gui.Create(MediaDir);
            gui.InitDialog(false, false);

            //gui.InsertMenuItem(ID_CLOSE, "Cerrar", "close.png", x0, y0, MediaDir, dx, dy);
            gui.InsertButton(ID_CLOSE, "Cerrar", x0 - 150, y0 + 150, dx, dy, Color.DarkRed);
        }
コード例 #8
0
ファイル: Transformers.cs プロジェクト: nicoschtein/TGC2014
        public override void init()
        {
            GuiController.Instance.CustomRenderEnabled = true;
            Cursor.Hide();

            Device d3dDevice = GuiController.Instance.D3dDevice;

            MyMediaDir  = GuiController.Instance.ExamplesDir + "Shaders\\WorkshopShaders\\Media\\";
            MyShaderDir = GuiController.Instance.ExamplesDir + "Shaders\\WorkshopShaders\\Shaders\\";

            // levanto el GUI
            gui.Create();

            // menu principal
            gui.InitDialog(false, false);
            int      W    = GuiController.Instance.Panel3d.Width;
            int      H    = GuiController.Instance.Panel3d.Height;
            int      x0   = 70;
            int      y0   = 10;
            int      dy   = 30;
            int      dy2  = dy;
            int      dx   = 250;
            gui_item item = gui.InsertImage("transformers//custom_char.png", x0, y0);

            item.image_centrada = false;
            y0 += dy;
            gui.InsertItem(new static_text(gui, "SCOUT", x0, y0, 400, 25));
            y0  += 45;
            item = gui.InsertImage("transformers//scout.png", x0 + dx, y0);
            item.image_centrada = false;
            gui.InsertItem(new menu_item(gui, "SCOUT 1", "transformers//scout1.png", ID_SCOUT, x0, y0, dx, dy));
            y0 += dy + 5;
            gui.InsertItem(new menu_item(gui, "SCOUT 2", "transformers//scout2.png", ID_SCOUT, x0, y0, dx, dy));
            y0 += 2 * dy;


            gui.InsertItem(new static_text(gui, "HUNTER", x0, y0, 400, 25));
            y0  += 45;
            item = gui.InsertImage("transformers//hunter.png", x0 + dx, y0);
            item.image_centrada = false;
            menu_item hunter1 = (menu_item)gui.InsertItem(new menu_item(gui, "HUNTER 1", "transformers//hunter1.png", ID_HUNTER, x0, y0, dx, dy));

            hunter1.pos_imagen.Y = y0;

            y0 += 2 * dy;

            gui.InsertItem(new static_text(gui, "COMMANDER", x0, y0, 400, 25));
            y0  += 45;
            item = gui.InsertImage("transformers//commander.png", x0 + dx, y0);
            item.image_centrada = false;
            menu_item commander1 = (menu_item)gui.InsertItem(new menu_item(gui, "COMMANDER 1", "transformers//commander1.png", ID_COMMANDER, x0, y0, dx, 25));

            commander1.pos_imagen.Y = y0;
            y0 += 2 * dy;

            gui.InsertItem(new static_text(gui, "WARRIOR", x0, y0, 400, 25));
            y0  += 45;
            item = gui.InsertImage("transformers//warrior.png", x0 + dx, y0);
            item.image_centrada = false;
            menu_item warrior1 = (menu_item)gui.InsertItem(new menu_item(gui, "WARRIOR 1", "transformers//warrior1.png", ID_WARRIOR, x0, y0, dx, 30));

            warrior1.pos_imagen.Y = y0;

            dialog_sel = 0;
        }
コード例 #9
0
        public override void Init()
        {
            Cursor.Hide();

            Device d3dDevice = D3DDevice.Instance.Device;

            //Cargar Shader personalizado
            string compilationErrors;

            effect = Effect.FromFile(d3dDevice, ShadersDir + "TgcViewer\\TgcSkeletalMeshShader.fx", null, null, ShaderFlags.PreferFlowControl, null, out compilationErrors);
            if (effect == null)
            {
                throw new Exception("Error al cargar shader. Errores: " + compilationErrors);
            }
            //Configurar Technique dentro del shader
            effect.Technique = "DIFFUSE_MAP";

            //Camara en primera persona
            Camara.SetCamera(new TGCVector3(0, 60, 200), new TGCVector3(0, 0, 0));

            //Cargar personaje con animaciones
            TgcSkeletalLoader skeletalLoader = new TgcSkeletalLoader();

            mesh = skeletalLoader.loadMeshAndAnimationsFromFile(MediaDir + "SkeletalAnimations\\BasicHuman\\" + "CombineSoldier-TgcSkeletalMesh.xml", MediaDir + "SkeletalAnimations\\BasicHuman\\", new string[] { MediaDir + "SkeletalAnimations\\BasicHuman\\Animations\\" + "StandBy-TgcSkeletalAnim.xml", MediaDir + "SkeletalAnimations\\BasicHuman\\Animations\\" + "Run-TgcSkeletalAnim.xml", });
            mesh.AutoTransform = true;

            //Configurar animacion inicial
            mesh.playAnimation("StandBy", true);
            mesh.Position  = new TGCVector3(0, -50, 0);
            mesh.Scale     = new TGCVector3(2f, 2f, 2f);
            mesh.Effect    = effect;
            mesh.Technique = "DIFFUSE_MAP";

            // levanto el GUI
            gui.Create(MediaDir);

            // menu principal
            gui.InitDialog(true);
            int W   = D3DDevice.Instance.Width;
            int H   = D3DDevice.Instance.Height;
            int x0  = 70;
            int y0  = 10;
            int dy  = 120;
            int dy2 = dy;
            int dx  = 400;

            gui.InsertMenuItem(ID_ABRIR_MISION, "Abrir Mision", "open.png", x0, y0, MediaDir, dx, dy);
            gui.InsertMenuItem(ID_NUEVA_MISION, "Play", "Play.png", x0, y0        += dy2, MediaDir, dx, dy);
            gui.InsertMenuItem(ID_CONFIGURAR, "Configurar", "navegar.png", x0, y0 += dy2, MediaDir, dx, dy);
            gui.InsertMenuItem(ID_APP_EXIT, "Salir", "salir.png", x0, y0          += dy2, MediaDir, dx, dy);

            // lista de colores
            lst_colores[0]  = Color.FromArgb(100, 220, 255);
            lst_colores[1]  = Color.FromArgb(100, 255, 220);
            lst_colores[2]  = Color.FromArgb(220, 100, 255);
            lst_colores[3]  = Color.FromArgb(220, 255, 100);
            lst_colores[4]  = Color.FromArgb(255, 100, 220);
            lst_colores[5]  = Color.FromArgb(255, 220, 100);
            lst_colores[6]  = Color.FromArgb(128, 128, 128);
            lst_colores[7]  = Color.FromArgb(64, 255, 64);
            lst_colores[8]  = Color.FromArgb(64, 64, 255);
            lst_colores[9]  = Color.FromArgb(255, 0, 255);
            lst_colores[10] = Color.FromArgb(255, 255, 0);
            lst_colores[11] = Color.FromArgb(0, 255, 255);
        }
コード例 #10
0
ファイル: ComboRata.cs プロジェクト: Farabute/tgc-viewer
        public override void Init()
        {
            time = 0f;
            Device d3dDevice = D3DDevice.Instance.Device;

            MyShaderDir = ShadersDir + "WorkshopShaders\\";

            //Crear loader
            TgcSceneLoader loader = new TgcSceneLoader();

            scene = loader.loadSceneFromFile(MediaDir + "WorkshopShaders\\comborata\\comborata-TgcScene.xml");

            g_pBaseTexture = TextureLoader.FromFile(d3dDevice, MediaDir + "Texturas\\rocks.jpg");
            g_pHeightmap   = TextureLoader.FromFile(d3dDevice, MediaDir + "Texturas\\NM_height_rocks.tga");

            g_pBaseTexture2 = TextureLoader.FromFile(d3dDevice, MediaDir + "Texturas\\stones.bmp");
            g_pHeightmap2   = TextureLoader.FromFile(d3dDevice, MediaDir + "Texturas\\NM_height_stones.tga");

            g_pBaseTexture3 = TextureLoader.FromFile(d3dDevice, MediaDir + "Texturas\\granito.jpg");
            g_pHeightmap3   = TextureLoader.FromFile(d3dDevice, MediaDir + "Texturas\\NM_height_saint.tga");

            g_pBaseTexture4 = TextureLoader.FromFile(d3dDevice, MediaDir + "Texturas\\granito.jpg");
            g_pHeightmap4   = TextureLoader.FromFile(d3dDevice, MediaDir + "Texturas\\NM_four_height.tga");

            foreach (TgcMesh mesh in scene.Meshes)
            {
                if (mesh.Name.Contains("Floor"))
                {
                    rooms.Add(mesh.BoundingBox);
                }
            }

            //Cargar Shader
            string compilationErrors;

            effect = Effect.FromFile(d3dDevice, MyShaderDir + "Parallax.fx", null, null, ShaderFlags.None, null, out compilationErrors);
            if (effect == null)
            {
                throw new Exception("Error al cargar shader. Errores: " + compilationErrors);
            }

            lightDirModifier       = AddVertex3f("LightDir", new TGCVector3(-1, -1, -1), new TGCVector3(1, 1, 1), TGCVector3.Down);
            minSampleModifier      = AddFloat("minSample", 1f, 10f, 10f);
            maxSampleModifier      = AddFloat("maxSample", 11f, 50f, 50f);
            heightMapScaleModifier = AddFloat("HeightMapScale", 0.001f, 0.5f, 0.1f);

            Camera = new TgcFpsCamera(new TGCVector3(147.2558f, 8.0f, 262.2509f), 100f, 10f, Input);
            Camera.SetCamera(new TGCVector3(147.2558f, 8.0f, 262.2509f), new TGCVector3(148.2558f, 8.0f, 263.2509f));

            //Cargar personaje con animaciones
            TgcSkeletalLoader skeletalLoader = new TgcSkeletalLoader();
            Random            rnd            = new Random();

            // meto un enemigo por cada cuarto
            cant_enemigos = 0;
            foreach (TgcMesh mesh in scene.Meshes)
            {
                if (mesh.Name.Contains("Floor"))
                {
                    float kx    = rnd.Next(25, 75) / 100.0f;
                    float kz    = rnd.Next(25, 75) / 100.0f;
                    float pos_x = mesh.BoundingBox.PMin.X * kx + mesh.BoundingBox.PMax.X * (1 - kx);
                    float pos_z = mesh.BoundingBox.PMin.Z * kz + mesh.BoundingBox.PMax.Z * (1 - kz);

                    TgcSkeletalMesh enemigo = skeletalLoader.loadMeshAndAnimationsFromFile(MediaDir + "SkeletalAnimations\\BasicHuman\\" + "CombineSoldier-TgcSkeletalMesh.xml", MediaDir + "SkeletalAnimations\\BasicHuman\\", new string[] { MediaDir + "SkeletalAnimations\\BasicHuman\\Animations\\" + "Walk-TgcSkeletalAnim.xml", });
                    enemigos.Add(enemigo);

                    //Configurar animacion inicial
                    enemigos[cant_enemigos].playAnimation("Walk", true);
                    enemigos[cant_enemigos].Position  = new TGCVector3(pos_x, 1f, pos_z);
                    enemigos[cant_enemigos].Scale     = new TGCVector3(0.3f, 0.3f, 0.3f);
                    enemigos[cant_enemigos].Transform = TGCMatrix.Scaling(enemigos[cant_enemigos].Scale) *
                                                        TGCMatrix.RotationYawPitchRoll(enemigos[cant_enemigos].Rotation.Y, enemigos[cant_enemigos].Rotation.X, enemigos[cant_enemigos].Rotation.Z) *
                                                        TGCMatrix.Translation(enemigos[cant_enemigos].Position);
                    enemigo_an[cant_enemigos] = 0;
                    cant_enemigos++;
                }
            }

            // levanto el GUI
            float W = D3DDevice.Instance.Width;
            float H = D3DDevice.Instance.Height;

            gui.Create(MediaDir);
            gui.InitDialog(false);
            gui.InsertFrame("Combo Rata", 10, 10, 200, 200, Color.FromArgb(32, 120, 255, 132), frameBorder.sin_borde);
            gui.InsertFrame("", 10, (int)H - 150, 200, 140, Color.FromArgb(62, 120, 132, 255), frameBorder.sin_borde);
            gui.cursor_izq = gui.cursor_der = tipoCursor.sin_cursor;

            // le cambio el font
            gui.font.Dispose();
            // Fonts
            gui.font = new Microsoft.DirectX.Direct3D.Font(d3dDevice, 12, 0, FontWeight.Bold, 0, false, CharacterSet.Default, Precision.Default, FontQuality.Default, PitchAndFamily.DefaultPitch, "Lucida Console");
            gui.font.PreloadGlyphs('0', '9');
            gui.font.PreloadGlyphs('a', 'z');
            gui.font.PreloadGlyphs('A', 'Z');

            gui.RTQ = gui.rectToQuad(0, 0, W, H, 0, 0, W - 150, 160, W - 200, H - 150, 0, H);
        }