예제 #1
0
        private void cmdAddSprite_Click(object sender, RoutedEventArgs e)
        {
            var sobj = Activator.CreateInstance(dbNewObj.SelectedItem as Type) as SpriteObject;

            sobj.Name     = txtSpriteName.Text;
            sobj.Position = new Vector(GameSlider.Value, 100);
            //sobj.CenterOfMass = new Vector(0, 0);
            sobj.IsMovable  = false;
            sobj.CanCollide = true;
            sobj.IsObstacle = false;
            //ThisLevel.selectImage(sobj);
            int idx = ThisLevel.Sprites.IndexOf(lstSprites.SelectedItem as SpriteObject);

            if ((idx >= 0) && (idx < ThisLevel.Sprites.Count - 1))
            {
                idx++;
                ThisLevel.Sprites.Insert(idx, sobj);
            }
            else
            {
                ThisLevel.Sprites.Add(sobj);
            }
            MainGFX.AddObject(sobj);
            lstSprites.Items.Refresh();
            txtSpriteName.Text = "";
        }
예제 #2
0
        private void cmdTest_Click(object sender, RoutedEventArgs e)
        {
            // Objekte erstellen
            IGFXObject obj1 = new SpriteObject("Test Sprite");
            //IGFXObject obj2 = new CarObject("Test Auto");  // erstellt ParticleSystem. passt nicht zu neuer Baumstruktur
            IGFXObject         obj2  = new SpriteObjectElastic("Fussball");
            IGFXObjComposition comp2 = new GFXComposition("Blumenbeet");

            comp2.AddObject(new SpriteObject("Sehr grüne Pflanze"));
            comp2.AddObject(new SpriteObject("Maiglöckchen"));

            IGFXObjComposition comp1 = new GFXComposition("Zusammengebautes Object");

            comp1.AddObject(new SpriteObject("Teil 1"));
            comp1.AddObject(new SpriteObject("Teil 2"));
            comp1.AddObject(comp2);
            comp1.AddObject(new SpriteObject("Teil 3"));

            MainGFX.AddObject(obj1);
            MainGFX.AddObject(obj2);
            MainGFX.AddObject(comp1);


            // Objekt-Baum listen
            lstTree.ItemsSource = MainGFX.ToList();
        }
예제 #3
0
 private void cmdSetLevelBkg_Click(object sender, RoutedEventArgs e)
 {
     MainGFX.RemoveObject(ThisLevel.LevelBkg);
     ThisLevel.LevelBkg              = new SpriteObject();
     ThisLevel.LevelBkg.Name         = "LevelBkg";
     ThisLevel.LevelBkg.CenterOfMass = new Vector(0, 0);
     ThisLevel.LevelBkg.IsMovable    = false;
     ThisLevel.LevelBkg.IsObstacle   = false;
     ThisLevel.selectImage(ThisLevel.LevelBkg);
     (ThisLevel.LevelBkg as SpriteObject).ZoomPreserveAspectRatio(height: GameWrapper.Height);
     (ThisLevel.Background as SpriteObject).ScrollScaling = (ThisLevel.Background.SizeV.X - (GameWrapper.Width / 2)) / ThisLevel.LevelBkg.SizeV.X;
     MainGFX.AddObject(ThisLevel.LevelBkg);
     MainGFX.Width = ThisLevel.LevelBkg.SizeV.X;
 }
예제 #4
0
 private void cmdSetParBkg_Click(object sender, RoutedEventArgs e)
 {
     //MainGFX.Height = 50;
     //GameWrapper.Width = 50;
     MainGFX.RemoveObject(ThisLevel.Background);
     ThisLevel.Background              = new SpriteObject();
     ThisLevel.Background.Name         = "Background";
     ThisLevel.Background.CenterOfMass = new Vector(0, 0);
     ThisLevel.Background.IsMovable    = false;
     ThisLevel.Background.IsObstacle   = false;
     ThisLevel.selectImage(ThisLevel.Background);
     (ThisLevel.Background as SpriteObject).ZoomPreserveAspectRatio(height: GameWrapper.Height);
     MainGFX.AddObject(ThisLevel.Background);
     MainGFX.Width = ThisLevel.Background.SizeV.X;
     // todo: eigentlich in setlvlbackg
     //MainGFX.Width = thisLevel.Background.SizeV.X;
     // MainGFX.Height = 500;
 }