package general;
import enums.ScreenType;
import gameobjects.Ammo;
import gameobjects.Background;
import gameobjects.Effect;
import gameobjects.Enemy;
import gameobjects.GameObject;
import gameobjects.Hero;
import gameobjects.InjureDisplay;
import gameobjects.MessageDialog;
import gameobjects.Skill;
import gameobjects.Tile;
import java.awt.Cursor;
import java.awt.Image;
import java.awt.Point;
import java.awt.geom.Rectangle2D;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Vector;
import levels.Level;
import movement.MoveInRoad;
import atk.AtkNormal0;
import atk.AtkNormal1;
import atk.AtkNormal2;
@SuppressWarnings("unchecked")
public class Model {
public static final int GAME_WINDOW_WIDTH = 1024;
public static final int GAME_WINDOW_HEIGHT = 680;
public static final int GAME_OPERATORPANEL_Y = 550;
public static final int GAME_OPERATORPANEL_HEIGHT = 130;
/**
* 全部图片
*/
private HashMap<String, Image> images;
/**
* 全部图片路径
*/
private Vector<String> allImages;
/**
* 背景对象集合
*/
private Vector<Background> background;
/**
* 效果对象集合
*/
private Vector<Effect> effects;
/**
* 技能对象集合
*/
private Vector<Skill> skills;
/**
* 敌人对象集合
*/
private Vector<Enemy> enemies;
/**
* 地图瓦片对象集合
*/
private Vector<Tile> tiles;
/**
* 英雄对象集合
*/
private Vector<Hero> heros;
/**
* 伤害显示对象集合
*/
private Vector<InjureDisplay> injureDisplays;
/**
* 可选择出场英雄集合
*/
private Vector<Hero> selectAbleHeros;
/**
* 已选择出场英雄集合
*/
private Vector<Hero> selectedHeros;
/**
* 选中的英雄可释放技能
*/
private Vector<Skill> selectHeroSkills;
/**
* 选中的英雄
*/
private Hero selectHero;
/**
* 准备放置英雄的位置
*/
private Point preparePutPoint;
/**
* 是否准备放英雄
*/
private boolean isPreparePutHero;
/**
* 选中的技能
*/
private Skill selectSkill;
/**
* 是否准备放技能
*/
private boolean isPreparePutSkill;
/**
* 子弹对象集合
*/
private Vector<Ammo> ammos;
/**
* 当前最后一个出场的敌人
*/
private static Enemy lastStageEmeny;
/**
* 可走区域
*/
private List<Rectangle2D> walkAbleArea;
/**
* 鼠标样式
*/
private Cursor curCursorType;
/**
* 当前等级
*/
private int level;
/**
* 当前等级对象
*/
private Level curLevel;
/**
* 游戏宽度
*/
public static int gameWidth;
/**
* 游戏高度
*/
public static int gameHeight;
/**
* 已流逝的时间
*/
public static double elapsedTime;
/**
* 总时间
*/
public static double totalTime = 0.0D;
/**
* 游戏界面类型
*/
public static HashMap<ScreenType, Boolean> screens;
/**
* 游戏控制类
*/
private GameControl gameControl;
/**
* 图片资源加载类
*/
private ImageLoader imageLoader;
/**
* 声音资源加载类
*/
private SoundLoader soundLoader;
/**
* 是否开启声音
*/
public static boolean isMute = false;
/**
* 是否停止全部声音
*/
public static boolean stopAllSounds = false;
/**
* 要播放的声音集合
*/
private static List<String> soundList = Collections.synchronizedList(new ArrayList());
/**
* 声音对象集合
*/
private ArrayList<Sound> allSounds;
/**
* 开始游戏按钮所在位置
*/
private static Rectangle2D startGameBtn;
/**
* 结束游戏按钮所在位置
*/
private static Rectangle2D exitGameBtn;
/**
* 操作区域
*/
private static Rectangle2D operatorArea;
/**
* 开始防守本波按钮位置
*/
private static Rectangle2D startDefendCurWaveArea;
/**
* 下一关操作按钮位置
*/
private static Rectangle2D nextLevelArea;
/**
* 开始攻击入口
*/
private static Rectangle2D startAtkEntrance;
/**
* 终点关卡建筑
*/
private static Rectangle2D defendBuilding;
/**
* 当前积分
*/
private static int totalScore;
/**
* 当前军费
*/
private static int totalMomey;
/**
* 终点关卡建筑血量
*/
private static int totalLife;
/**
* 当前波数
*/
private static int curWave;
/**
* 当前波数敌军次序
*/
private static int curWaveOrder;
/**
* 总波数
*/
private static int totalWave;
/**
* 是否初始化
*/
private boolean init = false;
private boolean initRestart = false;
private static Model instance = new Model();
public static Model getInstance() {
return instance;
}
private Model() {
this.background = new Vector<Background>();
this.effects = new Vector<Effect>();
this.skills = new Vector<Skill>();
this.enemies = new Vector<Enemy>();
this.tiles = new Vector<Tile>();
this.heros = new Vector<Hero>();
this.injureDisplays = new Vector<InjureDisplay>();
this.selectAbleHeros = new Vector<Hero>();
this.selectedHeros = new Vector<Hero>();
this.selectHeroSkills = new Vector<Skill>();
this.ammos = new Vector<Ammo>();
this.level = 0;
screens = new HashMap();
screens.put(ScreenType.TITLE, true);
screens.put(ScreenType.LOADINGLEVEL, false);
screens.put(ScreenType.NEXTLEVEL, false);
screens.put(ScreenType.GAMEOVER, false);
this.gameControl = new GameControl();
this.imageLoader = new ImageLoader();
this.allImages = new Vector();
this.imageLoader.loadImages(this.allImages);
this.images = new HashMap<String, Image>();
this.soundLoader = new SoundLoader();
this.allSounds = new ArrayList();
this.soundLoader.loadSounds(this.allSounds);
soundList = new ArrayList();
walkAbleArea = new ArrayList<Rectangle2D>();
operatorArea = new Rectangle2D.Double(0, GAME_OPERATORPANEL_Y, GAME_WINDOW_WIDTH, GAME_OPERATORPANEL_HEIGHT);
startDefendCurWaveArea = new Rectangle2D.Double(923, 570, 100, 20);
nextLevelArea = new Rectangle2D.Double(923, 600, 100, 20);
startGameBtn = new Rectangle2D.Double();
exitGameBtn = new Rectangle2D.Double();
}
public void updateGame() {
if (this.init && !Model.screens.get(ScreenType.LOADINGLEVEL).booleanValue()) {
this.level = 1;
this.gameControl.initLevel(level);
this.init = false;
} else if (this.initRestart) {
this.gameControl.initLevel(level);
initRestart = false;
} else if (Model.screens.get(ScreenType.NEXTLEVEL).booleanValue()) {
int level = Model.getInstance().getCurLevel().getLevel();
level = level + 1;
if (level <= this.gameControl.getLevels().getLevelsArray().length) {
this.gameControl.initLevel(level);
}
Model.screens.put(ScreenType.NEXTLEVEL, Boolean.valueOf(false));
}
if (this.gameControl.isLevelRunning()) {
this.gameControl.addWaveEnemies(this.enemies);
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
Swing 曹操传简易塔防 (591个子文件)
Model.java 25KB
Game.java 23KB
Sprite.java 14KB
ControlMouse.java 11KB
ImageUtils.java 9KB
Hero.java 7KB
MoveInRoad.java 7KB
Enemy.java 6KB
Levels.java 6KB
Skill.java 6KB
GameControl.java 5KB
MessageDialog.java 4KB
AlphaColorToTransparent.java 4KB
Level2.java 4KB
Picture.java 3KB
Effect.java 3KB
Level1.java 3KB
AtkNormal1.java 3KB
AtkNormal0.java 3KB
AtkNormal2.java 3KB
Animation.java 3KB
GameObject.java 2KB
Constant.java 2KB
SoundThread.java 2KB
ImageLoader.java 2KB
Level.java 2KB
InjureDisplay.java 1KB
LColor.java 1KB
AmmoFollow.java 1KB
Test.java 1003B
Logger.java 984B
Ammo.java 811B
StringUtils.java 789B
SpriteStates.java 691B
Sound.java 557B
Tile.java 536B
SoundLoader.java 483B
Background.java 411B
DateUtils.java 341B
Atkment.java 223B
MoveDirection.java 196B
AtkDirection.java 193B
Movement.java 132B
ScreenType.java 102B
level1.mid 18KB
level2.mid 3KB
level1.png 1.12MB
level2.png 1015KB
4.png 167KB
0.png 95KB
33.png 15KB
23.png 15KB
24.png 15KB
21.png 14KB
2.png 12KB
3.png 11KB
57.png 11KB
20.png 11KB
19.png 10KB
2.png 10KB
18.png 9KB
28.png 9KB
91.png 9KB
46.png 9KB
92.png 9KB
55.png 9KB
38.png 9KB
90.png 9KB
1.png 8KB
34.png 8KB
37.png 8KB
29.png 8KB
35.png 8KB
94.png 8KB
7.png 8KB
95.png 8KB
8.png 8KB
93.png 8KB
88.png 8KB
30.png 7KB
6.png 7KB
36.png 7KB
17.png 7KB
62.png 7KB
61.png 7KB
54.png 7KB
1.png 7KB
89.png 7KB
104.png 7KB
131.png 7KB
107.png 7KB
60.png 7KB
1.png 7KB
135.png 7KB
91.png 7KB
87.png 7KB
132.png 7KB
92.png 7KB
58.png 7KB
123.png 7KB
共 591 条
- 1
- 2
- 3
- 4
- 5
- 6
逝水
- 粉丝: 5
- 资源: 23
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
- 1
- 2
- 3
- 4
- 5
前往页