133 lines
5.2 KiB
C#
133 lines
5.2 KiB
C#
using System;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using DG.Tweening;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
public class Tree_Buildings : Buildings
|
|
{
|
|
[Header("资源动效相关")]
|
|
public Canvas IconCanvas;
|
|
public Image TargetIcon;
|
|
|
|
public WoodElasticHit weh;
|
|
[Header("buff专用")]
|
|
public TreeBud treeBud;
|
|
public bool isBuff_8_Active = false;
|
|
|
|
public override void Start()
|
|
{
|
|
base.Start();
|
|
//初始化基础BuildingTechItem
|
|
SpecailBuff_Buildings.BuildingTechItem BlobBTI = new SpecailBuff_Buildings.BuildingTechItem(
|
|
null, AddTuanZi, "砍树团子", 0, 0, 1, true,0
|
|
);
|
|
BlobBTI.SetEndless();
|
|
InformationPanel.AddTechItem(BlobBTI);
|
|
|
|
IconCanvas ??= GameObject.Find("-------UI区-------/Canvas").GetComponent<Canvas>();
|
|
TargetIcon ??= GameObject.Find("-------UI区-------/Canvas/TopBar/WoodStatus/Image").GetComponent<Image>();
|
|
}
|
|
public override void BuildingsActive()
|
|
{
|
|
base.BuildingsActive();
|
|
GetComponent<Animator>().Play("Upgrade_0");
|
|
}
|
|
public override void AddFunctionToTreeController()
|
|
{
|
|
Action Action1 = BuildingsActive;
|
|
TreeControl.Instance.AddEvent("伐木场", Action1);
|
|
}
|
|
|
|
public void CutTreeGenerate()
|
|
{
|
|
GameProcedureManager.Instance.WoodCount += (int)(
|
|
TuanZi_efficiency *
|
|
(GlobalBuffSystem.Instance.GlobalMultiplier *
|
|
//LocalBuff_Auto *
|
|
ReserveBuff_Auto *
|
|
(efficiency_Level_Auto[1] *
|
|
SpecalBuffMuti_efficiency_Auto
|
|
+ SpecalBuffAdd_efficiency_Auto))
|
|
);
|
|
}
|
|
|
|
private Tween TargetIconTween;
|
|
public override void AddResources_Click()
|
|
{
|
|
AudioManager.Instance.PlayChopWoodSFX();
|
|
var go = GameObjectPool.Instance.Spawn("ResourceIcon");
|
|
|
|
go.transform.SetParent(IconCanvas.transform);
|
|
go.transform.position = Camera.main.WorldToScreenPoint(transform.position);
|
|
|
|
// print($"from {go.transform.position} to {TargetIcon.rectTransform.anchoredPosition}");
|
|
weh.OnHit(0);
|
|
|
|
var tweenSequence = DOTween.Sequence();
|
|
tweenSequence.Append(go.GetComponent<RectTransform>().DOMoveX(TargetIcon.rectTransform.position.x, 0.5f).SetEase(ArrayUtils.UIEasing.RandomPick()));
|
|
tweenSequence.Join(go.GetComponent<RectTransform>().DOMoveY(TargetIcon.rectTransform.position.y, 0.5f).SetEase(ArrayUtils.UIEasing.RandomPick()));
|
|
tweenSequence.OnComplete(() =>
|
|
{
|
|
// print("move complete");
|
|
go.SetActive(false);
|
|
if(TargetIconTween!=null) TargetIconTween.Complete();
|
|
TargetIconTween = TargetIcon.rectTransform.DOPunchScale(Vector3.one, 0.1f);
|
|
if (!isBuff_8_Active)
|
|
{
|
|
GameProcedureManager.Instance.WoodCount += (int)(
|
|
(1 + GlobalBuffSystem.Instance.ClickAdder) * GlobalBuffSystem.Instance.ClickTimeMultiplier * GlobalBuffSystem.Instance.ClickMultiplier * ClickBuff * OutputBuff * GlobalBuffSystem.Instance.GlobalMultiplier
|
|
);
|
|
}
|
|
else
|
|
{
|
|
GameProcedureManager.Instance.WoodCount += (int)(treeBud.WoodProduceBuff*120*
|
|
(1 + GlobalBuffSystem.Instance.ClickAdder) * GlobalBuffSystem.Instance.ClickTimeMultiplier * GlobalBuffSystem.Instance.ClickMultiplier * ClickBuff * OutputBuff * GlobalBuffSystem.Instance.GlobalMultiplier
|
|
);
|
|
}
|
|
});
|
|
}
|
|
public override void AddResources_Auto()
|
|
{
|
|
GameProcedureManager.Instance.WoodCount += (int)(
|
|
(TuanZi_efficiency * TuanZi_Num) *
|
|
(GlobalBuffSystem.Instance.GlobalMultiplier * LocalBuff_Auto * ReserveBuff_Auto * (efficiency_Level_Auto[1] * SpecalBuffMuti_efficiency_Auto + SpecalBuffAdd_efficiency_Auto))
|
|
);
|
|
}
|
|
|
|
|
|
public void RemoveAllTuanzi()
|
|
{
|
|
foreach (BlobController tuanzi in TuanZiList)
|
|
{
|
|
tuanzi.BelongingBuilding = null;
|
|
tuanzi.GetComponent<Animator>().Play("BlobWalk");
|
|
}
|
|
TuanZiList.Clear();
|
|
TuanZi_Num=0;
|
|
}
|
|
|
|
public override void AddTuanZi()
|
|
{
|
|
BlobController tuanzi = BlobManager.Instance.AvailableBlobs[0];
|
|
Debug.Log("AddTuanZi "+tuanzi.gameObject.GetComponent<SpriteRenderer>().sortingLayerName);
|
|
tuanzi.gameObject.GetComponent<SpriteRenderer>().sortingLayerName = "家园团子";
|
|
Debug.Log("AddTuanZi "+tuanzi.gameObject.GetComponent<SpriteRenderer>().sortingLayerName);
|
|
//设置团子位置
|
|
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+ (TuanZi_Num / TuanZiPoint.Count) * 0.33f, point.y, point.z);
|
|
}
|
|
TuanZiList.Add(BlobManager.Instance.AvailableBlobs[0]);
|
|
tuanzi.BelongingBuilding = this;
|
|
TuanZi_Num++;
|
|
tuanzi.GetComponent<Animator>().Play("CutTrees");
|
|
}
|
|
}
|