Exemple #1
0
        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();
            }
        }
Exemple #2
0
    // Use this for initialization
    public override void Start()
    {
        base.Start();

        playerHealth   = GameObject.Find("Player").GetComponent <PlayerHealth>();
        playerMovement = GameObject.Find("Player").GetComponent <PlayerMovement>();

        tank_fieldOfView      = transform.Find("Vision").GetComponent <Tank_FieldOfView>();
        launchingPoint        = transform.Find("Launching Point").transform;
        spriteRenderer        = transform.GetComponent <SpriteRenderer>();
        animator              = transform.GetComponent <Animator>();
        fireIndicatorAnimator = transform.Find("Firing Indicator").GetComponent <Animator>();

        movingRangeCollider = transform.parent.Find("Moving Range").GetComponent <BoxCollider2D>();

        laserLeftCollider  = transform.Find("Laser Left").GetComponent <BoxCollider2D>();
        laserRightCollider = transform.Find("Laser Right").GetComponent <BoxCollider2D>();

        laserLeftSprite  = transform.Find("Laser Left").GetComponent <SpriteRenderer>();
        laserRightSprite = transform.Find("Laser Right").GetComponent <SpriteRenderer>();

        laserLeftAnimator  = transform.Find("Laser Left").GetComponent <Animator>();
        laserRightAnimator = transform.Find("Laser Right").GetComponent <Animator>();

        laserLeft  = transform.Find("Laser Left").GetComponent <LaserLeft>();
        laserRight = transform.Find("Laser Right").GetComponent <LaserRight>();

        timeToWaitForReActivate = 3f;

        timeForLaserShown        = 2.5f;
        currentTimeForLaserShown = timeForLaserShown;
        dirX = 1;

        timeToFire        = 1.3f;
        currentTimeToFire = timeToFire;

        end = true;

        laserLeftCollider.enabled = false;
        laserLeftSprite.enabled   = false;
        laserLeft.enabled         = false;

        laserRightCollider.enabled = false;
        laserRightSprite.enabled   = false;
        laserRight.enabled         = false;


        enemyHealth  = transform.GetComponent <EnemyHealthBar>();
        tankSpot     = GameObject.Find("Tank Spot").gameObject;
        mainCamera   = GameObject.Find("Main Camera").GetComponent <Camera>();
        cameraFollow = GameObject.Find("Main Camera").GetComponent <CameraFollow>();
        tankCamera   = tankSpot.transform.Find("Camera").GetComponent <Camera>();
        blocks10     = GameObject.Find("Blocks 10").gameObject;
        //StartCoroutine("WaitThenRoll", 3f);
    }
Exemple #3
0
        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();
            }
        }