Beispiel #1
0
 public override void load(AxiosGameScreen gameScreen, ref Dictionary<string, Texture2D> cache, Layer layer)
 {
     base.load(gameScreen, ref cache, layer);
     if (gameScreen.LoadRectangleItem(this))
     {
         _body = BodyFactory.CreateRectangle(gameScreen.World, ConvertUnits.ToSimUnits(Width), ConvertUnits.ToSimUnits(Height), 1f);
         _body.Position = ConvertUnits.ToSimUnits(Position) + new Vector2(ConvertUnits.ToSimUnits(Width) / 2, ConvertUnits.ToSimUnits(Height) / 2);
         _body.UserData = this;
     }
 }
Beispiel #2
0
 public override void load(AxiosGameScreen gameScreen, ref Dictionary<string, Texture2D> cache, Layer layer)
 {
     base.load(gameScreen, ref cache, layer);
     if (gameScreen.LoadCircleItem(this))
     {
         _body = BodyFactory.CreateCircle(gameScreen.World, Radius, 1f);
         _body.Position = ConvertUnits.ToSimUnits(Position);
         _body.UserData = this;
     }
 }
Beispiel #3
0
        public override void load(AxiosGameScreen gameScreen)
        {
            base.load(gameScreen);

            Vertices v = new Vertices(LayerItem.LocalPoints.Count);
            foreach (Vector2 vec in LayerItem.LocalPoints)
                v.Add(new Vector2(ConvertUnits.ToSimUnits(vec.X), ConvertUnits.ToSimUnits(vec.Y)));

            _body = BodyFactory.CreateLoopShape(gameScreen.World, v);
            _body.Position = ConvertUnits.ToSimUnits(this.LayerItem.Position);
            _body.UserData = this;
        }
Beispiel #4
0
        /// <summary>
        /// Called by Level.FromFile(filename) on each Item after the deserialization process.
        /// Loads all assets needed by the TextureItem, especially the Texture2D.
        /// You must provide your own implementation. However, you can rely on all public fields being
        /// filled by the level deserialization process.
        /// </summary>
        public override void load(AxiosGameScreen gameScreen)
        {
            base.load(gameScreen);
            //throw new NotImplementedException();

            //TODO: provide your own implementation of how a TextureItem loads its assets
            //for example:
            //this.texture = Texture2D.FromFile(<GraphicsDevice>, texture_filename);
            //or by using the Content Pipeline:
            /*if (!cache.ContainsKey(LayerItem.AssetName))
            {
                cache[LayerItem.AssetName] = gameScreen.ScreenManager.Game.Content.Load<Texture2D>(LayerItem.AssetName);
            }*/
            this.texture = gameScreen.ScreenManager.Game.Content.Load<Texture2D>(LayerItem.AssetName);
            //Visible = gameScreen.LoadTextureItem(this);

            //this.texture = cm.Load<Texture2D>(asset_name);
        }
Beispiel #5
0
        public static Level FromFile(string filename, AxiosGameScreen gameScreen)
        {
            Dictionary<string, Texture2D> cache = new Dictionary<string, Texture2D>();
            FileStream stream = System.IO.File.Open(filename, FileMode.Open);
            XmlSerializer serializer = new XmlSerializer(typeof(Level));
            Level level = (Level)serializer.Deserialize(stream);
            stream.Close();

            foreach (Layer layer in level.Layers)
            {
                foreach (Item item in layer.Items)
                {
                    item.CustomProperties.RestoreItemAssociations(level);
                    item.load(gameScreen, ref cache, layer);
                }
            }

            return level;
        }
Beispiel #6
0
        public override void OnMouseUp(AxiosGameScreen gameScreen, InputState input)
        {
            base.OnMouseUp(gameScreen, input);

            this.Texture = _hovertexture;
        }
Beispiel #7
0
        public override void OnMouseLeave(AxiosGameScreen gameScreen, InputState input)
        {
            base.OnMouseLeave(gameScreen, input);

            this.Texture = _normaltexture;
        }
Beispiel #8
0
        public override void OnMouseDown(AxiosGameScreen gameScreen, InputState input)
        {
            base.OnMouseDown(gameScreen, input);

            this.Texture = _clicktexture;
        }
Beispiel #9
0
 public override void LoadContent(AxiosGameScreen gameScreen)
 {
     base.LoadContent(gameScreen);
 }
Beispiel #10
0
 public override void HandleCursor(AxiosGameScreen gameScreen, InputState input)
 {
     base.HandleCursor(gameScreen, input);
 }
Beispiel #11
0
 /// <summary>
 /// Called by Level.FromFile(filename) on each Item after the deserialization process.
 /// Should be overriden and can be used to load anything needed by the Item (e.g. a texture).
 /// </summary>
 public virtual void load(AxiosGameScreen gameScreen)
 {
 }