Example #1
0
        private void Map_ItemAdded(object sender, MapItemArgs e)
        {
            if (e.Item is SpaceStation || e.Item is Projectile)
            {
                // Space stations are always stationary

                // Not including projectiles, because guns could be mounted above and below the plane, and if projectiles are smashed onto
                // the plane, they sometimes collide with each other or the ship
                return;
            }

            e.Item.PhysicsBody.ApplyForceAndTorque += new EventHandler <BodyApplyForceAndTorqueArgs>(PhysicsBody_ApplyForceAndTorque);

            #region Keep 2D

            bool limitRotation = e.Item is Ship || e.Item is Bot;

            // Doing this in case the new item is the child of an exploding asteroid.  The parent asteroid can shatter in 3D, then ease
            // back onto the plane
            double animateDuration = 60;
            double animatePreDelay = 2;

            _keep2D.Add(e.Item, limitRotation, animateDuration, animatePreDelay);

            #endregion
        }
Example #2
0
 private void Map_ItemRemoved(object sender, MapItemArgs e)
 {
     for (int cntr = 0; cntr < _blips.Count; cntr++)
     {
         if (_blips[cntr].Item.Token == e.Item.Token)
         {
             _viewport.Children.RemoveAll(_blips[cntr].Visuals.Select(o => o.Visual));
             _blips.RemoveAt(cntr);
             return;
         }
     }
 }
Example #3
0
 private void Map_ItemAdded(object sender, MapItemArgs e)
 {
     try
     {
         if (e.Item.PhysicsBody != null)
         {
             e.Item.PhysicsBody.ApplyForceAndTorque += PhysicsBody_ApplyForceAndTorque;
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString(), this.Title, MessageBoxButton.OK, MessageBoxImage.Error);
     }
 }
Example #4
0
        private void Map_ItemRemoved(object sender, MapItemArgs e)
        {
            long token = e.Item.Token;

            int index = 0;

            while (index < _bots.Count)
            {
                if (_bots[index].Token == token)
                {
                    _bots.RemoveAt(index);
                }
                else
                {
                    index++;
                }
            }
        }
Example #5
0
        private void Map_ItemRemoved(object sender, MapItemArgs e)
        {
            try
            {
                //if (e.Item.PhysicsBody != null)
                //{
                //    e.Item.PhysicsBody.ApplyForceAndTorque -= PhysicsBody_ApplyForceAndTorque;
                //}

                //if (e.Item is IDisposable)
                //{
                //    ((IDisposable)e.Item).Dispose();
                //}
                //else if (e.Item.PhysicsBody != null)
                //{
                //    e.Item.PhysicsBody.Dispose();
                //}
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString(), this.Title, MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
Example #6
0
        private void Map_ItemRemoved(object sender, MapItemArgs e)
        {
            long token = e.Item.Token;

            int index = 0;
            while (index < _bots.Count)
            {
                if (_bots[index].Token == token)
                {
                    _bots.RemoveAt(index);
                }
                else
                {
                    index++;
                }
            }
        }
Example #7
0
 private void Map_ItemRemoved(object sender, MapItemArgs e)
 {
     e.Item.PhysicsBody.ApplyForceAndTorque -= new EventHandler <BodyApplyForceAndTorqueArgs>(PhysicsBody_ApplyForceAndTorque);
     _keep2D.Remove(e.Item);
 }
        private void Map_ItemRemoved(object sender, MapItemArgs e)
        {
            try
            {
                if (e.Item.PhysicsBody != null)
                {
                    e.Item.PhysicsBody.ApplyForceAndTorque -= PhysicsBody_ApplyForceAndTorque;
                }

                if (e.Item is IDisposable)
                {
                    ((IDisposable)e.Item).Dispose();
                }
                else if (e.Item.PhysicsBody != null)
                {
                    e.Item.PhysicsBody.Dispose();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString(), this.Title, MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
 private void Map_ItemAdded(object sender, MapItemArgs e)
 {
     try
     {
         if (e.Item.PhysicsBody != null)
         {
             e.Item.PhysicsBody.ApplyForceAndTorque += PhysicsBody_ApplyForceAndTorque;
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString(), this.Title, MessageBoxButton.OK, MessageBoxImage.Error);
     }
 }
 private void Map_ItemRemoved(object sender, MapItemArgs e)
 {
     if (e.Item is IDisposable)
     {
         ((IDisposable)e.Item).Dispose();
     }
     else if (e.Item.PhysicsBody != null)
     {
         e.Item.PhysicsBody.Dispose();
     }
 }
Example #11
0
        private void Map_ItemAdded(object sender, MapItemArgs e)
        {
            #region Create blip

            Visual3D blip;
            List <Tuple <Visual3D, bool> > blips = new List <Tuple <Visual3D, bool> >();;

            if (e.Item is Asteroid)
            {
                blip = GetAsteroidBlip((Asteroid)e.Item);
                blips.Add(Tuple.Create(blip, false));
            }
            else if (e.Item is Mineral)
            {
                blip = GetMineralBlip((Mineral)e.Item);
                blips.Add(Tuple.Create(blip, false));
            }
            else if (e.Item is SpaceStation2D)
            {
                blip = GetStationBlip((SpaceStation2D)e.Item);
                blips.Add(Tuple.Create(blip, true));
            }
            else if (e.Item is Bot)
            {
                blip = GetShipBlip((Bot)e.Item);
                blips.Add(Tuple.Create(blip, true));

                blip = GetShipCompassBlip((Bot)e.Item);
                blips.Add(Tuple.Create(blip, false));
            }

            #endregion

            // Remove nulls (if the item isn't very significant, then no blip is made)
            blips = blips.Where(o => o.Item1 != null).ToList();
            if (blips.Count == 0)
            {
                return;
            }

            #region Create transforms

            List <BlipVisual> blipVisuals = new List <BlipVisual>();

            foreach (var tuple in blips)
            {
                // Transform
                Transform3DGroup    transform = new Transform3DGroup();
                AxisAngleRotation3D rotate    = new AxisAngleRotation3D(new Vector3D(0, 0, 1), 0);
                transform.Children.Add(new RotateTransform3D(rotate));
                TranslateTransform3D translate = new TranslateTransform3D(e.Item.PositionWorld.ToVector());
                transform.Children.Add(translate);

                tuple.Item1.Transform = transform;

                blipVisuals.Add(new BlipVisual(tuple.Item1, tuple.Item2, translate, rotate));
            }

            #endregion

            // Store it
            _blips.Add(new Blip(e.Item, blipVisuals.ToArray()));
            _viewport.Children.AddRange(blipVisuals.Select(o => o.Visual));
        }
Example #12
0
 private void Map_ItemRemoved(object sender, MapItemArgs e)
 {
     for (int cntr = 0; cntr < _blips.Count; cntr++)
     {
         if (_blips[cntr].Item.Token == e.Item.Token)
         {
             _viewport.Children.RemoveAll(_blips[cntr].Visuals.Select(o => o.Visual));
             _blips.RemoveAt(cntr);
             return;
         }
     }
 }
Example #13
0
        private void Map_ItemAdded(object sender, MapItemArgs e)
        {
            #region Create blip

            Visual3D blip;
            List<Tuple<Visual3D, bool>> blips = new List<Tuple<Visual3D, bool>>(); ;

            if (e.Item is Asteroid)
            {
                blip = GetAsteroidBlip((Asteroid)e.Item);
                blips.Add(Tuple.Create(blip, false));
            }
            else if (e.Item is Mineral)
            {
                blip = GetMineralBlip((Mineral)e.Item);
                blips.Add(Tuple.Create(blip, false));
            }
            else if (e.Item is SpaceStation2D)
            {
                blip = GetStationBlip((SpaceStation2D)e.Item);
                blips.Add(Tuple.Create(blip, true));
            }
            else if (e.Item is Bot)
            {
                blip = GetShipBlip((Bot)e.Item);
                blips.Add(Tuple.Create(blip, true));

                blip = GetShipCompassBlip((Bot)e.Item);
                blips.Add(Tuple.Create(blip, false));
            }

            #endregion

            // Remove nulls (if the item isn't very significant, then no blip is made)
            blips = blips.Where(o => o.Item1 != null).ToList();
            if (blips.Count == 0)
            {
                return;
            }

            #region Create transforms

            List<BlipVisual> blipVisuals = new List<BlipVisual>();

            foreach (var tuple in blips)
            {
                // Transform
                Transform3DGroup transform = new Transform3DGroup();
                AxisAngleRotation3D rotate = new AxisAngleRotation3D(new Vector3D(0, 0, 1), 0);
                transform.Children.Add(new RotateTransform3D(rotate));
                TranslateTransform3D translate = new TranslateTransform3D(e.Item.PositionWorld.ToVector());
                transform.Children.Add(translate);

                tuple.Item1.Transform = transform;

                blipVisuals.Add(new BlipVisual(tuple.Item1, tuple.Item2, translate, rotate));
            }

            #endregion

            // Store it
            _blips.Add(new Blip(e.Item, blipVisuals.ToArray()));
            _viewport.Children.AddRange(blipVisuals.Select(o => o.Visual));
        }
 private void Map_ItemRemoved(object sender, MapItemArgs e)
 {
     e.Item.PhysicsBody.ApplyForceAndTorque -= new EventHandler<BodyApplyForceAndTorqueArgs>(PhysicsBody_ApplyForceAndTorque);
     _keep2D.Remove(e.Item);
 }
        private void Map_ItemAdded(object sender, MapItemArgs e)
        {
            if (e.Item is SpaceStation || e.Item is Projectile)
            {
                // Space stations are always stationary

                // Not including projectiles, because guns could be mounted above and below the plane, and if projectiles are smashed onto
                // the plane, they sometimes collide with each other or the ship
                return;
            }

            e.Item.PhysicsBody.ApplyForceAndTorque += new EventHandler<BodyApplyForceAndTorqueArgs>(PhysicsBody_ApplyForceAndTorque);

            #region Keep 2D

            bool limitRotation = e.Item is Ship || e.Item is Bot;

            // Doing this in case the new item is the child of an exploding asteroid.  The parent asteroid can shatter in 3D, then ease
            // back onto the plane
            double animateDuration = 60;
            double animatePreDelay = 2;

            _keep2D.Add(e.Item, limitRotation, animateDuration, animatePreDelay);

            #endregion
        }