示例#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 || m is P2Player)
            {
                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;
        }
示例#2
0
文件: Scene.cs 项目: zy691357966/Tank
        //确定某个坦克是否处于堵塞状态(可以是敌人或者自己的坦克)
        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;
        }