Beispiel #1
0
        public void Wiggle(Inker inker)
        {
            if (Coordinates[0, 0] > 0)
            {
                if (!(Coordinates[0, 0] > inker.X - inker.Width / 2))
                {
                    SetTarget(Target += inker.Speed, inker);
                }
            }
            else
            {
                SetTarget(inker.Beam.Target += inker.Speed, inker);
            }

            if (Coordinates[1, 0] < GameController.SCREEN_WIDTH)
            {
                if (!(Coordinates[1, 0] < inker.X + inker.Width * 1.5))
                {
                    SetTarget(Target -= inker.Speed, inker);
                }
            }
            else
            {
                SetTarget(Target -= inker.Speed, inker);
            }

            Lazer.Update(this);
            SetOrigin(inker);
        }
Beispiel #2
0
 public Beam(Inker p)
 {
     Coordinates = new short[4, 2];
     SetRange(RANGE);
     SetWidth(WIDTH);
     Place(p);
     SetTarget(p.X, p);
     Ammo  = new Stack <Projectile>();
     Lazer = new Lazer(this);
 }
Beispiel #3
0
        public static Projectile NearestProjectile(List <Projectile> projectiles, Inker inker)
        {
            SortedList <double, int> projectilesByDistance = new SortedList <double, int>();
            double distance;

            for (int i = 0; i < projectiles.Count; i++)
            {
                distance = (Math.Pow(projectiles[i].Coordinates[2, 0] - (inker.X + inker.Width / 2), 2) +
                            Math.Pow(projectiles[i].Coordinates[2, 1] - inker.Y, 2));
                if (!projectilesByDistance.ContainsKey(distance))
                {
                    projectilesByDistance.Add(distance, i);
                }
            }
            KeyValuePair <double, int> minElement = projectilesByDistance.ElementAt(0);

            return(projectiles[minElement.Value]);
        }
Beispiel #4
0
        public void Place(Inker inker)
        {
            SetOrigin(inker);

            Coordinates[0, 0] = (short)(inker.X - Width + inker.Width / 2);
            Coordinates[1, 0] = (short)(inker.X + Width + inker.Width / 2);

            if (inker.PlayerNumber == 1)
            {
                Coordinates[2, 1] = (short)(inker.Y + 12);
                Coordinates[3, 1] = Coordinates[2, 1];
                Coordinates[0, 1] = (short)(inker.Y - Range);
                Coordinates[1, 1] = Coordinates[0, 1];
            }
            else
            {
                Coordinates[2, 1] = (short)(inker.Y + inker.Height - 6);
                Coordinates[3, 1] = Coordinates[2, 1];
                Coordinates[0, 1] = (short)(Coordinates[2, 1] + Range);
                Coordinates[1, 1] = Coordinates[0, 1];
            }

            Target = (short)(Coordinates[0, 0] + Width);
        }
Beispiel #5
0
 public void SetTarget(short x, Inker inker)
 {
     Coordinates[0, 0] = (short)(x - Width + inker.Width / 2);
     Coordinates[1, 0] = (short)(x + Width + inker.Width / 2);
 }
Beispiel #6
0
 public void SetOrigin(Inker inker)
 {
     Coordinates[2, 0] = (short)(inker.X + 35);
     Coordinates[3, 0] = (short)(inker.X + 41);
 }
Beispiel #7
0
 public bool Crashes(Inker target)
 {
     return(!((Coordinates[0, 0] < target.X && Coordinates[1, 0] < target.X) ||
              (Coordinates[0, 0] > target.X + target.Width && Coordinates[1, 0] > target.X + target.Width)) &&
            Damage);
 }
Beispiel #8
0
 public void DrawInker(Inker inker)
 {
     Sdl.SDL_Rect src  = new Sdl.SDL_Rect(0, 0, inker.Width, inker.Height);
     Sdl.SDL_Rect dest = new Sdl.SDL_Rect(inker.GetX(), inker.GetY(), inker.Width, inker.Height);
     Sdl.SDL_BlitSurface(inker.GetSprite().ImagePtr, ref src, screen, ref dest);
 }