public static void Update() { Time.time += (uint)Time.delta; Characters.Update(); Time.delta = 0; Sun.Draw(); App.ColorizeLabels(); }
public void Draw(SpriteBatch spriteBatch) { sky.Draw(spriteBatch); stars.Draw(spriteBatch); moon.Draw(spriteBatch); sun.Draw(spriteBatch); clouds.Draw(spriteBatch); }
public void Draw(Vector2 CamSpot, float zoom) { //Draw the sun if (Vector2.Distance(CamSpot, ConvertUnits.ToDisplayUnits(Sun.Body.Position)) < _spriteBatch.GraphicsDevice.Viewport.Width + drawRad * 1 / zoom) { Sun.Draw(_spriteBatch); } // Draw all of the planets in the system for (int i = 0; i < planetList.Count; i++) { p = planetList[i]; if (Vector2.Distance(CamSpot, ConvertUnits.ToDisplayUnits(p.body.Position)) < _spriteBatch.GraphicsDevice.Viewport.Width + drawRad * 1 / zoom) { _spriteBatch.Draw(p.baseTexture, ConvertUnits.ToDisplayUnits(p.pos), null, Color.White, 0, new Vector2(p.baseTexture.Width / 2, p.baseTexture.Height / 2), p.scale, SpriteEffects.None, 0.9f); _spriteBatch.Draw(p.shadowTexture, ConvertUnits.ToDisplayUnits(p.pos), null, Color.White, p.angle, new Vector2(p.shadowTexture.Width / 2, p.shadowTexture.Height / 2), p.scale, SpriteEffects.None, 0.89f); } for (int n = 0; n < p.moonList.Count; n++) { m = p.moonList[n]; if (Vector2.Distance(CamSpot, ConvertUnits.ToDisplayUnits(m.body.Position)) < _spriteBatch.GraphicsDevice.Viewport.Width + drawRad * 1 / zoom) { _spriteBatch.Draw(m.baseTexture, ConvertUnits.ToDisplayUnits(m.pos), null, Color.White, 0, new Vector2(m.baseTexture.Width / 2, m.baseTexture.Height / 2), m.scale, SpriteEffects.None, 0.9f); if (m.moon) // If you're not a port, draw me a shadow! { _spriteBatch.Draw(m.shadowTexture, ConvertUnits.ToDisplayUnits(m.pos), null, Color.White, p.angle, new Vector2(m.shadowTexture.Width / 2, m.shadowTexture.Height / 2), m.scale, SpriteEffects.None, 0.89f); } p.moonList[n] = m; } } planetList[i] = p; } }
public MainWindow() { InitializeComponent(); App = this; Console.WriteLine("Moving to draw map..."); MapInfo.Update(); Console.WriteLine("Map is drawn..."); Sun.Draw(); Events.Start.Load(); Test(); }
public void Draw(GameTime gameTime, GraphicsDevice gDevice, SpriteBatch sBatch) { gDevice.Clear(Color.SkyBlue); //Set some draw things gDevice.DepthStencilState = DepthStencilState.None; gDevice.BlendState = BlendState.AlphaBlend; gDevice.SamplerStates[0] = SamplerState.PointWrap; gDevice.DepthStencilState = new DepthStencilState { StencilEnable = true, StencilFunction = CompareFunction.GreaterEqual, ReferenceStencil = 254, DepthBufferEnable = true }; if (_gamemanager.Pbag.WireMode) { gDevice.RasterizerState = _wired; } else { gDevice.RasterizerState = _solid; } foreach (Chunk c in Chunks) { c.Draw(gDevice); } //After the blocks make sure fillmode = solid once again gDevice.RasterizerState = _solid; //Draw the other players foreach (ClientPlayer dummy in Playerlist.Values) { dummy.Draw(Player.Cam.View, Player.Cam.Projection); } //Draw our beautifull sky _sun.Draw(gDevice); _moon.Draw(gDevice); }
/// <summary>Renders the specified sun.</summary> /// <param name="component">The component.</param> /// <param name="transform">The transform.</param> /// <param name="translation">The translation.</param> private void RenderSun(SunRenderer component, Matrix transform, FarPosition translation) { // Get absolute position of sun. var position = ((ITransform)Manager.GetComponent(component.Entity, TransformTypeId)).Position; // Apply transformation. _sun.Center = (Vector2)FarUnitConversion.ToScreenUnits(position + translation); _sun.SetTransform(transform); _sun.Color = component.Tint; // Set remaining parameters for draw. _sun.SetSize(component.Radius * 2); _sun.SurfaceRotation = component.SurfaceRotation; _sun.PrimaryTurbulenceRotation = component.PrimaryTurbulenceRotation; _sun.SecondaryTurbulenceRotation = component.SecondaryTurbulenceRotation; // And draw it. _sun.Draw(); }
public override void Draw(Graphics g) { if (backgroundImage != null) { g.DrawImage(backgroundImage, -(int)(MyAPI.GamePanelX * 1.0), 0, 1400, 600); } for (int i = 0; i < plants.Count; i++) { Plant p = (Plant)plants[i]; p.Draw(g); } for (int i = 0; i < zombies.Count; i++) { Zombie zombie = (Zombie)zombies[i]; zombie.Draw(g); } for (int i = 0; i < cleaners.Count; i++) { Cleaner c = (Cleaner)cleaners[i]; c.Draw(g); } for (int i = 0; i < plantscards.Count; i++) { PlantCard pc = (PlantCard)plantscards[i]; pc.Draw(g); } for (int i = 0; i < bullets.Count; i++) { //Bullet b = (Bullet)bullets[i]; ((Bullet)bullets[i]).Draw(g); } for (int i = 0; i < suns.Count; i++) { Sun sun = (Sun)suns[i]; sun.Draw(g); } if (pb.IsAcitive != false) { pb.Draw(g); } if (shovel != null) { shovel.Draw(g); } if (sunBoard != null) { sunBoard.Draw(g); } if (noticeImage != null) { g.DrawImage(noticeImage, 900 / 2 - noticeImage.Width / 2 + 120, 600 / 2 - noticeImage.Height / 2, noticeImage.Width, noticeImage.Height); } //绘制介绍区域 //if (isIntroduce) //{ // showIntroduce(g); //} }
private void Button_Click(object sender, RoutedEventArgs e) { Time.time += Time.day * 14; Sun.Draw(); }
// interactive stuffs private void MapMouseDrag(object sender, MouseEventArgs e) { if (MapInfo.DoDrag && MapInfo.CanDrag) { bool doupdate = false; Vec deltamouse = MapInfo.OldMousePos - new Vec() { e.GetPosition(map).X, e.GetPosition(map).Y }; Areas.TotalDistance += deltamouse.Mag; Time.delta = (deltamouse.Mag * MapInfo.MoveRate); Time.time += (uint)Time.delta; MapInfo.position = MapInfo.position + deltamouse; if (MapInfo.position[0] < -100) { MapInfo.position[0] += 200; MapInfo.chunkpos[0] -= 1; doupdate = true; } if (MapInfo.position[0] > 100) { MapInfo.position[0] -= 200; MapInfo.chunkpos[0] += 1; doupdate = true; } if (MapInfo.position[1] < -100) { MapInfo.position[1] += 200; MapInfo.chunkpos[1] -= 1; doupdate = true; } if (MapInfo.position[1] > 100) { MapInfo.position[1] -= 200; MapInfo.chunkpos[1] += 1; doupdate = true; } if (doupdate) { MapInfo.DoDrag = false; MapInfo.Update(); } MapInfo.MoveUpdate(); Areas.Load(MapInfo.CurrBiome); TransformGroup group = new TransformGroup(); group.Children.Add(new TranslateTransform(-MapInfo.position[0], -MapInfo.position[1])); map.RenderTransform = group; Characters.Update(); Sun.Draw(); double shortest_dist = double.MaxValue; for (int i = -1; i <= 1; i++) { for (int j = -1; j <= 1; j++) { try { foreach (Bases.Base checking in Bases.BaseList[(int)MapInfo.chunkpos[0] + i, (int)MapInfo.chunkpos[1] + j]) { Vec temp = MapInfo.position + new Vec() { 100, 100 } -(checking.pos + new Vec() { 200 * i, 200 * j }); double dist = temp * temp; if (dist <= shortest_dist) { shortest_dist = dist; Bases.NearestBase = checking; } } } catch { } } } Bases.Base temp_base = Bases.SelectedBase; if (Bases.NearestBase.distance_to <= 50) { Bases.SelectedBase = Bases.NearestBase; } else { Bases.SelectedBase = null; } if (temp_base != Bases.SelectedBase) { MapInfo.Update(); } } }