Пример #1
0
        public void HandleCollision(Laser l, Level parent)
        {
            /* Is this a laser we're generating? Don't bother! */
            if (m_collisions.ContainsValue(l)) { return; }

            Vector2? pIntersectNullable = l.FindIntersectionPoint(surfaceLineSegment);
            if (pIntersectNullable == null) {
                return;
            }

            Vector2 pIntersect = (Vector2)pIntersectNullable;

            Laser generating = null;

            // Have we already started a laser for this collision?
            if (!m_collisions.ContainsKey(l))
            {
                if (m_type == SurfaceType.Reflective || m_type == SurfaceType.Refractive)
                {
                    generating = new Laser(pIntersect, calculateBounceDirection(l), l.Color);
                    parent.AddLaser(generating);
                }
                m_collisions.Add(l, generating);
            } else {
                generating = m_collisions[l];
            }

            float chompdAmount = l.Chomp(surfaceLineSegment);

            if (m_type == SurfaceType.Reflective || m_type == SurfaceType.Refractive)
            {
                generating.AdjustLength(chompdAmount);
            }

            m_handledCollision.Add(l);
        }