📄 level.java
字号:
/*
* JCollapse - Java Collapse Game
* Copyright (C) 2005 Erico Gon鏰lves Rimoli
*
* This program 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.
*
* This program 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 this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package sourceforge.net.projects.jcollapse.game.levels;
import java.awt.Color;
import java.awt.Image;
import java.util.ArrayList;
import java.util.Collections;
import sourceforge.net.projects.jcollapse.engine.block.Block;
public class Level {
private String m_Name;
private String m_Notes;
private Image m_BackgroundImage;
private Color m_BackgroundColor;
private long m_RollInterval;
private int m_Width;
private int m_Height;
private ArrayList<Block> m_Blocks = new ArrayList<Block>();
/**
* Constructor for Level object
*/
public Level() {
}
/**
* Get the Level name
* @return the Level name
*/
public String getName() {
return m_Name;
}
/**
* Set the name for Level
* @param name the Level name
*/
public void setName( String name ) {
m_Name = name;
}
/**
* Get the level notes
* @return the level notes
*/
public String getNotes() {
return m_Notes;
}
/**
* Set the level notes
* @param notes the level notes
*/
public void setNotes( String notes ) {
m_Notes = notes;
}
/**
* Get time to roll Block's
* @return the time to roll Block's
*/
public long getRollInterval() {
return m_RollInterval;
}
/**
* Set interval to roll Block's
* @param timeInterval the interval to roll Block's
*/
public void setRollInterval( long timeInterval ) {
m_RollInterval = timeInterval;
}
/**
* Get the quantity of Block's in horizontal
* @return the quantity of Block's in horizontal
*/
public int getWidth() {
return m_Width;
}
/**
* Set the quantity of Block's in horizontal
* @param width the quantity of Block's in horizontal
*/
public void setWidth( int width ) {
m_Width = width;
}
/**
* Get the quantity of Block's in vertical
* @return the quantity of Block's in vertical
*/
public int getHeight() {
return m_Height;
}
/**
* Set the quantity of Block's in vertical
* @param height the quantity of Block's in vertical
*/
public void setHeight( int height ) {
m_Height = height;
}
/**
* Change the size of level<br>
* Example:<br>
* You can have 10 Block's in horizontal (width) and <br>
* you can have 15 Block's in vertical (height) <br>
* TOTAL: 10x15=150 Block's
* @param width quantity of horizontal Block's
* @param height quantity of vertical Block's
*/
public void setSize( int width, int height ) {
setWidth( width );
setHeight( height );
}
/**
* Add a new block to the current Level
* @param block the Block object
*/
public void addBlock( Block block ) {
m_Blocks.add( block );
}
/**
* Clear all block's in current level
*/
public void clearBlocks() {
m_Blocks.clear();
}
/**
* Get Block in specified index
* @param index the index to get Block
* @return the Block object
*/
public Block getBlock( int index ) {
return m_Blocks.get( index );
}
/**
* Quantity of Blocks in current level
* @return the quantity of Blocks in current level
*/
public int countBlocks() {
return m_Blocks.size();
}
/**
* Get the background image
* @return Image object of background (null for none)
*/
public Image getBackgroundImage() {
return m_BackgroundImage;
}
/**
* Set the background image
* @param image the Image object for background or null if none is set
*/
public void setBackgroundImage( Image image ) {
m_BackgroundImage = image;
}
/**
* Get the background color.
* @return the background color or null if none is set
*/
public Color getBackgroundColor() {
return m_BackgroundColor;
}
/**
* Set the background color. ImageBackground ovewrite this property
* @param color the Color object or null if none is set
*/
public void setBackgroundColor( Color color ) {
m_BackgroundColor = color;
}
/**
* Randomize blocks in this level.
*/
public void randomize() {
Collections.shuffle( m_Blocks );
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -