亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? hexm.java

?? 用java開發的一個實施策略游戲源碼 值得學習一下
?? JAVA
字號:
/*
	Netwar
	Copyright (C) 2002  Daniel Grund, Kyle Kakligian, Jason Komutrattananon, & Brian Hibler.

	This file is part of Netwar.

	Netwar is free software; you can redistribute it and/or modify
	it under the terms of the GNU General Public License as published by
	the Free Software Foundation; either version 2 of the License, or
	(at your option) any later version.

	Netwar is distributed in the hope that it will be useful,
	but WITHOUT ANY WARRANTY; without even the implied warranty of
	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
	GNU General Public License for more details.

	You should have received a copy of the GNU General Public License
	along with Netwar; if not, write to the Free Software
	Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

package netwar.mapper;
import netwar.utils.*;
import netwar.utils.vectorgraphics.*;
import java.awt.*;
import netwar.game.GameObject;
import netwar.game.GameViewer;
import java.io.*;

/** This class represents a single hexagon-shaped region of game-space.
 * These regions are used to simplify path-finding algorithms,
 * graphical draw-order, and terrain logic and display.
 * A Hex may contain up to one GameObject at a time.
 * @author Group N2 - Project Netwar
 * @author Daniel Grund, with adjustments by Kyle Kakligian
 */
public class HexM {
	/** The square root of three, which is particularly relavent to hexagon geometry. */ 
	public static final double sqrt3 = Math.sqrt(3);
	private static HexM board[][];
	private static int radius;
	private GameObject occupant;
	private HexTypeM hexType;
	private static HexM baseLocations[] = new HexM[12];
        private boolean passable;
        public static Vector hexTypes = new LVector();
        private static final String IDENT = new String("Map File");
        //public static Vector gameObjectList = new LVector();
        public static Vector unitTypes = new LVector();
        //public static Vector gameObjectLocations = new LVector();

        public void addGameObject(GameObject go, int x, int y) {
            clear();
            go.newGameObjectM(go,x,y,3);
            enter(go);
        }
        /** takes care of removing the contained unit. (if it exists)
         */        
        public void clear() {
            if(occupant != null) {
                occupant.remove();
		occupant.killGraphics();
            }
                        
            occupant = null;
        }
        /** sets the HexType of this Hex
         */        
        public void setType(HexTypeM t) {
            hexType = t;
        }
	/** Initializes the board, which is a static array of Hex objects,
	 * designed to produce a hexagon of hexagons.
	 * Also initializes the HexType objects, and assigns them to the appropriate Hexes.
	 * @param rad The radius of the board in Hexes.
	 */
	public static void makeBoard(int rad) {
                hexTypes.clear();
                //gameObjectList.clear();
                unitTypes.clear();
                //gameObjectLocations.clear();
                ObjectComponent.curr = null;
                TileComponent.curr = null;
                
                if(netwar.Mapper.rightPanel != null)
                    netwar.Mapper.rightPanel.getList().removeAll();
		HexTypeM tile1 = new HexTypeM("tiles/template.gif", Color.orange, true);
		HexTypeM tile2 = new HexTypeM("tiles/template.gif", Color.blue, false);
		hexTypes.append(tile1);
                hexTypes.append(tile2);

		int i, j;
		radius = rad;
		board = new HexM[2 * radius - 1][];
		for(i = 0; i < radius; i++)
		{
			board[i] = new HexM[i + radius];
			for(j = 0; j < i + radius; j++) {
				board[i][j] = new HexM(tile1);
			}
		}
		for(i = radius; i < (2 * radius - 1); i++)
		{
			board[i] = new HexM[2 * radius - 1];
			for(j = i - (radius - 1); j < (2 * radius - 1); j++) {
				board[i][j] = new HexM(tile2);
			}
		}
                System.gc();
	}
        /** Loads a map file.
         */        
        public static void load() {
        }
        /** saves a map file.
         */        
        public static void save() {
            FileOutputStream ostream = null;
            javax.swing.JFileChooser chooser = new javax.swing.JFileChooser();
            int returnVal = chooser.showOpenDialog(netwar.Mapper.theApp);
            if(returnVal == javax.swing.JFileChooser.APPROVE_OPTION) {try {
                ostream = new FileOutputStream(chooser.getSelectedFile().getName());
                ObjectOutputStream p = new ObjectOutputStream(ostream);

                String types[] = new String[hexTypes.getLength()];
                int t = 0;
                for(hexTypes.goFirst(); hexTypes.isInList(); hexTypes.goNext()){
                    HexTypeM ht = (HexTypeM)hexTypes.get();
                    if(ht != null)
                        types[t] = ht.getClass().getName();
                    t++;
                }
                HexTypeStruct units[] = new HexTypeStruct[unitTypes.getLength()];
                t = 0;
                for(unitTypes.goFirst(); unitTypes.isInList(); unitTypes.goNext()){
                    TileComponent tc = (TileComponent)unitTypes.get();
                    if(tc != null)
                        units[t] = new HexTypeStruct(tc.fileName, tc.pass, tc.c);
                    t++;
                }
                GameObjectLocationStruct locs[] = GameObject.getLocationStruct();
                String sgo[] = GameObject.getLocationStructStrings();
                for(t = 0; t< sgo.length; t++) {
                    int i= 0;
                    while(i < units.length && !units[i].filename.equals(sgo[t])) i++;
                    
                    locs[t].unitIndex = i;
                }
                int hexIndexes[][] = new int[2 * radius - 1][];
		for(int i = 0; i < radius; i++) {
                    hexIndexes[i] = new int[i + radius];
                    for(int j = radius + i - 1; j >= 0; j--) {
                        int u = 0;
                        while(u < types.length && !types[u].equals(board[i][j].hexType.getClass().getName())) u++;
                        hexIndexes[i][j] = u;
                    }
		}
		for(int i = radius; i < (2 * radius - 1); i++) {
                    hexIndexes[i] = new int[2 * radius - 1];
                    for(int j = 1 - (radius - 1); j < (2 * radius - 1); j++) {
                        int u = 0;
                        while(u < types.length && !types[u].equals(board[i][j].hexType.getClass().getName())) u++;
                        hexIndexes[i][j] = u;
                    }
		}
                
                p.writeObject(IDENT);       // String
                p.writeInt(radius);         // int
                p.writeObject(types);       // String[]
                p.writeObject(units);       // HexTypeStruct[]
                p.writeObject(locs);        // GameObjectLocationStruct[]
                p.writeObject(hexIndexes);  // int[][]
                
                p.flush();
                ostream.close();
            } catch(Exception e) {
                System.out.println(e.getMessage());
                System.out.println(e);
            }
            }
        }
	/** Retrieves a Hex from the board.
	 * @param x The x part of the Hex coordinate of the desired hex.
	 * @param y The y part of the Hex coordinate of the desired hex.
	 * @return The desired Hex, or null if the coordinates are invalid.
	 */
	public static HexM getHex(int x, int y)
	{
		//Confirm validity
		if(x < 0 || x >= 2 * radius - 1 || y < 0 || y >= 2 * radius - 1 || (x < radius && y >= radius + x))
			return null;
		return board[x][y];
	}
	/** This constructor initializes the Hex according to a HexType's initializing data.
	 * @param h The HexType containing the data for this type of Hex.
	 */
	protected HexM(HexTypeM h) {
		hexType = h;
		passable = h.getPassable();
		occupant = null;
	}
	/** Draws all hexes onto GameViewer v.
	 * @param v A GameViewer seeking to display the entire map (or at least the visible portion).
	 */
	public static void draw(Graphics2D g)
	{
		int i, j;
		Point3D vm = new Point3D();
		for(i = 0; i < radius; i++)
		{
			for(j = radius + i - 1; j >= 0; j--)
			{
				vm = getMapPoint(i,j);
				board[i][j].hexType.draw(g, vm);
			}
		}
		for(i = radius; i < 2 * radius - 1; i++)
		{
			for(j = 2 * (radius - 1); j >= i - (radius - 1); j--)
			{
				vm = getMapPoint(i,j);
				board[i][j].hexType.draw(g, vm);
			}
		}
	}
	/** Draws all the GameObjects in the game onto GameViewer v.
	 * These are drawn in order from south to north to enable the Z-order to
	 * be preserved.
	 * @param v The GameViewer seeking to display all of the GameObjects.
	 */
	public static void drawGameObject(GameViewer v)
	{
		int i, j;
		Point3D vm = new Point3D();
		//if(x is within viewable range) {
		for(j = 2 * (radius - 1); j > radius - 1; j--)
		{
			for(i = j - (radius - 1); i <= 2 * (radius - 1); i++)
			{
				//if(y is within viewable range)
				if(board[i][j].occupant != null)
					board[i][j].occupant.draw(v);
			}
		//}
		}
		//if(x is within viewable range) {
		for(j = radius - 1; j >= 0; j--)
		{
			for(i = 0; i < radius + j; i++)
			{
				//if(y is within viewable range)
				if(board[i][j].occupant != null)
					board[i][j].occupant.draw(v);
			}
		//}
		}
	}
	/** Gets the ground-center of the Hex at hex coordinate (x,y).
	 * @param x The x part of the hex coordinate.
	 * @param y The y part of the hex coordinate.
	 * @return The ground-center of the specified hex.
	 */
	public static Point3D getMapPoint(int x, int y)
	{
		return (new Point3D(10 * sqrt3 * (-radius + x), 10 * (2 * y - radius - x + 1), 0));
	}
	/** Gets the Hex containing a game-space point, and alters the parameter
	 * to contain the hex coordinates, by storing the hex x in vr.x and the
	 * hex y in vr.y
	 * @param vr The game-space point to locate, and the storage space for the x and y.
	 * @return The Hex containing the game-space point.
	 */
	public static HexM getXY(Point3D vr)
	{
		vr.x = Math.round(vr.x/(10 * sqrt3) + radius);
		vr.y = Math.round((vr.y/10 + radius + vr.x - 1)/2);
		return getHex((int)vr.x, (int)vr.y);
	}
	/** Attempts to put the GameObject into this Hex.
	 * @param u The GameObject which is attempting to occupy the Hex.
	 * @return True if the GameObject was put into this Hex.
	 */
	public boolean enter(GameObject u) {
		if(occupant != null)
			return false;
		occupant = u;

		return true;
	}
	/** Removes the GameObject from the Hex, if it is the GameObject which was in the Hex.
	 * @param u The GameObject which is leaving the Hex.
	 */
	public void leave(GameObject u) {
		if(occupant != u)
			return;
		occupant = null;
	}
	/** Checks if the Hex is unoccupied.
	 * @return true if there is no GameObject in the Hex.
	 */
	public boolean isEmpty() {
		return (occupant == null);
	}
	/** Returns the GameObject which is in the Hex.
	 * @return the occupant, or null if the Hex is empty.
	 */
	public GameObject getOccupant() {
		return occupant;
	}
	/** Returns the Color to display on the minimap.
	 * @return A Color for use on the Minimap.
	 */
	public Color getMinimapColor() {
		return hexType.getColor();
	}
	/** Returns the size of a rectangle just big enough to contain one Hex.
	 * This size is stored into a Point2D as x = width, y = height.
	 * @return the Point2D containing the size of the rectangle.
	 */
	public static Point2D getHexDimension() {
		netwar.utils.vectorgraphics.Transform t = netwar.gui.HexViewer.getHexViewer().getTransform();
		return new Point2D(Math.abs(t.getPoint2D(HexTypeM.m_middleLeft).x * 2),
				Math.abs(t.getPoint2D(HexTypeM.m_topLeft).y * 2));
        }
        /** returns the Hex's HexType
         */        
        public HexTypeM getHexType() {
            return this.hexType;
        }
}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
欧美一级免费大片| 亚洲精品五月天| 椎名由奈av一区二区三区| 亚洲一区电影777| 国产精品99久久久久久宅男| 在线观看欧美黄色| 国产欧美一区二区三区在线看蜜臀 | 欧美成人精品3d动漫h| 亚洲女同ⅹxx女同tv| 久久国产尿小便嘘嘘| 91黄视频在线观看| 国产精品无遮挡| 精品一区二区av| 欧美日韩一区二区三区不卡 | 在线电影国产精品| 中文字幕一区二区在线观看| 国产一区美女在线| 91精品国产免费| 婷婷开心激情综合| 色狠狠色噜噜噜综合网| 国产精品国产三级国产专播品爱网 | 国产伦精品一区二区三区免费迷 | 午夜亚洲国产au精品一区二区| 国产91综合网| 久久久久亚洲蜜桃| 激情综合亚洲精品| 制服丝袜av成人在线看| 亚洲国产aⅴ成人精品无吗| 91丨porny丨国产入口| 中文字幕不卡在线| 国产成人免费xxxxxxxx| 久久伊人中文字幕| 国产在线麻豆精品观看| 精品日韩一区二区三区| 美女精品自拍一二三四| 日韩一区二区三区精品视频 | 精久久久久久久久久久| 日韩一区二区三区在线视频| 日韩av成人高清| 日韩一区二区三区视频| 另类小说色综合网站| 日韩午夜激情视频| 久久精品国产秦先生| 日韩一区二区精品在线观看| 成人在线综合网站| 精品理论电影在线观看| 国产真实乱对白精彩久久| 欧美精品一区二区三区很污很色的 | 椎名由奈av一区二区三区| 99vv1com这只有精品| 亚洲欧美日韩国产一区二区三区 | 欧美精品久久天天躁| 日韩电影在线一区| 精品福利二区三区| 国产大陆a不卡| 亚洲婷婷综合久久一本伊一区| 91麻豆国产精品久久| 亚洲aⅴ怡春院| 欧美一区午夜精品| 国模大尺度一区二区三区| 久久亚洲精华国产精华液 | 美女视频黄频大全不卡视频在线播放| 日韩精品资源二区在线| 国产91精品精华液一区二区三区 | 精品国产一区二区三区久久久蜜月 | 在线免费不卡电影| 免费成人在线网站| 中文字幕在线播放不卡一区| 欧美日韩中文一区| 国产乱人伦精品一区二区在线观看| 欧美国产成人精品| 欧美久久一二三四区| 国产剧情一区二区三区| 亚洲综合小说图片| 久久亚洲精品国产精品紫薇| 在线影院国内精品| 国产成人亚洲精品青草天美| 亚洲午夜激情网站| 亚洲国产精品ⅴa在线观看| 欧美人妇做爰xxxⅹ性高电影| 国产麻豆精品视频| 午夜a成v人精品| 中文字幕中文字幕在线一区 | 国产三级一区二区| 欧美日韩一级二级三级| 一区二区免费视频| 欧美一级在线免费| 成人中文字幕在线| 一区在线中文字幕| 久久你懂得1024| 在线看国产一区| 国产在线一区二区综合免费视频| 亚洲免费观看高清完整版在线观看 | 91黄色激情网站| 韩国精品免费视频| 一区二区三区四区在线免费观看| 欧美大胆人体bbbb| 色一情一乱一乱一91av| 久久se精品一区二区| 亚洲男人的天堂在线观看| 精品欧美乱码久久久久久 | 国产欧美日产一区| 欧美情侣在线播放| 99久免费精品视频在线观看| 蜜桃视频一区二区三区| 亚洲美女一区二区三区| 精品粉嫩超白一线天av| 欧美老女人第四色| 91小视频在线| 国产精品一区二区无线| 三级久久三级久久久| 国产精品美女视频| 日韩视频123| 欧洲精品视频在线观看| 成人av高清在线| 国产精品一级二级三级| 亚洲午夜精品一区二区三区他趣| 亚洲美女免费在线| 国产精品国产三级国产三级人妇 | 国产69精品久久99不卡| 久久成人麻豆午夜电影| 日韩专区中文字幕一区二区| 亚洲老妇xxxxxx| 亚洲欧洲无码一区二区三区| 久久嫩草精品久久久精品一| 欧美一区二区三区免费在线看| 欧美曰成人黄网| 色欧美片视频在线观看在线视频| www.激情成人| 粉嫩绯色av一区二区在线观看| 国产在线播放一区三区四| 日韩电影免费在线看| 久久99久久精品| 午夜精品成人在线视频| 亚洲一二三四在线观看| 亚洲一区免费观看| 亚洲黄色片在线观看| 一区二区三区四区中文字幕| 亚洲精品乱码久久久久久久久| 亚洲人成网站在线| 亚洲免费av高清| 国产日韩亚洲欧美综合| 亚洲久草在线视频| 亚洲精品免费在线| 亚洲二区视频在线| 三级影片在线观看欧美日韩一区二区| 午夜电影一区二区| 性做久久久久久| 精品系列免费在线观看| 国产成人aaa| aa级大片欧美| 欧美亚洲自拍偷拍| 日韩精品专区在线影院观看| 日韩精品一区二区在线观看| 26uuu国产在线精品一区二区| 久久精品夜色噜噜亚洲aⅴ| 欧美极品少妇xxxxⅹ高跟鞋| 成人免费小视频| 天天做天天摸天天爽国产一区| 亚洲国产成人av好男人在线观看| 国产专区综合网| av资源网一区| 777a∨成人精品桃花网| 久久久久久久久99精品| 亚洲日本在线视频观看| 久久99热99| 91在线精品秘密一区二区| 91成人国产精品| 欧美精品一区二区三区高清aⅴ | 久久精品国产一区二区三区免费看| 国产激情一区二区三区桃花岛亚洲| 春色校园综合激情亚洲| 99久久久精品免费观看国产蜜| 欧美日韩电影在线| 国产亚洲欧美一区在线观看| 亚洲午夜羞羞片| 国产精品99久久久久久似苏梦涵 | 黄一区二区三区| 91福利视频网站| 精品国产青草久久久久福利| 亚洲美女精品一区| 国产成人av一区二区| 56国语精品自产拍在线观看| 欧美激情艳妇裸体舞| 男女男精品视频网| 成人美女视频在线观看| 久久久激情视频| 午夜电影网一区| 99国产精品久久久| 欧美精品一区二区三区久久久| 亚洲男女一区二区三区| bt欧美亚洲午夜电影天堂| 欧美成人精品1314www| 亚洲一卡二卡三卡四卡无卡久久| 国产成人免费9x9x人网站视频| 欧美一区二区福利视频| 中文字幕视频一区| 成人av资源在线| 久久久久久久久久美女| 日本v片在线高清不卡在线观看|