⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 manager.java

📁 一款一个益智类的手机游戏源码
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
                            else
                            {
                                subSituCount++;
                                return;
                            }
                        }
                        if (15 <= subSituCount)
                        {
                            setSituation( (byte) 3);
                            resetReStartGame();
                            soundCount = 0;
                            return;
                        }
                        break label0;

                    case 3: // '\003'
                        if (getStageEndState() == 0 && subSituCount == 2)
                        {
                            if (!isSkip)
                            {
                                return;
                            }
                            setSkip(false);
                        }
                        subSituCount = subSituCount >= 10 ? 10 :
                            subSituCount + 1;
                        if (subSituCount == 10 && isSkip)
                        {
                            setSituation( (byte) 0);
                            soundCount = 0;
                            setSkip(false);
                        }
                        break;
                }
                break;

            case -1:
                setGameMode( (byte) 1);
                break;

            case 3: // '\003'
                subSituCount++;
                break;
        }
    }

    public void setGameMode(byte byte0)
    {
        gameMode = byte0;
    }

    public int getGameMode()
    {
        return gameMode;
    }

    public void setSituation(byte byte0)
    {
        situation = byte0;
        subSituCount = 0;
    }

    public int getSituation()
    {
        return situation;
    }

    public void setSkip(boolean flag)
    {
        isSkip = flag;
    }

    public int getLevel()
    {
        return level;
    }

    public int getScore()
    {
        return score;
    }

    public byte getStageEndState()
    {
        return stageEndState;
    }

    public int[] getGameInfo()
    {
        int ai[] = new int[6];
        ai[0] = life;
        ai[1] = userLevel;
        ai[2] = score;
        ai[3] = cartridge;
        ai[4] = bullet;
        ai[5] = directOfOutRoad;
        return ai;
    }

    public void setGameInfo(int ai[])
    {
        userLevel = ai[1];
        if (userLevel != 0)
        {
            life = ai[0];
            cartridge = (byte) ai[3];
            if (cartridge == 0)
            {
                cartridge = 1;
            }
            bullet = (byte) ai[4];
        }
        else
        {
            life = 3;
            userLevel = 1;
            cartridge = 1;
            bullet = 2;
        }
        level = userLevel <= 19 ? userLevel - 1 : 19;
        score = ai[2];
        directOfOutRoad = (byte) ai[5];
    }

    public Manager(int i, int j)
    {
        players = new int[2][4];
        natives = new int[20][4];
        girlTarget = new int[4];
        nativeTarget = new int[3];
        previousXY = new int[2];
        situation = 0;
        directOfOutRoad = 4;
        directOfInRoad = 0;
        obstacle2 = new byte[20][2][2];
        heroCount = 0;
        girlCount = 0;
        nativeCount = 0;
        bulletCount = 1;
        seizeCount = 0;
        soundCount = 0;
        resultCount = 0;
        subSituCount = 0;
        threadCount = 0;
        isSkip = false;
        System.gc();
        WIDTH = i;
        HEIGHT = j;
        half_width = WIDTH / 2;
        half_height = HEIGHT / 2;
        ROWS = j / 5;
        COLUMNS = i / 5;
        GROUND_START_ROW = ROWS <= 24 ? 0 : (ROWS - 24) / 2;
        bgArray = new byte[ROWS][COLUMNS];
        loadObjectLoc();
        System.gc();
    }

    public void destoryGM()
    {
        treeArray = null;
        item = null;
        rnd = null;
        System.gc();
    }

    public void startGame(boolean flag)
    {
        if (!flag)
        {
            life = 3;
            level = 0;
            userLevel = 1;
            score = 0;
            cartridge = 1;
            bullet = 2;
            directOfOutRoad = 0;
        }
        setGameMode( (byte) - 1);
        setSituation( (byte) 0);
        nativeNum = 0;
        dieNativeNum = 0;
        lifeBonus = false;
        scoreBonus = false;
        initGame();
    }

    public void initGame()
    {
        directOfInRoad = (byte) getOppositeDirect(directOfOutRoad);
        threadCount = 0;
        treeArray = null;
        item = null;
        treeArray = new byte[treeNumInLevel[level]][3];
        byte byte0 = itemNumInLevel[level];
        if (byte0 != 0)
        {
            item = new int[byte0][3];
        }
        rnd = new Random();
        treeMap = new byte[19][13][2];
        loadMap();
        initBoard();
        initLocation(true);
        treeMap = null;
        setNativeMoveSize();
    }

    public void setNativeMoveSize()
    {
        if (level < 10)
        {
            nativeMoveSize = 2;
        }
        else
        if (level < 18)
        {
            nativeMoveSize = 3;
        }
        else
        if (level < 20)
        {
            nativeMoveSize = 4;
        }
        else
        {
            nativeMoveSize = 3;
        }
    }

    public void resetLevelUpGame()
    {
        for (int i = natives.length - 1; i >= 0; i--)
        {
            natives[i][3] = natives[i][2] = natives[i][1] = natives[i][0] = 0;
        }

        if (dieNativeNum == nativeNum)
        {
            if (level < 10 && life < 6)
            {
                life++;
                lifeBonus = true;
            }
            score += 10;
            scoreBonus = true;
        }
        else
        {
            lifeBonus = false;
            scoreBonus = false;
        }
        nativeNum = 0;
        level = level <= 18 ? level + 1 : 19;
        userLevel++;
        initGame();
    }

    public void resetReStartGame()
    {
        life--;
        threadCount = 0;
        if (life <= 0)
        {
            return;
        }
        else
        {
            restartNativeLoc();
            initLocation(false);
            return;
        }
    }

    public void useCartridge()
    {
        if (situation != 0)
        {
            return;
        }
        if (0 < cartridge)
        {
            cartridge--;
            bullet = 5;
            playSound("/item.ott", 6, 1);
        }
    }

    private void initBoard()
    {
        for (int i = 2; i < ROWS - 2; i++)
        {
            for (int k = 2; k < COLUMNS - 2; k++)
            {
                bgArray[i][k] = 1;
            }

        }

        for (int l = 0; l < COLUMNS; l++)
        {
            bgArray[0][l] = 0;
            bgArray[1][l] = 0;
            bgArray[ROWS - 0 - 1][l] = 0;
            bgArray[ROWS - 1 - 1][l] = 0;
        }

        for (int j = 0; j < ROWS; j++)
        {
            bgArray[j][1] = bgArray[j][COLUMNS - 2] = 0;
            bgArray[j][0] = bgArray[j][COLUMNS - 1] = 0;
        }

        setRoad();
        setTreeLoc();
        setObstacle();
    }

    private void setObstacle()
    {
        for (int i = obstacle2[level].length - 1; i >= 0; i--)
        {
            bgArray[GROUND_START_ROW +
                obstacle2[level][i][0]][obstacle2[level][i][1]] = 3;
        }

    }

    private void setTreeLoc()
    {
        int i = Math.abs(rnd.nextInt()) % 19;
        int k = Math.abs(rnd.nextInt()) % 13;
        setTreeBlock(treeNumInLevel[level], i, k);
        if (item == null)
        {
            return;
        }
        for (int i1 = item.length; i1 > 0; )
        {
            int j = Math.abs(rnd.nextInt()) % 19;
            int l = Math.abs(rnd.nextInt()) % 13;
            if (bgArray[treeMap[j][l][0]][treeMap[j][l][1]] == 1)
            {
                item[i1 - 1][0] = treeMap[j][l][0];
                item[i1 - 1][1] = treeMap[j][l][1];
                item[i1 - 1][2] = 0;
                i1--;
            }
        }

    }

    private void setTreeBlock(int i, int j, int k)
    {
        nativeNum = treeNumInLevel[level] - 3;
        for (int l = 0; l < i; l++)
        {
            treeArray[l][0] = treeMap[j][k][0];
            treeArray[l][1] = treeMap[j][k][1];
            bgArray[treeArray[l][0]][treeArray[l][1]] = 2;
            k = (k + 1) % 13;
            j = (j + 1) % 19;
            if (l < nativeNum)
            {
                treeArray[l][2] = 1;
                natives[l][0] = treeArray[l][1] * 5;
                natives[l][1] = treeArray[l][0] * 5;
            }
        }

    }

    public void restartNativeLoc()
    {
        int i = nativeNum - 1;
        for (int j = treeArray.length - 1; j >= 0; j--)
        {
            if (treeArray[j][2] == 1)
            {
                natives[i][0] = treeArray[j][1] * 5;
                natives[i--][1] = treeArray[j][0] * 5;
            }
        }

    }

    private void setRoad()
    {
        setRoad(directOfInRoad);
        setRoad(directOfOutRoad);
        switch (Math.abs(rnd.nextInt()) % 4)
        {
            default:
                break;

            case 0: // '\0'
                int i = directOfOutRoad + 2;
                if (i > 7)
                {
                    i = 0;
                }
                setRoad(i);
                break;

            case 1: // '\001'
                int j = directOfOutRoad - 2;
                if (j < 0)
                {
                    j = 6;
                }
                setRoad(j);
                break;
        }
    }

    private void setRoad(int i)
    {
        switch (i)
        {
            case 1: // '\001'
            case 3: // '\003'
            case 5: // '\005'
            default:
                break;

            case 0: // '\0'
                for (int j = 0; j < 6; j++)
                {
                    bgArray[GROUND_START_ROW + 9 + j][COLUMNS - 2] = 4;
                }

                break;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -