예제 #1
0
        public bool isTouchMyTank()
        {
            for (int i = 0; i < Map.enemyList.Count; i++)
            {
                if (this != Map.enemyList[i] && Crash.crash(this.getRectangle(), Map.enemyList[i].getRectangle()))
                {
                    switch (this.bulletDirection)
                    {
                    case MoveDiretion.Up:
                        this.y = (y / 40 + 1) * 40;
                        break;

                    case MoveDiretion.Down:
                        this.y = y / 40 * 40;
                        break;

                    case MoveDiretion.Left:
                        this.x = (x / 40 + 1) * 40;
                        break;

                    case MoveDiretion.Right:
                        this.x = x / 40 * 40;
                        break;

                    default:
                        break;
                    }
                    this.speed = 0;         //是碰撞瞬间坦克的速度变为零
                    return(true);
                }
            }
            return(false);
        }
예제 #2
0
 public Boolean isTouchEnemy()
 {
     for (int i = 0; i < Map.enemyList.Count; i++)
     {
         if (Crash.crash(Map.Gametank.getRectangle(), Map.enemyList[i].getRectangle()))
         {
             return(true);
         }
     }
     return(false);
 }
예제 #3
0
 public int isEatProp()
 {
     for (int i = 0; i < Map.propList.Count; i++)
     {
         int type = Map.propList[i].getType();
         if (Crash.crash(Map.Gametank.getRectangle(), Map.propList[i].getRectangle()))
         {
             Map.propList.Remove(Map.propList[i]);
             return(type);
         }
     }
     return(-1);
 }
예제 #4
0
파일: map.cs 프로젝트: zxc6114/TankDemo
        public void enemyBulletMove()
        {
            for (int i = 0; i < enemyBullets.Count; i++)
            {
                enemyBullets[i].Move(this);
            }

            for (int i = 0; i < enemyBullets.Count; i++)
            {
                if (Crash.isCrashWall(enemyBullets[i]))
                {
                    bool a = enemyBullets.Remove(enemyBullets[i]);
                }
            }
        }
예제 #5
0
파일: map.cs 프로젝트: zxc6114/TankDemo
        private void myBulletMove()
        {
            for (int i = 0; i < planeBullets.Count; i++)
            {
                planeBullets[i].Move(this);
            }

            for (int i = 0; i < planeBullets.Count; i++)
            {
                if (Crash.isCrashWall(planeBullets[i]))
                {
                    //撞墙
                    planeBullets.Remove(planeBullets[i]);
                    break;
                }
                for (int j = 0; j < enemyList.Count; j++)
                {
                    if (Crash.crash(enemyList[j].getRectangle(), planeBullets[i].getRectangle()))
                    {
                        //撞敌机
                        score += 10;
                        SoundPlayer p = new SoundPlayer(Properties.Resources.boom);
                        p.Play();
                        planeBullets.Remove(planeBullets[i]);

                        blastX = enemyList[j].X;
                        blastY = enemyList[j].Y;


                        enemyList.Remove(enemyList[j]);
                        break;
                    }
                }

                for (int j = 0; j < enemyBullets.Count; j++)
                {
                    if (planeBullets.Count > 0 && Crash.crash(planeBullets[i].getRectangle(), enemyBullets[j].getRectangle()))
                    {
                        bool a = planeBullets.Remove(planeBullets[i]);
                        bool b = enemyBullets.Remove(enemyBullets[j]);
                        break;
                    }
                }
            }
        }
예제 #6
0
        public bool isTouchWall()
        {
            for (int j = 0; j < Map.wallList.Count; j++)
            {
                if (Crash.crash(this.getRectangle(), Map.wallList[j].getRectangle()))
                {
                    if (Map.wallList[j].getType() == 3)
                    {
                        return(false);
                    }
                    else
                    {
                        switch (this.bulletDirection)
                        {
                        case MoveDiretion.Up:
                            this.y = (y / 40 + 1) * 40;
                            break;

                        case MoveDiretion.Down:
                            this.y = y / 40 * 40;
                            break;

                        case MoveDiretion.Left:
                            this.x = (x / 40 + 1) * 40;
                            break;

                        case MoveDiretion.Right:
                            this.x = x / 40 * 40;
                            break;

                        default:
                            break;
                        }
                        //重新规整x坐标
                        //重新规整y坐标
                    }
                    this.speed = 0;         //是碰撞瞬间坦克的速度变为零
                    return(true);
                }
            }
            return(false);
        }