using System; using System.Collections; using System.Collections.Generic; using TMPro; using UnityEngine; using UnityEngine.UI; public class WoodSculpture_Buildings : Buildings { [Header("特有内容")] public int Craftsman_Num; //public List TuanZi_Craftsman_Point = new List(); public Transform AppearPoint; public int Current_WoodSculpture; public int Max_WoodSculpture; public int CurrentSculptureValue = 100; public int CurrentSculptureCost { get { return currentScCost; } set { currentScCost = value; Max_Progress = currentScCost / 10; } } private int currentScCost = 100; public int Max_Progress = 100; public List WoodSculpture_List = new List(); public int progress; public bool isProducing = true; [Header("木像及其摆放位置")] public GameObject WoodSculpture_Prefab_Simple; public GameObject WoodSculpture_Prefab_Super; public GameObject WoodSculpture_Prefab_Special; public List WoodSculpture_Point; public List AvailableScuplturePoints = new List(); public Transform Special_WoodSculpture_Point; public WoodElasticHit weh; public GameObject wehObject; [Header("Buff专用")] public bool is_Buff3_Active = false; public int WoodSculpture_to_FaithBuff = 1; //public GameObject WoodSculpture_Forever; public override void AddFunctionToTreeController() { Action Action1 = BuildingsActive; TreeControl.Instance.AddEvent("木像台", Action1); Action Action2 = () => { AddCeremony("春之初级仪式", 2); BuildingUpgrade(); }; TreeControl.Instance.AddEvent("春之初级仪式", Action2); Action Action3 = () => { AddCeremony("春之中级仪式", 5); //BuildingUpgrade(); }; TreeControl.Instance.AddEvent("春之中级仪式", Action3); Action Action4 = () => AddCeremony("春之高级仪式", 8); TreeControl.Instance.AddEvent("春之高级仪式", Action4); } public override void Start() { base.Start(); SpecailBuff_Buildings.BuildingTechItem BlobBTI = new SpecailBuff_Buildings.BuildingTechItem( null,AddTuanZi_Craftsman, "工匠团子", 0, 0, 1, true,0 ); BlobBTI.SetEndless(); InformationPanel.AddTechItem(BlobBTI); for (int i = 0; i < WoodSculpture_Point.Count; i++) { AvailableScuplturePoints.Add(true); } } public override void AddResources_Auto() { /*if (GameProcedureManager.Instance.WoodCount>=5 && Current_WoodSculpture < Max_WoodSculpture && isProducing) { int addNum = (int)(GlobalBuffSystem.Instance.GlobalMultiplier * LocalBuff_Auto * TuanZi_efficiency * TuanZi_Num * (efficiency_Level_Auto[1] * SpecalBuffMuti_efficiency_Auto + SpecalBuffAdd_efficiency_Auto)); progress += addNum; if (addNum>0) { GameProcedureManager.Instance.WoodCount -= 5; } }*/ } public override void SpecalUpdate() { if (progress >= Max_Progress && Current_WoodSculpture().avaIndex = avaint; } else { float x = 0 + 0.1f * Craftsman_Num; float r = UnityEngine.Random.Range(0f, 1f); if (r <= x) { int avaint = GetAvailablePosi(); Transform avaPosi = WoodSculpture_Point[avaint]; new_WoodSculpture = Instantiate(WoodSculpture_Prefab_Super, avaPosi); new_WoodSculpture.GetComponent().avaIndex = avaint; } else { int avaint = GetAvailablePosi(); Transform avaPosi = WoodSculpture_Point[avaint]; new_WoodSculpture = Instantiate(WoodSculpture_Prefab_Simple, avaPosi); new_WoodSculpture.GetComponent().avaIndex = avaint; } } WoodSculpture_List.Add(new_WoodSculpture); new_WoodSculpture.GetComponent().woodSculpture_Buildings = this; new_WoodSculpture.GetComponent().Value = CurrentSculptureValue; ClearSculp(); } } public void ClearSculp() { //weh.TargetGameObject.SetActive(false); isProducing = false; progress = 0; } public void ReStartBuilding() { isProducing = true; weh.ResetBranch(); //weh.TargetGameObject.SetActive(true); progress = 0; //weh.ResetBranch(); while (controllers.Count > 0) { /*if (cc.animator.GetCurrentAnimatorStateInfo(0).IsName("木锤移动")&&!cc.isFalling) { cc.animator.SetTrigger("Landed"); }*/ controllers[0].animator.SetTrigger("Landed"); controllers.RemoveAt(0); } } public void AddSpecialWoodSculpture() { GameObject Special = Instantiate(WoodSculpture_Prefab_Special, Special_WoodSculpture_Point); Special.transform.localPosition = new Vector3(0,0,0); WoodSculpture_List.Add(Special); Special.GetComponent().woodSculpture_Buildings = this; } public void StopandStart() { isProducing = !isProducing; } public bool BuildingSwitch = true; public void BuildingToggle() { BuildingSwitch = !BuildingSwitch; } public void Update() { if (Input.GetKeyDown(KeyCode.Space)) { Debug.Log(progress); progress += 2; weh.OnHit((float)(progress)/Max_Progress); } if (BuildingSwitch && !isProducing && Current_WoodSculpture().Play("木锤移动"); tuanzi.GetComponent().SetTrigger("Landed"); tuanzi.GetComponent().flipX = false; //tuanzi.GetComponent().Play("Kowtow_JiSi 1"); } public void Punch(int num) { if(isProducing) progress += num; weh.OnHit((float)(progress)/Max_Progress); } public int GetAvailablePosi() { //Debug.Log(AvailableScuplturePoints); for (int i = 0; i < AvailableScuplturePoints.Count; i++) { if (AvailableScuplturePoints[i]) { AvailableScuplturePoints[i] = false; return i; } } return -1; } public void RemoveScuplture(WoodSculpture sculpTrans) { AvailableScuplturePoints[sculpTrans.avaIndex] = true; Current_WoodSculpture -= 1; WoodSculpture_List.Remove(gameObject); } public List controllers = new List(); public void AddController(BlobAnimationController controller) { controllers.Add(controller); } public void RemoveController(BlobAnimationController controller) { controllers.Remove(controller); } }