Exemplo n.º 1
0
        public BulletPathBlueprint[] PrecalcLaser(LevelBlueprint lvl, ICannonBlueprint cannon)
        {
            var worldNormal = CreateRayWorld(lvl, 0, 1);
            var worldExtend = CreateRayWorld(lvl, HITBOX_ENLARGE, 1.5f);

            var rayClock = new List <Tuple <BulletPathBlueprint, float> > [RESOLUTION];

            for (int ideg = 0; ideg < RESOLUTION; ideg++)
            {
                float deg  = ideg * (360f / RESOLUTION);
                var   rays = FindLaserPaths(lvl, worldNormal, worldExtend, cannon, deg);

                rayClock[ideg] = rays;
            }

            List <BulletPathBlueprint> resultRays = new List <BulletPathBlueprint>();

            for (;;)
            {
                for (int ideg = 0; ideg < RESOLUTION; ideg++)
                {
                    if (rayClock[ideg].Any())
                    {
                        resultRays.Add(ExtractBestRay(rayClock, ideg, rayClock[ideg].First().Item1.TargetCannonID));
                    }
                }
                break;
            }

            return(resultRays.ToArray());
        }
Exemplo n.º 2
0
        private void DrawGenericCannon(char chr, ICannonBlueprint c)
        {
            var x = c.X / 64;
            var y = c.Y / 64;

            if (c.Fraction == 0)
            {
                SetMap(x - 0.5f, y, '<');
                SetMap(x, y, chr);
                SetMap(x + 0.5f, y, '>');
            }
            else
            {
                if (c.Diameter <= 48)
                {
                    SetMap(x, y, chr);
                }
                else
                {
                    SetMap(x, y, chr);

                    SetMap(x - 0.5f, y - 0.5f, '/');
                    SetMap(x + 0.5f, y - 0.5f, '\\');
                    SetMap(x - 0.5f, y + 0.5f, '\\');
                    SetMap(x + 0.5f, y + 0.5f, '/');
                }
            }
        }
Exemplo n.º 3
0
        private BulletPathBlueprint[] Precalc(LevelBlueprint lvl, ICannonBlueprint cannon)
        {
            var worldNormal = CreateRayWorld(lvl);

            var rayClock = new List <Tuple <BulletPathBlueprint, float> > [RESOLUTION];

            for (int ideg = 0; ideg < RESOLUTION; ideg++)
            {
                float deg  = ideg * (360f / RESOLUTION);
                var   rays = FindBulletPaths(lvl, worldNormal, cannon, deg);

                rayClock[ideg] = rays;
            }

            RemoveUntrusted(rayClock);

            List <BulletPathBlueprint> resultRays = new List <BulletPathBlueprint>();

            for (;;)
            {
                for (int ideg = 0; ideg < RESOLUTION; ideg++)
                {
                    if (rayClock[ideg].Any())
                    {
                        resultRays.Add(ExtractBestRay(rayClock, ideg, rayClock[ideg].First().Item1.TargetCannonID));
                    }
                }
                break;
            }

            return(resultRays.ToArray());
        }
Exemplo n.º 4
0
 private List <Tuple <BulletPathBlueprint, float> > FindLaserPaths(LevelBlueprint lvl, World wBase, World wCollision, ICannonBlueprint cannon, float deg)
 {
     return(FindLaserPaths(lvl, wBase, wCollision, cannon.CannonID, new FPoint(cannon.X, cannon.Y), new List <Tuple <Vector2, Vector2> >(), deg * FloatMath.DegRad, deg * FloatMath.DegRad, MAX_COUNT_REFLECT, false, null));
 }
Exemplo n.º 5
0
        private List <Tuple <BulletPathBlueprint, float> > FindBulletPaths(LevelBlueprint lvl, World world, ICannonBlueprint cannon, float deg)
        {
            float startRadians = deg * FloatMath.DegRad;
            var   scale        = cannon.Diameter / Cannon.CANNON_DIAMETER;
            var   spawnPoint   = new FPoint(cannon.X, cannon.Y) + new Vector2(scale * (Cannon.CANNON_DIAMETER / 2 + Bullet.BULLET_DIAMETER * 0.66f), 0).Rotate(startRadians);
            var   spawnVeloc   = new Vector2(1, 0).Rotate(startRadians) * Cannon.BULLET_INITIAL_SPEED;

            var fbpresult = FindBulletPaths(lvl, world, cannon.CannonID, spawnPoint, spawnVeloc, new List <Vector2>(), scale, 0);

            var result = new List <Tuple <BulletPathBlueprint, float> >();

            foreach (var r in fbpresult)
            {
                var tgray = new BulletPathBlueprint(r.Item2.CannonID, startRadians, SimplifyRays(new Vector2(cannon.X, cannon.Y), r.Item1), r.Item1);
                result.Add(Tuple.Create(tgray, r.Item3));
            }

            return(result);
        }