Beispiel #1
0
        public bool IsCollided(Shot shot, Room room)
        {
            var intersectionDeter = new IntersectionDeterminant();
            var border = room.Border;
            if (intersectionDeter.IsIntersected(shot.Form,
                new RectangleF(room.Form.Left, room.Form.Top, border.Width, room.Form.Height)))
            {
                return true;
            }

            if (intersectionDeter.IsIntersected(shot.Form,
                new RectangleF(room.Form.Left, room.Form.Top, room.Form.Width, -border.Height)))
            {
                return true;
            }

            if (intersectionDeter.IsIntersected(shot.Form,
                new RectangleF(room.Form.Right - border.Width, room.Form.Top, border.Width, room.Form.Height)))
            {
                return true;
            }

            if (intersectionDeter.IsIntersected(shot.Form,
                new RectangleF(room.Form.Left, room.Form.Bottom + border.Height, room.Form.Width, -border.Height)))
            {
                return true;
            }

            return false;
        }
Beispiel #2
0
 public void Draw(Shot shot)
 {
     GL.BindTexture(TextureTarget.Texture2D, _textures[shot.Texture]);
     GL.Enable(EnableCap.Blend);
     GL.BlendFunc(BlendingFactorSrc.SrcAlpha, BlendingFactorDest.OneMinusSrcAlpha);
     new RectangleDrawer().Draw(shot.Form);
     GL.Disable(EnableCap.Blend);
 }
Beispiel #3
0
 public void Shoot(Room room, Shot shot)
 {
     if (_canShoot)
     {
         room.Shots.Add(shot);
         _canShoot = false;
         var timer = new Timer(_attackSpeed);
         timer.AutoReset = false;
         timer.Elapsed += OnTimedEvent;
         timer.Start();
     }
 }
Beispiel #4
0
        public bool IsCollided(Shot shot, Enemy enemy)
        {
            var intersectionDeter = new IntersectionDeterminant();

            return(intersectionDeter.IsIntersected(shot.Form, enemy.Form));
        }
Beispiel #5
0
        public bool IsCollided(Shot shot, Player player)
        {
            var intersectionDeter = new IntersectionDeterminant();

            return(intersectionDeter.IsIntersected(shot.Form, player.Form));
        }
Beispiel #6
0
 private void ShotPlayerHandle(Shot shot, Player player)
 {
     player.TakeDamage(shot.Damage);
     shot.IsRemoved = true;
 }
Beispiel #7
0
 private void ShotEnemyHandle(Shot shot, Enemy enemy)
 {
     enemy.TakeDamage(shot.Damage);
     shot.IsRemoved = true;
 }
Beispiel #8
0
 private void ShotBorderHandle(Shot shot, Room room)
 {
     shot.IsRemoved = true;
 }
Beispiel #9
0
 private static bool ShotIsRemoved(Shot shot)
 {
     return (shot.Range <= 0 || shot.IsRemoved);
 }
Beispiel #10
0
 public bool IsCollided(Shot shot, Player player)
 {
     var intersectionDeter = new IntersectionDeterminant();
     return intersectionDeter.IsIntersected(shot.Form, player.Form);
 }
Beispiel #11
0
 public bool IsCollided(Shot shot, Enemy enemy)
 {
     var intersectionDeter = new IntersectionDeterminant();
     return intersectionDeter.IsIntersected(shot.Form, enemy.Form);
 }