public World(Engine engine) { _engine = engine; _mobiles = new Dictionary<Serial, Mobile>(); _items = new Dictionary<Serial, Item>(); }
private void OnLoad(object sender, RoutedEventArgs e) { if (GraphicsDeviceManager.Current.RenderMode != RenderMode.Hardware) { MessageBox.Show("Please activate enableGPUAcceleration=true on your Silverlight plugin page.", "Warning", MessageBoxButton.OK); return; } IConfigurationService configurationService = new ConfigurationService(); Tracer.TraceLevel = configurationService.GetValue<TraceLevels>(ConfigSections.Debug, ConfigKeys.DebugLogLevel); Tracer.Info("Checking for updates..."); //Application.Current.CheckAndDownloadUpdateCompleted += Current_CheckAndDownloadUpdateCompleted; //Application.Current.CheckAndDownloadUpdateAsync(); _game = new Engine(DrawingSurface); IInputService inputService = new InputService(_game); _game.Services.AddService(typeof(IConfigurationService), configurationService); _game.Services.AddService(typeof(IInputService), inputService); _game.Run(); }
public Cube(Engine engine, float size) { this.graphicsDevice = engine.GraphicsDevice; this.mySilverlightEffect = engine.Content.Load<SilverlightEffect>("CustomEffect"); // Cache effect parameters worldViewProjectionParameter = mySilverlightEffect.Parameters["WorldViewProjection"]; //lightDirectionParameter = mySilverlightEffect.Parameters["LightDirection"]; // Init static parameters //this.LightDirection = new Vector3(0, 0, 1); // Temporary lists List<VertexPositionNormalTexture> vertices = new List<VertexPositionNormalTexture>(); List<ushort> indices = new List<ushort>(); // A cube has six faces, each one pointing in a different direction. Vector3[] normals = { new Vector3(0, 0, 1), new Vector3(0, 0, -1), new Vector3(1, 0, 0), new Vector3(-1, 0, 0), new Vector3(0, 1, 0), new Vector3(0, -1, 0) }; // Create each face in turn. foreach (Vector3 normal in normals) { // Get two vectors perpendicular to the face normal and to each other. Vector3 side1 = new Vector3(normal.Y, normal.Z, normal.X); Vector3 side2 = Vector3.Cross(normal, side1); // Six indices (two triangles) per face. indices.Add((ushort)vertices.Count); indices.Add((ushort)(vertices.Count + 1)); indices.Add((ushort)(vertices.Count + 2)); indices.Add((ushort)vertices.Count); indices.Add((ushort)(vertices.Count + 2)); indices.Add((ushort)(vertices.Count + 3)); vertices.Add(new VertexPositionNormalTexture((normal - side1 - side2) * size / 2, normal, new Vector2(0, 0))); vertices.Add(new VertexPositionNormalTexture((normal - side1 + side2) * size / 2, normal, new Vector2(1, 0))); vertices.Add(new VertexPositionNormalTexture((normal + side1 + side2) * size / 2, normal, new Vector2(1, 1))); vertices.Add(new VertexPositionNormalTexture((normal + side1 - side2) * size / 2, normal, new Vector2(0, 1))); } // Create a vertex buffer, and copy our vertex data into it. vertexBuffer = new VertexBuffer(graphicsDevice, VertexPositionNormalTexture.VertexDeclaration, vertices.Count, BufferUsage.None); vertexBuffer.SetData(0, vertices.ToArray(), 0, vertices.Count, VertexPositionNormalTexture.Stride); // Create an index buffer, and copy our index data into it. indexBuffer = new IndexBuffer(graphicsDevice, IndexElementSize.SixteenBits, indices.Count, BufferUsage.None); indexBuffer.SetData(0, indices.ToArray(), 0, indices.Count); // Statistics VerticesCount = vertices.Count; FaceCount = indices.Count / 3; }
public GQuestionMenu(int serial, int menuID, string question, AnswerEntry[] answers) : base(0x23f4, Engine.ScreenWidth / 2, 100, 50, 50, true) { base.m_CanDrag = true; base.m_QuickDrag = true; this.m_Serial = serial; this.m_MenuID = menuID; GWrappedLabel toAdd = new GWrappedLabel(question, Engine.GetFont(1), Hues.Load(0x455), base.OffsetX + 4, base.OffsetY + 4, base.UseWidth - 8); base.m_Children.Add(toAdd); this.m_Entries = new GQuestionMenuEntry[answers.Length]; GBackground background = new GQuestionBackground(this.m_Entries, base.UseWidth - 8, ((base.UseHeight - 8) - toAdd.Height) - 4, base.OffsetX + 4, (toAdd.Y + toAdd.Height) + 4); background.SetMouseOverride(this); int offsetX = background.OffsetX; int offsetY = background.OffsetY; int useWidth = background.UseWidth; for (int i = 0; i < answers.Length; i++) { GQuestionMenuEntry entry = new GQuestionMenuEntry(offsetX, offsetY, useWidth, answers[i]); background.Children.Add(entry); entry.Radio.ParentOverride = background; this.m_Entries[i] = entry; offsetY += entry.Height + 4; } background.Height = ((offsetY - 4) - background.OffsetY) + (background.Height - background.UseHeight); this.Height = (((((this.Height - base.UseHeight) + 4) + toAdd.Height) + 4) + background.Height) + 4; int num5 = (int)(Engine.ScreenHeight * 0.75); if (this.Height > num5) { this.Height = num5; background.Height = ((base.UseHeight - 8) - toAdd.Height) - 4; } offsetY -= 4; offsetY -= background.OffsetY; if (offsetY > background.UseHeight) { int num6 = offsetY; background.Width += 0x13; this.Width += 0x13; offsetX = (background.OffsetX + background.UseWidth) - 15; offsetY = background.OffsetY; background.Children.Add(new GImage(0x101, offsetX, offsetY)); background.Children.Add(new GImage(0xff, offsetX, (offsetY + background.UseHeight) - 0x20)); for (int j = offsetY + 30; (j + 0x20) < background.UseHeight; j += 30) { background.Children.Add(new GImage(0x100, offsetX, j)); } this.m_Slider = new GVSlider(0xfe, offsetX + 1, (offsetY + 1) + 12, 13, (background.UseHeight - 2) - 0x18, 0.0, 0.0, (double)(num6 - background.UseHeight), 1.0); this.m_Slider.OnValueChange = new OnValueChange(this.OnScroll); this.m_Slider.ScrollOffset = 20.0; background.Children.Add(this.m_Slider); background.Children.Add(new GHotspot(offsetX, offsetY, 15, background.UseHeight, this.m_Slider)); } GButtonNew new2 = new GButtonNew(0xf3, 0xf2, 0xf1, 0, (background.Y + background.Height) + 4); GButtonNew new3 = new GButtonNew(0xf9, 0xf7, 0xf8, 0, new2.Y); new2.Clicked += new EventHandler(this.Cancel_Clicked); new3.Clicked += new EventHandler(this.Okay_Clicked); new2.X = ((base.OffsetX + base.UseWidth) - 4) - new2.Width; new3.X = (new2.X - 4) - new3.Width; base.m_Children.Add(new2); base.m_Children.Add(new3); this.Height += 4 + new2.Height; base.m_Children.Add(background); this.Center(); }
private void Button_OnClick(Gump g) { Engine.OpenBrowser(this.m_Url); m_Visited[this.m_Url] = true; base.DefaultHue = base.FocusHue = VisitedHue; }