static void Main() { Console.SetWindowSize(80, 25); Console.SetBufferSize(80, 25); Aquarium aq = new Aquarium(); ClownFish c = new ClownFish(); c.X = 15; c.Y = 16; Trout t = new Trout(); t.X = 5; t.Y = 6; Shark s = new Shark(); s.X = 60; s.Y = 22; Rock r1 = new Rock(); r1.X = 10; r1.Y = 24; Rock r2 = new Rock(); r2.X = 40; r2.Y = 24; Coral co = new Coral(); co.X = 18; co.Y = 19; do { System.Console.Clear(); c.Swim(); t.Swim(); s.Swim(); c.Display(); t.Display(); s.Display(); co.Display(); r1.Display(); r2.Display(); System.Threading.Thread.Sleep(200); } while (true); }
public static void Main() { ConsoleKeyInfo key; bool finished = false; Fishes myFish = new Fishes(); Environment myEnv = new Environment(); Coral myCoral = new Coral(); SeaWeed myWeed = new SeaWeed(); Rocks myRock = new Rocks(); Bubbles myBubble = new Bubbles(); while (!finished) { Console.Clear(); myFish.Draw(); myFish.Move(); myEnv.Draw(); myCoral.Draw(); myWeed.Draw(); myRock.Draw(); myBubble.Draw(); Thread.Sleep(100); if (Console.KeyAvailable) { key = Console.ReadKey(); if (key.Key == ConsoleKey.Escape) { finished = true; } } } Console.Clear(); Console.SetCursorPosition(35, 12); Console.ForegroundColor = ConsoleColor.White; Console.WriteLine("Bye Bye!"); Console.ReadKey(); }
void Awake() { coralGO = GameObject.FindGameObjectWithTag("Coral"); coral = coralGO.GetComponent <Coral>(); }
/// <summary> /// Se llama una sola vez, al principio cuando se ejecuta el ejemplo. /// Escribir aquí todo el código de inicialización: cargar modelos, texturas, estructuras de optimización, todo /// procesamiento que podemos pre calcular para nuestro juego. /// Borrar el codigo ejemplo no utilizado. /// </summary> public override void Init() { //Device de DirectX para crear primitivas. var d3dDevice = D3DDevice.Instance.Device; timestamp = DateTime.Now; //Utilizando esta propiedad puedo activar el update/render a intervalos constantes. FixedTickEnable = true; //Se puede configurar el tiempo en estas propiedades TimeBetweenUpdates y TimeBetweenRenders, por defecto esta puedo en 1F / FPS_60 es a lo minimo que deberia correr el TP. //De no estar a gusto como se ejecuta el metodo Tick (el que maneja el GameLoop) el mismo es virtual con lo cual pueden sobrescribirlo. //Esconder cursor focusWindows = d3dDevice.CreationParameters.FocusWindow; mousePosition = focusWindows.PointToScreen(new Point(focusWindows.Width / 2, focusWindows.Height / 2)); //Cursor.Hide(); Sounds.SoundsManager.Instance().sound = DirectSound.DsDevice; Sounds.SoundsManager.Instance().mediaDir = MediaDir; //Burbujas D3DDevice.Instance.ParticlesEnabled = true; D3DDevice.Instance.EnableParticles(); Particulas.Init(MediaDir, 20); //Oceano Oceano.Init(TGCVector3.Up * nivelDelAgua * 0.8f, 100, 100, ShadersDir); //Settear jugador y camara FPSCamara = new FPSCamara(Camera, Input); Player = Player.Instance(); Player.SetInput(Input); Player.Init(FPSCamara); //Inicializar camara var cameraPosition = new TGCVector3(0, 100, -250); var lookAt = new TGCVector3(0, nivelDelAgua, 0); Camera.SetCamera(cameraPosition, lookAt); sonidoUnderwater = new TgcStaticSound(); sonidoUnderwater.loadSound(MediaDir + "Sounds\\mar.wav", DirectSound.DsDevice); effect = TGCShaders.Instance.LoadEffect(ShadersDir + "e_fog.fx"); efectoInterior = TGCShaders.Instance.LoadEffect(ShadersDir + "interior.fx"); //Iniciar HUD Hud.Init(MediaDir); Hud.ChangeStatus(Hud.Status.MainMenu); //Cargar enviroment oceano = new Fondo(MediaDir, ShadersDir); oceano.Init(); oceano.Camera = Camera; heightmap = new TgcSimpleTerrain(); heightmap.loadHeightmap(MediaDir + marBnwDir, marScaleXZ, marScaleY, new TGCVector3(0, marOffsetY, 0)); heightmap.loadTexture(MediaDir + marTexDir); //Cargar entidades var loader = new TgcSceneLoader(); var scene = loader.loadSceneFromFile(MediaDir + "yellow_fish-TgcScene.xml"); var mesh = scene.Meshes[0]; peces = new List <Fish>(); corales = new List <Coral>(); metales = new List <Metal>(); piedras = new List <Metal>(); int i = 0; while (i < 20) { Fish fish; string meshName = i.ToString(); fish = new Fish(mesh.clone(meshName)); fish = (Fish)setearMeshParaLista(fish, i); peces.Add(fish); fish.Effect(effect); fish.Technique("RenderScene"); i++; } scene = loader.loadSceneFromFile(MediaDir + "shark-TgcScene.xml"); mesh = scene.Meshes[0]; shark = new Shark(mesh); shark.Init(); sharkSound = new Tgc3dSound(MediaDir + "Sounds\\shark.wav", shark.GetMesh().Position, DirectSound.DsDevice); shark.setearSonido(sharkSound); shark.setearAlturaMaxima(nivelDelAgua - 19f); efectoDesaparecer = TGCShaders.Instance.LoadEffect(ShadersDir + "perlin.fx"); shark.setearEfectoPerlin(efectoDesaparecer); perlinTexture = TgcTexture.createTexture(D3DDevice.Instance.Device, MediaDir + "Textures\\perlin.png"); shark.setearPerlin(perlinTexture); scene = loader.loadSceneFromFile(MediaDir + "coral-TgcScene.xml"); mesh = scene.Meshes[0]; i = 0; while (i < 25) { Coral coral; string meshName = i.ToString(); coral = new Coral(mesh.createMeshInstance(meshName)); coral = (Coral)setearMeshParaLista(coral, i * 4, -17); corales.Add(coral); coral.Effect(effect); coral.Technique("RenderScene"); i++; } scene = loader.loadSceneFromFile(MediaDir + "Oro-TgcScene.xml"); mesh = scene.Meshes[0]; i = 0; while (i < 15) { Metal oro; string meshName = i.ToString(); oro = new Metal(mesh.createMeshInstance(meshName)); oro = (Metal)setearMeshParaLista(oro, i * 8, -17); oro.Tipo = ElementoRecolectable.oro; metales.Add(oro); oro.Effect(effect); oro.Technique("RenderSceneLight"); i++; } scene = loader.loadSceneFromFile(MediaDir + "Hierro-TgcScene.xml"); mesh = scene.Meshes[0]; i = 0; while (i < 15) { Metal hierro; string meshName = i.ToString() + i.ToString(); hierro = new Metal(mesh.createMeshInstance(meshName)); hierro = (Metal)setearMeshParaLista(hierro, (i + 10) * 8, -17); hierro.Tipo = ElementoRecolectable.hierro; metales.Add(hierro); hierro.Effect(effect); hierro.Technique("RenderScene"); i++; } scene = loader.loadSceneFromFile(MediaDir + "Roca-TgcScene.xml"); mesh = scene.Meshes[0]; i = 0; while (i < 15) { Metal roca; string meshName = i.ToString() + i.ToString() + i.ToString(); roca = new Metal(mesh.createMeshInstance(meshName)); roca = (Metal)setearMeshParaLista(roca, (i + 10) * 8, -17); roca.Tipo = ElementoRecolectable.madera; roca.escalar(new TGCVector3(0.3f, 0.3f, 0.3f)); piedras.Add(roca); roca.Effect(effect); roca.Technique("RenderScene"); i++; } scene = loader.loadSceneFromFile(MediaDir + "ship-TgcScene.xml"); nave = Nave.Instance(); nave.Init(scene, nivelDelAgua); scene = loader.loadSceneFromFile(MediaDir + "EspadaDoble-TgcScene.xml"); mesh = scene.Meshes[0]; arma = new Arma(mesh); scene = loader.loadSceneFromFile(MediaDir + "Mesa-TgcScene.xml"); mesaNave = MesaNave.Instance(); mesaNave.Init(scene); mesaNave.Effect(efectoInterior); mesaNave.Technique("RenderScene"); scene = loader.loadSceneFromFile(MediaDir + "SogaEnrollada-TgcScene.xml"); mesh = scene.Meshes[0]; sogaInterior = SogaInterior.Instance(); sogaInterior.Init(mesh); sogaInterior.Effect(efectoInterior); sogaInterior.Technique("RenderScene"); scene = loader.loadSceneFromFile(MediaDir + "silla-TgcScene.xml"); sillaInterior = SillaInterior.Instance(); sillaInterior.Init(scene); sillaInterior.Effect(efectoInterior); sillaInterior.Technique("RenderScene"); scene = loader.loadSceneFromFile(MediaDir + "Timon-TgcScene.xml"); timonInterior = TimonInterior.Instance(); timonInterior.Init(scene); timonInterior.Effect(efectoInterior); timonInterior.Technique("RenderScene"); scene = loader.loadSceneFromFile(MediaDir + "LamparaTecho-TgcScene.xml"); lamparaNave = new LamparaNave(scene.Meshes[0]); lamparaNave.Effect(efectoInterior); lamparaNave.Technique("RenderScene"); //Cargar shaders fog = new TgcFog(); fog.Color = Color.FromArgb(30, 144, 255); fog.Density = 1; fog.EndDistance = 1000; fog.StartDistance = 1; fog.Enabled = true; effect.SetValue("screen_dx", d3dDevice.PresentationParameters.BackBufferWidth); effect.SetValue("screen_dy", d3dDevice.PresentationParameters.BackBufferHeight); //Fog + Lights effect.SetValue("nivelAgua", nivelDelAgua); interiorNave = InteriorNave.Instance(); interiorNave.Init(MediaDir); DirectSound.ListenerTracking = Player.Instance().mesh; //Mascara post process maskTexture = TgcTexture.createTexture(D3DDevice.Instance.Device, MediaDir + "Textures\\mascara.png"); effect.SetValue("textura_mascara", maskTexture.D3dTexture); // seteamos los efectos aca porque son fijos oceano.Effect(effect); oceano.Technique("RenderScene"); heightmap.Effect = effect; heightmap.Technique = "RenderScene"; shark.Effect(effect); shark.Technique("RenderScene"); nave.Effect(effect); nave.Technique("RenderSceneLight"); effect.SetValue("ambientColor", Color.FromArgb(255, 255, 255).ToArgb()); effect.SetValue("diffuseColor", Color.FromArgb(255, 255, 255).ToArgb()); effect.SetValue("specularColor", Color.FromArgb(255, 255, 255).ToArgb()); efectoInterior.SetValue("ambientColor", Color.FromArgb(255, 255, 255).ToArgb()); efectoInterior.SetValue("diffuseColor", Color.FromArgb(255, 255, 255).ToArgb()); efectoInterior.SetValue("specularColor", Color.FromArgb(255, 255, 255).ToArgb()); // dibujo el full screen 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 fullScreenQuad = new VertexBuffer(typeof(CustomVertex.PositionTextured), 4, d3dDevice, Usage.Dynamic | Usage.WriteOnly, CustomVertex.PositionTextured.Format, Pool.Default); fullScreenQuad.SetData(vertices, 0, LockFlags.None); // dibujo render target depthStencil = d3dDevice.CreateDepthStencilSurface(d3dDevice.PresentationParameters.BackBufferWidth, d3dDevice.PresentationParameters.BackBufferHeight, DepthFormat.D24S8, MultiSampleType.None, 0, true); renderTarget = new Texture(d3dDevice, d3dDevice.PresentationParameters.BackBufferWidth, d3dDevice.PresentationParameters.BackBufferHeight, 1, Usage.RenderTarget, Format.X8R8G8B8, Pool.Default); // inicializo los FB que uso para el Bloom coralesBrillantes = new Texture(d3dDevice, d3dDevice.PresentationParameters.BackBufferWidth, d3dDevice.PresentationParameters.BackBufferHeight, 1, Usage.RenderTarget, Format.X8R8G8B8, Pool.Default); FBHorizontalBool = new Texture(d3dDevice, d3dDevice.PresentationParameters.BackBufferWidth, d3dDevice.PresentationParameters.BackBufferHeight, 1, Usage.RenderTarget, Format.X8R8G8B8, Pool.Default); FBVerticalBloom = new Texture(d3dDevice, d3dDevice.PresentationParameters.BackBufferWidth, d3dDevice.PresentationParameters.BackBufferHeight, 1, Usage.RenderTarget, Format.X8R8G8B8, Pool.Default); }