Exemplo n.º 1
0
 void explosion()
 {
     //爆炸,產生衝擊波
     bool stop = false;
     int lenght_up = _power;
     int lenght_down = _power;
     int lenght_left = _power;
     int lenght_right = _power;
     //修正上衝擊波長度
     for (int i = 1; i <= _power; i++)
     {
         int num_y = _position[1] - i;
         if (num_y >= 0 && !stop)
         {
             if (!check_map(_position[0], num_y))
             {
                 lenght_up = i - 1;
                 stop = true;
             }
             if (num_y == 0 && !stop)
             {
                 lenght_up = i;
                 stop = true;
             }
         }
     }
     //修正下衝擊波長度
     stop = false;
     for (int i = 1; i <= _power; i++)
     {
         int num_y = _position[1] + i;
         if (num_y <= 12 && !stop)
         {
             if (!check_map(_position[0], num_y))
             {
                 lenght_down = i - 1;
                 stop = true;
             }
             if (num_y == 12 && !stop)
             {
                 lenght_down = i;
                 stop = true;
             }
         }
     }
     //修正左衝擊波長度
     stop = false;
     for (int i = 1; i <= _power; i++)
     {
         int num_x = _position[0] - i;
         if (num_x >= 0 && !stop)
         {
             if (!check_map(num_x, _position[1]))
             {
                 lenght_left = i - 1;
                 stop = true;
             }
             if (num_x == 0 && !stop)
             {
                 lenght_left = i;
                 stop = true;
             }
         }
     }
     //修正右衝擊波長度
     stop = false;
     for (int i = 1; i <= _power; i++)
     {
         int num_x = _position[0] + i;
         if (num_x <= 18 && !stop)
         {
             if (!check_map(num_x, _position[1]))
             {
                 lenght_right = i - 1;
                 stop = true;
             }
             if (num_x == 18 && !stop)
             {
                 lenght_right = i;
                 stop = true;
             }
         }
     }
     //傳入長度以算出衝擊波範圍
     Laser horizontal_laser = new Laser(Game_data.instance.worldTime);
     horizontal_laser.set_pos(true, lenght_left, lenght_right, _position);
     Game_data.instance.Laser_list.Add(horizontal_laser);
     Laser vertical_laser = new Laser(Game_data.instance.worldTime);
     vertical_laser.set_pos(false, lenght_up, lenght_down, _position);
     Game_data.instance.Laser_list.Add(vertical_laser);
 }
Exemplo n.º 2
0
        public void Explosion()
        {
            //爆炸,產生衝擊波
            bool stop = false;
            int lenght_up = _power;
            int lenght_down = _power;
            int lenght_left = _power;
            int lenght_right = _power;
            //修正上衝擊波長度
            for (int i = 1; i <= _power; i++)
            {
                int num_y = _position[1] - i;
                if (num_y >= 0 && !stop)
                {
                    if (!check_map(_position[0], num_y))
                    {
                        lenght_up = i - 1;
                        stop = true;
                    }
                    if (num_y == 0 && !stop)
                    {
                        lenght_up = i;
                        stop = true;
                    }
                }
            }
            //修正下衝擊波長度
            stop = false;
            for (int i = 1; i <= _power; i++)
            {
                int num_y = _position[1] + i;
                if (num_y <= 12 && !stop)
                {
                    if (!check_map(_position[0], num_y))
                    {
                        lenght_down = i - 1;
                        stop = true;
                    }
                    if (num_y == 12 && !stop)
                    {
                        lenght_down = i;
                        stop = true;
                    }
                }
            }
            //修正左衝擊波長度
            stop = false;
            for (int i = 1; i <= _power; i++)
            {
                int num_x = _position[0] - i;
                if (num_x >= 0 && !stop)
                {
                    if (!check_map(num_x, _position[1]))
                    {
                        lenght_left = i - 1;
                        stop = true;
                    }
                    if (num_x == 0 && !stop)
                    {
                        lenght_left = i;
                        stop = true;
                    }
                }
            }
            //修正右衝擊波長度
            stop = false;
            for (int i = 1; i <= _power; i++)
            {
                int num_x = _position[0] + i;
                if (num_x <= 18 && !stop)
                {
                    if (!check_map(num_x, _position[1]))
                    {
                        lenght_right = i - 1;
                        stop = true;
                    }
                    if (num_x == 18 && !stop)
                    {
                        lenght_right = i;
                        stop = true;
                    }
                }
            }
            //傳入長度以算出衝擊波範圍
            Laser horizontal_laser = new Laser(Game_data.instance.worldTime);
            horizontal_laser.set_pos(true, lenght_left, lenght_right, _position);
            Game_data.instance.Laser_list.Add(horizontal_laser);
            Laser vertical_laser = new Laser(Game_data.instance.worldTime);
            vertical_laser.set_pos(false, lenght_up, lenght_down, _position);
            Game_data.instance.Laser_list.Add(vertical_laser);

            //如果沒超過自己能擁有的數量
            /*if (Game_data.instance.Player_list[_player]._Can_BNumber < Game_data.instance.Player_list[_player].MaxBNumber)
            {*/
            //目前可放炸彈數+1
            Game_data.instance.Player_list[_player]._Can_BNumber++;
            //}
            //destroy掉
            _Is_alive = false;
            myImage.Source = null;
            _position = new int[] { 300, 300 };
            //Game_data.instance.Bomb_list.Remove(this);
        }