/**
* Created by xingxiaoyu on 16/6/2.
*/
import java.awt.BorderLayout;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.BufferedWriter;
import java.io.DataOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.FileWriter;
import java.io.Serializable;
import java.net.URL;
import java.util.ArrayList;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JFileChooser;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JRadioButton;
import javax.swing.Timer;
public class Player implements CanBeFined {
static Player player1 = new Player(50000, 20000, 0, 0, 0, "顺时针");
static Player player2 = new Player(50000, 20000, 0, 0, 0, "顺时针");
public static int number = 0;// 玩家创建的次序
public static int round = 1;// 奇数局为A,偶数局为B
private String name;// 姓名
private ImageIcon photo1;// 头像
private ImageIcon photo2;// 地图上显示的头像
private ImageIcon photo3;// 罚款时显示的图标头像
private int cash;// 现金
private int deposit;// 存款
private int stock;// 股票
private int ticket;// 点券
private int houseNum;// 房屋数量
private int property;// 总资产
private int houseValue;// 房屋资产
private Card[] cards = new Card[4];
private ArrayList<Card> cardList = new ArrayList<Card>();// 刚开始拥有的卡片
private ArrayList<House> houseList = new ArrayList<House>();
private String direction;// 前进方向
private int location;// 玩家的位置
private int step;// 玩家前进的步数
private int count;// 控制一步步前进,直到与step相同
private Timer timer = new Timer(300, new TimeListener());
private Mortgage mortgage;
private boolean nishizhen;
private boolean bankHere;
private boolean useDiceCard;
private int turn = 1;
private Player(int cash, int deposit, int ticket, int stock, int houseNum,
String direction) {// 不允许在外部创建
number++;
cards[0] = new TurnCard(1, "转向卡", 5, false);
cards[1] = new ControlDice(2, "遥控骰子", 5, false);
cards[2] = new TaxCard(3, "查税卡", 5, false);
cards[3] = new BuyLandCard(4, "购地卡", 5, false);
for (int i = 0; i < cards.length; i++) {
cardList.add(cards[i]);
}
if (number == 1) {
this.name = "丸子";
URL url1 = this.getClass().getResource("image/photo10.png");
this.photo1 = new ImageIcon(url1);
URL url2 = this.getClass().getResource("image/photo11.png");
this.photo2 = new ImageIcon(url2);
URL url3 = this.getClass().getResource("image/photo12.png");
this.photo3 = new ImageIcon(url3);
this.location = 0;
} else if (number == 2) {
this.name = "花轮";
URL url1 = this.getClass().getResource("image/photo20.png");
this.photo1 = new ImageIcon(url1);
URL url2 = this.getClass().getResource("image/photo21.png");
this.photo2 = new ImageIcon(url2);
URL url3 = this.getClass().getResource("image/photo22.png");
this.photo3 = new ImageIcon(url3);
this.location = 12;
}
this.direction = direction;
this.cash = cash;
this.deposit = deposit;
this.ticket = ticket;
this.stock = stock;
this.houseNum = houseNum;
}
public Player() {
}
public void setCards(Card[] card) {
cards = card;
}
public Card[] getCards() {
return cards;
}
public void setCardList(ArrayList<Card> array) {
cardList = array;
}
// 一轮结束使用完道具后重置道具列表
public void ressetCardList() {
cardList.clear();
for (int i = 0; i < cards.length; i++) {
cards[i].setUsed(false);
if (cards[i].getQuality() > 0) {
cardList.add(cards[i]);
}
}
}
// 重复点击重置道具List
public void ressetCardList2() {
cardList.clear();
for (int i = 0; i < cards.length; i++) {
if (cards[i].getQuality() > 0 && cards[i].getUsed() == false) {
cardList.add(cards[i]);
}
}
}
// 重置房屋列表
public void ressetHouseList() {
player1.houseList.clear();
player2.houseList.clear();
House[] houses = Main.frame.getMapPanel().getHouses();
for (int i = 0; i < houses.length; i++) {
if (houses[i].getOwner() == player1) {
player1.houseList.add(houses[i]);
} else if (houses[i].getOwner() == player2) {
player2.houseList.add(houses[i]);
}
}
}
public void setName(String name) {
this.name = name;
}
public ArrayList<House> getHouseList() {
return houseList;
}
public String getName() {
return name;
}
public ImageIcon getPhoto() {
return photo1;
}
public ImageIcon getIcon() {
return photo2;
}
public int getCash() {
return cash;
}
public void addCash(int cash) {
this.cash = this.cash + cash;
}
public int getDeposit() {
return deposit;
}
public int getHouseNum() {
return houseNum;
}
public Mortgage getMortgage() {
return mortgage;
}
public void addDeposit(int deposit) {
this.deposit = this.deposit + deposit;
}
public int getStock() {
return stock;
}
public int getTicket() {
return ticket;
}
public void addTicket(int ticket) {
if (ticket >= 0) {
this.ticket = this.ticket + ticket;
} else {
this.ticket = this.ticket - ticket;
}
}
public ImageIcon getPhoto3() {
return photo3;
}
public void addHouse() {
this.houseNum++;
}
public void minusHouse() {
this.houseNum--;
}
public int getProperty() {
property = cash + deposit + getHouseValue();// 现金+存款+房屋价值
return property;
}
public String getDirection() {
return direction;
}
public int getStep() {
return step;
}
public int getLocation() {
return location;
}
public void changeDirection(String direction) {
this.direction = direction;
}
public Timer getTimer() {
return timer;
}
public int getCount() {
return count;
}
public void setCount(int x) {
count = x;
}
public void goForward() {
step = Main.frame.getMapPanel().getDice().getCurrentImage() + 1;
timer.start();
}
public void changeB() {
nishizhen = true;
}
public void changeF() {
nishizhen = false;
}
public void setCash(int cash) {
this.cash = cash;
}
public void setDeposit(int deposit) {
this.deposit = deposit;
}
public void setTicket(int ticket) {
this.ticket = ticket;
}
public void setStock(int stock) {
this.stock = stock;
}
public ArrayList<Card> getCardList() {
return cardList;
}
public void setLocation(int x) {
this.location = x;
}
public boolean getUseDiceCard() {
return useDiceCard;
}
public void setUseDiceCard(boolean useDiceCard) {
this.useDiceCard = useDiceCard;
}
public ControlDice getControlDice() {
return (ControlDice) cards[1];
}
public void turning(Player player) {
if (player.turn == 1) {
player.changeDirection("逆时针");
player.nishizhen = true;
辣椒种子
- 粉丝: 4257
- 资源: 5837
最新资源
- 【无人机】四旋翼飞行器目标分配、全局路径规划和局部路径规划附Matlab代码.rar
- 【无人机三维路径规划】基于PSO无人机路径规划3D城市附Matlab代码.rar
- 【无人机路径规划】粒子群优化和遗传算法实现有效的水陆两栖无人机任务规划和执行Matlab实现.rar
- 基于mediapipe和KNN分类算法的健身计数器引体向上-深蹲-俯卧撑计数器源码+项目文档说明.zip
- 【无人机路径规划】用于无人机路径规划的多目标 PSO实现Matlab代码.rar
- 【无线传感器】基于 Mamdani 模糊推理系统改进无线传感器网络路由和数据包传递附Matlab代码.rar
- 【物理应用】基于Matlab计算并绘制一维量子和经典谐振子的波函数和概率分布.rar
- 【物理应用】使用提升算子计算量子谐振子的激发态研究附Matlab代码.rar
- 【物理】弹簧-质量-阻尼器系统行为分析附Matlab代码.rar
- 【物理应用】基于Zernike 多项式在圆形、六边形、椭圆形、矩形或环形瞳孔上应用Matlab代码实现.rar
- 【物理应用】基于物理场的动态模式分解(piDMD)研究附Matlab代码.rar
- 【信号处理】天线分集与空时编码技术——空时格码matlab代码.rar
- 【信道估计】基于鲸鱼优化算法的5G信道估计Matlab代码.rar
- 【物流选址】基于免疫优化算法的物流配送中心选址规划研究Matlab实现.rar
- proteus图,重庆邮电大学,单片机实验
- 【信号去噪】基于马氏距离和EDF统计IEE-TSP小波的多元信号去噪方法研究附Matlab代码.rar
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈