Example #1
0
        //用missile对象确定场景中目标的生命值小于等于0,并删除掉该对象
        public bool CheckDeadAndRemove(Missile m)
        {
            List <Missile> deadMissiles = new List <Missile>();
            int            i            = 0;

            for (i = 0; i < wallList.Count; i++)
            {
                if (m.GetRectangle().IntersectsWith(wallList[i].GetRectangle()))
                {
                    wallList.RemoveAt(i);
                    return(true);
                }
            }

            for (i = 0; i < steelList.Count; i++)
            {
                if (m.GetRectangle().IntersectsWith(steelList[i].GetRectangle()))
                {
                    //deadMissiles.Add(m);
                    if (m.power > 2)
                    {
                        steelList.RemoveAt(i);
                        i--;
                    }
                    return(true);
                }
            }


            if (m.GetRectangle().IntersectsWith(P1Play.GetRectangle()))
            {
                //deadMissiles.Add(m);
                P1Play.life = 0;
                //MessageBox.Show("Game Over!");
                return(true);
            }


            for (i = 0; i < enemyList.Count; i++)
            {
                if (m.GetRectangle().IntersectsWith(enemyList[i].GetRectangle()))
                {
                    enemyList.RemoveAt(i);
                    i--;
                    //deadMissiles.Add(m);
                    return(true);
                }
            }

            if (m.X == 0 || m.Y == 0 || m.X >= ParamSetting.Map_Width || m.Y >= ParamSetting.Map_Height)
            {
                //  deadMissiles.Add(m);
                return(true);
            }
            if (enemyList.Count == 0)
            {
            }
            // MessageBox.Show("Yow Win!");

            //m.IsBlocked = false;
            return(false);
        }
Example #2
0
        //用missile对象确定场景中目标的生命值小于等于0,并删除掉该对象
        public void CheckDeadAndRemove(Missile m)
        {
            int i = 0;

            //打中普通墙壁
            for (i = 0; i < wallList.Count; i++)
            {
                if (m.GetRectangle().IntersectsWith(wallList[i].GetRectangle()))    //墙壁与子弹是否相交
                {
                    deadMissiles.Add(m);
                    wallList.RemoveAt(i);
                    return;
                }
            }
            //打中钢墙
            for (i = 0; i < steelList.Count; i++)
            {
                if (m.GetRectangle().IntersectsWith(steelList[i].GetRectangle()))
                {
                    deadMissiles.Add(m);
                    if (m.power > 2)
                    {
                        steelList.RemoveAt(i);
                        i--;
                    }
                    return;
                }
            }

            //子弹打中P1Play
            if (P1Play != null)
            {
                if (m.GetRectangle().IntersectsWith(P1Play.GetRectangle()))
                {
                    //打击声
                    SoundPlayer hitsound = new SoundPlayer(Resources.hit);
                    hitsound.Play();
                    //子弹移除
                    deadMissiles.Add(m);
                    //被击中扣血复活,当前版本只有一滴血直接死亡 复活
                    if (P1Play.bornTime >= 16) //如果还在闪光 则无敌
                    {
                        P1Play.life--;
                        SoundPlayer deadsound = new SoundPlayer(Resources.Bang);
                        deadsound.Play();
                        if (P1Play.life >= 0) //还有命就复活,不然狗带吧
                        {
                            P1Play.bornTime = 0;
                            P1Play.X        = 240;
                            P1Play.Y        = 540;
                            P1Play.direct   = DIRECTION.UP;
                        }
                        else                //狗带
                        {
                            P1Play = null;
                        }
                    }

                    //  P1Play.
                    //MessageBox.Show("Game Over!");
                    return;
                }
            }
            //子弹打中P2Play
            if (P2Play != null)
            {
                if (m.GetRectangle().IntersectsWith(P2Play.GetRectangle()))
                {
                    //打击声
                    SoundPlayer hitsound = new SoundPlayer(Resources.hit);
                    hitsound.Play();
                    //子弹移除
                    deadMissiles.Add(m);
                    //被击中扣血复活,当前版本只有一滴血直接死亡 复活
                    if (P2Play.bornTime >= 16) //如果还在闪光 则无敌
                    {
                        P2Play.life--;
                        SoundPlayer deadsound = new SoundPlayer(Resources.Bang);
                        deadsound.Play();
                        if (P2Play.life >= 0) //还有命就复活,不然狗带吧
                        {
                            P2Play.bornTime = 0;
                            P2Play.X        = 480;
                            P2Play.Y        = 540;
                            P2Play.direct   = DIRECTION.UP;
                        }
                        else                //狗带
                        {
                            P2Play = null;
                        }
                    }
                    //  P2Play.
                    //MessageBox.Show("Game Over!");
                    return;
                }
            }
            //消灭敌人
            for (i = 0; i < enemyList.Count; i++)
            {
                if (m.GetRectangle().IntersectsWith(enemyList[i].GetRectangle()))
                {
                    //打击声
                    SoundPlayer hitsound = new SoundPlayer(Resources.hit);
                    hitsound.Play();
                    //移除敌人,当前小兵默认一点生命值,直接移除
                    enemyList.RemoveAt(i);
                    //死亡音效
                    SoundPlayer deadsound = new SoundPlayer(Resources.Bang);
                    deadsound.Play();

                    i--;
                    killnum++;
                    deadMissiles.Add(m);
                    return;
                }
            }
            //打BOSS
            //打老鹰
            if (symbol != null)
            {
                if (m.GetRectangle().IntersectsWith(symbol.GetRectangle()))
                {
                    //打击声
                    SoundPlayer hitsound = new SoundPlayer(Resources.hit);
                    hitsound.Play();
                    symbol = null;
                    deadMissiles.Add(m);
                    return;
                }
            }
            if (boss != null)
            {
                if (m.GetRectangle().IntersectsWith(boss.GetRectangle()))
                {
                    //打击声
                    SoundPlayer hitsound = new SoundPlayer(Resources.hit);
                    hitsound.Play();
                    boss.life -= m.power; //减少子弹的伤害
                    if (boss.life <= 0)   //BOSS死亡
                    {
                        //死亡音效
                        SoundPlayer deadsound1 = new SoundPlayer(Resources.Bang);
                        deadsound1.Play();
                        boss = null;
                        //杀死BOSS即胜利
                        win = 1;
                    }
                    deadMissiles.Add(m);
                    return;
                }
            }
            //子弹进入边缘
            if (m.X == 0 || m.Y == 0 || m.X >= ParamSetting.Map_Width || m.Y >= ParamSetting.Map_Height)
            {
                deadMissiles.Add(m);
            }
            //满足条件召唤BOSS

            //   if (enemyList.Count == 0)
            //    {
            //         MessageBox.Show("You Win!");

            //  }
            //m.IsBlocked = false;

            return;
        }
Example #3
0
        //用missile对象确定场景中目标的生命值小于等于0,并删除掉该对象
        public List<Missile> CheckDeadAndRemove(Missile m)
        {
            List<Missile> deadMissiles = new List<Missile>();
            int i = 0;
            for (i = 0; i < wallList.Count; i++)
            {
                if (m.GetRectangle().IntersectsWith(wallList[i].GetRectangle()))
                {
                    deadMissiles.Add(m);
                    wallList.RemoveAt(i);
                    return deadMissiles;
                }
            }

            for (i = 0; i < steelList.Count; i++)
            {
                if (m.GetRectangle().IntersectsWith(steelList[i].GetRectangle()))
                {
                    deadMissiles.Add(m);
                    if (m.power > 2)
                    {
                        steelList.RemoveAt(i);
                        i--;
                    }
                    return deadMissiles;
                }
            }

            if (m.GetRectangle().IntersectsWith(P1Play.GetRectangle()))
            {
                deadMissiles.Add(m);
                P1Play.life = 0;
                //MessageBox.Show("Game Over!");
                return deadMissiles;
            }

            if (m.GetRectangle().IntersectsWith(P2Play.GetRectangle()))
            {
                deadMissiles.Add(m);
                P2Play.life = 0;
                //MessageBox.Show("Game Over!");
                return deadMissiles;
            }

            for (i = 0; i < enemyList.Count; i++)
            {
                if (m.GetRectangle().IntersectsWith(enemyList[i].GetRectangle()))
                {
                    enemyList.RemoveAt(i);
                    i--;
                    deadMissiles.Add(m);
                    return deadMissiles;
                }
            }

            if (m.X == 0 || m.Y == 0 || m.X >= ParamSetting.Map_Width || m.Y >= ParamSetting.Map_Height)
                deadMissiles.Add(m);

            if (enemyList.Count == 0)
                MessageBox.Show("Yow Win!");

            //m.IsBlocked = false;
            return deadMissiles;
        }
Example #4
0
        //用missile对象确定场景中目标的生命值小于等于0,并删除掉该对象
        public void CheckDeadAndRemove(Missile m)
        {
           
            int i = 0;
            //打中普通墙壁
            for (i = 0; i < wallList.Count; i++)
            {
                if (m.GetRectangle().IntersectsWith(wallList[i].GetRectangle()))    //墙壁与子弹是否相交
                {
                    deadMissiles.Add(m);
                    wallList.RemoveAt(i);
                    return;
                }
            }
            //打中钢墙
            for (i = 0; i < steelList.Count; i++)
            {
                if (m.GetRectangle().IntersectsWith(steelList[i].GetRectangle()))
                {
                    deadMissiles.Add(m);
                    if (m.power > 2)
                    {
                        steelList.RemoveAt(i);
                        i--;
                    }
                    return;
                }
            }
            
            //子弹打中P1Play
            if(P1Play!=null)
            if (m.GetRectangle().IntersectsWith(P1Play.GetRectangle()))
            {
                //打击声
                SoundPlayer hitsound = new SoundPlayer(Resources.hit);
                hitsound.Play();
                //子弹移除
                deadMissiles.Add(m);
                //被击中扣血复活,当前版本只有一滴血直接死亡 复活
                if (P1Play.bornTime >= 16) //如果还在闪光 则无敌
                {
                    P1Play.life--;
                    SoundPlayer deadsound = new SoundPlayer(Resources.Bang);
                    deadsound.Play();
                    if (P1Play.life >= 0)   //还有命就复活,不然狗带吧
                    {
                        P1Play.bornTime = 0;
                        P1Play.X = 240;
                        P1Play.Y = 540;
                        P1Play.direct = DIRECTION.UP;
                    }
                    else                    //狗带
                    {
                        P1Play = null;
                    }
               }

                //  P1Play.
                //MessageBox.Show("Game Over!");
                return;
            }
             //子弹打中P2Play
            if(P2Play!=null)
            if (m.GetRectangle().IntersectsWith(P2Play.GetRectangle()))
            {
                //打击声
                SoundPlayer hitsound = new SoundPlayer(Resources.hit);
                hitsound.Play();
                //子弹移除
                deadMissiles.Add(m);
                //被击中扣血复活,当前版本只有一滴血直接死亡 复活
                if (P2Play.bornTime >= 16) //如果还在闪光 则无敌
                {
                    P2Play.life--;
                    SoundPlayer deadsound = new SoundPlayer(Resources.Bang);
                    deadsound.Play();
                    if (P2Play.life >= 0)   //还有命就复活,不然狗带吧
                    {

                        P2Play.bornTime = 0;
                        P2Play.X = 480;
                        P2Play.Y = 540;
                        P2Play.direct = DIRECTION.UP;
                    }
                    else                    //狗带
                    {
                        P2Play = null;
                    }
                }
              //  P2Play.
                //MessageBox.Show("Game Over!");
                return;
            }
            //消灭敌人
            for (i = 0; i < enemyList.Count; i++)
            {
                if (m.GetRectangle().IntersectsWith(enemyList[i].GetRectangle()))
                {
                    //打击声
                    SoundPlayer hitsound = new SoundPlayer(Resources.hit);
                    hitsound.Play();
                    //移除敌人,当前小兵默认一点生命值,直接移除
                    enemyList.RemoveAt(i);
                    //死亡音效
                    SoundPlayer deadsound = new SoundPlayer(Resources.Bang);
                    deadsound.Play();
                    
                    i--;
                    killnum++;
                    deadMissiles.Add(m);
                    return;
                }
            }
            //打BOSS
            //打老鹰
            if (symbol != null)
            {
                if (m.GetRectangle().IntersectsWith(symbol.GetRectangle()))
                {
                    //打击声
                    SoundPlayer hitsound = new SoundPlayer(Resources.hit);
                    hitsound.Play();
                    symbol = null;
                    deadMissiles.Add(m);
                    return;
                }
            }
            if (boss != null)
            {
                if (m.GetRectangle().IntersectsWith(boss.GetRectangle()))
                {
                    //打击声
                    SoundPlayer hitsound = new SoundPlayer(Resources.hit);
                    hitsound.Play();
                    boss.life-=m.power;//减少子弹的伤害
                    if (boss.life <= 0) //BOSS死亡
                    {
                        //死亡音效
                        SoundPlayer deadsound1 = new SoundPlayer(Resources.Bang);
                        deadsound1.Play();
                        boss = null;
                        //杀死BOSS即胜利
                        win = 1;
                    }    
                    deadMissiles.Add(m);
                    return;
                }
            }
            //子弹进入边缘
            if (m.X == 0 || m.Y == 0 || m.X >= ParamSetting.Map_Width || m.Y >= ParamSetting.Map_Height)
                deadMissiles.Add(m);
            //满足条件召唤BOSS

         //   if (enemyList.Count == 0)
        //    {
       //         MessageBox.Show("You Win!");
                
          //  }
            //m.IsBlocked = false;
           
            return ;
        }