예제 #1
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);
        }
예제 #2
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);
        }
예제 #3
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;
                }
            }
        }
예제 #4
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;
            }
        }