Exemplo n.º 1
0
        private void GenerateBonus()
        {
            Random rand = new Random();
            int    x    = rand.Next(4, w_count - 2);
            int    y    = 0;
            Point  pos  = new Point(block_size * x, block_size * y);

            if (rand.NextDouble() > 0.9 && player.lifecount < 50)
            {
                RepairKit rk = new RepairKit(pos, 40);
                canvas.setPosition(rk);
                canvas.Add(rk);
                bonuses.AddLast(rk);
            }
            else
            if (rand.NextDouble() > 0.96)
            {
                DoubleDamage dd = new DoubleDamage(pos, 40);
                canvas.setPosition(dd);
                canvas.Add(dd);
                bonuses.AddLast(dd);
            }
        }
Exemplo n.º 2
0
        private void timer_tick1(object sender, EventArgs e)
        {
            life_label.Content = "Strength: " + player.lifecount;
            canvas.setPosition(player);
            LinkedList <Asteroid> blocks_local = new LinkedList <Asteroid>();

            foreach (Asteroid th in blocks)
            {
                th.position.Y = th.position.Y + th.speed;
                if (th.position.Y > height)
                {
                    canvas.Remove(th);
                    player.decrementLife(th.getDamage());
                    canvas.Add(red_disp);
                    red_disp_count = 1;
                    change_panel_image();
                }
                else if (th.position.Y > height - 100 && Tools.hasColision(player, th))
                {
                    player.decrementLife(th.getDamage() * 2);
                    canvas.Remove(th);
                    canvas.Add(red_disp);
                    red_disp_count = 1;
                    change_panel_image();
                }
                else
                {
                    blocks_local.AddLast(th);
                }
                canvas.setPosition(th);
            }
            LinkedList <Quad> bonuses_local = new LinkedList <Quad>();

            foreach (Quad th in bonuses)
            {
                th.position.Y = th.position.Y + 5;
                if (th.position.Y > height)
                {
                    canvas.Remove(th);
                    if (typeof(RepairKit).IsInstanceOfType(th))
                    {
                        RepairKit rk = (RepairKit)th;
                        player.incrementLife(rk.hill_count);
                        green_disp_count = 1;
                        canvas.Add(green_disp);
                        change_panel_image();
                    }
                    else if (typeof(DoubleDamage).IsInstanceOfType(th))
                    {
                        double_damage_count += ((DoubleDamage)th).life_time;
                    }
                }
                else
                {
                    bonuses_local.AddLast(th);
                }
                canvas.setPosition(th);
            }

            blocks  = blocks_local;
            bonuses = bonuses_local;
            if (player.lifecount < 0)
            {
                Game_end();
            }
        }