73 lines
2.5 KiB
C#
73 lines
2.5 KiB
C#
|
using System;
|
||
|
using System.Collections;
|
||
|
using System.Collections.Generic;
|
||
|
using UnityEngine;
|
||
|
using UnityEngine.UI;
|
||
|
using DG.Tweening;
|
||
|
public class Bud : MonoBehaviour
|
||
|
{
|
||
|
public bool isActive = false;
|
||
|
public Canvas IconCanvas;
|
||
|
public Image TargetIcon;
|
||
|
|
||
|
public int budWoodNum = 160;
|
||
|
private void Start()
|
||
|
{
|
||
|
IconCanvas ??= GameObject.Find("-------UI区-------/Canvas").GetComponent<Canvas>();
|
||
|
TargetIcon ??= GameObject.Find("-------UI区-------/Canvas/TopBar/WoodStatus/Image").GetComponent<Image>();
|
||
|
}
|
||
|
|
||
|
//[Header("Buff用")]
|
||
|
private void OnMouseDown()
|
||
|
{
|
||
|
if (isActive)
|
||
|
{
|
||
|
isActive = false;
|
||
|
transform.parent.GetComponent<TreeBud>().disActiveBud.Add(this);
|
||
|
transform.parent.GetComponent<TreeBud>().ActiveBud.Remove(this);
|
||
|
|
||
|
GetComponent<Animator>().Play("BudDisAppear");
|
||
|
//int output = 120 * transform.parent.GetComponent<TreeBud>().WoodProduceBuff;
|
||
|
|
||
|
|
||
|
//for (int i = 0; i < output/2; i++)
|
||
|
//{
|
||
|
|
||
|
//}
|
||
|
|
||
|
var go = GameObjectPool.Instance.Spawn("ResourceIcon");
|
||
|
|
||
|
go.transform.SetParent(IconCanvas.transform);
|
||
|
go.transform.position = Camera.main.WorldToScreenPoint(transform.position);
|
||
|
|
||
|
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);
|
||
|
TargetIcon.rectTransform.DOPunchScale(Vector3.one, 0.1f);
|
||
|
GameProcedureManager.Instance.WoodCount += (int)(budWoodNum * (int)transform.parent.GetComponent<TreeBud>().WoodProduceBuff *
|
||
|
GlobalBuffSystem.Instance.GlobalMultiplier);
|
||
|
});
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
//GameProcedureManager.Instance.WoodCount += 60 * transform.parent.GetComponent<TreeBud>().WoodProduceBuff;
|
||
|
//buff7效果
|
||
|
if (transform.parent.GetComponent<TreeBud>().buff_7_active)
|
||
|
{
|
||
|
GlobalBuffSystem.Instance.GlobalMultiplier += 5;
|
||
|
Invoke("Buff_7_disActive", 5);
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
private void Buff_7_disActive()
|
||
|
{
|
||
|
GlobalBuffSystem.Instance.GlobalMultiplier -= 5;
|
||
|
}
|
||
|
}
|