public EscenarioCamino(GameModel contexto, Personaje personaje) : base(contexto, personaje, 0, 0) { }
public GUI(String mediaDir, D3DDevice device, Player player, GameModel gameModel) { Device = device; Player1 = player; gameModelInstance = gameModel; gameOverSpriteLocation = mediaDir + "2d\\gui\\gameover.png"; drawer = new Drawer2D(); statusBarContent = new Dictionary <StatusBarElements, TgcText2D>(); //armo sprite de selección Vector2 scaling = new Vector2(0.35f, 0.35f); itemSelectionSprite = null; itemSelectionSprite = new CustomSprite(); itemSelectionSprite.Bitmap = new CustomBitmap(mediaDir + "2d\\gui\\items\\selection.png", Device.Device); itemSelectionSprite.Scaling = scaling; itemCombinationSprite = null; itemCombinationSprite = new CustomSprite(); itemCombinationSprite.Bitmap = new CustomBitmap(mediaDir + "2d\\gui\\items\\combination.png", Device.Device); itemCombinationSprite.Scaling = scaling; itemEquippedSprite = null; itemEquippedSprite = new CustomSprite(); itemEquippedSprite.Bitmap = new CustomBitmap(mediaDir + "2d\\gui\\items\\equipped.png", Device.Device); itemEquippedSprite.Scaling = scaling; //creo sprites para cada tipo de objeto foreach (InventoryObject.ObjectTypes type in Enum.GetValues(typeof(InventoryObject.ObjectTypes))) { CustomSprite sprite = null; sprite = new CustomSprite(); sprite.Bitmap = new CustomBitmap(mediaDir + "2d\\gui\\items\\" + type.ToString() + ".png", Device.Device); sprite.Scaling = scaling; //agrego objetos a la lista InventorySprites.Add(type, sprite); } //creo sprites para cada tipo de clima foreach (World.Weather weather in Enum.GetValues(typeof(World.Weather))) { CustomSprite sprite = null; sprite = new CustomSprite(); sprite.Bitmap = new CustomBitmap(mediaDir + "2d\\gui\\weather_" + weather.ToString() + ".png", Device.Device); sprite.Scaling = new Vector2(0.35f, 0.35f); //agrego objetos a la lista WeatherSprites.Add(weather, sprite); } //fecha y hora //contabilizo texto fps usedSpace += (int)(DefaultFontSize * 1.1f); dayTime = GameUtils.createText("", 0, usedSpace); //barras de status hpBarSprite = new CustomSprite(); hpBarSprite.Bitmap = new CustomBitmap(mediaDir + "2d\\gui\\hp-bar.png", Device.Device); hpBarSprite.Position = new Vector2(Device.Width - (hpBarSprite.Bitmap.Width * hpBarSprite.Scaling.X), Device.Height - (hpBarSprite.Bitmap.Height * 1.05f)); hpBarFrameSprite = new CustomSprite(); hpBarFrameSprite.Bitmap = new CustomBitmap(mediaDir + "2d\\gui\\frame-hp-bar.png", Device.Device); hpBarFrameSprite.Position = new Vector2(Device.Width - (hpBarSprite.Bitmap.Width * hpBarSprite.Scaling.X), Device.Height - (hpBarSprite.Bitmap.Height * 1.05f)); hungerBarSprite = new CustomSprite(); hungerBarSprite.Bitmap = new CustomBitmap(mediaDir + "2d\\gui\\hunger-bar.png", Device.Device); hungerBarSprite.Position = new Vector2(Device.Width - (hungerBarSprite.Bitmap.Width * hungerBarSprite.Scaling.X), hpBarSprite.Position.Y - (hungerBarSprite.Bitmap.Height * 1.05f)); hungerBarFrameSprite = new CustomSprite(); hungerBarFrameSprite.Bitmap = new CustomBitmap(mediaDir + "2d\\gui\\frame-hunger-bar.png", Device.Device); hungerBarFrameSprite.Position = new Vector2(Device.Width - (hungerBarSprite.Bitmap.Width * hungerBarSprite.Scaling.X), hpBarSprite.Position.Y - (hungerBarSprite.Bitmap.Height * 1.05f)); thirstBarSprite = new CustomSprite(); thirstBarSprite.Bitmap = new CustomBitmap(mediaDir + "2d\\gui\\thirst-bar.png", Device.Device); thirstBarSprite.Position = new Vector2(Device.Width - (thirstBarSprite.Bitmap.Width * thirstBarSprite.Scaling.X), hungerBarSprite.Position.Y - (thirstBarSprite.Bitmap.Height * 1.05f)); thirstBarFrameSprite = new CustomSprite(); thirstBarFrameSprite.Bitmap = new CustomBitmap(mediaDir + "2d\\gui\\frame-thirst-bar.png", Device.Device); thirstBarFrameSprite.Position = new Vector2(Device.Width - (thirstBarSprite.Bitmap.Width * thirstBarSprite.Scaling.X), hungerBarSprite.Position.Y - (thirstBarSprite.Bitmap.Height * 1.05f)); staminaBarSprite = new CustomSprite(); staminaBarSprite.Bitmap = new CustomBitmap(mediaDir + "2d\\gui\\stamina-bar.png", Device.Device); staminaBarSprite.Position = new Vector2(Device.Width - (staminaBarSprite.Bitmap.Width * staminaBarSprite.Scaling.X), thirstBarSprite.Position.Y - (staminaBarSprite.Bitmap.Height * 1.05f)); staminaBarFrameSprite = new CustomSprite(); staminaBarFrameSprite.Bitmap = new CustomBitmap(mediaDir + "2d\\gui\\frame-stamina-bar.png", Device.Device); staminaBarFrameSprite.Position = new Vector2(Device.Width - (staminaBarSprite.Bitmap.Width * staminaBarSprite.Scaling.X), thirstBarSprite.Position.Y - (staminaBarSprite.Bitmap.Height * 1.05f)); foreach (World.Weather weather in Enum.GetValues(typeof(World.Weather))) { CustomSprite sprite = WeatherSprites[weather]; sprite.Position = new Vector2(Device.Width - sprite.Bitmap.Width / 2.5f, staminaBarSprite.Position.Y - (sprite.Bitmap.Height)); } }
public Sombras(GameModel gameModel) { MyShaderDir = gameModel.ShadersDir; this.gameModel = gameModel; }
//public void Update(float[] eyePosition) //{ // effect.SetValue("fvEyePosition", eyePosition); //} public void Init(GameModel model, Device device) { this.d3dDevice = device; this.gameModel = model; #region configurarEfecto string compilationErrors; effect = Effect.FromFile(d3dDevice, GameModel.shadersDir + "PostProcess.fx", null, null, ShaderFlags.PreferFlowControl, null, out compilationErrors); Console.WriteLine(compilationErrors); effect.Technique = "DefaultTechnique"; #endregion depthStencil = d3dDevice.CreateDepthStencilSurface(d3dDevice.PresentationParameters.BackBufferWidth, d3dDevice.PresentationParameters.BackBufferHeight, DepthFormat.D24S8, MultiSampleType.None, 0, true); #region inicializarRenderTargets renderTarget = new Texture(d3dDevice, d3dDevice.PresentationParameters.BackBufferWidth , d3dDevice.PresentationParameters.BackBufferHeight, 1, Usage.RenderTarget, Format.X8R8G8B8, Pool.Default); renderTarget4 = new Texture(d3dDevice, d3dDevice.PresentationParameters.BackBufferWidth / 4 , d3dDevice.PresentationParameters.BackBufferHeight / 4, 1, Usage.RenderTarget, Format.X8R8G8B8, Pool.Default); renderTargetGlow = new Texture(d3dDevice, d3dDevice.PresentationParameters.BackBufferWidth / 4 , d3dDevice.PresentationParameters.BackBufferHeight / 4, 1, Usage.RenderTarget, Format.X8R8G8B8, Pool.Default); #endregion #region setEffectValues effect.SetValue("g_RenderTarget", renderTarget); // Resolucion de pantalla effect.SetValue("screen_dx", d3dDevice.PresentationParameters.BackBufferWidth); effect.SetValue("screen_dy", d3dDevice.PresentationParameters.BackBufferHeight); #endregion #region inicializarVertexBuffer //Creamos un FullScreen Quad CustomVertex.PositionTextured[] vertices = { new CustomVertex.PositionTextured(-1, 1, 1, 0, 0), new CustomVertex.PositionTextured(1, 1, 1, 1, 0), new CustomVertex.PositionTextured(-1, -1, 1, 0, 1), new CustomVertex.PositionTextured(1, -1, 1, 1, 1) }; //vertex buffer de los triangulos vertexBuffer = new VertexBuffer(typeof(CustomVertex.PositionTextured), 4, d3dDevice, Usage.Dynamic | Usage.WriteOnly, CustomVertex.PositionTextured.Format, Pool.Default); vertexBuffer.SetData(vertices, 0, LockFlags.None); #endregion #region shadowMap shadowTex = new Texture(D3DDevice.Instance.Device, SHADOWMAP_SIZE, SHADOWMAP_SIZE, 1, Usage.RenderTarget, Format.R32F, Pool.Default); stencilBuff = D3DDevice.Instance.Device.CreateDepthStencilSurface(SHADOWMAP_SIZE, SHADOWMAP_SIZE, DepthFormat.D24S8, MultiSampleType.None, 0, true); var aspectRatio = D3DDevice.Instance.AspectRatio; projMatrix = TGCMatrix.PerspectiveFovLH(Geometry.DegreeToRadian(80), aspectRatio, 50, 5000); D3DDevice.Instance.Device.Transform.Projection = TGCMatrix.PerspectiveFovLH(Geometry.DegreeToRadian(45.0f), aspectRatio, near_plane, far_plane).ToMatrix(); #endregion #region light lightPos = new TGCVector3(760, 520, 60); lightDir = TGCVector3.Empty - lightPos; lightDir.Normalize(); lightView = TGCMatrix.LookAtLH(lightPos, lightPos + lightDir, new TGCVector3(0, 0, 1)); #endregion }
public void Init(GameModel gameModel) { GModel = gameModel; var pisoTextura = TgcTexture.createTexture(D3DDevice.Instance.Device, GModel.MediaDir + "Texturas\\largerblock3b3dim.jpg"); var planeSize = new TGCVector3(500, 0, 500); var pisoOrientacion = TgcPlane.Orientations.XZplane; var texturaTipo1 = TgcTexture.createTexture(D3DDevice.Instance.Device, GModel.MediaDir + "\\Texturas\\blocks9.jpg"); var boxSize = new TGCVector3(20, 150, 500); var boxSize2 = new TGCVector3(500, 150, 20); pared1 = new List <TGCBox>(); pared2 = new List <TGCBox>(); piso = new List <TgcPlane>(); aabbDelEscenario = new List <TgcBoundingAxisAlignBox>(); plataformasDelEscenario = new List <TgcBoundingAxisAlignBox>(); desplazamientosDePlataformasDelEscenario = new List <TGCVector3>(); pilares = new List <TgcMesh>(); muebles = new List <TgcMesh>(); //--------------piso for (var i = 0; i < 8; i++) { var plane = new TgcPlane(new TGCVector3(0, 0, planeSize.Z * i), planeSize, pisoOrientacion, pisoTextura); piso.Add(plane); } for (var i = 9; i < 12; i++) { var plane = new TgcPlane(new TGCVector3(0, 0, planeSize.Z * i), planeSize, pisoOrientacion, pisoTextura); piso.Add(plane); } for (var i = 13; i < 16; i++) { var plane = new TgcPlane(new TGCVector3(0, 0, planeSize.Z * i), planeSize, pisoOrientacion, pisoTextura); piso.Add(plane); } for (var i = 2; i < 4; i++) { var plane = new TgcPlane(new TGCVector3(planeSize.X * i, 0, /*planeSize.Z * i*/ 8000), planeSize, pisoOrientacion, pisoTextura); piso.Add(plane); } //---------pared1 for (var i = 0; i < 8; i++) { var center = new TGCVector3(0, boxSize.Y / 2, (boxSize.Z / 2) + boxSize.Z * i); var box = TGCBox.fromSize(center, boxSize, texturaTipo1); box.AutoTransform = true; pared1.Add(box); aabbDelEscenario.Add(box.BoundingBox); } for (var i = 9; i < 12; i++) { var center = new TGCVector3(0, boxSize.Y / 2, (boxSize.Z / 2) + boxSize.Z * i); var box = TGCBox.fromSize(center, boxSize, texturaTipo1); box.AutoTransform = true; pared1.Add(box); aabbDelEscenario.Add(box.BoundingBox); } for (var i = 12; i < 17; i++) { var center = new TGCVector3(0, boxSize.Y / 2, (boxSize.Z / 2) + boxSize.Z * i); var box = TGCBox.fromSize(center, boxSize, texturaTipo1); box.AutoTransform = true; pared1.Add(box); aabbDelEscenario.Add(box.BoundingBox); } for (var i = 0; i < 4; i++) { var center = new TGCVector3((planeSize.X / 2) + boxSize2.X * i, boxSize2.Y / 2, 8500 /*(boxSize.Z / 2) + boxSize.Z * i*/); var box = TGCBox.fromSize(center, boxSize2, texturaTipo1); box.AutoTransform = true; pared1.Add(box); aabbDelEscenario.Add(box.BoundingBox); } //------pared2 for (var i = 0; i < 8; i++) { var center = new TGCVector3(planeSize.X, boxSize.Y / 2, (boxSize.Z / 2) + boxSize.Z * i); var box = TGCBox.fromSize(center, boxSize, texturaTipo1); box.AutoTransform = true; pared2.Add(box); aabbDelEscenario.Add(box.BoundingBox); } for (var i = 8; i < 12; i++) { var center = new TGCVector3(planeSize.X, boxSize.Y / 2, (boxSize.Z / 2) + boxSize.Z * i); var box = TGCBox.fromSize(center, boxSize, texturaTipo1); box.AutoTransform = true; pared2.Add(box); aabbDelEscenario.Add(box.BoundingBox); } for (var i = 12; i < 16; i++) { var center = new TGCVector3(planeSize.X, boxSize.Y / 2, (boxSize.Z / 2) + boxSize.Z * i); var box = TGCBox.fromSize(center, boxSize, texturaTipo1); box.AutoTransform = true; pared2.Add(box); aabbDelEscenario.Add(box.BoundingBox); } for (var i = 1; i < 4; i++) { var center = new TGCVector3((planeSize.X / 2) + boxSize2.X * i, boxSize2.Y / 2, 8000 /*(boxSize.Z / 2) + boxSize.Z * i*/); var box = TGCBox.fromSize(center, boxSize2, texturaTipo1); box.AutoTransform = true; pared1.Add(box); aabbDelEscenario.Add(box.BoundingBox); } //------------objetos estaticos---------------------------- //---------- var texturaCaja = TgcTexture.createTexture(D3DDevice.Instance.Device, GModel.MediaDir + "\\Texturas\\cajaMadera4.jpg"); var sizeCaja = new TGCVector3(50, 50, 50); caja1 = TGCBox.fromSize(new TGCVector3(35, sizeCaja.Y / 2, 150), sizeCaja, texturaCaja); caja1.AutoTransform = true; aabbDelEscenario.Add(caja1.BoundingBox); caja2 = TGCBox.fromSize(new TGCVector3(465, sizeCaja.Y / 2, 2300), sizeCaja, texturaCaja); caja2.AutoTransform = true; aabbDelEscenario.Add(caja2.BoundingBox); //------------objetos con matrices de movimiento---------------------------- var centro = new TGCVector3(0f, 0f, 0f); var tamanio = new TGCVector3(5f, 5f, 5f); //Caja con movimiento en Y caja3 = TGCBox.fromSize(centro, tamanio, texturaCaja); caja3.AutoTransform = false; plataformasDelEscenario.Add(caja3.BoundingBox); //Caja con movimiento en X caja4 = TGCBox.fromSize(centro, tamanio, texturaCaja); caja4.AutoTransform = false; plataformasDelEscenario.Add(caja4.BoundingBox); //Caja con movimiento circular sobre el eje Y caja5 = TGCBox.fromSize(centro, tamanio, texturaCaja); caja5.AutoTransform = false; plataformasDelEscenario.Add(caja5.BoundingBox); //---------------------Otros objetos var loader = new TgcSceneLoader(); var sceneBarril = loader.loadSceneFromFile(GModel.MediaDir + "\\MeshCreator\\Meshes\\Objetos\\BarrilPolvora\\BarrilPolvora-TgcScene.xml"); barril1 = sceneBarril.Meshes[0]; barril1.AutoTransform = true; barril1.Position = new TGCVector3(100, 0, 300); aabbDelEscenario.Add(barril1.BoundingBox); var sceneCalabera = loader.loadSceneFromFile(GModel.MediaDir + "\\MeshCreator\\Meshes\\Esqueletos\\Calabera\\Calabera-TgcScene.xml"); var sceneEsqueleto = loader.loadSceneFromFile(GModel.MediaDir + "\\MeshCreator\\Meshes\\Esqueletos\\EsqueletoHumano\\Esqueleto-TgcScene.xml"); calabera = sceneCalabera.Meshes[0]; calabera.AutoTransform = true; calabera.Position = new TGCVector3(400, 0, 1000); aabbDelEscenario.Add(calabera.BoundingBox); esqueleto = sceneEsqueleto.Meshes[0]; esqueleto.AutoTransform = true; esqueleto.Position = new TGCVector3(25, 0, 1600); aabbDelEscenario.Add(esqueleto.BoundingBox); for (var i = 1; i < 8; i++) { var scenePilar = loader.loadSceneFromFile(GModel.MediaDir + "\\MeshCreator\\Meshes\\Cimientos\\PilarEgipcio\\PilarEgipcio-TgcScene.xml"); pilar = scenePilar.Meshes[0]; pilar.Position = new TGCVector3(35, 0, planeSize.Z * i); pilar.Scale = new TGCVector3(2f, 2f, 2f); pilar.AutoTransform = true; pilares.Add(pilar); aabbDelEscenario.Add(pilar.BoundingBox); } for (var i = 1; i < 8; i++) { var scenePilar = loader.loadSceneFromFile(GModel.MediaDir + "\\MeshCreator\\Meshes\\Cimientos\\PilarEgipcio\\PilarEgipcio-TgcScene.xml"); pilar = scenePilar.Meshes[0]; pilar.Position = new TGCVector3(465, 0, planeSize.Z * i); pilar.Scale = new TGCVector3(2f, 2f, 2f); pilar.AutoTransform = true; pilares.Add(pilar); aabbDelEscenario.Add(pilar.BoundingBox); } for (var i = 1; i < 7; i++) { var sceneMesaLuz = loader.loadSceneFromFile(GModel.MediaDir + "\\MeshCreator\\Meshes\\Muebles\\MesaDeLuz\\MesaDeLuz-TgcScene.xml"); mueble1 = sceneMesaLuz.Meshes[0]; if ((i % 2) == 0) { mueble1.Position = new TGCVector3(465, 0, 575 * i); mueble1.RotateY(FastMath.PI_HALF); } else { mueble1.Position = new TGCVector3(35, 0, 575 * i); mueble1.RotateY(-FastMath.PI_HALF); } mueble1.AutoTransform = true; muebles.Add(mueble1); aabbDelEscenario.Add(mueble1.BoundingBox); } var scenePilar2 = loader.loadSceneFromFile(GModel.MediaDir + "\\MeshCreator\\Meshes\\Cimientos\\PilarEgipcio\\PilarEgipcio-TgcScene.xml"); pilarCaido1 = scenePilar2.Meshes[0]; pilarCaido1.AutoTransform = false; aabbDelEscenario.Add(pilarCaido1.BoundingBox); pilarCaido1.Transform = TGCMatrix.RotationYawPitchRoll(0f, 0f, 1.5f) * TGCMatrix.Translation(120f, 10f, 1330f) * TGCMatrix.Scaling(3f, 1.2f, 1.2f); pilarCaido1.BoundingBox.transform(TGCMatrix.RotationYawPitchRoll(0f, 0f, 1.5f) * TGCMatrix.Translation(120f, 10f, 1330f) * TGCMatrix.Scaling(3f, 1.2f, 1.2f));//TGCMatrix.Scaling(6f, 0.5f, 1f)); //* TGCMatrix.RotationYawPitchRoll(0f, 0f, 1f)); var scenePilar3 = loader.loadSceneFromFile(GModel.MediaDir + "\\MeshCreator\\Meshes\\Cimientos\\PilarEgipcio\\PilarEgipcio-TgcScene.xml"); pilarCaido2 = scenePilar3.Meshes[0]; pilarCaido2.AutoTransform = false; aabbDelEscenario.Add(pilarCaido2.BoundingBox); pilarCaido2.Transform = TGCMatrix.RotationYawPitchRoll(0f, 0f, 1.5f) * TGCMatrix.Translation(120f, 10f, 2330f) * TGCMatrix.Scaling(3f, 1.2f, 1.2f); pilarCaido2.BoundingBox.transform(TGCMatrix.RotationYawPitchRoll(0f, 0f, 1.5f) * TGCMatrix.Translation(120f, 10f, 2330f) * TGCMatrix.Scaling(3f, 1.2f, 1.2f));//TGCMatrix.Scaling(6f, 0.5f, 1f)); //* TGCMatrix.RotationYawPitchRoll(0f, 0f, 1f)); //-------------------------------------------------- //---------plataformas var texturaPlataforma = TgcTexture.createTexture(D3DDevice.Instance.Device, GModel.MediaDir + "Texturas\\BM_DiffuseMap_pared.jpg"); var plataformaSize = new TGCVector3(100f, 20f, 100f); plaFija1 = TGCBox.fromSize(new TGCVector3(0, 0, 0), plataformaSize, texturaPlataforma); aabbDelEscenario.Add(plaFija1.BoundingBox); plaFija2 = TGCBox.fromSize(new TGCVector3(0, 0, 0), plataformaSize, texturaPlataforma); aabbDelEscenario.Add(plaFija2.BoundingBox); plaFija3 = TGCBox.fromSize(new TGCVector3(0, 0, 0), plataformaSize, texturaPlataforma); aabbDelEscenario.Add(plaFija3.BoundingBox); plaFija4 = TGCBox.fromSize(new TGCVector3(0, 0, 0), plataformaSize, texturaPlataforma); aabbDelEscenario.Add(plaFija4.BoundingBox); plaFija5 = TGCBox.fromSize(new TGCVector3(0, 0, 0), plataformaSize, texturaPlataforma); aabbDelEscenario.Add(plaFija5.BoundingBox); plaMovil1 = TGCBox.fromSize(new TGCVector3(0f, 0f, 0f), plataformaSize, texturaPlataforma); plaMovil1.AutoTransform = false; aabbDelEscenario.Add(plaMovil1.BoundingBox); //Matrices para el manejo de cajas escalaBaseParaCajas = TGCMatrix.Scaling(10f, 10f, 10f); var ajusteAlturaDelCentro = caja3.Size.Y / 2; posicionamientoCaja3 = TGCMatrix.Translation(20, ajusteAlturaDelCentro, 20); posicionamientoCaja4 = TGCMatrix.Translation(30, ajusteAlturaDelCentro, 30); pivoteCaja5 = TGCMatrix.Translation(30, ajusteAlturaDelCentro, 60); radioCaja5 = TGCMatrix.Translation(0, 0, 5); //Matrices para el manejo de plataformas posicionamientoPla1 = TGCMatrix.Translation(250, -10, 500 * 8 + 500 / 2); posicionamientoPla2 = TGCMatrix.Translation(150, -10, 500 * 16 + 500 / 2); posicionamientoPla3 = TGCMatrix.Translation(400, -10, 500 * 16 + 300); posicionamientoPla4 = TGCMatrix.Translation(650, -10, 500 * 16 + 500 / 2); posicionamientoPla5 = TGCMatrix.Translation(900, -10, 500 * 16 + 500 / 2); posPlaMovil1 = TGCMatrix.Translation(250, -10, 500 * 12 + plaMovil1.Size.Z / 2); //Asumo el orden en el que fueron agregadas desplazamientoCaja3 = new TGCVector3(0, 1, 0); desplazamientoCaja4 = new TGCVector3(1, 0, 0); desplazamientoCaja5 = new TGCVector3(0, 1, 0); //En principio pensamos en tener una lista de matricesDePlataformasDelEscenario pero //Al pasar las matrices no logramos lo esperado desplazamientosDePlataformasDelEscenario.Add(desplazamientoCaja3); //caja3 desplazamientosDePlataformasDelEscenario.Add(desplazamientoCaja4); //caja4 desplazamientosDePlataformasDelEscenario.Add(desplazamientoCaja5); //caja5 tiempoDeSubida = 5f; //Equivalente a 5 segundos? tiempoDeMovLateral = 10f; subir = true; //La caja empieza subiendo movLateral = true; rotacionTotal = 0f; //----------musica musicaFondo = new TgcMp3Player(); musicaFondo.FileName = GModel.MediaDir + "\\Sound\\LavTown.mp3"; musicaFondo.play(true); }
public Nota(TgcMesh mesh, GameModel gameModel) { this.mesh = mesh; this.gameModel = gameModel; }
public Plataforma(TGCVector3 posicionInicial, TgcMesh mesh, GameModel Context) : base(posicionInicial, mesh, Context) { this.transformacion = TGCMatrix.Zero; }
public void MoverPersonaje(char key, float elapsedTime, TgcD3dInput input, GameModel gameModel) { MovementSpeed = 800.0f; var movimiento = TGCVector3.Empty; var posicionOriginal = this.Position; var moving = false; var estoyFlotando = false; var adelante = false; var lateral = false; float rotY1 = input.XposRelative * 5 * elapsedTime; float rotX1 = input.YposRelative * 5 * elapsedTime; anguloAbsolutoEnY -= rotY1; anguloAbsolutoEnX += rotX1; if (key == key_forward) { movimiento.Z = -1; moving = true; adelante = true; } if (key == key_left) { movimiento.X = 1; moving = true; lateral = true; } if (key == key_back) { movimiento.Z = 1; moving = true; adelante = true; } if (key == key_right) { movimiento.X = -1; moving = true; lateral = true; } if (moving) { this.posicionAnterior = this.Position; var lastPos = meshPersonaje.Position; //movimiento *= MovementSpeed * elapsedTime; //meshPersonaje.Position = meshPersonaje.Position + movimiento; float MovimientoDelPersonaje = 0; if (adelante) { MovimientoDelPersonaje = (-1) * movimiento.Z * MovementSpeed; avanzarYretroceder(elapsedTime, MovimientoDelPersonaje, anguloAbsolutoEnY); } if (lateral) { MovimientoDelPersonaje = -1 * movimiento.X * MovementSpeed; DesplazamientoLateral(elapsedTime, MovimientoDelPersonaje, anguloAbsolutoEnY); } //RecalcularForward(); //en este metodo hay que poner bien forward y se soluciona el shader meshPersonaje.updateBoundingBox(); //COLISIONES bool chocaron = gameModel.escenario.tgcScene.Meshes.Any(mesh => TgcCollisionUtils.testAABBAABB(mesh.BoundingBox, meshPersonaje.BoundingBox)); if (chocaron) { meshPersonaje.Position = lastPos; var escalera = gameModel.escenario.tgcScene.Meshes.Find(mesh => mesh.Name.Contains("Escalera")); this.chocandoConEscalera = TgcCollisionUtils.testAABBAABB(escalera.BoundingBox, meshPersonaje.BoundingBox); } bool chocoConMonster = TgcCollisionUtils.testAABBAABB(gameModel.monster.ghost.BoundingBox, meshPersonaje.BoundingBox); if (chocoConMonster) { meshPersonaje.Position = lastPos; } if (!chocoConMonster && !chocaron) { vectorDeMovemiento = movimiento; } bool chocoConParedInvisible = TgcCollisionUtils.testAABBAABB(gameModel.paredInvisible.paredInvisible.BoundingBox, meshPersonaje.BoundingBox); if (chocoConParedInvisible) { meshPersonaje.Position = lastPos; } reproducirCaminata(); transformarMesh(); // Hace el mesh transform this.Position = meshPersonaje.Position; } //en este metodo hay que poner bien forward y se soluciona el shader eye = this.Position; target = puntoDemira(anguloAbsolutoEnY, anguloAbsolutoEnX);//movimiento; RecalcularForward(); //Hacer que la camara siga al personaje en su nueva posicion //camaraInterna.Target = this.Position; this.SetCamera(eye, target); }
public MonsterBlur(Escenario nuestra_scene, GameModel modelo) { escenario = nuestra_scene; gameModel = modelo; }
//public abstract TgcMesh Mesh(); protected Colisionable(GameModel Context) { this.Context = Context; }