📄 universe.java
字号:
/*
* Universe.java
*
* Copyright (C) 2000 Jason M. Hanley
* Released under the GNU General Public License (GPL)
* See license.txt for additional information.
*
* Created on July 30, 2000, 9:46 PM
*/
package fate.world;
import java.util.*;
import java.io.*;
/**
* The base storage object of the Fate "World".
*
* @author preylude@s3m.com
* @version 0.1.0
*/
public class Universe extends Object implements Serializable {
/** Map of all galaxies in the Universe */
public MapWorldObject mapGalaxies;
/** Map of all players in the Universe */
public MapWorldObject mapPlayers;
/** Highest numbered id generated */
int lastID;
public Galaxy defaultGalaxy;
public SolarSystem defaultSolarSystem;
public Planetoid defaultPlanetoid;
/** Creates new Universe */
public Universe() {
lastID = 100;
mapGalaxies = new MapWorldObject();
mapPlayers = new MapWorldObject();
}
/* Returns the next available globally unique identifier */
public synchronized int getNextID() {
lastID++;
return lastID;
}
/* Creates the default universe */
public void create() {
defaultGalaxy = new Galaxy();
defaultGalaxy.name = "Milky Way";
defaultGalaxy.distance = 100;
defaultGalaxy.position = 1.7;
mapGalaxies.put( defaultGalaxy );
defaultSolarSystem = new SolarSystem();
defaultSolarSystem.name = "Sol";
defaultSolarSystem.distance = 100;
defaultSolarSystem.position = 1.7;
defaultSolarSystem.parent = defaultGalaxy;
defaultGalaxy.mapSolarSystems.put( defaultSolarSystem );
defaultPlanetoid = new Planetoid();
defaultPlanetoid.name = "Earth";
defaultPlanetoid.distance = 50;
defaultPlanetoid.position = 1.7;
defaultPlanetoid.velocity = 0.05;
defaultPlanetoid.parent = defaultSolarSystem;
defaultSolarSystem.mapPlanetoids.put( defaultPlanetoid );
defaultSolarSystem.mapPlanetoids.put( new Planetoid( "Mercury", 20, 5.2, -0.05 ) );
defaultSolarSystem.mapPlanetoids.put( new Planetoid( "Venus", 35, 2.9, 0.1 ) );
defaultSolarSystem.mapPlanetoids.put( new Planetoid( "Mars", 70, 4.6, 0.05 ) );
defaultSolarSystem.mapPlanetoids.put( new Planetoid( "Jupiter", 100, 0.4, 0.075 ) );
defaultSolarSystem.mapPlanetoids.put( new Planetoid( "Saturn", 120, 2.5, -0.025 ) );
defaultSolarSystem.mapPlanetoids.put( new Planetoid( "Neptune", 140, 1.0, 0.011 ) );
defaultSolarSystem.mapPlanetoids.put( new Planetoid( "Uranus", 160, 3.8, -0.05 ) );
defaultSolarSystem.mapPlanetoids.put( new Planetoid( "Pluto", 180, 2.8, 0.1 ) );
}
/* Puts a new player into the world database */
public int createNewPlayer( int idLogin ) {
Player player = new Player();
player.name = "New Player";
player.idLogin = idLogin;
mapPlayers.put( player );
Ship ship = new Ship();
ship.owner = player;
ship.parent = defaultPlanetoid;
player.mapShips.put( ship );
defaultPlanetoid.mapOrbiting.put( ship );
return player.id;
}
public String toString() {
return "Fate Universe";
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -