Beispiel #1
0
 public void Destroy(meteor met, EventArgs e)
 {
     try
     {
         met.BackgroundImage       = Image.FromFile("explode.jpg");
         met.BackgroundImageLayout = ImageLayout.Stretch;
         AsteroidDestroy.Enabled   = true;
     }
     catch { };
     met.Dispose();
 }
Beispiel #2
0
        public void AddMeteor(int top, int left, int Size)
        {
            //Panel Meteor = new Panel();
            BonusMeteor   = MCol.Next() % BonusRate;
            Meteor        = new meteor();
            Meteor.Height = Meteor.Width = Size;

            switch (BonusMeteor)
            {
            case 3:
            {
                try
                {
                    Meteor.BackgroundImage       = Image.FromFile("weaponBonus.jpg");
                    Meteor.BackgroundImageLayout = ImageLayout.Stretch;
                }
                catch { };
                Meteor.BackColor = Color.Blue;
                Meteor.Height    = Meteor.Width = BonusSize;
                break;
            }

            case 2:
            {
                try
                {
                    Meteor.BackgroundImage       = Image.FromFile("NRJ.jpg");
                    Meteor.BackgroundImageLayout = ImageLayout.Stretch;
                }
                catch { };
                Meteor.BackColor = Color.Lime;
                Meteor.Height    = Meteor.Width = BonusSize;
                break;
            }

            default:
            {
                try
                {
                    Meteor.BackgroundImage       = Image.FromFile("meteor.jpg");
                    Meteor.BackgroundImageLayout = ImageLayout.Stretch;
                }
                catch { };
                Meteor.BackColor = Color.Brown;
                break;
            }
            }
            splitContainer1.Panel2.Controls.Add(Meteor);
            Meteor.Top         = top;
            Meteor.Left        = left;
            MeteorTime.Enabled = true;
            Meteor.Visible     = true;
            MeteorsExist       = true;
        }
Beispiel #3
0
    IEnumerator waveSpawner()
    {
        while (true)
        {
            // Pool them later.
            Vector3 spawnPos     = gridArray[Random.Range(0, 15)];
            int     whereToSpawn = Random.Range(0, 2);
            Vector2 realSpawnPos = new Vector2(0, 0);
            switch (whereToSpawn)
            {
            case 0:
                realSpawnPos = new Vector2(spawnPos.x, -29.25f);
                whereToSpawn = 0;
                break;

            case 1:
                realSpawnPos = new Vector2(0, spawnPos.y);
                whereToSpawn = Random.Range(0, 2);
                if (whereToSpawn != 0)
                {
                    realSpawnPos.x = -88.0f;
                    whereToSpawn   = 1;
                }
                else
                {
                    realSpawnPos.x = -73.0f;
                    whereToSpawn   = 2;
                }
                break;

            default:
                print("GameController :: Unknown range!");
                break;
            }
            GameObject spawnedMeteor       = Instantiate(meteorToSpawn, realSpawnPos, this.transform.rotation);
            meteor     meteorCompReference = spawnedMeteor.GetComponent <meteor>();
            meteorCompReference.GameContRef = this;
            switch (whereToSpawn)
            {
            case 0:
                meteorCompReference.YMov = -1.0f;
                meteorCompReference.XMov = 0.0f;
                break;

            case 1:
                meteorCompReference.XMov = 1.0f;
                meteorCompReference.YMov = 0.0f;
                break;

            case 2:
                meteorCompReference.XMov = -1.0f;
                meteorCompReference.YMov = 0.0f;
                break;

            default:
                break;
            }


            meteorSpawnInterval -= 0.1f;
            if (meteorSpawnInterval < 1f)
            {
                meteorSpawnInterval = 1f;
            }
            UpdateScore();
            yield return(new WaitForSeconds(meteorSpawnInterval));
        }
    }
Beispiel #4
0
        private void LaserTime_Tick(object sender, EventArgs e)
        {
            foreach (Control control in splitContainer1.Panel2.Controls)
            {
                laser tb = control as laser;
                if (tb != null)
                {
                    if (tb.Left > 0)
                    {
                        tb.Left -= 10;
                    }
                    else
                    {
                        tb.Dispose();
                    }
                    foreach (Control control1 in splitContainer1.Panel2.Controls)
                    {
                        meteor tb1 = control1 as meteor;
                        if (tb1 != null)
                        {
                            if (MeteorsExist)
                            {
                                if
                                (
                                    (
                                        (tb1.Top - DamageRange <= tb.Top)
                                        &&
                                        (tb1.Top + tb1.Height + DamageRange >= tb.Top + tb.Height)

                                    )
                                    &&
                                    (
                                        (tb1.Left <= tb.Left)
                                        &&
                                        (tb1.Left + tb1.Width >= tb.Left)
                                    )
                                )
                                {
                                    tb.Dispose();
                                    if (tb1.Height > 20)
                                    {
                                        int x = tb1.Left;
                                        int y = tb1.Top;
                                        int h = tb1.Height;
                                        Destroy(tb1, e);
                                        Random Ry = new Random();
                                        Random Rx = new Random();
                                        if (tb1.BackColor == Color.Brown)
                                        {
                                            if (tb1.Height < 50)
                                            {
                                                AddMeteor(y + Ry.Next() % Razbros, x + Rx.Next() % Razbros, h / 2);
                                                AddMeteor(y + h + Ry.Next() % Razbros, x + Rx.Next() % Razbros, h / 2);
                                            }
                                            else
                                            {
                                                AddMeteor(y + Ry.Next() % Razbros, x + Rx.Next() % Razbros, h / 2);
                                                AddMeteor(y - h + Ry.Next() % Razbros, x + Rx.Next() % Razbros, h / 2);
                                                AddMeteor(y + h + Ry.Next() % Razbros, x + Rx.Next() % Razbros, h / 2);
                                            }
                                        }
                                    }
                                    else
                                    {
                                        Destroy(tb1, e);
                                        Score += tb1.Width;
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
Beispiel #5
0
 private void MeteorTime_Tick(object sender, EventArgs e)
 {
     foreach (Control control in splitContainer1.Panel2.Controls)
     {
         meteor tb = control as meteor;
         if (tb != null)
         {
             if (tb.Left + tb.Width + 10 < splitContainer1.Width)
             {
                 tb.Left += MeteorSpeed;
             }
             else
             {
                 tb.Dispose();
             }
             if
             (
                 (
                     (
                         (tb.Top <= BattleShip.Top)
                         ||
                         (tb.Top <= BattleShip.Top + BattleShip.Height)
                     )
                     &&
                     (
                         (tb.Top + Meteor.Height >= BattleShip.Top)
                         ||
                         (tb.Top + Meteor.Height >= BattleShip.Top + BattleShip.Height)
                     )
                 )
                 &&
                 (
                     (
                         (tb.Left <= BattleShip.Left)
                         ||
                         (tb.Left <= BattleShip.Left + BattleShip.Width)
                     )
                     &&
                     (
                         (tb.Left + Meteor.Width >= BattleShip.Left)
                         ||
                         (tb.Left + Meteor.Width >= BattleShip.Left + BattleShip.Width)
                     )
                 )
             )
             {
                 int Wid = tb.Width;
                 Destroy(tb, e);
                 if (!failed)
                 {
                     if (!tb.Disposing)
                     {
                         if (tb.BackColor == Color.Brown)
                         {
                             Damage(Wid);
                         }
                         if (tb.BackColor == Color.Blue)
                         {
                             if (LaserLvl < MaxLaserLvl)
                             {
                                 LaserLvl++;
                             }
                             Score += BonusScore;
                         }
                         if (tb.BackColor == Color.Lime)
                         {
                             progressBar3.Maximum += NRJBonusCoast;
                             progressBar3.Value    = progressBar3.Maximum;
                             Score += BonusScore;
                             NRJrestoreVal++;
                         }
                     }
                 }
             }
         }
     }
 }