Ejemplo n.º 1
0
            /// <summary>
            /// This tells me about a collision.  If I return true, I don't know about it.  If I return false, I still know about it.
            /// </summary>
            /// <returns>
            /// True:  Run the collision
            /// False:  Ignore the collision
            /// </returns>
            public bool AddCollision(Collision collision)
            {

                return true;

                // Always put the lower as the key

                long lower, upper;

                #region Sort the tokens

                if (collision.Blip1.Token < collision.Blip2.Token)
                {
                    lower = collision.Blip1.Token;
                    upper = collision.Blip2.Token;
                }
                else
                {
                    lower = collision.Blip2.Token;
                    upper = collision.Blip1.Token;
                }

                #endregion

                // Check the list
                if (_collisions.ContainsKey(lower))
                {
                    if (_collisions[lower].ContainsKey(upper))
                    {
                        // I found it, return false
                        return false;
                    }
                    else
                    {
                        _collisions[lower].Add(upper, 0);
                    }
                }
                else
                {
                    #region Add New

                    _collisions.Add(lower, new SortedList<long, int>());
                    _collisions[lower].Add(upper, 0);

                    #endregion
                }

                // Exit Function
                return true;
            }
Ejemplo n.º 2
0
        private List<long> GetCollisionTokens(Collision[] collisions)
        {
            List<long> retVal = new List<long>();

            if (collisions != null)
            {
                foreach (Collision collision in collisions)
                {
                    if (!retVal.Contains(collision.Blip1.Token))
                    {
                        retVal.Add(collision.Blip1.Token);
                    }

                    if (!retVal.Contains(collision.Blip2.Token))
                    {
                        retVal.Add(collision.Blip2.Token);
                    }
                }
            }

            return retVal;
        }
Ejemplo n.º 3
0
        private void AddToGlobalCollisions(SortedList<long, List<long>> returnTokens, Collision collision)
        {
            long lower, upper;

            if (collision.Blip1.Token < collision.Blip2.Token)
            {
                lower = collision.Blip1.Token;
                upper = collision.Blip2.Token;
            }
            else
            {
                lower = collision.Blip2.Token;
                upper = collision.Blip1.Token;
            }

            // Always put the lower as the key

            if (returnTokens.ContainsKey(lower))
            {
                #region Add upper to lower

                if (!returnTokens[lower].Contains(upper))
                {
                    returnTokens[lower].Add(upper);
                }

                #endregion
            }
            else
            {
                #region Add New

                returnTokens.Add(lower, new List<long>());
                returnTokens[lower].Add(upper);

                #endregion
            }
        }
Ejemplo n.º 4
0
        private void Map_Collisions(object sender, Collision[] collisions)
        {
            if (_state != ProjectileState.Flying)
            {
                return;
            }

            long token = this.Token;		// cache the property

            for (int cntr = 0; cntr < collisions.Length; cntr++)
            {
                if (collisions[cntr].Blip1.Token == token || collisions[cntr].Blip2.Token == token)
                {
                    if (_ignoreOtherProjectiles && (collisions[cntr].Blip1 is Projectile) && (collisions[cntr].Blip2 is Projectile))
                    {
                        // I don't explode against other projectiles
                        continue;
                    }

                    if (_explosion != null)
                    {
                        if (!(collisions[cntr].Blip1 is Projectile))
                        {
                            ApplyExplosionForce(collisions[cntr].Blip1);
                        }
                        else if (!(collisions[cntr].Blip2 is Projectile))
                        {
                            ApplyExplosionForce(collisions[cntr].Blip2);
                        }
                    }

                    if (_state == ProjectileState.Flying)
                    {
                        // I only want to explode once
                        Explode();
                    }
                }
            }
        }