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

📄 game.java

📁 j2me游戏Global星球文明,是国外的游戏,45度视角.
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
// Decompiled by DJ v3.9.9.91 Copyright 2005 Atanas Neshkov Date: 2006-3-25 下午
// 09:40:59
//Home Page : http://members.fortunecity.com/neshkov/dj.html - Check often for
// new version!
//Decompiler options: packimports(3)

import java.io.*;
import java.util.Random;
import javax.microedition.lcdui.Display;
import javax.microedition.rms.RecordEnumeration;
import javax.microedition.rms.RecordStore;

public class Game {

	public Game(Global global) {
		resNum = 15;
		stock = new short[resNum + 2];
		objects = new byte[120][8];
		buildsQuantity = new int[17];
		people = new short[240][12];
		gw = global;

	}

	public Game() {
		resNum = 15;
		stock = new short[resNum + 2];
		objects = new byte[120][8];
		buildsQuantity = new int[17];
		people = new short[240][12];
	}

	public void build(int i, int j) {
		for (int k = 0; k < 3; k++) {
			byte byte0 = forbuild[gw.gs.buildNum][k][0];
			if (byte0 > 0)
				stock[byte0] -= forbuild[gw.gs.buildNum][k][1];
		}

		gw.lv.map[j][i] = 45;
		for (int i1 = -3; i1 <= 3; i1++) {
			byte byte1 = -3;
			byte byte2 = 3;
			if (i1 == -3 || i1 == 3) {
				byte1 = -2;
				byte2 = 2;
			}
			for (int l = byte1; l <= byte2; l++)
				try {
					gw.lv.flags[j + i1][i + l] &= 0xfe;
				} catch (Exception exception) {
				}

		}

		newBuild();
	}

	public void calculateBuilds() {
		int i = 0;
		do {
			GameScreen _tmp = gw.gs;
			if (i < 17) {
				buildsQuantity[i] = 0;
				i++;
			} else {
				break;
			}
		} while (true);
		for (int j = 0; j < buildsNum; j++)
			buildsQuantity[objects[j][2]]++;

	}

	public void dayFinished() {
		for (int i1 = buildsNum - 1; i1 >= 0; i1--) {
			int i = objects[i1][3];
			if (i < 1) {
				i++;
				objects[i1][3] = (byte) i;
				if (i == 1) {
					GameScreen _tmp = gw.gs;
					gw.lv.map[objects[i1][1]][objects[i1][0]] = GameScreen.builds[objects[i1][2]];
					gw.lv.flags[objects[i1][1]][objects[i1][0]] &= 0xfb;
					newPeople(objects[i1][2], objects[i1][0] * 22,
							objects[i1][1] * 22, i1);
					newPeople(80, objects[i1][0] * 22, objects[i1][1] * 22, i1);
				}
			} else {
				byte byte13 = objects[i1][2];
				if ((byte13 < 7 || byte13 > 9) && byte13 != 16) {
					byte byte8 = production[objects[i1][2]][0][0];
					byte byte9 = production[objects[i1][2]][0][1];
					byte byte0 = production[objects[i1][2]][1][0];
					byte byte4 = production[objects[i1][2]][1][1];
					byte byte2 = production[objects[i1][2]][2][0];
					byte byte6 = production[objects[i1][2]][2][1];
					if (byte8 > 0 && objects[i1][6] >= byte4
							&& objects[i1][7] >= byte6) {
						objects[i1][6] -= byte4;
						objects[i1][7] -= byte6;
						objects[i1][5] += byte9;
					}
				} else if (byte13 == 16 && objects[i1][6] >= 5) {
					objects[i1][6] -= 5;
					gw.gm.scores += 50;
				}
			}
		}

		calculateBuilds();
		switch (mission) {
		case 0: // '\0'
			if (buildsQuantity[1] >= 1 && buildsQuantity[2] >= 1
					&& buildsQuantity[0] >= 1) {
				mission = 1;
				Strings _tmp1 = gw.st;
				gw.gs.beginTicker(Strings.mission[gw.st.locint][gw.gm.mission]);
			}
			break;

		case 1: // '\001'
			if (buildsQuantity[3] >= 1) {
				mission = 2;
				Strings _tmp2 = gw.st;
				gw.gs.beginTicker(Strings.mission[gw.st.locint][gw.gm.mission]);
			}
			break;

		case 2: // '\002'
			if (stock[2] >= 10) {
				mission = 3;
				Strings _tmp3 = gw.st;
				gw.gs.beginTicker(Strings.mission[gw.st.locint][gw.gm.mission]);
			}
			break;

		case 3: // '\003'
			if (stock[7] >= 20) {
				chapter = 2;
				mission = 4;
				Strings _tmp4 = gw.st;
				gw.gs.beginSplash(gw.gs.countryName,
						Strings.chapter2[gw.st.locint]);
			}
			break;

		case 4: // '\004'
			if (buildsQuantity[7] >= 1 && buildsQuantity[8] >= 1) {
				mission = 5;
				Strings _tmp5 = gw.st;
				gw.gs.beginTicker(Strings.mission[gw.st.locint][gw.gm.mission]);
			}
			break;

		case 5: // '\005'
			if (stock[9] >= 5 && stock[10] >= 5) {
				mission = 6;
				Strings _tmp6 = gw.st;
				gw.gs.beginTicker(Strings.mission[gw.st.locint][gw.gm.mission]);
			}
			break;

		case 6: // '\006'
			if (stock[5] >= 5) {
				chapter = 3;
				mission = 7;
				Strings _tmp7 = gw.st;
				gw.gs.beginSplash(gw.gs.countryName,
						Strings.chapter3[gw.st.locint]);
			}
			break;

		case 7: // '\007'
			if (buildsQuantity[12] >= 1 && buildsQuantity[4] >= 1) {
				mission = 8;
				Strings _tmp8 = gw.st;
				gw.gs.beginTicker(Strings.mission[gw.st.locint][gw.gm.mission]);
			}
			break;

		case 8: // '\b'
			if (buildsQuantity[13] >= 1 && buildsQuantity[14] >= 1) {
				mission = 9;
				Strings _tmp9 = gw.st;
				gw.gs.beginTicker(Strings.mission[gw.st.locint][gw.gm.mission]);
			}
			break;

		case 9: // '\t'
			if (buildsQuantity[15] >= 1) {
				mission = 10;
				Strings _tmp10 = gw.st;
				gw.gs.beginTicker(Strings.mission[gw.st.locint][gw.gm.mission]);
			}
			break;

		case 10: // '\n'
			if (stock[16] > 20) {
				chapter = 4;
				mission = 11;
				Strings _tmp11 = gw.st;
				Strings _tmp12 = gw.st;
				gw.gs
						.beginSplash(
								gw.gs.countryName,
								Strings.chapter4[gw.st.locint]
										+ " "
										+ Strings.chapter4loc[gw.st.locint][gw.gs.country]);
			}
			break;
		}
		if (buildsNum >= 100)
			gameWin();
		for (int j1 = peopleNum - 1; j1 >= 0; j1--)
			if (people[j1][9] == 5) {
				people[j1][4]++;
				if (people[j1][4] == 3) {
					int j = people[j1][8];
					if (j == 1 || j == 3 || j >= 7 && j <= 9) {
						int k = gw.lv.resources[people[j1][11]][people[j1][10]];
						int l = k >> 6 & 3;
						k &= 0x3f;
						if (--k <= 0) {
							gw.lv.map[people[j1][11]][people[j1][10]] = 1;
							l = 0;
							k = 0;
						}
						gw.lv.resources[people[j1][11]][people[j1][10]] = (byte) (l << 6 | k);
					} else if (j == 0
							&& gw.lv.map[people[j1][11]][people[j1][10]] == 5
							&& gw.lv.resources[people[j1][11]][people[j1][10]] > 0)
						gw.lv.resources[people[j1][11]][people[j1][10]]--;
					if (j == 1 || j == 0 || j == 3 || j >= 7 && j <= 9) {
						short word0 = people[j1][3];
						people[j1][5] = (short) (objects[word0][0] * 22);
						people[j1][6] = (short) (objects[word0][1] * 22);
						people[j1][9] = 6;
						people[j1][7] = 0;
						people[j1][2] = (short) j;
					}
				}
			} else if (people[j1][8] == 80 && people[j1][9] == 0) {
				short word1 = people[j1][3];
				byte byte1 = production[objects[word1][2]][1][0];
				byte byte5 = production[objects[word1][2]][1][1];
				byte byte3 = production[objects[word1][2]][2][0];
				byte byte7 = production[objects[word1][2]][2][1];
				byte byte10 = objects[word1][6];
				byte byte11 = objects[word1][7];
				byte byte12 = 0;
				if (byte1 > 0)
					if (byte10 < byte5 && stock[byte1] >= byte5)
						byte12 = byte1;
					else if (byte3 > 0 && byte11 < byte7
							&& stock[byte3] >= byte7)
						byte12 = byte3;
				if (byte12 > 0) {
					people[j1][9] = 2;
					people[j1][5] = (short) (objects[word1][0] * 22);
					people[j1][6] = (short) (objects[word1][1] * 22);
					people[j1][7] = 0;
					people[j1][2] = byte12;
					if (byte12 == 16)
						if (stock[7] > 0)
							stock[7]--;
						else if (stock[8] > 0)
							stock[8]--;
						else if (stock[14] > 0)
							stock[14]--;
					stock[byte12]--;
				} else if (objects[people[j1][3]][5] > 0) {
					people[j1][9] = 2;
					people[j1][5] = (short) (objects[word1][0] * 22);
					people[j1][6] = (short) (objects[word1][1] * 22);
					people[j1][7] = 0;
					people[j1][2] = 0;
				}
			}

		if ((gw.gs.rnd.nextInt() & 0xff) < Ppesok)
			gw.lv.pesok();
		if ((gw.gs.rnd.nextInt() & 0xff) < Plednik)
			gw.lv.moroz();
		if ((gw.gs.rnd.nextInt() & 0xff) < Pvoda)
			gw.lv.navodnenie();
		int k1 = (gw.gs.days * 26) / 500;
		if (k1 > 16)
			k1 = 16;
		Puragan = 16 + k1;
		if (!gw.gs.uragan && (gw.gs.rnd.nextInt() & 0xff) < Puragan)
			gw.gs.createUragan();
		if (!gw.gs.earthQuake
				&& (gw.gs.rnd.nextInt() & 0xff) < 3 * Puragan >> 2)
			gw.gs.beginEarthQuake();
		calculateBuilds();
	}

	public void delete() {
		try {
			RecordStore.deleteRecordStore("globalw");
		} catch (Exception exception) {
		}
	}

	public void destroyBuild(int i, int j) {
		int k = -1;
		if (gw.lv.map[j][i] == 60) {
			if (gw.gs.vibration)
				try {
					Display.getDisplay(gw).vibrate(1000);
				} catch (Exception exception) {
				}
			gw.lv.map[j][i] = 1;
			gameOver();
		} else {
			for (int i1 = 0; i1 < buildsNum; i1++) {
				if (objects[i1][0] != i || objects[i1][1] != j)
					continue;
				k = i1;
				break;
			}

			if (k != -1) {
				if (gw.gs.vibration)
					try {
						Display.getDisplay(gw).vibrate(1000);
					} catch (Exception exception1) {
					}
				if (buildsNum > 0) {
					buildsNum--;
					System.arraycopy(objects[buildsNum], 0, objects[k], 0, 8);
					int l = k << 1;
					peopleNum--;
					System
							.arraycopy(people[peopleNum], 0, people[l + 1], 0,
									12);
					people[l + 1][3] = (short) k;
					peopleNum--;
					System.arraycopy(people[peopleNum], 0, people[l], 0, 12);
					people[l][3] = (short) k;
					stock[15] = (short) peopleNum;
				}
				gw.lv.map[j][i] = 1;
			}
		}
	}

	public int findFish(int i, int j) {
		for (int l = 3; l >= -3; l--) {
			int k;
			byte byte0;
			byte0 = -3;
			byte byte1 = 3;
			if (l == -3 || l == 3) {
				byte0 = -2;
				byte1 = 2;
			}
			k = byte1;
			for (; k >= byte0; k--) {
				if ((k == 0) & (l == 0))
					continue; /* Loop/switch isn't completed */
				byte byte2 = gw.lv.map[j + l][i + k];
				if (byte2 == 5 && gw.lv.resources[j + l][i + k] > 0)
					return (j + l << 8) + (i + k);
				if (byte2 == 3 || byte2 == 4 || byte2 == 11 || byte2 == 12)
					return (j + l << 8) + (i + k);
				continue; /* Loop/switch isn't completed */
			}

		}
		return 0;
	}

	public int findMine(int i, int j, int k) {
		for (int i1 = -3; i1 <= 3; i1++) {
			int l;
			byte byte0;
			byte0 = -3;
			byte byte1 = 3;
			if (i1 == -3 || i1 == 3) {
				byte0 = -2;
				byte1 = 2;
			}
			l = byte1;
			for (; l >= byte0; l--) {
				if ((l == 0) & (i1 == 0))
					continue; /* Loop/switch isn't completed */
				int j1;
				int k1;
				byte byte2 = gw.lv.resources[j + i1][i + l];
				j1 = byte2 >> 6 & 3;
				k1 = byte2 & 0x3f;
				if (j1 == k && k1 > 0)
					return (j + i1 << 8) + (i + l);
				continue; /* Loop/switch isn't completed */
			}

		}
		return 0;
	}

	public int findResource(int i, int j, int k) {
		for (int i1 = -3; i1 <= 3; i1++) {
			int l;
			byte byte1;

⌨️ 快捷键说明

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