/// <summary> /// Loads this scene node from a given binary reader. /// </summary> /// <param name="reader">Binary reader to load this scene node from.</param> public override void Load(BinaryReader reader) { // Load all the basic entity details. base.Load(reader); // Load all the camera specific details. _viewport.X = reader.ReadInt16(); _viewport.Y = reader.ReadInt16(); _viewport.Width = reader.ReadInt16(); _viewport.Height = reader.ReadInt16(); _boundingRectangle.Width = _viewport.Width; _boundingRectangle.Height = _viewport.Height; _clearColor = reader.ReadInt32(); _zoom = reader.ReadSingle(); if (reader.ReadBoolean() == true) { string imageUrl = reader.ReadString(); int cellWidth = reader.ReadInt32(); int cellHeight = reader.ReadInt32(); int hSpacing = reader.ReadInt16(); int vSpacing = reader.ReadInt16(); if (ResourceManager.ResourceExists(imageUrl) == true) { _backgroundImage = GraphicsManager.LoadImage(imageUrl, cellWidth, cellHeight, hSpacing, vSpacing, 0); } } }
/// <summary> /// A WalkWith Effect /// </summary> /// <param name="img1">First Image</param> /// <param name="img2">Second Image</param> /// <param name="vect1">Return Vector For The First Image</param> /// <param name="vect2">Return Vector For The Second Image</param> public static void WalkWith(Graphics.Image img1, Graphics.Image img2, ref Vector2 vect1, ref Vector2 vect2) { Vector2 velocity = Velocity(img1, img2); vect1 = (-velocity); vect2 = (velocity); }
/// <summary> /// A Half Bouncing Effect /// </summary> /// <param name="img1">First Image</param> /// <param name="img2">Second Image</param> /// <param name="vect1">Return Vector For The First Image</param> /// <param name="vect2">Return Vector For The Second Image</param> public static void HalfBounce(Graphics.Image img1, Graphics.Image img2, ref Vector2 vect1, ref Vector2 vect2) { Vector2 velocity = Velocity(img1, img2); vect1 = new Vector2(0, 0); vect2 = (-velocity); }
/// <summary> /// Initialize The Effect /// </summary> /// <param name="graphics">XNA GraphicsDevice Reference</param> /// <param name="txt">The Text To Scroll</param> public void Initialize(GraphicsDeviceManager graphics, Graphics.TextWriter txt) { enable = true; reclimite = new Rectangle(graphics.GraphicsDevice.Viewport.X, graphics.GraphicsDevice.Viewport.Y, graphics.GraphicsDevice.Viewport.Width, graphics.GraphicsDevice.Viewport.Height); this.txt = txt; this.img = null; speed = new Vector2(1f); }
/// <summary> /// Initialize The Effect /// </summary> /// <param name="rec">The Rectangle Where The Effect Will Happen</param> /// <param name="txt">The Text To Scroll</param> public void Initialize(Rectangle rec, Graphics.TextWriter txt) { enable = true; reclimite = rec; this.txt = txt; this.img = null; speed = new Vector2(1f); }
/// <summary> /// Get Randomize Velocity Effects /// </summary> /// <param name="img1">First Image</param> /// <param name="img2">Second Image</param> /// <param name="vect1">Return Vector For The First Image</param> /// <param name="vect2">Return Vector For The Second Image</param> public static void RandomVelocityEffects(Graphics.Image img1, Graphics.Image img2, ref Vector2 vect1, ref Vector2 vect2) { Vector2 velocity = Velocity(img1, img2); Random rnd = new Random(DateTime.Now.Millisecond); vect1 = (velocity * rnd.Next(-1, 1)); vect2 = (velocity * rnd.Next(-1, 1)); }
/// <summary> /// Initialize The Effect /// </summary> /// <param name="rec">The Rectangle Where The Effect Will Happen</param> /// <param name="img">The Image To Scroll</param> public void Initialize(Rectangle rec, Graphics.Image img) { enable = true; reclimite = rec; this.img = img; txt = null; speed = new Vector2(1f); }
/// <summary> /// Entry point for the font loading thread. /// </summary> private void LoadFont() { lock (_fontLock) { _font = GraphicsManager.LoadFont(_loadFontUrl); _fontImage = GraphicsManager.LoadImage(_font.NormalImage.URL, 0); } _loadFontThread = null; }
/// <summary> /// Check For A Potential Collision /// </summary> /// <param name="img1">The First Image To Check</param> /// <param name="img2">The Second Image To Check</param> /// <returns>Return True If The Two Image Are In Collision)</returns> public static bool IsCollid(Graphics.Image img1, Graphics.Image img2) { Rectangle rec = Intersection(img1, img2); Rectangle rec1, rec2; rec1 = Normalize(new Rectangle((int)img1.Position.X, (int)img1.Position.Y, (int)(img1.Size.X + img1.Position.X), (int)(img1.Size.Y + img1.Position.Y)), rec); rec2 = Normalize(new Rectangle((int)img2.Position.X, (int)img2.Position.Y, (int)(img2.Size.X + img2.Position.X), (int)(img2.Size.Y + img2.Position.Y)), rec); return(TestCollision(img1.Texture, rec1, img2.Texture, rec2)); }
/// <summary> /// Calculate a Velocity Vector /// </summary> /// <param name="img1">First Image</param> /// <param name="img2">Second Image</param> /// <returns></returns> public static Vector2 Velocity(Graphics.Image img1, Graphics.Image img2) { Vector2 center1 = new Vector2((img1.Position.X + img1.Size.X) / 2, (img1.Position.Y + img1.Size.Y) / 2); Vector2 center2 = new Vector2((img2.Position.X + img2.Size.X) / 2, (img2.Position.Y + img2.Size.Y) / 2); Vector2 velocity = center1 - center2; velocity.Normalize(); return(velocity); }
/// <summary> /// Optimize Drawing Of The Image /// </summary> /// <param name="img">Image To Optimize</param> public static void DrawElement(Graphics.Image img) { if ((img.Position.X <= graphics.Viewport.Width) && (img.Position.Y <= graphics.Viewport.Height) && (img.Position.X + img.Size.X >= graphics.Viewport.X) && (img.Position.Y + img.Size.Y >= graphics.Viewport.Y)) { img.Draw(); } }
/// <summary> /// Calculate The Intersection Rectangle Of Two Images /// </summary> /// <param name="img1"></param> /// <param name="img2"></param> /// <returns>Return The Intersection Rectangle Of Two Images</returns> public static Rectangle Intersection(Graphics.Image img1, Graphics.Image img2) { int x1 = Math.Max((int)img1.Position.X, (int)img2.Position.X); int y1 = Math.Max((int)img1.Position.Y, (int)img2.Position.Y); int x2 = Math.Min((int)(img1.Position.X + img1.Size.X), (int)(img2.Position.X + img2.Size.X)); int y2 = Math.Min((int)(img1.Position.Y + img1.Size.Y), (int)(img2.Position.Y + img2.Size.Y)); if ((x2 >= x1) && (y2 >= y1)) { return(new Rectangle(x1, y1, x2 - x1, y2 - y1)); } return(Rectangle.Empty); }
/// <summary> /// Initialize The Map /// </summary> /// <param name="mapsize">Map Size</param> public void Initialize(Vector2 mapsize) { this.mapsize = mapsize;//nombre d'image Fields = new Graphics.Image [(int)mapsize.X, (int)mapsize.Y]; for (int i = 0; i < mapsize.X; i++) { for (int j = 0; j < mapsize.Y; j++) { Fields[i, j] = new Graphics.Image(); } } size.X = Screen.Width / mapsize.X;//taille d'une image size.Y = Screen.Height / mapsize.Y; }
/// <summary> /// Called when the visibility of this window is changed. /// </summary> /// <param name="sender">Recent file menu that caused this event.</param> /// <param name="e">Arguments explaining why this event was invoked.</param> private void ImageSelectorWindow_VisibleChanged(object sender, EventArgs e) { if (Visible == true) { fileTreeView.Nodes.Clear(); _ignoreSelections = true; PopulateFileTree(Engine.GlobalInstance.FontPath, fileTreeView.Nodes); _ignoreSelections = false; if (_font != null && _fontImage == null) { _fontImage = GraphicsManager.LoadImage(_font.NormalImage.URL, 0); } } else if (_canvas != null) { fileTreeView.Nodes.Clear(); } }
/// <summary> /// Check For A Potential Collision (Using Boding Box Test , If It's The /// </summary> /// <param name="img1">The First Image To Check</param> /// <param name="img2">The Second Image To Check</param> /// <returns>Return True If The Two Image Are In Collision,Testing First With The Bouding Box Technic ( Optimized )</returns> public static bool IsBoxedCollid(Graphics.Image img1, Graphics.Image img2) { BoundingBox b1, b2; b1 = new BoundingBox(); b2 = new BoundingBox(); b1.Initialize(img1); b2.Initialize(img2); if (b1.IsCollid(b2)) { Rectangle rec = Intersection(img1, img2); Rectangle rec1, rec2; rec1 = Normalize(new Rectangle((int)img1.Position.X, (int)img1.Position.Y, (int)(img1.Size.X + img1.Position.X), (int)(img1.Size.Y + img1.Position.Y)), rec); rec2 = Normalize(new Rectangle((int)img2.Position.X, (int)img2.Position.Y, (int)(img2.Size.X + img2.Position.X), (int)(img2.Size.Y + img2.Position.Y)), rec); return(TestCollision(img1.Texture, rec1, img2.Texture, rec2)); } else { return(false); } }
/// <summary> /// Reloads the currently selected font. /// </summary> private void ReloadFont() { // Check we have selected a node. if (fileTreeView.SelectedNode == null || _loadFontThread != null) { return; } // Work out the path to the node. _loadFontUrl = Engine.GlobalInstance.FontPath + "\\" + fileTreeView.SelectedNode.FullPath; // Check its not a dictionary. if (ResourceManager.ResourceExists(_loadFontUrl) == false) { return; } // Start up the loading thread. _font = null; _fontImage = null; _loadFontThread = new Thread(new ThreadStart(LoadFont)); _loadFontThread.IsBackground = true; _loadFontThread.Start(); }
/// <summary> /// Reloads the currently selected image. /// </summary> private void ReloadImage() { // Check we have selected a node. if (fileTreeView.SelectedNode == null || _loadImageThread != null) { return; } // Work out the path to the node. _loadImageUrl = Engine.GlobalInstance.GraphicPath + "\\" + fileTreeView.SelectedNode.FullPath; // Check its not a dictionary. if (ResourceManager.ResourceExists(_loadImageUrl) == false) { return; } // Start up the loading thread. int originalColorKey = GraphicsManager.ColorKey; GraphicsManager.ColorKey = maskColorPanel.BackColor.ToArgb(); _image = GraphicsManager.LoadImage(_loadImageUrl, 0, false); GraphicsManager.ColorKey = originalColorKey; }
/// <summary> /// Saves this entity into a given binary writer. /// </summary> /// <param name="writer">Binary writer to save this entity into.</param> public override void Save(BinaryWriter writer) { // Save all the basic entity details. base.Save(writer); // Save all the scripted entity specific details. writer.Write((_process.Process != null && _process.Process.Url != null)); if ((_process.Process != null && _process.Process.Url != null)) { writer.Write(_process.Process.Url); int propertyCount = 0; foreach (Symbol symbol in _process.Process.GlobalScope.Symbols) { if (symbol is VariableSymbol == false || ((VariableSymbol)symbol).IsProperty == false) { continue; } propertyCount++; } writer.Write((short)propertyCount); // Write in the value of all the properties stored in the process. foreach (Symbol symbol in _process.Process.GlobalScope.Symbols) { if (symbol is VariableSymbol == false || ((VariableSymbol)symbol).IsProperty == false) { continue; } VariableSymbol variableSymbol = symbol as VariableSymbol; // Quickly find out the meta data of this symbol. string editMethod = ""; foreach (Symbol subSymbol in symbol.Symbols) { if (subSymbol is MetaDataSymbol) { if (((MetaDataSymbol)subSymbol).Identifier.ToLower() == "editmethod") { editMethod = ((MetaDataSymbol)subSymbol).Value; break; } } } writer.Write(variableSymbol.Identifier); writer.Write((byte)variableSymbol.DataType.DataType); writer.Write(variableSymbol.IsArray); if (variableSymbol.IsArray == true) { int arrayIndex = _process.Process[0].GetArrayGlobal(variableSymbol.Identifier); writer.Write(arrayIndex != 0); if (arrayIndex != 0) { int arrayLength = _process.Process[0].GetArrayLength(arrayIndex); writer.Write(arrayLength); for (int i = 0; i < arrayLength; i++) { switch (variableSymbol.DataType.DataType) { case DataType.Bool: writer.Write(_process.Process[0].GetBooleanArrayElement(arrayIndex, i)); break; case DataType.Byte: writer.Write(_process.Process[0].GetByteArrayElement(arrayIndex, i)); break; case DataType.Double: writer.Write(_process.Process[0].GetDoubleArrayElement(arrayIndex, i)); break; case DataType.Float: writer.Write(_process.Process[0].GetFloatArrayElement(arrayIndex, i)); break; case DataType.Int: writer.Write(_process.Process[0].GetIntArrayElement(arrayIndex, i)); break; case DataType.Long: writer.Write(_process.Process[0].GetLongArrayElement(arrayIndex, i)); break; case DataType.Short: writer.Write(_process.Process[0].GetShortArrayElement(arrayIndex, i)); break; case DataType.String: writer.Write(_process.Process[0].GetStringArrayElement(arrayIndex, i)); break; case DataType.Object: RuntimeObject obj = _process.Process[0].GetObjectArrayElement(arrayIndex, i); if (obj != null) { if (editMethod.ToLower() == "image") { if (obj is NativeObject && ((Graphics.Image)((NativeObject)obj).Object) != null) { Graphics.Image img = ((Graphics.Image)((NativeObject)obj).Object); writer.Write(true); writer.Write((byte)0); writer.Write(img.URL); writer.Write(img.Width); writer.Write(img.Height); writer.Write((short)img.VerticalSpacing); writer.Write((short)img.HorizontalSpacing); } else { writer.Write(false); } } else if (editMethod.ToLower() == "sound") { if (obj is NativeObject && ((Audio.Sound)((NativeObject)obj).Object) != null) { Audio.Sound sound = ((Audio.Sound)((NativeObject)obj).Object); writer.Write(true); writer.Write((byte)1); writer.Write(sound.URL); writer.Write(sound.Frequency); writer.Write(sound.InnerRadius); writer.Write(sound.Looping); writer.Write(sound.OuterRadius); writer.Write(sound.Pan); writer.Write(sound.Volume); writer.Write(sound.Streaming); writer.Write(sound.Positional); } else { writer.Write(false); } } else { writer.Write(false); } } else { writer.Write(false); } break; } } } } else { switch (variableSymbol.DataType.DataType) { case DataType.Bool: writer.Write(_process.Process[0].GetBooleanGlobal(variableSymbol.Identifier)); break; case DataType.Byte: writer.Write(_process.Process[0].GetByteGlobal(variableSymbol.Identifier)); break; case DataType.Double: writer.Write(_process.Process[0].GetDoubleGlobal(variableSymbol.Identifier)); break; case DataType.Float: writer.Write(_process.Process[0].GetFloatGlobal(variableSymbol.Identifier)); break; case DataType.Int: writer.Write(_process.Process[0].GetIntegerGlobal(variableSymbol.Identifier)); break; case DataType.Long: writer.Write(_process.Process[0].GetLongGlobal(variableSymbol.Identifier)); break; case DataType.Short: writer.Write(_process.Process[0].GetShortGlobal(variableSymbol.Identifier)); break; case DataType.String: string value = _process.Process[0].GetStringGlobal(variableSymbol.Identifier); writer.Write(value == null || value == "" ? "" : value); break; case DataType.Object: RuntimeObject obj = _process.Process[0].GetObjectGlobal(variableSymbol.Identifier); if (obj != null) { if (editMethod.ToLower() == "image") { if (obj is NativeObject && ((Graphics.Image)((NativeObject)obj).Object) != null) { Graphics.Image img = ((Graphics.Image)((NativeObject)obj).Object); writer.Write(true); writer.Write((byte)0); writer.Write(img.URL); writer.Write(img.Width); writer.Write(img.Height); writer.Write((short)img.VerticalSpacing); writer.Write((short)img.HorizontalSpacing); } else { writer.Write(false); } } else if (editMethod.ToLower() == "sound") { if (obj is NativeObject && ((Audio.Sound)((NativeObject)obj).Object) != null) { Audio.Sound sound = ((Audio.Sound)((NativeObject)obj).Object); writer.Write(true); writer.Write((byte)1); writer.Write(sound.URL); writer.Write(sound.Frequency); writer.Write(sound.InnerRadius); writer.Write(sound.Looping); writer.Write(sound.OuterRadius); writer.Write(sound.Pan); writer.Write(sound.Volume); writer.Write(sound.Streaming); writer.Write(sound.Positional); } else { writer.Write(false); } } else { writer.Write(false); } } else { writer.Write(false); } break; } } } } }
/// <summary> /// Set Mouse Image /// </summary> /// <param name="img">Set An Image For The Mouse Pointer</param> public static void SetImage(Graphics.Image img) { cursor = img; }
/// <summary> /// the Default Constructor /// </summary> static Mouse() { cursor = new Graphics.Image(); }
/// <summary> /// Constructor /// </summary> /// <param name="graphics">XNA GraphicsDeviceManager</param> /// <param name="Image">The Image On What The Effect Will Be Applied</param> public BreakingSquare(GraphicsDeviceManager graphics, Graphics.Image Image) { this.graphics = graphics; breaking = new Breaking(graphics, Image); }
/// <summary> /// Initialize The Effect /// </summary> /// <param name="txt">Text On What The Effect Will Be Applied</param> public void Initialize(Graphics.TextWriter txt) { this.img = null; this.txt = txt; this.Reset(); }
/// <summary> /// Initialize The Effect /// </summary> /// <param name="img">Image On What The Effect Will Be Applied</param> public void Initialize(Graphics.Image img) { this.img = img; this.txt = null; this.Reset(); }
/// <summary> /// Optimize Drawing Of An Element Of List /// </summary> /// <param name="index">Image Index</param> public static void StretchDrawlementOfList(int index) { Graphics.Image img = list[index]; StretchDrawElement(img); }
/// <summary> /// Optimize Drawing Of An Element Of List /// </summary> /// <param name="index">Image Index</param> public static void DefaultDrawlementOfList(int index) { Graphics.Image img = list[index]; DefaultDrawElement(img); }
/// <summary> /// Initialize The System /// </summary> /// <param name="img"></param> public void Initialize(Graphics.Image img) { this.img = img; this._boundingbox = new Microsoft.Xna.Framework.BoundingBox(new Vector3(img.Position.X, img.Position.Y, 0), new Vector3(img.Position.X + img.Size.X, img.Position.Y + img.Size.Y, 0)); }
/// <summary> /// A Constructor /// </summary> /// <param name="graphics">XNA GraphicsDeviceManager</param> /// <param name="Image">Image On What The Effect Will Be Applied</param> public HidingLine(GraphicsDeviceManager graphics, Graphics.Image Image) { this.graphics = graphics; hiding = new Hiding(graphics, Image); }
/// <summary> /// Constructor /// </summary> /// <param name="Image">The Image on what the effect will be applied</param> public PartialFadingLine(Graphics.Image Image) { partialfading = new PartialFading(Image); }
/// <summary> /// Set The Mouse Image /// </summary> /// <param name="img">Image To Bet Set</param> public static void SetImage(Graphics.Image img) { Graphics.Mouse.SetImage(img); }
/// <summary> /// Initialize The System /// </summary> /// <param name="img">Image</param> public void Initialize(Graphics.Image img) { this.img = img; this._boundingsphere = new Microsoft.Xna.Framework.BoundingSphere(new Vector3(this.img.Position.X + (this.img.Size.X / 2), this.img.Position.Y + (this.img.Size.Y / 2), 0), this.img.Size.X / 2); }