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

📄 donghua.java

📁 HappyTreeFriends手机游戏的源代码
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
            {
                m_mechModel[i * 4 + j] = (short)Xiyou.ReadUnsignedShort(dis);
            }
        }


		
    }

   
    private void LoadGfx()
    {
        try
        {
            DataInputStream dis = new DataInputStream(FILE_NAME_GFXDATA.getClass().getResourceAsStream(FILE_NAME_GFXDATA));
            int textureCount = Xiyou.ReadUnsignedVarshort(dis);
            int[] texturepanYis = new int[textureCount+1];
            for (int i = 0; i < textureCount+1; i++)
            {
                texturepanYis[i] = Xiyou.ReadUnsignedShort(dis);
            }
            dis.skip(texturepanYis[m_ID]);

            m_imageFormat = Xiyou.ReadUnsignedByte(dis);
            dis.skip(1);
            m_imageID = Xiyou.ReadUnsignedByte(dis);
            if (m_imageFormat == IMAGE_FORMAT_PNG)
            {
                int flag = Xiyou.ReadUnsignedByte(dis);
                m_largeMokuaiiiiiiiiiiiiiies = (flag & 0x01) != 0;
            }
            int moduleCount = Xiyou.ReadUnsignedVarshort(dis);
            if (m_imageFormat == IMAGE_FORMAT_PNG)
            	{
            		m_MOkkkai = new byte[moduleCount * 4];
   			m_modid = new byte[moduleCount];
            	}
                
            else
                m_MOkkkai = new byte[moduleCount * 2];

   
            for (int i = 0; i < moduleCount; i++)
            {
                if (m_imageFormat == IMAGE_FORMAT_PNG)
                {
                    m_MOkkkai[i*4] = (byte)Xiyou.ReadUnsignedByte(dis);
                    m_MOkkkai[i*4+1] = (byte)Xiyou.ReadUnsignedByte(dis);
                    m_MOkkkai[i*4+2] = (byte)Xiyou.ReadUnsignedByte(dis);
                    m_MOkkkai[i*4+3] = (byte)Xiyou.ReadUnsignedByte(dis);
                }
                else
                {
                    m_MOkkkai[i*2] = (byte)Xiyou.ReadUnsignedByte(dis);
                    m_MOkkkai[i*2+1] = (byte)Xiyou.ReadUnsignedByte(dis);
                }
            }

   			 updateMokuaiiiiiiiiiiiiiies(m_imageID, m_MOkkkai ,m_modid);

 
           
            dis.skip(texturepanYis[textureCount] - texturepanYis[m_ID+1]);

            int imageCount = Xiyou.ReadUnsignedVarshort(dis);
            int[] imagepanYis = new int[imageCount+1];
            for (int i = 0; i < imageCount+1; i++)
            {
                imagepanYis[i] = Xiyou.ReadUnsignedShort(dis);
            }
            dis.skip(imagepanYis[m_imageID]);

            if (m_imageFormat == IMAGE_FORMAT_PNG)
            {
            }

            dis.close();
            dis = null;
        }
        catch (Exception e)
        {
            Debug.PrintException(e);
        }
    }


  
    private void Free()
    {
        if (m_imageFormat == IMAGE_FORMAT_PNG)
        {
            s_pngImagesRefs[m_imageID]--;
            Debug.Assert(s_pngImagesRefs[m_imageID] >= 0,
                         "the references shumu of image " + m_imageID + " is less than 0");
        }
        m_MOkkkai = null;
        m_frames = null;
        m_actions = null;
    }

    private static void FreeUnusedPngImages()
    {
        for (int i = 0; i < DWorld.IMAGE_COUNT; i++)
        {
            if (s_pngImagesRefs[i] == 0)
            {
                s_pngImages[i] = null;
            }
        }
    }


 
  public static void FreeAnimationAndImg()
 	{
 		if (s_anims!= null)
 			{
 				for(int i = 0 ; i < s_anims.length ; i++)
 					{
 						if (s_anims[i] != null)
 							{
 								s_anims[i].Free();
                        					s_anims[i] = null;
 							}
 					}
 			}

		for (int i = 0; i < DWorld.IMAGE_COUNT; i++)
        	{
	           
	                s_pngImages[i] = null;
     
     		}

 	}
  


    private byte[] m_modid;

    public void updateMokuaiiiiiiiiiiiiiies(int imageIndex, byte[] MOkkkai , byte[] m_modid) {
      try {
        byte[][] tmp = null;
        if (Xiyou.s_imgsRect[imageIndex] != null
            && Xiyou.s_imgsRect[imageIndex].length > 1) {
          tmp = Xiyou.s_imgsRect[imageIndex];
        }
        if (tmp != null) {
          int shumu = MOkkkai.length >> 2;

          for (int j = 0; j < shumu; j++) {
            int mid = j << 2;
            int modX = MOkkkai[mid] & 0xFF;
            int modY = MOkkkai[mid + 1] & 0xFF;
            int modW = MOkkkai[mid + 2];
            int modH = MOkkkai[mid + 3];
            int cX = modX + (modW >> 1);
            int cY = modY + (modH >> 1);
            int id = 0;
            int tx = tmp[0][0] & 0xff,
                ty = tmp[0][1] & 0xff,
                tw = tmp[0][2] & 0xff,
                th = tmp[0][3] & 0xff;

            for (; id < tmp.length; id++) {
                tx = tmp[id][0] & 0xff;
                ty = tmp[id][1] & 0xff;
                tw = tmp[id][2] & 0xff;
                th = tmp[id][3] & 0xff;

              if (cX >= tx
                  && cY >= ty
                  && cX <= tx + tw
                  && cY <= ty + th) {
                break;
              }
            }
            if (id >= tmp.length) {
              id = 0;
            }
            int x = (modX - tx);
            int y = (modY - ty);
            if (x < 0) {
              modW += x;
              x = 0;
            }
            if (y < 0) {
              modH += y;
              y = 0;
            }
            MOkkkai[mid] = (byte) x;
            MOkkkai[mid + 1] = (byte) y;
	
            m_modid[j ] = (byte)id; 
            MOkkkai[mid + 2] = (byte) modW ;
            MOkkkai[mid + 3] = (byte) modH ;
	
          }
        }
      }
      catch (Exception ex) {
        ex.printStackTrace();
      }
    }




   public void Draw(Graphics g, int x, int y, boolean flipX, boolean flipY, int frameID, int scenePalID, boolean insideViewport)
    {
            drawZhennnnnn(g, x, y, flipX, flipY, frameID, scenePalID);
    }

    public void drawZhennnnnn(Graphics g, int x, int y, boolean flipX, boolean flipY, int frameIndex, int pal)
    {
        int piece;
        boolean oflipx = flipX;

        Image img;
        byte[] frame = m_frames[frameIndex];

        int imgID = m_imageID;

        int imgW;
        int imgH;

        int modID, flag, posX, posY;
        int modX, modY, modW, modH;
        boolean flipX_real, flipY_real;
        for (int i=0; i<frame.length; i+=4)
        {
            piece = 0;
            flipX = oflipx;
			

            modID = (frame[i] & 0xFF) << 2;
            flag = frame[i+1] & 0xFF;
            modX = m_MOkkkai[modID]   & 0xFF;
            modY = m_MOkkkai[modID+1] & 0xFF;
            modW = m_MOkkkai[modID+2] & 0xFF;
            modH = m_MOkkkai[modID+3] & 0xFF;

       
            if (Xiyou.s_imgsRect[imgID] != null)
            {
                piece = m_modid[(frame[i] & 0xFF) ]; 
		


            }

            img = Xiyou.s_tupians[imgID][pal][0][piece];
            imgW = img.getWidth();
            imgH = img.getHeight();

            if (modX + modW > imgW)
                modW = imgW - modX;
            if (modY + modH > imgH)
                modH = imgH - modY;
            if (modW <= 0 || modH <= 0)
                continue;

            flipX_real = flipX ^ ((flag & 0x01) != 0);
            flipY_real = flipY ^ ((flag & 0x02) != 0);

            posX = x;
            posY = y;

      
            if ((flag & 0x01) != 0)
                posX -= modW - frame[i+2];
            else
                posX += frame[i+2];
            if ((flag & 0x02) != 0)
                posY -= modH - frame[i+3];
            else
                posY += frame[i+3];

            if (flipX)
                posX = (x<<1) - posX - modW;
            if (flipY)
                posY = (y<<1) - posY - modH;

            flag = 0;

            g.setClip(0, PINGMUDDD.sssCHUANNN_TOP, PINGMUDDD.sssCHUANNN_WIDTH, PINGMUDDD.sssCHUANNN_HEIGHT);
            g.clipRect(posX, posY, modW, modH);

            drawRegion(g, imgID, pal, piece, modX, modY, modW, modH, flag, posX, posY);
        }
        g.setClip(0, PINGMUDDD.sssCHUANNN_TOP, PINGMUDDD.sssCHUANNN_WIDTH, PINGMUDDD.sssCHUANNN_HEIGHT);
    }


    public static void drawRegion(Graphics ig, int imageID, int palID, int piece, int srcX, int srcY, int width, int height,
                       int flag, int destX, int destY)
    {
    	int startX;
	int startY;
    	int imgH;
	int imgW;
	


	if (Xiyou.s_tupians == null
		|| Xiyou.s_tupians[imageID] == null
		|| Xiyou.s_tupians[imageID][palID] == null
		|| Xiyou.s_tupians[imageID][palID][flag] == null
		|| Xiyou.s_tupians[imageID][palID][flag][piece] == null)
	{
		return;
	}

	Image img = Xiyou.s_tupians[imageID][palID][flag][piece];

	imgH = img.getHeight();
	imgW = img.getWidth();

	startX = destX - srcX;
	startY = destY - srcY;
		
	ig.drawImage(img, startX, startY, Graphics.LEFT|Graphics.TOP);
    }	




    
    
    public static boolean IsHuanchongedAnimation(int animationID)
    {
        return false;
       
    }
    


    public int GetZhennnnnnDuration(int actionID, int embeddingZhennnnnnID)
    {
        Debug.Assert(actionID >= 0 && actionID < m_actions.length,
                    "actionID " + actionID + " overflows in Donghua.getZhennnnnnDuration");
        Debug.Assert(embeddingZhennnnnnID >= 0 && embeddingZhennnnnnID < m_actions[actionID].length,
                    "embeddingZhennnnnnID " + embeddingZhennnnnnID + " overflows in Donghua.getZhennnnnnDuration");

        return (m_actions[actionID][embeddingZhennnnnnID] & 0xFFFF) >> 8;
    }

  
    public int GetZhennnnnnID(int actionID, int embeddingZhennnnnnID)
    {
        Debug.Assert(actionID >= 0 && actionID < m_actions.length,
                    "actionID " + actionID + " overflows in Donghua.getZhennnnnnDuration");
        Debug.Assert(embeddingZhennnnnnID >= 0 && embeddingZhennnnnnID < m_actions[actionID].length,
                    "embeddingZhennnnnnID " + embeddingZhennnnnnID + " overflows in Donghua.getZhennnnnnDuration");

        return m_actions[actionID][embeddingZhennnnnnID] & 0x00FF;
    }

  
    public int GetZhennnnnnCount(int actionID)
    {
        Debug.Assert(actionID >= 0 && actionID < m_actions.length,
                    "actionID " + actionID + " overflows in Donghua.getZhennnnnnCount");

        return m_actions[actionID].length;
    }

}

⌨️ 快捷键说明

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