Beispiel #1
0
        private void checkPerson(int mappos)
        {
            if (OurGame.Master.deadDelay == 0 && OurGame.Master.Active != 0 && MyHelp.Vector2ToPos(OurGame.Master.pos, 20) == mappos)
            {
                OurGame.Master.speed     = 2;
                OurGame.Master.deadDelay = 200;
                if (OurGame.Master.Active >= 0x10)
                {
                    OurGame.Master.Active = 1;
                }
                else
                {
                    OurGame.Master.Active = 2;
                    --OurGame.Life.number;
                }
            }

            for (int i = 0; i < MyHelp.maxEnemy; ++i)
            {
                if (OurGame.Enemy[i].Active != 0 && OurGame.Enemy[i].deadDelay == 0 && MyHelp.Vector2ToPos(OurGame.Enemy[i].pos, 20) == mappos)
                {
                    OurGame.Enemy[i].speed     = 2;
                    OurGame.Enemy[i].deadDelay = 200;
                    if (OurGame.Enemy[i].Active >= 0x10)
                    {
                        OurGame.Enemy[i].Active = 1;
                    }
                    else
                    {
                        OurGame.Enemy[i].Active = 2;
                    }
                }
            }
        }
Beispiel #2
0
        public void move()
        {
            //到边界,不可以向前走了。
            if ((pos.Y <= MyHelp.StartPos.Y && _dir == 0) || (pos.Y >= MyHelp.StartPos.Y + 240 && _dir == 1) || (pos.X <= MyHelp.StartPos.X && _dir == 2) || (pos.X >= MyHelp.StartPos.X + 320 && _dir == 3))
            {
                _dir |= 0x10;
                return;
            }
            //正常移动。
            if (MyHelp.isInPatten(pos))
            {
                if (!canMove())
                {
                    _dir |= 0x10;
                    return;
                }
            }
            if ((_dir & 0x10) != 0)
            {
                return;
            }

            pos.X += MyHelp.moveLen[_dir * 2] * _speed;
            pos.Y += MyHelp.moveLen[_dir * 2 + 1] * _speed;
            //是否到整Patten上,停步
            if (MyHelp.isInPatten(pos))
            {
                OurGame.map[MyHelp.Vector2ToPos(pos) - MyHelp.posLen[_dir]].canMove &= 0x7f;
                _dir |= 0x10;
            }
        }
Beispiel #3
0
        //开始新的一关
        private void InitLevel()
        {
            int n = 0;

            for (int i = 0; i < MyHelp.HEIGHT; ++i)
            {
                for (int j = 0; j < MyHelp.WIDTH; ++j)
                {
                    map[MyHelp.mapPos(i, j)].mapData   = level1[MyHelp.mapPos(i, j)];
                    map[MyHelp.mapPos(i, j)].leiActive = false;
                    map[MyHelp.mapPos(i, j)].canMove   = 0;
                    if (map[MyHelp.mapPos(i, j)].mapData < 0x10)
                    {
                        switch (map[MyHelp.mapPos(i, j)].mapData)
                        {
                        case 1:
                            Master.Active         = 1;
                            Master.postion        = MyHelp.mapPos(i, j);
                            MyHelp.masterStartPos = Master.pos;
                            break;

                        case 2:
                            Enemy[n].Active  = 1;
                            Enemy[n].postion = MyHelp.mapPos(i, j);
                            ++n;
                            break;
                        }
                        map[MyHelp.mapPos(i, j)].mapData = 0;
                    }
                }
            }
        }
Beispiel #4
0
        public void createLei()
        {
            if (haveLei >= maxLei)
            {
                return;
            }
            int pos;
            int i;

            pos = MyHelp.Vector2ToPos(this.pos, 20);
            for (i = 0; i < MyHelp.maxLei; ++i)
            {
                if (OurGame.lei[i].Active != 0 && pos == OurGame.lei[i].Pos)
                {
                    return;
                }
            }
            for (i = 0; i < MyHelp.maxLei; ++i)
            {
                if (OurGame.lei[i].Active == 0)
                {
                    OurGame.lei[i].CreateLei(this);
                    ++haveLei;
                    break;
                }
            }
        }
Beispiel #5
0
        private void updataMap()
        {
            switch (boxAndTree)
            {
            case 0:
                break;

            case 1:
                boxAndTreePos.X += MyHelp.moveLen[(_dir & 0xf) * 2] * 5;
                boxAndTreePos.Y += MyHelp.moveLen[(_dir & 0xf) * 2 + 1] * 5;
                if (MyHelp.isInPatten(boxAndTreePos))
                {
                    boxAndTree = 0;
                    int nowpos = MyHelp.Vector2ToPos(boxAndTreePos);
                    OurGame.map[nowpos].mapData  = backData;
                    OurGame.map[nowpos].canMove &= 0xBF;            //去掉箱子标志
                }
                break;

            case 0x10:
                if (MyHelp.isInPatten(pos))
                {
                    int nowpos = MyHelp.Vector2ToPos(boxAndTreePos);
                    OurGame.map[nowpos].mapData = backData;
                    boxAndTree = 0;
                }
                break;

            default:
                if (mapDelay == 0)
                {
                    mapDelay = 2;
                    ++boxAndTree;
                    if ((boxAndTree & 1) != 0)
                    {
                        ++boxAndTreePos.X;
                    }
                    else
                    {
                        --boxAndTreePos.X;
                    }
                    if (boxAndTree >= 4)
                    {
                        boxAndTree = 0x10;
                    }
                }
                else
                {
                    --mapDelay;
                }
                break;
            }
        }
Beispiel #6
0
        private bool canCreateLei()
        {
            int i, length, nextpos;

            for (i = 0; i < 4; ++i)
            {
                length = dirLen(i);
                if (leiLen >= length && OurGame.map[MyHelp.Vector2ToPos(pos) + MyHelp.posLen[i] * length].mapData < 0x40)
                {
                    break;
                }
            }
            if (i >= 4 && MyHelp.Random(50) > 20)
            {
                return(false);
            }
            for (i = 0; i < 4; ++i)
            {
                nextpos = MyHelp.Vector2ToPos(pos);
                if (MyHelp.isInBound(ref nextpos, i))
                {
                    if (dirLen(i) != 0)
                    {
                        if (i == 0 || i == 1)
                        {
                            if (dirLen(nextpos, 2) != 0 || dirLen(nextpos, 3) != 0)
                            {
                                return(true);
                            }
                        }
                        else
                        {
                            if (dirLen(nextpos, 1) != 0 || dirLen(nextpos, 0) != 0)
                            {
                                return(true);
                            }
                        }
                    }
                }
            }
            for (i = 0; i < 4; ++i)
            {
                if (dirLen(i) > leiLen)
                {
                    return(true);
                }
            }
            return(false);
        }
Beispiel #7
0
        static public bool createArticle(byte pos)
        {
            if (MyHelp.Random(50) > 30)
            {
                return(false);
            }
            for (int i = 0; i < MyHelp.maxActicle; ++i)
            {
                if (acticle[i].active == false)
                {
                    acticle[i].Create((byte)MyHelp.Random(7), pos);
                    return(true);
                }
            }

            return(false);
        }
Beispiel #8
0
        private byte dirLen(int dir)
        {
            byte len     = 0;
            bool flag    = true;
            int  nextPos = MyHelp.Vector2ToPos(pos);

            while (true)
            {
                if (MyHelp.isInBound(ref nextPos, dir))
                {
                    if (OurGame.map[nextPos].mapData == 0 || (OurGame.map[nextPos].mapData & 0xf0) == 0x30)
                    {
                        ++len;
                    }
                    else if (flag && (OurGame.map[nextPos].mapData & 0xf0) == 0x10)
                    {
                        if (MyHelp.isInBound(ref nextPos, dir))
                        {
                            if (OurGame.map[nextPos].mapData == 0)
                            {
                                ++len;
                                flag = false;
                            }
                            else
                            {
                                break;
                            }
                        }
                        else
                        {
                            break;
                        }
                    }
                    else
                    {
                        break;
                    }
                }
                else
                {
                    break;
                }
            }
            return(len);
        }
Beispiel #9
0
        public void Draw()
        {
            bool flag;

            flag = (boxAndTree == 1 && _dir == 0);
            if (!flag)
            {
                if (Active >= 0x10)
                {
                    MyHelp.foreSpriteBatch.Draw(MyHelp.wuguiSprite, pos, guiRect, Color.White, 0, MyHelp.personCenter, 1, SpriteEffects.None, 0);
                }
                MyHelp.foreSpriteBatch.Draw(_personTexture, pos, rect, Color.White, 0, MyHelp.personCenter, 1, SpriteEffects.None, 0);
                if (Active == 3)
                {
                    MyHelp.foreSpriteBatch.Draw(MyHelp.baoSprite, pos, baoRect, Color.White, 0, MyHelp.baoCenter, 1, SpriteEffects.None, 0);
                }
            }
            hasDraw = 0xFF;
            switch (boxAndTree)
            {
            case 0:
                break;

            case 1:
                MyHelp.foreSpriteBatch.Draw(MyHelp.mapSprite, boxAndTreePos, boxRect, Color.White, 0, MyHelp.mapDataCenter, 1, SpriteEffects.None, 0);
                break;

            default:
                MyHelp.foreSpriteBatch.Draw(MyHelp.mapSprite, boxAndTreePos, boxRect, Color.White, 0, MyHelp.mapDataCenter, 1, SpriteEffects.None, 0);
                break;
            }
            if (flag)
            {
                if (Active >= 0x10)
                {
                    MyHelp.foreSpriteBatch.Draw(MyHelp.wuguiSprite, pos, guiRect, Color.White, 0, MyHelp.personCenter, 1, SpriteEffects.None, 0);
                }
                MyHelp.foreSpriteBatch.Draw(_personTexture, pos, rect, Color.White, 0, MyHelp.personCenter, 1, SpriteEffects.None, 0);
                if (Active == 3)
                {
                    MyHelp.foreSpriteBatch.Draw(MyHelp.baoSprite, pos, baoRect, Color.White, 0, MyHelp.baoCenter, 1, SpriteEffects.None, 0);
                }
            }
            OurGame.map[MyHelp.Vector2ToPos(pos)].canMove |= 0x80;
        }
Beispiel #10
0
        public void CreateLei(Person father)
        {
            for (int i = 0; i < 4; ++i)
            {
                _dir[i] = 0;
            }
            parent = father;
            _len   = father.leiLen;
            _frame = 0;

            Active  = 1;
            _delay  = 0;
            _mapPos = (Byte)MyHelp.Vector2ToPos(father.pos, 20);
            OurGame.map[_mapPos].leiActive = true;
            OurGame.map[_mapPos].leiDir    = 0;
            OurGame.map[_mapPos].leiID     = 0;
            OurGame.map[_mapPos].leiFrame  = 0;
            OurGame.map[_mapPos].canMove  |= 0x20;

            OurGame._drop = true;
        }
Beispiel #11
0
        private void checkPeng()
        {
            int i;

            if (OurGame.Master != this && (OurGame.Master.Active == 1 || OurGame.Master.Active == 0x10 || OurGame.Master.Active == 0x11))
            {
                if (MyHelp.checkHit(pos, OurGame.Master.pos, 30))
                {
                    _frame = 10;
                }
            }
            for (i = 0; i < MyHelp.maxEnemy; ++i)
            {
                if (OurGame.Enemy[i] != this && (OurGame.Enemy[i].Active == 1 || OurGame.Enemy[i].Active == 0x10 || OurGame.Enemy[i].Active == 0x11))
                {
                    if (MyHelp.checkHit(pos, OurGame.Enemy[i].pos, 30))
                    {
                        _frame = 10;
                    }
                }
            }
        }
Beispiel #12
0
        public void ChangDir()
        {
            if (Active > 1 && Active < 0x10)
            {
                return;
            }
            int k;
            int newDir;

            if (canCreateLei())
            {
                createLei();
            }
            checkSafe();
            switch (moveDir.count)
            {
            case 0:
                dir |= 0x10;
                break;

            case 1:
                for (k = 0; k < 4; ++k)
                {
                    if ((moveDir.canMove & (1 << k)) != 0)
                    {
                        dir = k;
                        break;
                    }
                }

                break;

            default:
                if (this.X > OurGame.Master.X)
                {
                    if (this.Y > OurGame.Master.Y)
                    {
                        newDir = 5;
                    }
                    else if (this.Y == OurGame.Master.Y)
                    {
                        newDir = 4;
                    }
                    else
                    {
                        newDir = 6;
                    }
                }
                else if (this.X == OurGame.Master.X)
                {
                    if (this.Y > OurGame.Master.Y)
                    {
                        newDir = 1;
                    }
                    else if (this.Y == OurGame.Master.Y)
                    {
                        newDir = 15;
                    }
                    else
                    {
                        newDir = 2;
                    }
                }
                else
                {
                    if (this.Y > OurGame.Master.Y)
                    {
                        newDir = 9;
                    }
                    else if (this.Y == OurGame.Master.Y)
                    {
                        newDir = 8;
                    }
                    else
                    {
                        newDir = 10;
                    }
                }
                if (MyHelp.Random(50) < 40 && (newDir & moveDir.canMove) != 0)
                {
                    for (k = 0; k < 4; ++k)
                    {
                        if ((newDir & moveDir.canMove & (1 << k)) != 0)
                        {
                            dir = k;
                            break;
                        }
                    }
                }
                else if (!(MyHelp.Random(50) > 10 && dir < 4 && (moveDir.canMove & (1 << dir)) != 0))
                {
                    newDir = 0;
                    int part = MyHelp.Random(moveDir.count);
                    for (k = 0; k < 4; ++k)
                    {
                        if ((moveDir.canMove & (1 << k)) != 0)
                        {
                            ++newDir;
                        }
                        if (newDir > part)
                        {
                            break;
                        }
                    }
                    dir = k;
                }
                break;
            }
        }
Beispiel #13
0
        public void updata()
        {
            int  i, n, nextPos;
            byte data;

            switch (Active)
            {
            case 0:
                break;

            case 1:         //ÅÝÅݵÄÏÔʾ״̬
                if (_delay == 0)
                {
                    _delay = 5;
                    ++_frame;
                    if (_frame > 20)
                    {
                        Active = 2;
                    }
                    OurGame.map[_mapPos].leiFrame = (Byte)(_frame % 4);
                }
                else
                {
                    --_delay;
                }
                break;

            case 2:     //ת»»µ½±¬Õ¨×´Ì¬

                OurGame._lei = true;

                _frame = 0xFF;
                _delay = 0;
                Active = 3;
                OurGame.map[_mapPos].leiID    = 1;
                OurGame.map[_mapPos].leiFrame = 0;

                if (OurGame.map[_mapPos].mapData != 0)
                {
                    OurGame.createArticle((byte)_mapPos);
                }

                OurGame.map[_mapPos].mapData = 0;

                for (i = 0; i < 4; ++i)
                {
                    n       = 0;
                    nextPos = _mapPos;
                    while (n < _len)
                    {
                        if (MyHelp.isInBound(ref nextPos, i))
                        {
                            ++n;
                            data = OurGame.map[nextPos].mapData;
                            if (data < 0x40)
                            {
                                ++_dir[i];
                                OurGame.map[nextPos].leiID = 3;
                                if (n > 1)
                                {
                                    OurGame.map[nextPos - MyHelp.posLen[i]].leiID = 2;
                                }
                                OurGame.map[nextPos].leiFrame = 0;
                                OurGame.map[nextPos].mapData  = 0;
                                OurGame.map[nextPos].leiDir   = rotation[i];
                                for (int k = 0; k < MyHelp.maxActicle; ++k)
                                {
                                    if (OurGame.acticle[k].active && OurGame.acticle[k].postion == nextPos)
                                    {
                                        OurGame.acticle[k].active = false;
                                    }
                                }

                                if (data != 0)
                                {
                                    OurGame.map[nextPos].mapData = 0;
                                    OurGame.createArticle((byte)nextPos);
                                    break;
                                }
                            }
                            else
                            {
                                break;
                            }
                        }
                        else
                        {
                            break;
                        }
                    }
                }
                break;

            case 3:     //±¬Õ¨×´Ì¬
                if (_delay == 0)
                {
                    ++_frame;
                    _delay = 1;
                    OurGame.map[_mapPos].leiID    = 1;
                    OurGame.map[_mapPos].leiFrame = (byte)(_frame % 4);
                    checkPerson(_mapPos);

                    for (i = 0; i < 4; ++i)
                    {
                        n       = 0;
                        nextPos = _mapPos;
                        while (n < _dir[i])
                        {
                            ++n;
                            nextPos += MyHelp.posLen[i];
                            checkPerson(nextPos);
                            OurGame.map[nextPos].leiID = 3;
                            if (OurGame.map[nextPos].leiID == 3)
                            {
                                OurGame.map[nextPos].leiFrame = (byte)(_frame % 12);
                            }
                            if (n > 1)
                            {
                                OurGame.map[nextPos - MyHelp.posLen[i]].leiID = 2;
                                if (OurGame.map[nextPos - MyHelp.posLen[i]].leiID == 2)
                                {
                                    OurGame.map[nextPos - MyHelp.posLen[i]].leiFrame = (byte)(_frame % 2);
                                }
                            }
                            for (int k = 0; k < MyHelp.maxLei; ++k)
                            {
                                if (OurGame.lei[k].Active == 1 && OurGame.lei[k].Pos == nextPos)
                                {
                                    OurGame.lei[k].Active = 2;
                                }
                            }
                        }
                    }
                    if (_frame >= 12)
                    {
                        Active = 0;
                        --parent.haveLei;
                        OurGame.map[_mapPos].leiActive = false;
                        OurGame.map[_mapPos].canMove  &= 0xDF;    //È¥µôÀ×±êÖ¾
                        for (i = 0; i < 4; ++i)
                        {
                            n       = 0;
                            nextPos = _mapPos;
                            while (n < _dir[i])
                            {
                                nextPos += MyHelp.posLen[i];
                                OurGame.map[nextPos].leiActive = false;
                                ++n;
                            }
                        }
                    }
                }
                else
                {
                    --_delay;
                }

                break;
            }
        }
Beispiel #14
0
        private bool canMove()
        {
            checkMapPos();
            if ((_dir & 0x10) != 0)
            {
                return(false);
            }
            int dir     = _dir & 0xF;
            int nextPos = MyHelp.posLen[dir] + mapPos;

            if ((OurGame.map[nextPos].canMove & 0x6f) != 0)
            {
                return(false);
            }
            int posData;

            if (nextPos >= 0 && nextPos < MyHelp.LENGTH)
            {
                posData = OurGame.map[nextPos].mapData & 0xF0;
                if (posData == 0)
                {
                    return(true);
                }
                else
                {
                    if (posData == 0x30) //是否可以进入树中
                    {
                        mapDelay   = 0;
                        boxAndTree = 2;
                        MyHelp.PosToVector2(mapPos + MyHelp.posLen[dir], out boxAndTreePos);
                        backData = OurGame.map[MyHelp.posLen[dir] + mapPos].mapData;
                        OurGame.map[nextPos].mapData = 0;
                        boxRect.X = 0;
                        boxRect.Y = 160;
                        return(true);
                    }
                    else if (posData == 0x10)   //是否可以推箱子
                    {
                        nextPos += MyHelp.posLen[dir];
                        if (nextPos < 0 || nextPos >= MyHelp.LENGTH)
                        {
                            return(false);
                        }
                        posData = OurGame.map[nextPos].mapData & 0xF0;
                        if ((OurGame.map[nextPos].canMove) != 0)
                        {
                            return(false);
                        }
                        //可以推箱子
                        if (posData == 0)
                        {
                            OurGame.map[nextPos].canMove |= 0x40;
                            mapDelay   = 0;
                            boxAndTree = 1;

                            MyHelp.PosToVector2(mapPos + MyHelp.posLen[dir], out boxAndTreePos);
                            backData = OurGame.map[MyHelp.posLen[dir] + mapPos].mapData;
                            OurGame.map[mapPos + MyHelp.posLen[dir]].mapData = 0;
                            boxRect.X = 0;
                            boxRect.Y = 0;
                            return(true);
                        }
                        else
                        {
                            return(false);
                        }
                    }
                    return(false);
                }
            }
            else
            {
                return(false);
            }
        }
Beispiel #15
0
        protected override void Draw(GameTime gameTime)
        {
            int i, j, k;

            graphics.GraphicsDevice.Clear(Color.CornflowerBlue);

            if (_gameState == "title")
            {
                _title.Show();
            }

            else
            {
                //开始绘制背景
                MyHelp.bgSpriteBatch.Begin();
                MyHelp.bgSpriteBatch.Draw(MyHelp.bgSprite, MyHelp.bgRect, Color.White);
                MyHelp.bgSpriteBatch.End();
                MyHelp.foreSpriteBatch.Begin(SpriteBlendMode.AlphaBlend);


                //绘制数字
                Life.Draw();
                for (i = 0; i < 3; ++i)
                {
                    prop[i].Draw();
                }
                //绘制地图
                for (i = 0; i < MyHelp.HEIGHT; ++i)
                {
                    _pos.Y    = MyHelp.StartPos.Y + i * 40;
                    _leiPos.Y = MyHelp.StartPos.Y + i * 40 + 20;


                    //绘制雷
                    for (j = 0; j < MyHelp.WIDTH; ++j)
                    {
                        _leiPos.X = MyHelp.StartPos.X + j * 40 + 20;
                        if (map[MyHelp.mapPos(i, j)].leiActive)
                        {
                            _leiRect.X = 50 * map[MyHelp.mapPos(i, j)].leiFrame;
                            _leiRect.Y = 50 * map[MyHelp.mapPos(i, j)].leiID;
                            MyHelp.foreSpriteBatch.Draw(MyHelp.leiSprite, _leiPos, _leiRect, Color.White, map[MyHelp.mapPos(i, j)].leiDir, MyHelp.leiCenter, 1, SpriteEffects.None, 0);
                        }
                    }
                    //物品
                    for (k = 0; k < MyHelp.maxActicle; ++k)
                    {
                        if (acticle[k].active && (acticle[k].hasDraw == 0) && acticle[k].Y <= _pos.Y)
                        {
                            acticle[k].hasDraw = 1;
                        }
                    }

                    //主角
                    if (Master.Active != 0)
                    {
                        if ((Master.hasDraw == 0) && (Master.Y <= _pos.Y))
                        {
                            Master.hasDraw = 1;
                        }
                    }
                    //敌人
                    for (k = 0; k < MyHelp.maxEnemy; ++k)
                    {
                        if ((Enemy[k].Active != 0) && (Enemy[k].hasDraw == 0) && Enemy[k].Y <= _pos.Y)
                        {
                            Enemy[k].hasDraw = 1;
                        }
                    }
                    for (j = 0; j < MyHelp.WIDTH; ++j)
                    {
                        _pos.X = MyHelp.StartPos.X + j * 40;
                        //物品
                        for (k = 0; k < MyHelp.maxActicle; ++k)
                        {
                            if (acticle[k].active && (acticle[k].hasDraw == 1) && acticle[k].X <= _pos.X)
                            {
                                acticle[k].Draw();
                            }
                        }
                        //显示主角
                        if (Master.Active != 0)
                        {
                            if ((Master.hasDraw == 1) && (Master.X <= _pos.X + 35))
                            {
                                Master.Draw();
                            }
                        }

                        //敌人
                        for (k = 0; k < MyHelp.maxEnemy; ++k)
                        {
                            if ((Enemy[k].Active != 0) && (Enemy[k].hasDraw == 1) && (Enemy[k].X < _pos.X + 35))
                            {
                                Enemy[k].Draw();
                            }
                        }

                        //显示地图
                        if (map[MyHelp.mapPos(i, j)].mapData >= 0x10)
                        {
                            _mapDataRect.Y = 80 * (((map[MyHelp.mapPos(i, j)].mapData & 0xf0) >> 4) - 1);
                            _mapDataRect.X = 40 * (map[MyHelp.mapPos(i, j)].mapData & 0xf);
                            MyHelp.foreSpriteBatch.Draw(MyHelp.mapSprite, _pos, _mapDataRect, Color.White, 0, MyHelp.mapDataCenter, 1, SpriteEffects.None, 0);
                        }
                    }
                }


                if (Master.Active != 0)
                {
                    if (Master.hasDraw != 0xff)
                    {
                        Master.Draw();
                    }
                }
                for (k = 0; k < MyHelp.maxEnemy; ++k)
                {
                    if ((Enemy[k].Active != 0) && (Enemy[k].hasDraw != 0xFF))
                    {
                        Enemy[k].Draw();
                    }
                }
                for (k = 0; k < MyHelp.maxActicle; ++k)
                {
                    if (acticle[k].active && acticle[k].hasDraw != 0xff)
                    {
                        acticle[k].Draw();
                    }
                }

                if (_gameState == "result")
                {
                    if (_hasEnter == false)
                    {
                        _soundBankBG.GetCue("enter").Play();
                        _hasEnter = true;
                    }
                    if (_isWin == true)
                    {
                        MyHelp.foreSpriteBatch.Draw(MyHelp.winSprite, new Vector2(100.0f, 100.0f), Color.White);
                    }
                    else
                    {
                        MyHelp.foreSpriteBatch.Draw(MyHelp.loseSprite, new Vector2(100.0f, 100.0f), Color.White);
                    }
                }

                MyHelp.foreSpriteBatch.End();

                Master.hasDraw = 0;
                for (k = 0; k < MyHelp.maxEnemy; ++k)
                {
                    Enemy[k].hasDraw = 0;
                }
                for (k = 0; k < MyHelp.maxActicle; ++k)
                {
                    if (acticle[k].active)
                    {
                        acticle[k].hasDraw = 0;
                    }
                }
            }

            base.Draw(gameTime);
        }
Beispiel #16
0
        private void checkSafe()
        {
            int i, j, k, len;
            int nextPos;

            moveDir.canMove = 0;
            moveDir.count   = 0;
            for (i = 0; i < 4; ++i)
            {
                moveDir.dirLen[i] = dirLen(i);
            }



            for (i = 0; i < 4; ++i)
            {
                nextPos = MyHelp.Vector2ToPos(pos);
                if (MyHelp.isInBound(ref nextPos, i))
                {
                    for (k = 0; k < MyHelp.maxLei; ++k)
                    {
                        if (OurGame.lei[k].Active != 0)
                        {
                            if (MyHelp.isInLine(nextPos, OurGame.lei[k].Pos, OurGame.lei[k].Len))
                            {
                                break;
                            }
                        }
                    }
                    //安全的地方,不会被炸

                    if (k >= MyHelp.maxLei)
                    {
                        if (moveDir.dirLen[i] != 0)
                        {
                            moveDir.canMove |= (byte)(1 << i);
                            ++moveDir.count;
                        }
                    }
                }
            }
            if (moveDir.count == 0)
            {
                nextPos = MyHelp.Vector2ToPos(pos);
                for (k = 0; k < MyHelp.maxLei; ++k)
                {
                    if (OurGame.lei[k].Active != 0)
                    {
                        if (MyHelp.isInLine(nextPos, OurGame.lei[k].Pos, OurGame.lei[k].Len))
                        {
                            break;
                        }
                    }
                }
                if (k >= MyHelp.maxLei)
                {
                    return;
                }
            }
            j = 0;
            if (moveDir.count == 0)
            {
                len = 0;

                for (i = 0; i < 4; ++i)
                {
                    if (moveDir.dirLen[i] > len)
                    {
                        len = moveDir.dirLen[i];
                        j   = i;
                    }
                    else if (moveDir.dirLen[i] == len)
                    {
                        nextPos = MyHelp.Vector2ToPos(pos);
                        if (MyHelp.isInBound(ref nextPos, i))
                        {
                            if (i < 2)
                            {
                                if ((dirLen(nextPos, 2) != 0) || (dirLen(nextPos, 3) != 0))
                                {
                                    j = i;
                                }
                            }
                            else
                            {
                                if ((dirLen(nextPos, 0) != 0) || (dirLen(nextPos, 1) != 0))
                                {
                                    j = i;
                                }
                            }
                        }
                    }
                }
                if (len != 0)
                {
                    for (k = 0; k < MyHelp.maxLei; ++k)
                    {
                        nextPos = MyHelp.Vector2ToPos(pos);
                        if (OurGame.lei[k].Active != 0)
                        {
                            len = OurGame.lei[k].Len;
                            if (nextPos == OurGame.lei[k].Pos)
                            {
                                break;
                            }

                            if (MyHelp.isInBound(ref nextPos, j))
                            {
                                if (MyHelp.isInLine(nextPos, OurGame.lei[k].Pos, len))
                                {
                                    if (MyHelp.isSafe(nextPos, OurGame.lei[k].Pos, len, j))
                                    {
                                        return;
                                    }
                                }
                            }
                        }
                        if (k >= MyHelp.maxLei)
                        {
                            return;
                        }
                    }
                    moveDir.canMove |= (byte)(1 << j);
                    ++moveDir.count;
                }
            }
        }
Beispiel #17
0
        private void check()
        {
            if (MyHelp.checkHit(OurGame.Master.pos, _pos, 5))
            {
                switch (_ID)
                {
                case 0:         //增加雷数
                    OurGame.Master.maxLei = MyHelp.Min(OurGame.Master.maxLei + 1, 3);
                    break;

                case 1:         //增加长度
                    OurGame.Master.leiLen = MyHelp.Min(OurGame.Master.leiLen + 1, 3);
                    break;

                case 2:         //数度为4
                    if (OurGame.Master.speed == 2)
                    {
                        OurGame.Master.speed = 4;
                    }
                    break;

                case 3:         //加龟
                    if (OurGame.Master.speed == 2 || OurGame.Master.speed == 4)
                    {
                        if (MyHelp.Random(20) <= 10)
                        {
                            OurGame.Master.speed  = 5;
                            OurGame.Master.Active = 0x11;
                        }
                        else
                        {
                            OurGame.Master.speed  = 1;
                            OurGame.Master.Active = 0x10;
                        }
                    }
                    break;

                case 4:         //加分4
                    break;

                case 5:         //加分1
                    break;

                case 6:         //加分2
                    break;
                }
                Active = false;
                return;
            }
            for (int i = 0; i < MyHelp.maxEnemy; ++i)
            {
                if (MyHelp.checkHit(OurGame.Enemy[i].pos, _pos, 5))
                {
                    switch (_ID)
                    {
                    case 0:         //增加雷数
                        OurGame.Enemy[i].maxLei = MyHelp.Min(OurGame.Enemy[i].maxLei + 1, 3);
                        break;

                    case 1:         //增加长度
                        OurGame.Enemy[i].leiLen = MyHelp.Min(OurGame.Enemy[i].leiLen + 1, 3);
                        break;

                    case 2:         //数度为4
                        if (OurGame.Enemy[i].speed == 2)
                        {
                            OurGame.Enemy[i].speed = 4;
                        }
                        break;

                    case 3:         //加龟
                        if (OurGame.Enemy[i].speed == 2 || OurGame.Enemy[i].speed == 4)
                        {
                            if (MyHelp.Random(20) <= 10)
                            {
                                OurGame.Enemy[i].speed  = 5;
                                OurGame.Enemy[i].Active = 0x11;
                            }
                            else
                            {
                                OurGame.Enemy[i].speed  = 1;
                                OurGame.Enemy[i].Active = 0x10;
                            }
                        }
                        break;
                    }
                    Active = false;
                    return;
                }
            }
        }