Beispiel #1
0
        public bool CollidesWith(double x, double y, double facing, DCollider other, double otherX, double otherY, double otherFacing)
        {
            foreach (var c in dCircles)
            {
                var rotatedC = Geometry.Rotate((float)c.X, (float)c.Y, (float)facing);
                var cX       = x + rotatedC.X - otherX;
                var cY       = y + rotatedC.Y - otherY;
                foreach (var d in other.dCircles)
                {
                    var rotatedD = Geometry.Rotate((float)d.X, (float)d.Y, (float)otherFacing);
                    var distX    = cX - rotatedD.X;
                    var distY    = cY - rotatedD.Y;
                    var rad      = c.Radius + d.Radius;
                    if (distX * distX + distY * distY < rad * rad)
                    {
                        return(true);
                    }
                }
            }

            return(false);
        }
Beispiel #2
0
        public Projectile(BulletType bulletType, int lifetime, UnitGraphics uGraphics, DCollider collider,
                          double shooterVelocity, double shooterFacing, double bulletVelocity, double shooterAngle,
                          double spawnX, double spawnY)
        {
            this.bulletType = bulletType;
            this.angle      = shooterAngle;
            this.velocity   = shooterVelocity;
            this.facing     = shooterFacing;

            this.uGraphics = uGraphics;
            this.collider  = collider;
            this.lifetime  = lifetime;
            this.posX      = spawnX;
            this.posY      = spawnY;

            Geometry.ApplyForce(ref this.velocity, ref this.angle, bulletVelocity, shooterFacing);
            if (bulletType == BulletType.Straight)
            {
                damage = 1;
            }
            else if (bulletType == BulletType.StraightStrong)
            {
                damage = 3;
            }
            else if (bulletType == BulletType.FourWay)
            {
                damage = 1;
            }
        }