private void Slow(Asteroid ast, bool exact) { IMovementControl c = ast.GetControlOfType <IMovementControl>(); LinearRotationControl c1 = ast.GetControlOfType <LinearRotationControl>(); if (c == null || c1 == null) { return; } float time = exact ? 1.5f * exactBonus : 1.5f; List <IControl> controls = new List <IControl>(); controls.Add(c); controls.Add(c1); AsteroidFreezeControl removal = new AsteroidFreezeControl(); removal.SetControlsForDisable(controls); removal.Time = time; ast.AddControl(removal); // led je posunut o pulku radiusu doleva Vector p = new Vector(ast.Position.X - (ast.Radius / 2), ast.Position.Y - (ast.Radius / 2)); // potom jeho sirka musi byt prumer + 2 * posunuti (vlevo a vpravo) => r * (2 + 0.5 + 0.5) IceSquare s = SceneObjectFactory.CreateIceSquare(SceneMgr, p, new Size(ast.Radius * 3, ast.Radius * 3)); s.AddControl(new LimitedLifeControl(time)); SceneMgr.DelayedAttachToScene(s); }
public static DrawingGroup CreateIceCube(IceSquare s) { DrawingGroup g = null; s.SceneMgr.Invoke(new Action(() => { BitmapImage bi = new BitmapImage(); bi.BeginInit(); bi.UriSource = new Uri("pack://application:,,,/resources/images/actions/ice-cube.png"); bi.DecodePixelWidth = (int)s.Size.Width * 2; bi.DecodePixelHeight = (int)s.Size.Height * 2; bi.EndInit(); g = new DrawingGroup(); ImageDrawing img = new ImageDrawing(); img.ImageSource = bi; img.Rect = new Rect(s.Size); TransformGroup tg = new TransformGroup(); tg.Children.Add(new TranslateTransform(s.Position.X, s.Position.Y)); g.Transform = tg; g.Children.Add(img); })); return(g); }
public static IceSquare CreateIceSquare(SceneMgr mgr, Vector position, Size size) { IceSquare s = new IceSquare(mgr, IdMgr.GetNewId(mgr.GetCurrentPlayer().GetId())); s.Size = size; s.Position = position; s.Category = DrawingCategory.BACKGROUND; s.SetGeometry(SceneGeometryFactory.CreateIceCube(s)); return(s); }