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

📄 human.java

📁 又是一款j2me 游戏
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
    {
        return legArea;
    }

    public boolean ChangeAction(int newAct)
    {
        if(actionId == 0 || newAct == 0)
        {
            SetAction(newAct);
            return true;
        } else
        {
            return false;
        }
    }

    public void SetAction(int newAct)
    {
        actionId = newAct;
        actionScript = 0;
        switch(newAct)
        {
        default:
            break;

        case 0: // '\0'
            actionScriptLength = 0;
            dalayAction = 0;
            drawImgId = 0;
            break;

        case 1: // '\001'
            actionScriptLength = 3;
            dalayAction = 2;
            drawImgId = 1;
            break;

        case 2: // '\002'
            actionScriptLength = 2;
            dalayAction = 2;
            drawImgId = 1;
            break;

        case 3: // '\003'
            switch(super.direction)
            {
            default:
                break;

            case 0: // '\0'
                if(GetType() == 20 || GetType() == 22)
                    attArea.SetBounds(GetCenterLocationX() - attWidth / 2, GetCenterLocationY() - attHeight, attWidth, attHeight);
                else
                    attArea.SetLocation(GetCenterLocationX() - attWidth / 2, GetCenterLocationY() - 17);
                break;

            case 1: // '\001'
                if(GetType() == 20 || GetType() == 22)
                    attArea.SetBounds(GetCenterLocationX() - attWidth / 2, GetCenterLocationY() + 10, attWidth, attHeight);
                else
                    attArea.SetLocation(GetCenterLocationX() - attWidth / 2, GetCenterLocationY() - 3);
                break;

            case 2: // '\002'
                if(GetType() == 20 || GetType() == 22)
                    attArea.SetBounds(GetCenterLocationX() - 28, GetCenterLocationY() - attWidth / 2, attHeight, attWidth);
                else
                    attArea.SetLocation(GetCenterLocationX() - attWidth / 2 - 10, GetCenterLocationY() - 13);
                break;

            case 3: // '\003'
                if(GetType() == 20 || GetType() == 22)
                    attArea.SetBounds(GetCenterLocationX() + 5, GetCenterLocationY() - attWidth / 2, attHeight, attWidth);
                else
                    attArea.SetLocation((GetCenterLocationX() - attWidth / 2) + 10, GetCenterLocationY() - 13);
                break;
            }
            actionScriptLength = 2;
            dalayAction = 2;
            drawImgId = 3;
            break;

        case 4: // '\004'
            actionScriptLength = 0;
            dalayAction = 4;
            drawImgId = 6;
            break;

        case 5: // '\005'
            actionScriptLength = 1;
            dalayAction = 10;
            drawImgId = 2;
            break;

        case 6: // '\006'
            super.stage = 0;
            explosionStage = 0;
            actionScriptLength = 1;
            dalayAction = 4;
            drawImgId = 7;
            break;

        case 7: // '\007'
            super.stage = 0;
            explosionStage = 0;
            actionScriptLength = 2;
            dalayAction = 6;
            drawImgId = 7;
            break;

        case 8: // '\b'
            actionScriptLength = 6;
            dalayAction = 4;
            drawImgId = 2;
            break;

        case 9: // '\t'
            actionScriptLength = 1;
            dalayAction = 4;
            drawImgId = 3;
            break;

        case 10: // '\n'
            actionScriptLength = 1;
            dalayAction = 15;
            drawImgId = 8;
            break;
        }
    }

    public int GetAction()
    {
        return actionId;
    }

    public int GetLegLocationY()
    {
        return curPosY;
    }

    public int FindDistance(int toX, int toY)
    {
        int disX = Math.abs(GetCenterLocationX() - toX);
        int disY = Math.abs(GetCenterLocationY() - toY);
        int min = disX >= disY ? disY : disX;
        return ((disX + disY) - (min >> 1) - (min >> 2)) + (min >> 4);
    }

    public void ChangeDirection(int newDir)
    {
        if(actionId != 6 || actionId != 7)
            super.direction = newDir;
    }

    public void SetHP(int newHP)
    {
        damage = newHP - hp;
        hp = newHP;
        if(hp > 0)
        {
            super.destroy = false;
            SetAction(0);
        } else
        if(hp < 0)
        {
            hp = 0;
            SetAction(7);
        }
    }

    public int GetHP()
    {
        return hp;
    }

    public int GetMaxHP()
    {
        return MAX_HP;
    }

    public void SetMaxHP(int maxHP)
    {
        MAX_HP = maxHP;
    }

    public int GetItem(int num)
    {
        return itemStock[num];
    }

    public void SetItem(int id, int itemId)
    {
        itemStock[id] = itemId;
    }

    public boolean AddNewItem(int itemId)
    {
        for(int i = 3; i < itemStock.length; i++)
            if(itemStock[i] == -1)
            {
                itemStock[i] = itemId;
                newItem = itemId;
                return true;
            }

        return false;
    }

    public int UseItem(int id)
    {
        if(itemStock[id] != -1)
        {
            switch(itemStock[id])
            {
            case 4: // '\004'
                MAX_HP += 15;
                SetHP(GetHP() + 50 <= MAX_HP ? hp + 50 : MAX_HP);
                break;

            case 5: // '\005'
                itemStock[id] = -1;
                gauge = 114;
                return gauge;

            case 6: // '\006'
                gauge = 114;
                invisible += 114;
                break;

            default:
                return -1;
            }
            itemStock[id] = -1;
        }
        return -1;
    }

    public boolean RemoveItem(int iId)
    {
        for(int i = 3; i < itemStock.length; i++)
            if(itemStock[i] == iId)
            {
                itemStock[i] = -1;
                return true;
            }

        return false;
    }

    public boolean HasItemId(int iId)
    {
        for(int i = 0; i < itemStock.length; i++)
            if(itemStock[i] == iId)
                return true;

        return false;
    }

    public int GetNumWeapon()
    {
        return numWeapon;
    }

    public void SetNumWeapon(int num)
    {
        numWeapon = num;
    }

    public boolean SetNewWeapon(int weapId)
    {
        for(int i = 0; i < 3; i++)
            if(itemStock[i] == weapId)
                return false;

        itemStock[numWeapon] = weapId;
        numWeapon++;
        return true;
    }

    public int GetWeaponId()
    {
        return weaponId;
    }

    public void SetWeaponId(int id)
    {
        weaponId = id;
        switch(id)
        {
        case 0: // '\0'
            attPower = DEFAULT_ATT_POWER;
            defPower = DEFAULT_DEF_POWER;
            break;

        case 1: // '\001'
            attPower = DEFAULT_ATT_POWER * 2;
            defPower = DEFAULT_DEF_POWER + 3;
            break;

        case 2: // '\002'
            attPower = DEFAULT_ATT_POWER * 3;
            defPower = DEFAULT_DEF_POWER + 8;
            break;
        }
    }

    public int GetAttackPower()
    {
        return attPower;
    }

    public int GetDefensePower()
    {
        return defPower;
    }

    public void KeyUp()
    {
        ChangeDirection(0);
        SetKeyHold(true);
    }

    public void KeyDown()
    {
        ChangeDirection(1);
        if(GetType() != 22)
            SetKeyHold(true);
    }

    public void KeyLeft()
    {
        ChangeDirection(2);
        if(GetType() != 22)
            SetKeyHold(true);
    }

    public void KeyRight()
    {
        ChangeDirection(3);
        if(GetType() != 22)
            SetKeyHold(true);
    }

    public void KeyFire()
    {
        if(GetType() != 22)
            ChangeAction(3);
    }

    public void SetKeyHold(boolean keyHold)
    {
        isKeyHold = keyHold;
        if(GetType() != 22 && !isKeyHold && (actionId == 1 || actionId == 2))
            SetAction(0);
    }

⌨️ 快捷键说明

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