private void Shoot() { Point playerLocation = new Point(form.player.Charc.Location.X + 50, form.player.Charc.Location.Y + 50); Point enemyShootingLocation = new Point(enemy.Location.X + 40, enemy.Location.Y + 40); if (playerLocation.X < enemy.Location.X) { LaserLeft laser = new LaserLeft(); laser.BackColor = Color.Red; laser.Location = new Point(playerLocation.X, enemyShootingLocation.Y); laser.Size = new System.Drawing.Size(enemyShootingLocation.X - playerLocation.X, playerLocation.Y - enemyShootingLocation.Y); form.Controls.Add(laser); laser.BringToFront(); PlayerHitCheck(new Point(laser.Location.X, laser.Location.Y + laser.Height)); laser.Dispose(); } else { LaserRight laser = new LaserRight(); laser.BackColor = Color.Red; laser.Location = new System.Drawing.Point(enemyShootingLocation.X, enemyShootingLocation.Y); laser.Size = new System.Drawing.Size(playerLocation.X - enemyShootingLocation.X, playerLocation.Y - enemyShootingLocation.Y); form.Controls.Add(laser); laser.BringToFront(); PlayerHitCheck(new Point(laser.Location.X + laser.Width, laser.Location.Y + laser.Height)); laser.Dispose(); } }
public void Shoot(int xMouse, int yMouse) { if (form.Pause) { return; } if (this.PlayerInCover) { return; } Point playerCenter = new Point(Charc.Location.X + (Charc.Width / 2), Charc.Location.Y + (Charc.Height / 2)); if (xMouse > playerCenter.X) { //player's right ... which means left sided laser is drawn (from start point to left side) Charc.Image = Properties.Resources.Idle_Right; LaserLeft laser = new LaserLeft(); Point shootingPoint = new Point(Charc.Location.X + 54, Charc.Location.Y + 65); laser.Location = new System.Drawing.Point(shootingPoint.X, yMouse); laser.Size = new System.Drawing.Size(xMouse - shootingPoint.X, shootingPoint.Y - yMouse); form.Controls.Add(laser); laser.BringToFront(); laser.Dispose(); } else { //player's left ... which means right sided laser is drawn (from start point to right side) Charc.Image = Properties.Resources.Idle_Left; LaserRight laser = new LaserRight(); Point shootingPoint = new Point(Charc.Location.X + 0, Charc.Location.Y + 69); laser.Location = new System.Drawing.Point(xMouse, yMouse); laser.Size = new System.Drawing.Size(shootingPoint.X - xMouse, shootingPoint.Y - yMouse); form.Controls.Add(laser); laser.BringToFront(); laser.Dispose(); } }