Example #1
0
        //确定某个坦克是否处于堵塞状态(可以是敌人或者自己的坦克)
        public void CheckBlock(Member m)
        {
            int       i    = 0;
            Rectangle rect = m.GetRectangle();

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

            for (i = 0; i < waterList.Count; i++)
            {
                if (rect.IntersectsWith(waterList[i].GetRectangle()))
                {
                    m.IsBlocked = true;
                    return;
                }
            }
            for (i = 0; i < steelList.Count; i++)
            {
                if (rect.IntersectsWith(steelList[i].GetRectangle()))
                {
                    m.IsBlocked = true;
                    return;
                }
            }
            if (m is P1Player)
            {
                for (i = 0; i < enemyList.Count; i++)
                {
                    if (rect.IntersectsWith(enemyList[i].GetRectangle()))
                    {
                        m.IsBlocked = true;
                        return;
                    }
                }
            }

            if (m is Enemy)
            {
                if (rect.IntersectsWith(P1Play.GetRectangle()))
                {
                    m.IsBlocked = true;
                    return;
                }
            }

            if (rect.Right >= ParamSetting.Map_Width || rect.Left < 0 || rect.Bottom > ParamSetting.Map_Height || rect.Top < 0)
            {
                m.IsBlocked = true;
                return;
            }

            m.IsBlocked = false;
        }
Example #2
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 #3
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 #4
0
        //确定某个坦克是否处于堵塞状态(可以是敌人或者自己的坦克)
        public void CheckBlock(Member m)
        {
            int       i    = 0;
            Rectangle rect = m.GetRectangle();

            for (i = 0; i < wallList.Count; i++)
            {
                if (rect.IntersectsWith(wallList[i].GetRectangle()))
                {
                    m.IsBlocked = true;
                    return;
                }
            }
            for (i = 0; i < waterList.Count; i++)
            {
                if (rect.IntersectsWith(waterList[i].GetRectangle()))
                {
                    m.IsBlocked = true;
                    return;
                }
            }
            for (i = 0; i < steelList.Count; i++)
            {
                if (rect.IntersectsWith(steelList[i].GetRectangle()))
                {
                    m.IsBlocked = true;
                    return;
                }
            }
            if (m is P1Player)
            {
                for (i = 0; i < starList.Count; i++)
                {
                    if (rect.IntersectsWith(starList[i].GetRectangle()))
                    {
                        starList.RemoveAt(i);
                        m.power += 1;
                    }
                }
                for (i = 0; i < enemyList.Count; i++)
                {
                    if (rect.IntersectsWith(enemyList[i].GetRectangle()))
                    {
                        m.IsBlocked = true;
                        return;
                    }
                }
            }
            if (m is P2Player)
            {
                for (i = 0; i < starList.Count; i++)
                {
                    if (rect.IntersectsWith(starList[i].GetRectangle()))
                    {
                        starList.RemoveAt(i);
                        m.power += 1;
                    }
                }
                for (i = 0; i < enemyList.Count; i++)
                {
                    if (rect.IntersectsWith(enemyList[i].GetRectangle()))
                    {
                        m.IsBlocked = true;
                        return;
                    }
                }
            }
            if (m is Enemy)
            {
                //修复BUG 判断P1Play 是否为NULL
                if (P1Play != null && rect.IntersectsWith(P1Play.GetRectangle()))
                {
                    m.IsBlocked = true;
                    return;
                }
                if (P2Play != null && rect.IntersectsWith(P2Play.GetRectangle()))
                {
                    m.IsBlocked = true;
                    return;
                }
            }

            /* BOSS太智能 消除他和P1 P2体积碰撞
             * if (m is Boss)
             * {
             *     //修复BUG 判断P1Play 是否为NULL
             *     if (P1Play!=null&&rect.IntersectsWith(P1Play.GetRectangle()))
             *     {
             *         m.IsBlocked = true;
             *         return;
             *     }
             *     if (P2Play != null && rect.IntersectsWith(P2Play.GetRectangle()))
             *     {
             *         m.IsBlocked = true;
             *         return;
             *     }
             * }
             */
            if (rect.Right >= ParamSetting.Map_Width || rect.Left < 0 || rect.Bottom > ParamSetting.Map_Height || rect.Top < 0)
            {
                m.IsBlocked = true;
                return;
            }
            m.IsBlocked = false;
        }