241 lines
5.9 KiB
C#
241 lines
5.9 KiB
C#
using System.Collections;
|
||
using System.Collections.Generic;
|
||
using UnityEngine;
|
||
using static UnityEngine.ParticleSystem;
|
||
/// <summary>
|
||
/// 铁匠类
|
||
/// </summary>
|
||
public class Blacksmith
|
||
{
|
||
/// <summary>
|
||
/// 姓名
|
||
/// </summary>
|
||
private string name;
|
||
/// <summary>
|
||
/// 店铺状态
|
||
/// </summary>
|
||
private BlacksmithType blacksmithtype;
|
||
/// <summary>
|
||
/// 铁匠等级
|
||
/// </summary>
|
||
private int grade;
|
||
/// <summary>
|
||
/// 财产
|
||
/// </summary>
|
||
private int money;
|
||
/// <summary>
|
||
/// 声望
|
||
/// </summary>
|
||
private int reputation;
|
||
/// <summary>
|
||
/// 体力
|
||
/// </summary>
|
||
private int strength;
|
||
/// <summary>
|
||
/// 物品栏:储存材料和相关数量
|
||
/// </summary>
|
||
private Dictionary<Article,int>articles;
|
||
/// <summary>
|
||
/// 锻造锤
|
||
/// </summary>
|
||
private HammerBase hammerBase;
|
||
/// <summary>
|
||
/// 锻造台
|
||
/// </summary>
|
||
private ForgingTable forgingTable;
|
||
/// <summary>
|
||
/// 锻造图纸组合
|
||
/// </summary>
|
||
private List<Drawing> drawings;
|
||
/// <summary>
|
||
/// 客户列表
|
||
/// </summary>
|
||
private List<Client> clients;
|
||
/// <summary>
|
||
/// 构造方法
|
||
/// </summary>
|
||
public Blacksmith() {
|
||
this.articles = new Dictionary<Article, int>();
|
||
this.blacksmithtype=BlacksmithType.REST;
|
||
}
|
||
/// <summary>
|
||
/// 返回还有多少客户
|
||
/// </summary>
|
||
/// <returns></returns>
|
||
public int GetClientsLength()
|
||
{
|
||
return this.clients.Count;
|
||
}
|
||
/// <summary>
|
||
/// 物品添加到物品栏
|
||
/// </summary>
|
||
/// <param name="article_"></param>
|
||
/// <param name="mun_"></param>
|
||
public void add_articles(Article article_,int mun_)
|
||
{
|
||
foreach (KeyValuePair<Article, int> entry_ in articles)
|
||
{
|
||
if (entry_.Key.getId() == article_.getId()) {
|
||
this.articles[entry_.Key] += mun_;
|
||
//对象添加成功退出
|
||
return;
|
||
}
|
||
|
||
}
|
||
//为查找到元素则补充新的元素进入背包
|
||
this.articles.Add(article_, mun_);
|
||
}
|
||
/// <summary>
|
||
/// 返回背包材料数据
|
||
/// </summary>
|
||
/// <returns></returns>
|
||
public Dictionary<Article, int> get_articles()
|
||
{
|
||
return this.articles;
|
||
}
|
||
/// <summary>
|
||
/// 删除材料
|
||
/// </summary>
|
||
/// <param name="id_">材料id</param>
|
||
/// <param name="mun_">数量</param>
|
||
/// <returns>是否删除成功</returns>
|
||
public bool del_material(int id_,int mun_)
|
||
{
|
||
foreach (KeyValuePair<Article, int> entry_ in articles)
|
||
{
|
||
if (entry_.Key.getId() == id_)
|
||
{
|
||
this.articles[entry_.Key] -= mun_;
|
||
if (this.articles[entry_.Key] <= 0)
|
||
{
|
||
this.articles.Remove(entry_.Key);
|
||
}
|
||
//对象删除成功退出
|
||
return true;
|
||
}
|
||
|
||
}
|
||
//对象删除失败
|
||
return false;
|
||
}
|
||
/// <summary>
|
||
/// 根据传入的id查找背包里的材料,如果有则返回物品
|
||
/// </summary>
|
||
/// <param name="id_">材料id</param>
|
||
/// <returns>返回材料</returns>
|
||
public Article find_article(int id_)
|
||
{
|
||
foreach (KeyValuePair<Article, int> entry_ in articles)
|
||
{
|
||
if (entry_.Key.getId() == id_)
|
||
{
|
||
//对象删除成功退出
|
||
return entry_.Key;
|
||
}
|
||
|
||
}
|
||
return null;
|
||
}
|
||
/// <summary>
|
||
/// 返回财产
|
||
/// </summary>
|
||
/// <returns>金币数量</returns>
|
||
public int getmoney() {
|
||
return this.money;
|
||
}
|
||
/// <summary>
|
||
/// 增加财产
|
||
/// </summary>
|
||
/// <param name="money_">金币数量</param>
|
||
public void add_money(int money_)
|
||
{
|
||
this.money += money_;
|
||
}
|
||
/// <summary>
|
||
/// 添加客户列表
|
||
/// </summary>
|
||
/// <param name="client_"></param>
|
||
public void add_client(Client client_)
|
||
{
|
||
if (this.clients == null)
|
||
{
|
||
this.clients = new List<Client>();
|
||
}
|
||
this.clients.Add(client_);
|
||
}
|
||
/// <summary>
|
||
/// 删除首位顾客
|
||
/// </summary>
|
||
public void remove_clientfirst() {
|
||
this.clients.RemoveAt(0);
|
||
}
|
||
/// <summary>
|
||
/// 获取首位顾客的信息
|
||
/// </summary>
|
||
/// <returns>首位顾客的信息</returns>
|
||
public Client GetClient()
|
||
{
|
||
return this.clients[0];
|
||
}
|
||
/// <summary>
|
||
/// 获取铁匠铺当前状态
|
||
/// </summary>
|
||
/// <returns></returns>
|
||
public BlacksmithType getBlacksmithType() {
|
||
return this.blacksmithtype;
|
||
}
|
||
|
||
/// <summary>
|
||
/// 开门营业
|
||
/// </summary>
|
||
public void OpenShop()
|
||
{
|
||
this.blacksmithtype=BlacksmithType.WAIT;
|
||
}
|
||
/// <summary>
|
||
/// 锻造中
|
||
/// </summary>
|
||
public void Forging()
|
||
{
|
||
this.blacksmithtype =BlacksmithType.WORK;
|
||
}
|
||
/// <summary>
|
||
/// 不结算,休息一下
|
||
/// </summary>
|
||
public void CloseDoor() {
|
||
this.blacksmithtype=BlacksmithType.CLOSEDOOR;
|
||
}
|
||
/// <summary>
|
||
/// 关门
|
||
/// </summary>
|
||
public void CloseShop()
|
||
{
|
||
this.blacksmithtype = BlacksmithType.REST;
|
||
}
|
||
|
||
/// <summary>
|
||
/// 传入锻造的的武器提交订单
|
||
/// </summary>
|
||
/// <param name="weapons_">提交的武器</param>
|
||
/// <returns>返回的价值</returns>
|
||
public int SubmitOrder(Weapons weapons_)
|
||
{
|
||
this.remove_clientfirst();
|
||
|
||
if (this.GetClient().getweaponid() == weapons_.getId())
|
||
{
|
||
Debug.Log("武器锻造正确,顾客很满意的离开了");
|
||
//this.add_money(weapons_.getweaponsmoney());
|
||
return weapons_.getweaponsmoney();
|
||
|
||
}
|
||
else
|
||
{
|
||
Debug.Log("武器锻造错误,顾客生气的离开了");
|
||
return weapons_.getweaponsmoney()/2;
|
||
|
||
|
||
}
|
||
}
|
||
}
|