Ejemplo n.º 1
0
 public TilePropertiesWindow(Tile tile, DesignerItem item, Level level)
     : base()
 {
     InitializeComponent();
     item.PropertyWindow = this;
     DataContext = new TileModel(tile, item, level);
     item.SizeChanged += new SizeChangedEventHandler(item_SizeChanged);
 }
Ejemplo n.º 2
0
            public TileModel(Tile tile, DesignerItem item, Level level)
                : base(item, level)
            {
                Data = mTile = tile;

                if(!level.Tiles.Contains(mTile))
                    level.Tiles.Add(mTile);

                Type = Type;
                Width = tile.Dimensions.Width;
                Height = tile.Dimensions.Height;
                X = tile.Dimensions.X;
                Y = tile.Dimensions.Y;
            }
Ejemplo n.º 3
0
 protected override void HandleTileCollision(Tile tile, Rectangle result, Level level)
 {
     this.Visible = false;
     Velocity = Acceleration = Vector2.Zero;
 }
Ejemplo n.º 4
0
 protected abstract void HandleTileCollision(Tile tile, Rectangle result, Level level);
Ejemplo n.º 5
0
 protected override void HandleTileCollision(Tile tile, Rectangle result, Level level)
 {
     HandleCollision(tile.Dimensions, result, level, tile.Type, Vector2.Zero, tile);
 }
Ejemplo n.º 6
0
 protected override void HandleTileCollision(Tile tile, Rectangle result, Level level)
 {
     switch (tile.Type)
     {
         case Surface.Amplifies:
             Amplify(tile.Dimensions, result, level, Vector2.Zero);
             break;
         case Surface.Normal:
             Act(tile.Dimensions, result, level, Vector2.Zero);
             break;
         case Surface.Reflects:
             Reflect(result);
             break;
         default:
             Absorb();
             break;
     }
 }
Ejemplo n.º 7
0
        EventHandler<BoolEventArgs> NewTileHandler(DesignerItem item)
        {
            Rectangle rect=  new Rectangle();
            rect.IsHitTestVisible = false;
            rect.Fill = (Window.GetWindow(this) as MainWindow).Settings.NormalBrush;
            rect.MinHeight = 2;
            rect.MinWidth = 2;

            item.Content = rect;

            Tile t = new Tile();
            t.Type = Surface.Normal;
            t.Dimensions.Width = 50;
            t.Dimensions.Height = 50;

            TilePropertiesWindow tpw = new TilePropertiesWindow(t, item, Level);
            this.Children.Add(tpw);

            return tpw.SelectionHandler;
        }
Ejemplo n.º 8
0
        private void SaveLevel(string path)
        {
            Tile[] boundaries = null;
            if (mFirstSave)
            {
                boundaries = new Tile[]{ new Tile(new Microsoft.Xna.Framework.Rectangle(-2, 0, 2,(int) MyDesignerCanvas.ActualHeight), Surface.Absorbs),
                                            new Tile(new Microsoft.Xna.Framework.Rectangle(0, -2, (int) MyDesignerCanvas.ActualWidth, 2), Surface.Absorbs),
                                            new Tile(new Microsoft.Xna.Framework.Rectangle(0, (int) MyDesignerCanvas.ActualHeight + 1, (int) MyDesignerCanvas.ActualWidth, 2), Surface.Absorbs),
                                            new Tile(new Microsoft.Xna.Framework.Rectangle((int) MyDesignerCanvas.ActualWidth + 1, 0, 2, (int) MyDesignerCanvas.ActualHeight), Surface.Absorbs) };

                Level.Tiles.AddRange(boundaries);
            }

            Level.AssetName = path.Substring(path.LastIndexOf('\\') + 1);

            XmlSerializer serializer = new XmlSerializer(typeof(Level));
            TextWriter textWriter = new StreamWriter(path + ".xml");
            serializer.Serialize(textWriter, Level);

            textWriter.Close();

            if (mFirstSave)
                Level.Tiles.RemoveAll(t => boundaries.Contains(t));
            mFirstSave = false;
        }
Ejemplo n.º 9
0
        private void AddTile(Tile t)
        {
            Rectangle rect = new Rectangle();
            rect.IsHitTestVisible = false;
            rect.Fill = Settings.NormalBrush;

            DesignerItem item = new DesignerItem();
            item.Content = rect;
            item.MinHeight = item.MinWidth = 1;
            MyDesignerCanvas.Children.Add(item);

            PropertiesWindow pw = new TilePropertiesWindow(t, item, Level);
            MyDesignerCanvas.Children.Add(pw);

            item.OnSelected += pw.SelectionHandler;
            item.IsSelected = true;
        }