Beispiel #1
0
        private void Collision_BotBot(object sender, MaterialCollisionArgs e)
        {
            try
            {
                //TODO: Tell the bots so they can increase their personal space
                //Also may want to slightly damage them


                //Bean bean = _beans.Where(o => o.PhysicsBody.Equals(e.Body0)).FirstOrDefault();
                //if (bean != null)
                //{
                //    bean.CollidedBean();
                //}

                //bean = _beans.Where(o => o.PhysicsBody.Equals(e.Body1)).FirstOrDefault();
                //if (bean != null)
                //{
                //    bean.CollidedBean();
                //}
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString(), this.Title, MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
Beispiel #2
0
        private void Collision_BotFood(object sender, MaterialCollisionArgs e)
        {
            try
            {
                Body shipBody    = e.GetBody(_material_Bot);
                Body mineralBody = e.GetBody(_material_Food);

                Swimbot bot = _bots.Where(o => o.PhysicsBody.Equals(shipBody)).FirstOrDefault();
                if (bot == null)
                {
                    return;
                }

                Mineral mineral = _map.GetItem <Mineral>(mineralBody);
                if (mineral == null)
                {
                    return;
                }

                bot.CollidedMineral(mineral);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString(), this.Title, MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
Beispiel #3
0
        private void Collision_SpaceStation(object sender, MaterialCollisionArgs e)
        {
            SpaceStation station = _map.GetItem <SpaceStation>(e.GetBody(_material_SpaceStation));

            if (station != null)
            {
                station.Collided(e);
            }
        }
Beispiel #4
0
 private void Collision_BotAsteroid(object sender, MaterialCollisionArgs e)
 {
     try
     {
         //TODO: Damage the asteroid, slightly damage the bot
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString(), this.Title, MessageBoxButton.OK, MessageBoxImage.Error);
     }
 }
Beispiel #5
0
        /// <summary>
        /// Whenever the station collides with something, the force field shows full intensity, then fades to zero (purely visual)
        /// </summary>
        public void Collided(MaterialCollisionArgs e)
        {
            if (_timer == null)
            {
                _timer          = new DispatcherTimer();
                _timer.Interval = new TimeSpan(0, 0, 0, 0, 50);
                _timer.Tick    += new EventHandler(Timer_Tick);
            }

            _forceFieldOpacity = 1d;
            _timer.Start();
        }
Beispiel #6
0
        private void Collision_BotBot(object sender, MaterialCollisionArgs e)
        {
            try
            {
                //TODO: If they are able to reproduce, create an egg


                //Bean bean = _beans.Where(o => o.PhysicsBody.Equals(e.Body0)).FirstOrDefault();
                //if (bean != null)
                //{
                //    bean.CollidedBean();
                //}

                //bean = _beans.Where(o => o.PhysicsBody.Equals(e.Body1)).FirstOrDefault();
                //if (bean != null)
                //{
                //    bean.CollidedBean();
                //}
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString(), this.Title, MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }