상속: Laser
예제 #1
0
 public void ShootLaser()
 {
     if (_currentAmountBullerForLaser > 0)
     {
         SetCurrentAmountBulletForLaser(_currentAmountBullerForLaser - 1);
         LaserShot?.Invoke(_position, _direction);
     }
 }
    private void OnTriggerEnter(Collider other)
    {
        LaserShot laserShot = other.gameObject.GetComponent <LaserShot>();

        if (laserShot != null)
        {
            boxHitSound.Play();
            gameObject.SetActive(false);
            shootableBoxparticleSystem.Play();
        }
    }
예제 #3
0
    public override void Updgrade(GameObject player)
    {
        Destroy(player.GetComponent <BaseWeapon>());
        Destroy(player.GetComponent <TripleShot>());
        Destroy(player.GetComponent <SpreadShot>());
        LaserShot laser = player.AddComponent <LaserShot>();

        laser.firepoint    = player.GetComponent <PlayerController>().firePoint.transform;
        laser.bulletPrefab = player.GetComponent <PlayerController>().laserPrefab;
        player.GetComponent <PlayerController>().attack = laser;
    }
예제 #4
0
 public override void SetShots()
 {
     allshots    = new IShotType[6];
     allshots[0] = new LaserShot(2, 2.5f, 2, 1.3f, 0.6f);
     allshots[1] = new LaserShot(2, 2.3f, 4, 1.7f, 0.6f);
     allshots[2] = new LaserShot(2, 2.1f, 6, 2, 0.6f);
     allshots[3] = new LaserFocus(1, 2.3f, 8, 1.7f, 0);
     allshots[4] = new LaserFocus(1, 2.1f, 10, 2f, 0);
     allshots[5] = new LaserFocus(1, 2f, 12, 1.95f, 0);
     bomb        = new Magicannon();
 }
예제 #5
0
    void OnTriggerEnter2D(Collider2D col)
    {
        LaserShot missile = col.gameObject.GetComponent <LaserShot>();

        if (missile)
        {
            Instantiate(smallHit, new Vector3(transform.position.x, transform.position.y - 0.4f, transform.position.z), Quaternion.identity);
            //Destroy (smallHit,3.0f);
            missile.HitDone();
            enemyHealth -= missile.DamageTaken();
            if (enemyHealth <= 0)
            {
                EnemyDefeat();
            }
        }
    }
예제 #6
0
파일: Player.cs 프로젝트: Valefors/SHMUP
    private void OnTriggerEnter2D(Collider2D pCol)
    {
        Shot shotCollided = pCol.gameObject.GetComponent <Shot>();

        if (shotCollided != null)
        {
            if (shotCollided.GetSide())
            {
                shotCollided.Touch();
                this.GetHit();
            }
        }
        LaserShot laserShotCollided = pCol.gameObject.GetComponent <LaserShot>();

        if (laserShotCollided != null)
        {
            if (laserShotCollided.GetSide() && laserShotCollided.isActive)
            {
                this.GetHit();
            }
        }
    }
예제 #7
0
 private void SpinShotLaser(BCBlockGameState gstate, LaserShot shot, LinkedList<PointF> laserPoints)
 {
 }
예제 #8
0
    void Update()
    {
        // Is this me?
        if (!networkView.isMine && !is_menu_ship)
        {
            SyncedMovement();
            return;
        }

        string fire_string  = "fire";
        string boost_string = "boost";
        string brake_string = "brake";

        // Stop all thrusters when pressing Fire 1
        if (Input.GetButtonDown(brake_string))
        {
            foreach (Thruster _thruster in thrusters)
            {
                _thruster.StopThruster();
            }
        }
        // Start all thrusters when releasing Fire 1
        if (Input.GetButtonUp(brake_string))
        {
            foreach (Thruster _thruster in thrusters)
            {
                _thruster.StartThruster();
            }
        }
        // Boost all thrusters when pressing Fire 3
        if (Input.GetButtonDown(boost_string))
        {
            foreach (Thruster _thruster in thrusters)
            {
                _thruster.BoostThruster();
            }
        }
        // Unboost all thrusters when releasing Fire 3
        if (Input.GetButtonUp(boost_string))
        {
            foreach (Thruster _thruster in thrusters)
            {
                _thruster.StartThruster();
            }
        }
        if (Input.GetButton(fire_string) && Time.time > nextFire)
        {
            nextFire = Time.time + fireRate;
            // Itereate through each weapon mount point Vector3 in array
            foreach (Vector3 _wmp in weaponMountPoints)
            {
                // Calculate where the position is in world space for the mount point
                Vector3 _pos = transform.position + transform.right * _wmp.x + transform.up * _wmp.y + transform.forward * _wmp.z;

                // Instantiate the laser prefab at position with the spaceships rotation
                Transform _laserShot;
                bool      isLocal = false;
                if (!is_menu_ship)
                {
                    _laserShot = (Transform)Network.Instantiate(laserShotPrefab, _pos, transform.rotation, 0);
                }
                else
                {
                    _laserShot = (Transform)GameObject.Instantiate(laserShotPrefab, _pos, transform.rotation);
                    isLocal    = true;
                }
                // Specify which transform it was that fired this round so we can ignore it for collision/hit
                LaserShot shot = _laserShot.GetComponent <LaserShot>();
                shot.firedBy = transform;
                shot.isLocal = isLocal;
            }
            // Play sound effect when firing
            if (soundEffectFire != null)
            {
                audio.PlayOneShot(soundEffectFire);
            }
        }
    }
        private void ShootFunction(int chargeticks)
        {
            // TerminatorBehaviour Power Levels
            // Each Terminator Power up will add one to the power.
            //Power Level One: Machine gun
            // Power level Two: Shoot a single ball from the center of the paddle upwards.
            // Power Level Three: similar to Level one, but it shoots from each side of the paddle.
            //power level Four: shoots a single laser from the center of the paddle.
            //power level Five: shoots a laser from each side.
            // power level Six: Shoot a single ball from the center of the paddle upwards: however,
            //this will have a laserspinball behaviour, delay set to half a second.
            //power level Seven, same as five, but with laser spin
            //power level eight: SpinShot.

            if (mstate.PlayerPaddle == null) return;

            //only shoot if we are the first in the list of behaviours that are this type....
            if (!mstate.PlayerPaddle.Behaviours.Contains(this)) return;
            if (mstate.PlayerPaddle.Behaviours.First((x) => x.GetType() == typeof (TerminatorBehaviour)) == this)
            {
                if (mstate.PlayerPaddle.Energy == 0)
                {
                    BCBlockGameState.Soundman.PlaySound("shootfail");
                    //and, again, showmanship at work- "shoot" some black light orbs... to simulate smoke...

                    for (int i = 0; i < 6; i++)
                    {
                        PointF usespeed = new PointF(0, (float) (-3 - (BCBlockGameState.rgen.NextDouble())));
                        usespeed = BCBlockGameState.VaryVelocity(usespeed, Math.PI/6);
                        LightOrb addorb = new LightOrb(mstate.PlayerPaddle.Getrect().CenterPoint(),
                                                       BCBlockGameState.rgen.NextDouble() > 0.5d
                                                           ? Color.Black
                                                           : Color.Gray,
                                                       15 + (float) (15*BCBlockGameState.rgen.NextDouble()));
                        addorb.Velocity = usespeed;
                        addorb.VelocityDecay = new PointF(0.9f, 0.85f);
                        mstate.Particles.Add(addorb);
                        //take damage, too...
                    }
                    mstate.PlayerPaddle.HP -= 10;
                    return;
                }
                else
                {
                    BCBlockGameState.Soundman.PlaySound("firelaser");
                }
                mstate.PlayerPaddle.Energy--;
                Paddle pad = mstate.PlayerPaddle;
                RectangleF paddlerect = mstate.PlayerPaddle.Getrect();
                PointF MiddleTop = new PointF(paddlerect.Left + (paddlerect.Width/2), paddlerect.Top);
                PointF LeftTop = new PointF(paddlerect.Left, paddlerect.Top);
                PointF RightTop = new PointF(paddlerect.Right, paddlerect.Top);
                Pen ChosenPenColor = new Pen(Color.Blue, 2);
                //TODO: make it depend on the paddle health. (blue when full, red when damaged).

                //if the powerlevel exceeds MaxPowerup...
                if (PowerLevel > MaxPowerup)
                {
                    MachineGunTimer = new Timer(MachineGun, null, 60, 130); //120 ms delay...
                }
                //if it's larger than powerLevel*2, set it to powerLevel*2...
                if (PowerLevel > PowerLevel*2) PowerLevel = PowerLevel*2;
                int pPowerLevel = ((PowerLevel - 1)%(MaxPowerup)) + 1;
                //Power Level One: Machine gun

                if (pPowerLevel == 1)
                {
                    if (PowerLevel == 1)
                    {
                        for (int i = 0; i < 5; i++)
                        {
                            Bullet firebullet =
                                new Bullet(
                                    new PointF(
                                        mstate.PlayerPaddle.Getrect().Left + (mstate.PlayerPaddle.Getrect().Width/2),
                                        mstate.PlayerPaddle.Getrect().Top),
                                    BCBlockGameState.VaryVelocity(new PointF(0, -10), Math.PI/7));
                            mstate.GameObjects.AddLast(firebullet);
                        }
                    }
                    else
                    {
                        Bullet firebullet =
                            new Bullet(
                                new PointF(
                                    mstate.PlayerPaddle.Getrect().Left + (mstate.PlayerPaddle.Getrect().Width/2),
                                    mstate.PlayerPaddle.Getrect().Top),
                                BCBlockGameState.VaryVelocity(new PointF(0, -10), Math.PI/7));
                        mstate.GameObjects.AddLast(firebullet);
                    }
                }
                else if (pPowerLevel == 2)
                {
                    // Power level Two: Shoot a single ball from the center of the paddle upwards. (temp)
                    cBall shootball = new cBall(MiddleTop,
                                                BCBlockGameState.VaryVelocity(new PointF(0, -8), Math.PI/8));
                    shootball.Radius = 3;
                    shootball.DrawColor = Color.Yellow;
                    shootball.DrawPen = new Pen(Color.GreenYellow);
                    shootball.Behaviours.Add(new TempBallBehaviour());
                    mstate.ShootBalls.AddRange(new cBall[] {shootball});
                }
                else if (pPowerLevel == 3)
                {
                    // Power Level Three: similar to Level one, but it shoots from each side of the paddle.
                    PointF[] Originspots = new PointF[] {LeftTop, RightTop};
                    foreach (PointF ShotOrigin in Originspots)
                    {
                        cBall shootit = new cBall(ShotOrigin,
                                                  BCBlockGameState.VaryVelocity(new PointF(0f, -8.8f), Math.PI/8.8f));
                        shootit.Radius = 3;
                        shootit.DrawColor = Color.Yellow;
                        shootit.DrawPen = new Pen(Color.RoyalBlue);
                        shootit.Behaviours.Add(new TempBallBehaviour());
                        mstate.ShootBalls.Add(shootit);
                    }
                }
                else if (pPowerLevel == 4)
                {
                    //weak hitscan, straight upwards.
                    HitscanBullet hsb = new HitscanBullet(paddlerect.TopCenter(), new PointF(0, -2));
                    hsb.Penetrate = false;
                    hsb.Strength = HitscanBullet.HitscanStrengthConstants.hitscan_bullet;
                    mstate.GameObjects.AddLast(hsb);
                    BCBlockGameState.Soundman.PlaySound("laser2");
                }
                else if (pPowerLevel == 5)
                {
                    for (int i = 0; i < 5; i++)
                    {
                        PointF selectedvelocity = BCBlockGameState.VaryVelocity(new PointF(0, -8), Math.PI/16);
                        HitscanBullet hsb = new HitscanBullet(paddlerect.TopCenter(), selectedvelocity);
                        hsb.Penetrate = false;
                        hsb.Strength = HitscanBullet.HitscanStrengthConstants.hitscan_bullet;
                        mstate.GameObjects.AddLast(hsb);
                        BCBlockGameState.Soundman.PlaySound("laser2");
                    }
                }
                else if (pPowerLevel == 6)
                {
                    //power level Four: shoots a single laser from the center of the paddle.
                    LaserShot ShootLaser = new LaserShot(MiddleTop, new PointF(0, -9), ChosenPenColor, 36);
                    mstate.GameObjects.AddLast(ShootLaser);
                }
                else if (pPowerLevel == 7)
                {
                    PointF[] Originspots = new PointF[] {LeftTop, RightTop};
                    PointF usevelocity = BCBlockGameState.VaryVelocity(new PointF(0f, -8.8f), Math.PI/8.9f);
                    foreach (PointF ShotOrigin in Originspots)
                    {
                        LaserShot ShootLaser = new LaserShot(ShotOrigin, usevelocity, ChosenPenColor);
                        mstate.GameObjects.AddLast(ShootLaser);
                        //power level Five: shoots a laser from each side.
                    }
                }
                else if (pPowerLevel == 8)
                {
                    cBall shootball = new cBall(MiddleTop,
                                                BCBlockGameState.VaryVelocity(new PointF(0f, -1f), Math.PI/10));
                    shootball.Behaviours.Add(new LaserSpinBehaviour(new TimeSpan(0, 0, 0, 0, 300)));
                    shootball.Behaviours.Add(new TempBallBehaviour());
                    shootball.Radius = 3;
                    shootball.DrawColor = Color.Yellow;
                    shootball.DrawPen = new Pen(Color.GreenYellow);
                    mstate.ShootBalls.Add(shootball);
                    // power level Six: Shoot a single ball from the center of the paddle upwards: however,
                    //this will have a laserspinball behaviour, delay set to half a second.
                }
                else if (pPowerLevel == 9)
                {
                    //power level Seven, same as five, but with laser spin
                    //also same as 6 but with two of them...
                    PointF[] Originspots = new PointF[] {LeftTop, RightTop};
                    foreach (PointF ShotOrigin in Originspots)
                    {
                        cBall shootball = new cBall(ShotOrigin,
                                                    BCBlockGameState.VaryVelocity(new PointF(0f, -9f), Math.PI/10));
                        shootball.Behaviours.Add(new LaserSpinBehaviour(new TimeSpan(0, 0, 0, 300)));
                        shootball.Behaviours.Add(new TempBallBehaviour());
                        shootball.Radius = 3;
                        shootball.DrawColor = Color.Yellow;
                        shootball.DrawPen = new Pen(Color.GreenYellow);
                        mstate.ShootBalls.Add(shootball);
                    }
                }
                else if (pPowerLevel == 10)
                {
                    //spinshot
                    PointF selectedspeed = BCBlockGameState.VaryVelocity(new PointF(0, -9f), Math.PI/10);
                    SpinShot shootit = new SpinShot(mstate,
                                                    new PointF(
                                                        mstate.PlayerPaddle.Getrect().Left +
                                                        (mstate.PlayerPaddle.Getrect().Width/2),
                                                        mstate.PlayerPaddle.Getrect().Top), 12, 16,
                                                    ((float) Math.PI/6), selectedspeed);

                    mstate.GameObjects.AddLast(shootit);
                }
            }
            else
            {
                Debug.Print("Terminator Behaviour not first Terminator in behaviours collection... ignoring...");
            }
        }
예제 #10
0
        public override List<Block> PerformFrame(cBall ballobject, BCBlockGameState ParentGameState, ref List<cBall> ballsadded, ref List<cBall> ballsremove, out bool removethis)
        {
            if ((DateTime.Now - lastfire) > _Interval)
            {

                BCBlockGameState.Soundman.PlaySound("ELECTRICLASER");
                LaserShot makeshot = new LaserShot(ballobject.Location, (float)(Math.PI * 2 * BCBlockGameState.rgen.NextDouble()), 4, 9, ChooseLaserPen());
                //hook the event, if desired.
                makeshot.Weak = true;
                if (_EventFunction != null)
                    makeshot.LaserShotFrame += _EventFunction;
                ParentGameState.GameObjects.AddLast(makeshot);

                lastfire = DateTime.Now;
            }

            return base.PerformFrame(ballobject, ParentGameState, ref ballsadded, ref ballsremove, out removethis);
        }