void CreateNewDrop()
 {
     Graphics.Entity e = newDropCallback();
     if (e == null)
     {
         return;
     }
     if (e is Client.Game.Map.GameEntity)
     {
         var e_ = (Client.Game.Map.GameEntity)e;
         e_.Map = MainWindow.Instance.CurrentMap;
         e_.EditorInit();
         e_.EditorCreateNewName(MainWindow.Instance.worldView.Scene);
     }
     dropping = e as Client.Game.Map.GameEntity;
     if (e is Client.Game.Map.GameEntity && !((Client.Game.Map.GameEntity)e).Dynamic)
     {
         MainWindow.Instance.CurrentMap.StaticsRoot.AddChild(e);
     }
     else
     {
         MainWindow.Instance.CurrentMap.DynamicsRoot.AddChild(e);
     }
     UpdateDroppingPosition();
 }
        void Scene_EntityAdded(Graphics.Entity obj)
        {
            var cp = obj as Map.Checkpoint;

            if (cp != null)
            {
                Button b = new Button
                {
                    Text     = obj.Name,
                    Position = new Vector2(0, y),
                    Size     = new Vector2(200, 20),
                };
                b.Click += new EventHandler((o, e) =>
                {
                    Game.Instance.Map.MainCharacter.Position = obj.Translation;
                    Game.Instance.Map.MainCharacter.AddRageLevelProgress(cp.RagePerc);
                    Game.Instance.Map.MainCharacter.HitPoints  = (int)(Game.Instance.Map.MainCharacter.MaxHitPoints * cp.HitPointsPerc);
                    Game.Instance.Map.MainCharacter.PistolAmmo = cp.Ammo;
                });
                AddChild(b);
                y += 22;
            }
        }
        protected override void PerformingTick()
        {
            base.PerformingTick();

            for (int i = 0; i < frameSpawnN; i++)
                SpawnOneUnit();
            frameSpawnN = 0;

            if (!(SkipFirstTick && isFirstTick))
            {
                if (point == null && region == null)
                {
                    region = Game.Instance.Map.GetRegion(Point);
                    if (region == null)
                        point = Game.Instance.Scene.GetByName(Point);
                }

                if (region != null && Distribution == SpawnDistribution.GroupRandom)
                {
                    if (Distribution == SpawnDistribution.GroupRandom)
                        node = region.BoundingRegion.GetRandomNode(Game.Instance.SpawnRandomizer);
                    else
                        nodeI = 0;
                }

                int n = SpawnMinPerRound + Game.Instance.SpawnRandomizer.Next(SpawnMaxPerRound - SpawnMinPerRound);
                n = Math.Min(n, SpawnCount - spawnedCount);
                if (LimitSimultaneouslyAlive > 0)
                {
                    List<Destructible> alive=  new List<Destructible>();
                    foreach (var v in spawns)
                        if (v.State == UnitState.Alive)
                            alive.Add(v);
                    spawns = alive;
                    n = Common.Math.Clamp(n, 0, Math.Max(0, LimitSimultaneouslyAlive - alive.Count));
                }
                spawnedCount += n;
                frameSpawnN = n;

                if (n == 0 && EndPerformWhenAllUnitsHaveSpawned)
                    TryEndPerform(false);
            }
            isFirstTick = false;
            TickPeriod = MinPeriod + (float)Game.Instance.SpawnRandomizer.NextDouble() * (MaxPeriod - MinPeriod);
        }