예제 #1
0
파일: Tank.cs 프로젝트: cookiehhh/Cshape
        public void fire()
        {
            bullet b = new bullet(type); //根据坦克产生不同子弹

            b.Direct = Direct;           //坦克的朝向
            b.Top    = Top;
            b.Left   = Left;
            //b.move();
            bList.Add(b);
            if (type == 6)
            {
                PlaySound.Play("Sound/Shoot.wav");            //己方发射出声
            }
        }
예제 #2
0
파일: Tank.cs 프로젝트: cookiehhh/Cshape
 public void MoveBullet(ref int[,] Map)
 {
     for (int i = bList.Count - 1; i >= 0; i--) //遍历子弹序列
     //for (int i = 0; i < bList.Count;i++ )
     {
         bullet t = ((bullet)bList[i]);
         //移动以前
         if (t.Left < 0 || t.Left > 9 || t.Top < 0 || t.Top > 9)
         //超出边界
         {
             bList.RemoveAt(i);
             continue; //删除此颗子弹
         }
         if (Map[t.Left, t.Top] != 0 && Map[t.Left, t.Top] != type)
         //已遇到坦克和墙等障碍物
         {
             bList.RemoveAt(i);              //删除此颗子弹
             if (t.hitE(Map[t.Left, t.Top])) //击中对方坦克
             {
                 Map[t.Left, t.Top] = -1;    //此处坦克被打中
             }
             continue;
         }
         t.move(); //移动以后
         if (t.Left < 0 || t.Left > 9 || t.Top < 0 || t.Top > 9)
         //超出边界
         {
             bList.RemoveAt(i);
             continue;                       //删除此颗子弹
         }
         if (Map[t.Left, t.Top] != 0)        //已遇到物体
         {
             bList.RemoveAt(i);              //删除此颗子弹
             if (t.hitE(Map[t.Left, t.Top])) //击中对方坦克
             {
                 Map[t.Left, t.Top] = -1;    //此处坦克被打中
             }
             continue;
         }
     }
 }