コード例 #1
0
        public static void SetLaserLength(Scene scene, Laserbeam beam)
        {
            Level level = scene as Level;

            beam.Length = MaxBeamLength(level, beam);
            float shortestWidth = MaxBeamLength(level, beam);

            foreach (Solid s in scene.Tracker.GetEntities <Solid>())
            {
                if (beam.CollideCheck(s))
                {
                    if (s.Collider is Grid)
                    {
                        shortestWidth = Math.Min(shortestWidth, GetLaserLengthDACOnGrid(beam, s.Collider as Grid, shortestWidth));
                    }
                    else
                    {
                        shortestWidth = Math.Min(shortestWidth, LengthCalculatingFunctions[beam.Direction](beam, s.Collider));
                    }
                }
            }

            foreach (LaserDetectorActor entity in scene.Tracker.GetEntities <LaserDetectorActor>())
            {
                Collider origCollider = entity.Collider;

                Collider     collider     = entity.GetLaserBlockingCollider(beam);
                ColliderList colliderList = collider as ColliderList;

                if (colliderList == null)
                {
                    entity.Collider = collider;
                    if (beam.CollideCheck(entity))
                    {
                        shortestWidth = Math.Min(shortestWidth, LengthCalculatingFunctions[beam.Direction](beam, collider));
                    }
                }
                else
                {
                    foreach (Collider c in colliderList.colliders)
                    {
                        entity.Collider = c;
                        if (beam.CollideCheck(entity))
                        {
                            shortestWidth = Math.Min(shortestWidth, LengthCalculatingFunctions[beam.Direction](beam, c));
                        }
                    }
                }

                entity.Collider = origCollider;
            }

            beam.Length = shortestWidth;
        }
コード例 #2
0
        public override void OnNewLaserbeam(Laserbeam laserbeams)
        {
            Player  player   = base.Scene.Tracker.GetEntity <Player>();
            Vector2 position = player != null && atPlayer ? player.Position : Position;

            float pitch = NoteHelper.relativeA4ToFreq(this.pitch - 69) / 440f;

            FMOD.Studio.EventInstance instance = Audio.Play(SFX.EventnameByHandle(sound), position);

            instance?.setVolume(volume);
            instance?.setPitch(pitch);
        }
コード例 #3
0
        public virtual bool LaserBlockingCheck(Laserbeam beam)
        {
            Collider origCollider = Collider;

            Collider = GetLaserBlockingCollider(beam);

            bool colliding = Collide.Check(beam, this);

            Collider = origCollider;

            return(colliding);
        }
コード例 #4
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];
                }
            }
        }
コード例 #5
0
        public override void OnLaserbeams(List <Laserbeam> laserbeams)
        {
            HashSet <Laserbeam> needsUpdate = new HashSet <Laserbeam>(reflections.Keys);

            foreach (Laserbeam beam in laserbeams)
            {
                reflect(beam);
                needsUpdate.Remove(beam);
            }

            foreach (Laserbeam beam in needsUpdate)
            {
                Laserbeam target = reflections[beam];

                target.RemoveSelf();
                reflections.Remove(beam);
            }
        }
コード例 #6
0
ファイル: LaserEmitter.cs プロジェクト: Cruor/PandorasBox
        private void onLastFrame(string s)
        {
            if (isActive() && laserbeam == null)
            {
                Level level = Scene as Level;

                laserbeam = new Laserbeam(Position - laserOffset, direction, color, beamDuration, this);
                level.Add(laserbeam);

                idleSprite.Play("idle", true);
                idleSprite.Rate       = 1;
                idleSprite.Visible    = true;
                startupSprite.Visible = false;

                bloom.Visible = light.Visible = true;
            }

            inStartupAnimation = false;
            startupSprite.Stop();
        }
コード例 #7
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);
        }
コード例 #8
0
        public static float GetLaserLengthDACOnGrid(Laserbeam beam, Grid grid, float checking)
        {
            float origLength = beam.Length;

            float offset = checking / 2f;

            beam.Length = offset;

            while (offset >= 1f)
            {
                bool colliding = grid.Collide(beam);
                int  sign      = colliding ? -1 : 1;

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

            float res = beam.Length;

            beam.Length = origLength;

            return(res);
        }
コード例 #9
0
ファイル: LaserEmitter.cs プロジェクト: Cruor/PandorasBox
        public override void Update()
        {
            if (isActive())
            {
                if (laserbeam == null && !inStartupAnimation)
                {
                    startupSprite.Play("start", true);
                    startupSprite.Rate    = 1;
                    startupSprite.Visible = true;
                    idleSprite.Visible    = false;

                    inStartupAnimation = true;

                    bloom.Visible = light.Visible = true;
                }
            }
            else
            {
                if (laserbeam != null && !inStartupAnimation)
                {
                    startupSprite.Play("start", true);
                    startupSprite.Rate = -1;
                    startupSprite.SetAnimationFrame(startupSprite.CurrentAnimationTotalFrames - 1);
                    startupSprite.Visible = true;
                    idleSprite.Visible    = false;

                    inStartupAnimation = true;

                    laserbeam.RemoveSelf();
                    laserbeam = null;

                    bloom.Visible = light.Visible = false;
                }
            }

            base.Update();
        }
コード例 #10
0
 public virtual Collider GetLaserBlockingCollider(Laserbeam beam)
 {
     return(LaserBlockingCollider);
 }
コード例 #11
0
 public virtual void OnDeadLaserbeam(Laserbeam beam)
 {
 }
コード例 #12
0
 public virtual void OnNewLaserbeam(Laserbeam beam)
 {
 }
コード例 #13
0
        public static bool LaserBlockingCheck(Scene scene, Laserbeam beam)
        {
            var res = scene.Tracker.GetEntities <LaserDetectorActor>().Cast <LaserDetectorActor>().Any(entity => entity.LaserBlockingCheck(beam));

            return(res);
        }
コード例 #14
0
 public static string GetReflection(string opening, Laserbeam beam)
 {
     return(GetReflection(opening, beam.Direction));
 }
コード例 #15
0
 public static float MaxBeamLength(Level level, Laserbeam beam)
 {
     return(MaxLengthFunction[beam.Direction](level, beam));
 }
コード例 #16
0
        public override Collider GetLaserBlockingCollider(Laserbeam beam)
        {
            bool notBlocking = knownBeams != null && knownBeams.Contains(beam);

            return(notBlocking ? direcitonKnownBlockingColliders[direction] : direcitonBlockingColliders[direction]);
        }