Exemplo n.º 1
0
        private void UpdateLaserQueue()
        {
            if (laserbeamPaq.Count > DetectionDelay)
            {
                List <Laserbeam> laserbeams = laserbeamPaq.Peek(DetectionDelay);
                OnLaserbeams(laserbeams);
                HashSet <Laserbeam> handledThisUpdate = new HashSet <Laserbeam>();

                foreach (Laserbeam beam in laserbeams)
                {
                    if (!handledBeams.Contains(beam))
                    {
                        handledBeams.Add(beam);
                        OnNewLaserbeam(beam);
                    }

                    handledThisUpdate.Add(beam);
                }

                foreach (Laserbeam beam in handledBeams.Except(handledThisUpdate).ToArray())
                {
                    handledBeams.Remove(beam);
                    OnDeadLaserbeam(beam);
                }
            }

            laserbeamPaq.Enqueue(LaserHelper.ConnectedLasers(Scene, this));
        }
Exemplo n.º 2
0
        private void reflect(Laserbeam beam)
        {
            if (!reflections.ContainsKey(beam))
            {
                Level  level        = Scene as Level;
                string newDirection = LaserHelper.GetReflection(opening, beam);

                if (newDirection != null)
                {
                    reflections[beam] = new Laserbeam(Position, newDirection, beam.Color, beam.TTL);
                    level.Add(reflections[beam]);
                    reflections[beam].Depth     = beam.Depth + 1;
                    reflections[beam].Position += reflectionOffsets[newDirection];
                }
            }
        }
Exemplo n.º 3
0
        public static void SetLaserLengthDAQ(Scene scene, Laserbeam beam)
        {
            Level level     = scene as Level;
            float maxLength = LaserHelper.MaxBeamLength(level, beam);

            float offset = maxLength / 2f;

            beam.Length = offset;

            while (offset >= 1f)
            {
                bool colliding = beam.CollideCheck <Solid>() || LaserHelper.LaserBlockingCheck(scene, beam);
                int  sign      = colliding ? -1 : 1;

                offset      /= 2f;
                beam.Length += sign * offset;
            }

            beam.Length = (float)Math.Round(beam.Length);
        }