244 lines
6.8 KiB
C#
244 lines
6.8 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
using TMPro;
|
|
using System;
|
|
|
|
public class Buildings : MonoBehaviour
|
|
{
|
|
[Header("基础信息")]
|
|
public int Level;
|
|
public int MaxLevel;
|
|
public List<BlobController> TuanZiList = new List<BlobController>();
|
|
|
|
[Header("升级所需物资")]
|
|
public List<int> upgradeNeeds_Wood;
|
|
public List<int> upgradeNeeds_Faith;
|
|
|
|
[Header("自动产能相关参数")]
|
|
//public float GlobalBuff_Auto;//全局倍率
|
|
public float LocalBuff_Auto;//建筑倍率
|
|
public float Jisi_Add_Auto;//祭司加的倍率
|
|
public float ReserveBuff_Auto;//预留倍率
|
|
public int TuanZi_Num;//团子数
|
|
public float TuanZi_efficiency;//团子效率
|
|
public List<int> efficiency_Level_Auto;//基础产能
|
|
public float SpecalBuffMuti_efficiency_Auto;//内部倍率
|
|
private float specalBuffAdd_efficiency_Auto;//加法区
|
|
|
|
public float SpecalBuffAdd_efficiency_Auto
|
|
{
|
|
get => specalBuffAdd_efficiency_Auto;
|
|
set
|
|
{
|
|
specalBuffAdd_efficiency_Auto = value;
|
|
}
|
|
}//加法区
|
|
|
|
[Header("点击产能相关参数")]
|
|
//public float GlobalBuff_Click;
|
|
public float ClickBuff;//对应类型点击倍率
|
|
public float OutputBuff;//对应类型产出倍率
|
|
|
|
[Header("功能的激活")]
|
|
public bool isActive = false;
|
|
public List<GameObject> activeOBJ = new List<GameObject>();
|
|
|
|
|
|
[Header("预制体")]
|
|
public GameObject ceremonyButton_Prefab;
|
|
|
|
[Header("UI面板")]
|
|
public Canvas information_Panel;
|
|
public UI_InformationPanel InformationPanel;
|
|
|
|
[Header("团子停留位置")]
|
|
public List<Transform> TuanZiPoint = new List<Transform>();
|
|
|
|
|
|
public virtual void Start()
|
|
{
|
|
Level = 1;
|
|
if (!isActive)
|
|
{
|
|
foreach (GameObject item in activeOBJ)
|
|
{
|
|
item.SetActive(false);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
InvokeRepeating("AddResources_Auto", 1, 1);
|
|
}
|
|
|
|
//临时,为团子和建筑升级手动添加【建筑科技项】中的资源消耗
|
|
//修改,取消建筑等级,团子数量分布改在各建筑物中
|
|
//InformationPanel.GenerateResourceNeed(upgradeNeeds_Faith[Level], 0, upgradeNeeds_Wood[Level], InformationPanel.UpdateBuilding.GetChild(5));
|
|
//InformationPanel.GenerateResourceNeed(0,1,0, InformationPanel.SetBlob.GetChild(5));
|
|
|
|
|
|
AddFunctionToTreeController();
|
|
}
|
|
public virtual void BuildingsActive()//激活建筑
|
|
{
|
|
isActive = true;
|
|
foreach (GameObject item in activeOBJ)
|
|
{
|
|
item.SetActive(true);
|
|
}
|
|
}
|
|
|
|
void FixedUpdate()
|
|
{
|
|
//UI功能实时 - 建筑(应该要改,每帧判断当前建筑升级所需资源 —— 应调整为,更新时获取)
|
|
/*if (Level < MaxLevel)
|
|
{
|
|
InformationPanel.SetBuildingUpgradeStatus(
|
|
efficiency_Level_Auto[Level],
|
|
upgradeNeeds_Faith[Level], 0, upgradeNeeds_Wood[Level]);
|
|
}*/
|
|
|
|
//UI功能实时 - 团子
|
|
//InformationPanel.SetBlobUpgradeStatus(TuanZi_Num);
|
|
|
|
SpecalUpdate();
|
|
}
|
|
|
|
|
|
|
|
//对应资源是否满足
|
|
|
|
|
|
#region 按钮唤醒方法
|
|
public void BuildingUpgrade()
|
|
{
|
|
//播放升级动画
|
|
string Animation_Name = "Upgrade_" + Level;
|
|
GetComponent<Animator>().Play(Animation_Name);
|
|
Level += 1;
|
|
//更新建筑升级项
|
|
//InformationPanel.GenerateResourceNeed(upgradeNeeds_Faith[Level+1], 0, upgradeNeeds_Wood[Level+1], InformationPanel.UpdateBuilding.GetChild(5));
|
|
//更新数值
|
|
//GameProcedureManager.Instance.WoodCount -= upgradeNeeds_Wood[Level];
|
|
//GameProcedureManager.Instance.FaithCount -= upgradeNeeds_Faith[Level];
|
|
|
|
}
|
|
public void BuildingUpgrade(int Level)
|
|
{
|
|
//播放升级动画
|
|
string Animation_Name = "Upgrade_" + Level;
|
|
GetComponent<Animator>().Play(Animation_Name);
|
|
//更新建筑升级项
|
|
//InformationPanel.GenerateResourceNeed(upgradeNeeds_Faith[Level+1], 0, upgradeNeeds_Wood[Level+1], InformationPanel.UpdateBuilding.GetChild(5));
|
|
//更新数值
|
|
//GameProcedureManager.Instance.WoodCount -= upgradeNeeds_Wood[Level];
|
|
//GameProcedureManager.Instance.FaithCount -= upgradeNeeds_Faith[Level];
|
|
|
|
}
|
|
|
|
public virtual void AddTuanZi()
|
|
{
|
|
BlobController tuanzi = BlobManager.Instance.AvailableBlobs[0];
|
|
tuanzi.gameObject.GetComponent<SpriteRenderer>().sortingLayerID = 16;
|
|
//设置团子位置
|
|
if (TuanZiPoint.Count==0)
|
|
{
|
|
tuanzi.transform.position = transform.position;
|
|
}
|
|
else
|
|
{
|
|
Vector3 point = TuanZiPoint[TuanZi_Num % TuanZiPoint.Count].position;
|
|
tuanzi.transform.position = new Vector3(point.x,point.y,point.z);
|
|
}
|
|
//设置团子脚本
|
|
TuanZiList.Add(BlobManager.Instance.AvailableBlobs[0]);
|
|
tuanzi.BelongingBuilding = this;
|
|
|
|
TuanZi_Num++;
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
public virtual void AddCeremony(string CeremonyName,int index)
|
|
{
|
|
InformationPanel.InstantiateCeremony(CeremonyName, index);
|
|
}
|
|
|
|
private void OnMouseDrag()
|
|
{
|
|
|
|
}
|
|
|
|
|
|
#region Virtual functions
|
|
public virtual void SpecalUpdate()
|
|
{
|
|
|
|
}
|
|
public virtual void AddFunctionToTreeController()
|
|
{
|
|
|
|
}
|
|
public virtual void AddResources_Click()
|
|
{
|
|
|
|
}
|
|
public virtual void AddResources_Auto()
|
|
{
|
|
|
|
}
|
|
public virtual void AddSpecialBuff(string BuffName)
|
|
{
|
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
#region 鼠标UI唤醒
|
|
private Coroutine AppearCoroutine;
|
|
public void ContactBuildingsArea()//鼠标离开建筑群
|
|
{
|
|
information_Panel.transform.gameObject.SetActive(true);
|
|
//AppearCoroutine = StartCoroutine(InformationPanelAction(true));
|
|
}
|
|
public void ExitBuildingsArea()//鼠标进入建筑区
|
|
{
|
|
information_Panel.transform.gameObject.SetActive(false);
|
|
/*if (AppearCoroutine != null)
|
|
{
|
|
StopCoroutine(AppearCoroutine);
|
|
AppearCoroutine = null;
|
|
}
|
|
StartCoroutine(InformationPanelAction(false));*/
|
|
}
|
|
|
|
private IEnumerator InformationPanelAction(bool isUp)
|
|
{
|
|
if (isUp)
|
|
{
|
|
while (information_Panel.GetComponent<CanvasGroup>().alpha<1)
|
|
{
|
|
information_Panel.GetComponent<CanvasGroup>().alpha += 0.1f;
|
|
yield return null;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
while (information_Panel.GetComponent<CanvasGroup>().alpha > 0)
|
|
{
|
|
information_Panel.GetComponent<CanvasGroup>().alpha -= 0.1f;
|
|
yield return null;
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
}
|