160 lines
4.8 KiB
C#
160 lines
4.8 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using TMPro;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
/// <summary>
|
|
/// 顾客脚本组件
|
|
/// </summary>
|
|
public class Customer_Mon : MonoBehaviour
|
|
{
|
|
/// <summary>
|
|
/// 顾客对象
|
|
/// </summary>
|
|
private GameObject CustomerGame;
|
|
/// <summary>
|
|
/// 关门按钮
|
|
/// </summary>
|
|
private GameObject CloseButton;
|
|
/// <summary>
|
|
/// 门框状态不营业
|
|
/// </summary>
|
|
private bool mode=false;
|
|
/// <summary>
|
|
/// 剩余人数
|
|
/// </summary>
|
|
private TextMeshProUGUI SurplusPopulation;
|
|
/// <summary>
|
|
/// 顾客等待时间
|
|
/// </summary>
|
|
private float WaitTime = 30;
|
|
private void LoadGame()
|
|
{
|
|
this.CustomerGame = this.transform.Find("顾客").gameObject;
|
|
this.CloseButton= this.transform.Find("开门营业_闭门谢客").gameObject;
|
|
this.SurplusPopulation=this.transform.Find("剩余人数").GetComponent<TextMeshProUGUI>();
|
|
//暂时不营业
|
|
this.OpenDoorNotBusiness();
|
|
//设置进度条
|
|
this.transform.Find("等待进度").GetComponent<Image>().enabled = false;
|
|
this.transform.Find("等待进度value").GetComponent<Image>().enabled = false;
|
|
}
|
|
/// <summary>
|
|
/// 开门
|
|
/// </summary>
|
|
public void OpendDoor()
|
|
{
|
|
this.transform.Find("bg").GetComponent<Image>().sprite = Resources.Load<Sprite>("image/GUI/顾客背景");
|
|
this.CustomerGame.SetActive(true);
|
|
GameObject.Find("铁匠玩家").GetComponent<BlacksmithPlayer_Mon>().Customer();
|
|
//进度显示
|
|
this.transform.Find("等待进度").GetComponent<Image>().enabled = true;
|
|
this.transform.Find("等待进度value").GetComponent<Image>().enabled = true;
|
|
//重新加载时间
|
|
this.WaitTime=30;
|
|
|
|
}
|
|
/// <summary>
|
|
/// 关门
|
|
/// </summary>
|
|
public void CloseDoor()
|
|
{
|
|
this.transform.Find("bg").GetComponent<Image>().sprite = Resources.Load<Sprite>("image/GUI/顾客门");
|
|
//隐藏顾客
|
|
this.CustomerGame.SetActive(false);
|
|
//清除图纸
|
|
GameObject.Find("装备合成路径").GetComponent<EquipmentSynthesisPath_Mon>().CloseDrawing();
|
|
//进度隐藏
|
|
this.transform.Find("等待进度").GetComponent<Image>().enabled = false;
|
|
this.transform.Find("等待进度value").GetComponent<Image>().enabled = false;
|
|
GameObject.Find("铁匠玩家").GetComponent<BlacksmithPlayer_Mon>().Rest();
|
|
|
|
}
|
|
/// <summary>
|
|
/// 刷新客人
|
|
/// </summary>
|
|
public void Renovate_Visitor()
|
|
{
|
|
//重新加载时间
|
|
this.WaitTime = 30;
|
|
}
|
|
public void ButtonOn()
|
|
{
|
|
if (this.mode==false)
|
|
{
|
|
this.OpendDoor();
|
|
this.mode = true;
|
|
this.SurplusPopulation.text = "剩余人数:" + GameObject.Find("铁匠玩家").GetComponent<BlacksmithPlayer_Mon>().GetClientsLength();
|
|
|
|
//this.transform.Find("开门营业_闭门谢客").GetChild(0).GetComponent<TextMeshProUGUI>().text = "闭门谢客";
|
|
}
|
|
else
|
|
{
|
|
this.SurplusPopulation.text = "剩余人数:" + GameObject.Find("铁匠玩家").GetComponent<BlacksmithPlayer_Mon>().GetClientsLength();
|
|
//this.CloseDoor();
|
|
//this.mode = false;
|
|
//this.transform.Find("开门营业_闭门谢客").GetChild(0).GetComponent<TextMeshProUGUI>().text = "开门营业";
|
|
|
|
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// 暂时停业
|
|
/// </summary>
|
|
public void ShutDown()
|
|
{
|
|
|
|
}
|
|
/// <summary>
|
|
/// 开门不营业
|
|
/// </summary>
|
|
public void OpenDoorNotBusiness()
|
|
{
|
|
this.transform.Find("bg").GetComponent<Image>().sprite = Resources.Load<Sprite>("image/GUI/顾客门");
|
|
//隐藏顾客
|
|
this.CustomerGame.SetActive(false);
|
|
this.CloseButton.transform.GetChild(0).GetComponent<TextMeshProUGUI>().text = "开门营业";
|
|
|
|
|
|
}
|
|
void Start()
|
|
{
|
|
this.LoadGame();
|
|
}
|
|
|
|
// Update is called once per frame
|
|
void Update()
|
|
{
|
|
this.UpdateTime();
|
|
}
|
|
/// <summary>
|
|
/// 刷新进度条和时间
|
|
/// </summary>
|
|
private void UpdateTime()
|
|
{
|
|
//时间加载
|
|
this.WaitTime -= Time.deltaTime;
|
|
//进度条
|
|
this.transform.Find("等待进度value").GetComponent<Image>().fillAmount = this.WaitTime/30f;
|
|
if (this.mode)
|
|
{
|
|
if (this.WaitTime <= 0)
|
|
{
|
|
//玩家走了关门
|
|
this.CloseDoor();
|
|
this.mode = false;
|
|
GameObject.Find("铁匠玩家").GetComponent<BlacksmithPlayer_Mon>().Remove_Clientfirst();
|
|
this.SurplusPopulation.text="剩余人数:" + GameObject.Find("铁匠玩家").GetComponent<BlacksmithPlayer_Mon>().GetClientsLength();
|
|
//Debug.Log("顾客生气的离开了");
|
|
//GameObject.Find("铁匠玩家").GetComponent<BlacksmithPlayer_Mon>().Customer();
|
|
////删除首位顾客
|
|
|
|
////重新计时
|
|
//this.Renovate_Visitor();
|
|
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|