using System;
|
using System.Collections;
|
using System.Collections.Generic;
|
using DG.Tweening;
|
using KTGMGemClient;
|
using UnityEngine;
|
using UnityEngine.UI;
|
|
public class GuidePanelNew : MonoBehaviour
|
{
|
GameObject tipsUI;//显示文字的UI
|
CharForeach charForeach;//动态显示文字
|
Action callBack;//每一步操作后的回调
|
private GuideBox boxPanel;//宝箱面板
|
|
/// <summary>
|
/// 抠图脚本
|
/// </summary>
|
private RectGuidance guidance;
|
private RectTransform image_Rim_Rect;//边框
|
private GameObject particle_1, particle_2;//使用粒子特效
|
private RectTransform image_Tip_Rect;//可以移动的提示框
|
private Text text_Tip;//可以移动的提示框文字
|
|
Vector2 rimOffset = new Vector2(30, 30);//边框要比按钮大一些
|
|
Vector2 towerBuyBtnPos;//动态生成按钮抠图位置
|
Vector2 skillBtnPos = new Vector2(459, 121f);
|
|
private Image warningImg;//大波敌人来袭提示
|
|
private Vector2 tmpOffect;
|
GameObject towerBuyBtn;//购买宝石按钮
|
|
private string[] strArray;//按钮提示文字
|
GameObject offectBackground;//适配需要的黑色背景
|
ImageTowerPos towerPos;//塔位标识
|
ImageTowerPos towerPos2;//塔位标识
|
ImageTowerPos towerPos3;//塔位标识
|
|
Image tmpMask;//自身的阻挡射线Panel
|
//ParticleSystem finishPS;
|
Button finishBtn;
|
Image finishImg;
|
Canvas skillCanvasGroup;
|
void Awake()
|
{
|
|
tmpMask = transform.GetComponent<Image>();
|
tipsUI = transform.Find("Tips").gameObject;
|
tipsUI.transform.SetAsLastSibling();//把tips放在最下面
|
charForeach = tipsUI.GetComponent<CharForeach>();
|
|
boxPanel = transform.Find("BoxPanel").GetComponent<GuideBox>();
|
|
//生成抠图面板
|
GameObject go = Instantiate(Resources.Load<GameObject>("GuideFile/RectGuidance_Panel"), this.transform);
|
if (go != null)
|
{
|
go.transform.SetSiblingIndex(1);
|
guidance = go.GetComponent<RectGuidance>();
|
guidance.gameObject.SetActive(false);
|
}
|
else
|
{
|
Debug.LogError("遮罩生成失败了");
|
}
|
|
//购买按钮
|
towerBuyBtn = GameObject.Find("UICamera/BottomCanvas/Panel/TowerBuyBtn");
|
RectTransform tmpTs = towerBuyBtn.GetComponent<RectTransform>();
|
|
RectTransform canvasUI = transform.parent.parent.GetComponent<RectTransform>();
|
float tmpOffect = tmpTs.anchoredPosition.y - (canvasUI.sizeDelta.y * 0.5f);
|
towerBuyBtnPos = new Vector2(tmpTs.anchoredPosition.x, tmpOffect);//计算偏移量
|
|
//得到用来标记的粒子特效
|
image_Rim_Rect = transform.Find("Image_Rim").GetComponent<RectTransform>();
|
particle_1 = image_Rim_Rect.transform.Find("Particle System Small").gameObject;
|
particle_2 = image_Rim_Rect.transform.Find("Particle System Big").gameObject;
|
|
//为了防止各种适配出现白边,多做了黑色遮罩
|
offectBackground = transform.Find("OffectImage").gameObject;
|
offectBackground.SetActive(false);
|
|
image_Tip_Rect = transform.Find("Image_Tip").GetComponent<RectTransform>();
|
text_Tip = image_Tip_Rect.transform.Find("Text").GetComponent<Text>();
|
|
SetRimActive(false);
|
|
float a = 0.06666667f;
|
float b = canvasUI.localScale.x;
|
float tmpScale = a / b;
|
|
wood1 = transform.Find("Image_Wood1").GetComponent<ImageWood>();
|
wood1.GetComponent<RectTransform>().anchoredPosition *= tmpScale;
|
wood1PS1 = wood1.transform.Find("Mu/Particle System").GetComponent<ParticleSystem>();
|
//wood1PS2 = wood1.transform.Find("Mu_02/Particle System").GetComponent<ParticleSystem>();
|
|
wood2 = transform.Find("Image_Wood2").GetComponent<ImageWood2>();
|
wood2.GetComponent<RectTransform>().anchoredPosition *= tmpScale;
|
wood2PS1 = wood2.transform.Find("Mu/Particle System").GetComponent<ParticleSystem>();
|
//wood2PS2 = wood2.transform.Find("Mu_02/Particle System").GetComponent<ParticleSystem>();
|
|
wood1.gameObject.SetActive(false);
|
wood2.gameObject.SetActive(false);
|
|
fire = transform.Find("Image_Fire").GetComponent<ImageFire1>();
|
fire.GetComponent<RectTransform>().anchoredPosition *= tmpScale;
|
firePS1 = fire.transform.Find("Huo/Particle System").GetComponent<ParticleSystem>();
|
//firePS2 = fire.transform.Find("Huo_02/Particle System").GetComponent<ParticleSystem>();
|
fire.gameObject.SetActive(false);
|
|
water = transform.Find("Image_Water").GetComponent<ImageWater>();
|
water.GetComponent<RectTransform>().anchoredPosition *= tmpScale;
|
waterPS1 = water.transform.Find("Shui/Particle System").GetComponent<ParticleSystem>();
|
//waterPS2 = water.transform.Find("Shui_02/Particle System").GetComponent<ParticleSystem>();
|
water.gameObject.SetActive(false);
|
|
towerPos = transform.Find("Image_TowerPos").GetComponent<ImageTowerPos>();
|
towerPos.GetComponent<RectTransform>().anchoredPosition *= tmpScale;
|
towerPos.Init(wood1);
|
towerPos.enabled = false;
|
|
towerPos2 = transform.Find("Image_TowerPos2").GetComponent<ImageTowerPos>();
|
towerPos2.GetComponent<RectTransform>().anchoredPosition *= tmpScale;
|
towerPos2.Init(fire);
|
towerPos2.enabled = false;
|
|
towerPos3 = transform.Find("Image_TowerPos3").GetComponent<ImageTowerPos>();
|
towerPos3.GetComponent<RectTransform>().anchoredPosition *= tmpScale;
|
towerPos3.Init(water);
|
towerPos3.enabled = false;
|
|
dragHandImg = transform.Find("ImageHand").GetComponent<RectTransform>();
|
dragHandImg.gameObject.SetActive(false);
|
|
warningImg = transform.Find("Image_Warning").GetComponent<Image>();
|
warningImg.gameObject.SetActive(false);
|
|
boxPanel = transform.Find("BoxPanel").GetComponent<GuideBox>();
|
|
skillBtn = GameObject.Find("UICamera/BottomCanvas/Panel/Energy/FireSkillBg/SkillBtn").GetComponent<Button>();
|
skillBtn.interactable = false;
|
|
finishBtn = transform.Find("FinishImageBtn").GetComponent<Button>();
|
finishImg = finishBtn.transform.Find("FinishImage").GetComponent<Image>();
|
finishImg.transform.localScale = new Vector3(0.1f, 0.1f, 0.1f);
|
finishBtn.onClick.AddListener(OnClickFinish);
|
finishBtn.gameObject.SetActive(false);
|
//finishPS = transform.Find("Effect_UI_YinDaoJieShu/Particle System (3)").GetComponent<ParticleSystem>();
|
towerBuyBtn.gameObject.SetActive(false);
|
}
|
|
|
/// <summary>
|
/// Start is called on the frame when a script is enabled just before
|
/// any of the Update methods is called the first time.
|
/// </summary>
|
void Start()
|
{
|
tmpOffect = GetComponent<RectTransform>().offsetMin;
|
tmpOffect = new Vector2(tmpOffect.x, tmpOffect.y * 0.5f);
|
|
//fire1.GetComponent<RectTransform>().anchoredPosition -= tmpOffect;
|
//fire2.GetComponent<RectTransform>().anchoredPosition -= tmpOffect;
|
towerPos.GetComponent<RectTransform>().anchoredPosition -= tmpOffect;
|
towerPos2.GetComponent<RectTransform>().anchoredPosition -= tmpOffect;
|
towerPos3.GetComponent<RectTransform>().anchoredPosition -= tmpOffect;
|
wood1.GetComponent<RectTransform>().anchoredPosition -= tmpOffect;
|
wood2.GetComponent<RectTransform>().anchoredPosition -= tmpOffect;
|
fire.GetComponent<RectTransform>().anchoredPosition -= tmpOffect;
|
water.GetComponent<RectTransform>().anchoredPosition -= tmpOffect;
|
//fire.GetComponent<RectTransform>().anchoredPosition -= tmpOffect;
|
|
//skill.GetComponent<RectTransform>().anchoredPosition -= tmpOffect;
|
|
}
|
|
/// <summary>
|
/// 步骤1 :对话---开箱---玉米
|
/// </summary>
|
/// <param name="str"></param>
|
/// <param name="cb"></param>
|
public void Step1(string[] str, Action cb)
|
{
|
callBack = cb;
|
SetGuideUI(true);
|
StartShowWord(str, OpenBoxPanel);
|
}
|
|
/// <summary>
|
/// 开箱
|
/// </summary>
|
public void OpenBoxPanel()
|
{
|
//关闭对话框
|
SetGuideUI(false);
|
towerBuyBtn.gameObject.SetActive(true);
|
|
//开箱
|
boxPanel.ChangeType(GuideBoxType.Wood, Step1Finish);
|
}
|
|
/// <summary>
|
/// 步骤1结束
|
/// </summary>
|
private void Step1Finish()
|
{
|
if (callBack != null) callBack();
|
}
|
|
|
ImageWood wood1;
|
ParticleSystem wood1PS1;//出现的特效
|
ImageWood2 wood2;//两个用来合成的mu元素
|
ParticleSystem wood2PS1;
|
|
ImageFire1 fire;//火元素
|
ParticleSystem firePS1;
|
|
ImageWater water;//水元素
|
ParticleSystem waterPS1;
|
|
/// <summary>
|
/// 步骤2:购买---购买---合成---上阵 事件广播结束,不走回调
|
/// </summary>
|
public void Step2(string[] str)
|
{
|
strArray = str;
|
tmpMask.enabled = false;
|
|
AddButtonListener(towerBuyBtn, Step2_1);
|
Image btnImg = towerBuyBtn.GetComponent<Image>();
|
InitRectGuidance(btnImg, 159, 73.5f, Vector2.one);
|
SetRimPos(towerBuyBtn);
|
StartCoroutine(ShowRimTip(strArray[0]));
|
}
|
|
/// <summary>
|
/// 首次购买
|
/// </summary>
|
private void Step2_1()
|
{
|
Wood1Appear();
|
}
|
|
private void Wood1Appear()
|
{
|
if (!wood1.gameObject.activeSelf)
|
{
|
wood1.gameObject.SetActive(true);
|
wood1.transform.Find("Image_2").gameObject.SetActive(false);
|
wood1.enabled = false;
|
wood1PS1.Play();
|
//wood1PS2.Play();
|
RemoveButtonListener(towerBuyBtn);
|
AddButtonListener(towerBuyBtn, Step2_2);
|
StartCoroutine(ShowRimTip(strArray[1]));
|
}
|
}
|
|
/// <summary>
|
/// 再次购买后,引导合成
|
/// </summary>
|
private void Step2_2()
|
{
|
Wood2Appear();
|
|
|
|
//StartCoroutine(ShowRimTip(strArray[2]));
|
}
|
|
private void Wood2Appear()
|
{
|
if (!wood2.gameObject.activeSelf)
|
{
|
wood2.gameObject.SetActive(true);
|
wood2PS1.Play();
|
// wood2PS2.Play();
|
//fire2.enabled = false;
|
DestoryButtonListener(towerBuyBtn);
|
towerBuyBtn.gameObject.SetActive(false);
|
|
SetRimActive(false);
|
CloseGuidance();
|
tmpMask.enabled = true;
|
offectBackground.SetActive(true);
|
wood1.enabled = true;
|
wood2.enabled = true;
|
ShowDragPath(wood2.GetStartP, wood1.GetRect);
|
RimWood2();
|
image_Tip_Rect.gameObject.SetActive(false);
|
}
|
}
|
|
|
/// <summary>
|
/// 开始拖拽,提示玩家进行合成
|
/// </summary>
|
public void RimWood1()
|
{
|
SetRimPos(wood1.gameObject);
|
}
|
|
/// <summary>
|
/// 结束拖拽,未完成
|
/// </summary>
|
public void RimWood2()
|
{
|
SetRimPos(wood2.gameObject);
|
}
|
|
public void AddCard()
|
{
|
//合成了2级木
|
Step2_3();
|
}
|
|
|
/// <summary>
|
/// 合成了2级木 准备引导上阵
|
/// </summary>
|
private void Step2_3()
|
{
|
|
offectBackground.SetActive(false);
|
SetRimActive(true);
|
Image btnImg = transform.Find("Image_TowerPos").GetComponent<Image>();
|
towerPos.enabled = true;
|
InitRectGuidance(btnImg, 75, 80, tmpOffect);
|
SetRimPos(btnImg.gameObject);
|
StopShowDragPath(true);
|
ShowDragPath(wood1.GetStartP, btnImg.rectTransform);
|
//StartCoroutine(ShowRimTip(strArray[3]));
|
}
|
|
/// <summary>
|
/// 上阵成功
|
/// </summary>
|
public void OnWoodAttackPos()
|
{
|
towerPos.enabled = false;
|
SetRimActive(false);
|
CloseGuidance();
|
StopShowDragPath(true);
|
}
|
|
/// <summary>
|
/// 关闭技能X1的显示优先级
|
/// </summary>
|
public void CloseSkillImage()
|
{
|
GameObject go1 = GameObject.Find("UICamera/BottomCanvas/Panel/Energy/FireSkillBg/SkillCount1");
|
if (go1 != null)
|
{
|
skillCanvasGroup = go1.GetComponent<Canvas>();
|
skillCanvasGroup.overrideSorting = false;
|
}
|
}
|
|
/// <summary>
|
/// 步骤3 :对话---出兵后杀光---对话---展示火鸡
|
/// </summary>
|
/// <param name="str"></param>
|
/// <param name="cb"></param>
|
public void Step3(string[] str, Action cb)
|
{
|
SetGuideUI(true);
|
StartShowWord(str, cb);
|
}
|
|
public void Step3AfterTalk()
|
{
|
SetGuideUI(false);
|
}
|
|
|
public void Step3_3(Action cb)
|
{
|
//关闭对话框
|
SetGuideUI(false);
|
towerBuyBtn.gameObject.SetActive(true);
|
|
//开箱
|
boxPanel.ChangeType(GuideBoxType.Fire, cb);
|
}
|
|
/// <summary>
|
/// 步骤4 :点击购买---上阵
|
/// </summary>
|
/// <param name="str"></param>
|
/// <param name="cb"></param>
|
public void Step4(string[] str)
|
{
|
strArray = str;
|
tmpMask.enabled = false;
|
|
AddButtonListener(towerBuyBtn, Step4_1);
|
Image btnImg = towerBuyBtn.GetComponent<Image>();
|
InitRectGuidance(btnImg, 159, 73.5f, Vector2.one);
|
SetRimPos(towerBuyBtn);
|
StartCoroutine(ShowRimTip(strArray[0]));
|
}
|
|
/// <summary>
|
/// 购买火鸡
|
/// </summary>
|
private void Step4_1()
|
{
|
FireAppear();
|
}
|
|
private void FireAppear()
|
{
|
if (!fire.gameObject.activeSelf)
|
{
|
fire.gameObject.SetActive(true);
|
//fire.transform.Find("Image_2").gameObject.SetActive(false);
|
fire.enabled = true;
|
firePS1.Play();
|
firePS1.Play();
|
RemoveButtonListener(towerBuyBtn);
|
towerBuyBtn.gameObject.SetActive(false);
|
|
Step4_2();
|
}
|
}
|
|
/// <summary>
|
/// 引导上阵
|
/// </summary>
|
private void Step4_2()
|
{
|
tmpMask.enabled = true;
|
|
offectBackground.SetActive(false);
|
SetRimActive(true);
|
Image btnImg = transform.Find("Image_TowerPos2").GetComponent<Image>();
|
towerPos2.enabled = true;
|
InitRectGuidance(btnImg, 75, 80, tmpOffect);
|
SetRimPos(btnImg.gameObject);
|
ShowDragPath(fire.GetStartP, btnImg.rectTransform);
|
image_Tip_Rect.gameObject.SetActive(false);
|
}
|
|
public void OnFireAttackPos()
|
{
|
SetRimActive(false);
|
CloseGuidance();
|
StopShowDragPath(true);
|
}
|
|
/// <summary>
|
/// 步骤5:第二关出兵---三波后---对话框---置换
|
/// </summary>
|
/// <param name="str"></param>
|
/// <param name="cb"></param>
|
public void Step5(string[] str)
|
{
|
SetGuideUI(true);
|
StartShowWord(str, ChangeStep);
|
}
|
|
private void ChangeStep()
|
{
|
//开始引导
|
Step5Drag(0);
|
}
|
|
/// <summary>
|
/// 第12步,交换水火塔
|
/// </summary>
|
public void Step5Drag(int currentIndex)
|
{
|
if (currentIndex == 0)
|
{
|
GameConfig.CanDragTower = true;
|
//标记水塔 引导拖动
|
towerPos.GetComponent<Image>().raycastTarget = false;
|
towerPos2.GetComponent<Image>().raycastTarget = false;
|
//backgroundImg.raycastTarget = false;
|
tmpMask.enabled = false;
|
|
SetRimActive(true);
|
SetGuideUI(false);
|
Image btnImg = towerPos2.GetComponent<Image>();
|
btnImg.raycastTarget = false;
|
|
InitRectGuidance(btnImg, 75, 80, tmpOffect);
|
//SetRimPos(towerPos2.gameObject);
|
SetRimPos(towerPos2.gameObject, new Vector2(0, 30));
|
StartCoroutine(ShowRimTip("交换"));
|
ShowDragPath(towerPos2.GetComponent<RectTransform>().anchoredPosition, towerPos.GetComponent<RectTransform>());
|
|
}
|
else if (currentIndex == 1)
|
{
|
Image btnImg = towerPos.GetComponent<Image>();
|
btnImg.raycastTarget = false;
|
|
InitRectGuidance(btnImg, 75, 80, tmpOffect);
|
//SetRimPos(towerPos.gameObject);
|
SetRimPos(towerPos.gameObject, new Vector2(0, 10));
|
|
StartCoroutine(ShowRimTip("交换"));
|
|
}
|
else if (currentIndex == 2)
|
{
|
tmpMask.enabled = true;
|
|
SetRimActive(false);
|
StopShowDragPath(true);
|
CloseGuidance();
|
}
|
}
|
|
/// <summary>
|
/// 对话完毕后展示水
|
/// </summary>
|
/// <param name="str"></param>
|
/// <param name="ac"></param>
|
public void Step5Talk(string[] str, Action ac)
|
{
|
SetGuideUI(true);
|
StartShowWord(str, ac);
|
}
|
|
public void Step5_7(Action cb)
|
{
|
//关闭对话框
|
SetGuideUI(false);
|
towerBuyBtn.gameObject.SetActive(true);
|
|
//开箱
|
boxPanel.ChangeType(GuideBoxType.Water, cb);
|
}
|
|
|
/// <summary>
|
/// 步骤6:购买---上阵---第三关---杀光---结束引导
|
/// </summary>
|
/// <param name="str"></param>
|
public void Step6(string[] str)
|
{
|
strArray = str;
|
tmpMask.enabled = false;
|
|
AddButtonListener(towerBuyBtn, Step6_1);
|
Image btnImg = towerBuyBtn.GetComponent<Image>();
|
InitRectGuidance(btnImg, 159, 73.5f, Vector2.one);
|
SetRimPos(towerBuyBtn);
|
StartCoroutine(ShowRimTip(strArray[0]));
|
}
|
|
/// <summary>
|
/// 购买水
|
/// </summary>
|
private void Step6_1()
|
{
|
WaterAppear();
|
}
|
|
private void WaterAppear()
|
{
|
if (!water.gameObject.activeSelf)
|
{
|
water.gameObject.SetActive(true);
|
//fire.transform.Find("Image_2").gameObject.SetActive(false);
|
water.enabled = true;
|
waterPS1.Play();
|
//waterPS2.Play();
|
RemoveButtonListener(towerBuyBtn);
|
towerBuyBtn.gameObject.SetActive(false);
|
|
Step6_2();
|
}
|
}
|
/// <summary>
|
/// 引导上阵
|
/// </summary>
|
private void Step6_2()
|
{
|
tmpMask.enabled = true;
|
offectBackground.SetActive(false);
|
SetRimActive(true);
|
Image btnImg = transform.Find("Image_TowerPos3").GetComponent<Image>();
|
towerPos3.enabled = true;
|
InitRectGuidance(btnImg, 75, 80, tmpOffect);
|
SetRimPos(btnImg.gameObject);
|
ShowDragPath(water.GetStartP, btnImg.rectTransform);
|
image_Tip_Rect.gameObject.SetActive(false);
|
}
|
public void OnWaterAttackPos()
|
{
|
SetRimActive(false);
|
CloseGuidance();
|
StopShowDragPath(true);
|
}
|
|
/// <summary>
|
/// 步骤7:一大波敌人---引导释放技能
|
/// </summary>
|
public void Step7()
|
{
|
warningImg.color = new Color(1.0f, 1.0f, 1.0f, 0);
|
warningImg.gameObject.SetActive(true);
|
colorCount = 0;
|
SetWarningColor();
|
}
|
|
int colorCount = 0;
|
private void SetWarningColor()
|
{
|
if (colorCount < 6)
|
{
|
colorCount++;
|
warningImg.DOFade(colorCount % 2, 1.0f).OnComplete(SetWarningColor);
|
}
|
else
|
{
|
EventCenter.Ins.BroadCast((int)KTGMGemClient.EventType.CreateFourthWave);//开始第三关
|
warningImg.gameObject.SetActive(false);
|
}
|
}
|
|
|
public void Step7Talk(string[] str, Action ac)
|
{
|
callBack = ac;
|
GameObject.Find("UICamera/MainUI/BloodUI").SetActive(false);
|
|
SetGuideUI(true);
|
StartShowWord(str, GuideEnergyUp);
|
}
|
|
Button skillBtn;//
|
|
/// <summary>
|
/// 引导释放技能
|
/// </summary>
|
public void GuideEnergyUp()
|
{
|
EventCenter.Ins.BroadCast((int)KTGMGemClient.EventType.GuideEnergyUp, 100);
|
|
tmpMask.enabled = false;
|
skillBtn.interactable = true;
|
SetGuideUI(false);
|
|
SetRimActive(true);
|
AddButtonListener(skillBtn.gameObject, callBack);
|
Image btnImg = skillBtn.GetComponent<Image>();
|
InitRectGuidance(btnImg, 79, 79f, Vector2.one);
|
SetRimPos(skillBtn.gameObject, new Vector2(-15, -241));
|
StartCoroutine(ShowRimTip("释放技能"));
|
}
|
|
string[] laterStr;
|
public void SkillRelease(string[] str, Action ac)
|
{
|
|
GameObject.Find("UICamera/MainUI/BloodUI").SetActive(true);
|
|
RemoveButtonListener(skillBtn.gameObject);
|
SetRimActive(false);
|
CloseGuidance();
|
callBack = ac;
|
|
laterStr = str;
|
Invoke("LaterShow", 2f);
|
}
|
|
private void LaterShow()
|
{
|
SetGuideUI(true);
|
StartShowWord(laterStr, ShowFinishPanel);
|
|
}
|
|
private void ShowFinishPanel()
|
{
|
SetGuideUI(false);
|
//显示引导结束面板,再次点击按钮关闭
|
finishBtn.gameObject.SetActive(true);
|
finishImg.transform.DOScale(Vector3.one, 0.5f);
|
}
|
|
private void OnClickFinish()
|
{
|
callBack?.Invoke();
|
}
|
|
|
public void FinishGuide()
|
{
|
if (skillCanvasGroup != null)
|
skillCanvasGroup.overrideSorting = true;
|
towerBuyBtn.gameObject.SetActive(true);
|
}
|
|
|
#region 设置对话框
|
|
/// <summary>
|
/// 设置引导框
|
/// </summary>
|
/// <param name="active"></param>
|
private void SetGuideUI(bool active)
|
{
|
if (tipsUI.activeSelf != active)
|
tipsUI.SetActive(active);
|
}
|
|
//开始打印文字
|
private void StartShowWord(string[] str, Action cb)
|
{
|
charForeach.StartShowWord(str, cb);
|
}
|
|
/// <summary>
|
/// 立刻完成打印
|
/// </summary>
|
private void ShowWordImmediately()
|
{
|
charForeach.ShowWordImmediately();
|
}
|
|
#endregion
|
|
#region 按钮以及提示
|
|
private void SetRimActive(bool isOn)
|
{
|
if (image_Rim_Rect.gameObject.activeSelf != isOn)
|
{
|
image_Rim_Rect.gameObject.SetActive(isOn);
|
image_Tip_Rect.gameObject.SetActive(isOn);
|
}
|
}
|
/// <summary>
|
/// 设置边框的大小和位置
|
/// </summary>
|
/// <param name="target"></param>
|
private void SetRimPos(GameObject target, bool changeTipPos = true)
|
{
|
SetRimActive(true);
|
RectTransform rt = target.GetComponent<RectTransform>();
|
if (target.gameObject.name == "TowerBuyBtn")
|
{
|
image_Rim_Rect.anchoredPosition = towerBuyBtnPos - tmpOffect;
|
}
|
else if (target.gameObject.name == "SkillBtn")
|
{
|
image_Rim_Rect.anchoredPosition = skillBtnPos - tmpOffect;
|
}
|
else
|
{
|
image_Rim_Rect.anchoredPosition = rt.anchoredPosition;
|
}
|
image_Rim_Rect.sizeDelta = (rt.sizeDelta * rt.localScale) + rimOffset;
|
if (image_Rim_Rect.sizeDelta.x > 200)
|
{
|
particle_1.SetActive(false);
|
particle_2.SetActive(true);
|
}
|
else
|
{
|
particle_1.SetActive(true);
|
particle_2.SetActive(false);
|
}
|
|
if (changeTipPos)
|
{
|
image_Tip_Rect.anchoredPosition = new Vector2(image_Rim_Rect.anchoredPosition.x, image_Rim_Rect.anchoredPosition.y + 74 / 2 + image_Rim_Rect.sizeDelta.y / 2);
|
}
|
|
}
|
|
/// <summary>
|
/// 设置边框的大小和位置
|
/// </summary>
|
/// <param name="target"></param>
|
private void SetRimPos(GameObject target, Vector2 offect)
|
{
|
SetRimActive(true);
|
RectTransform rt = target.GetComponent<RectTransform>();
|
if (target.gameObject.name == "TowerBuyBtn")
|
{
|
image_Rim_Rect.anchoredPosition = towerBuyBtnPos - tmpOffect;
|
}
|
else if (target.gameObject.name == "SkillBtn")
|
{
|
image_Rim_Rect.anchoredPosition = skillBtnPos - tmpOffect;
|
}
|
else
|
{
|
image_Rim_Rect.anchoredPosition = rt.anchoredPosition;
|
}
|
image_Rim_Rect.sizeDelta = (rt.sizeDelta * rt.localScale) + rimOffset;
|
if (image_Rim_Rect.sizeDelta.x > 200)
|
{
|
particle_1.SetActive(false);
|
particle_2.SetActive(true);
|
}
|
else
|
{
|
particle_1.SetActive(true);
|
particle_2.SetActive(false);
|
}
|
image_Tip_Rect.anchoredPosition = new Vector2(image_Rim_Rect.anchoredPosition.x, image_Rim_Rect.anchoredPosition.y + 74 / 2 + image_Rim_Rect.sizeDelta.y / 2);
|
image_Tip_Rect.anchoredPosition += offect;
|
}
|
|
IEnumerator ShowRimTip(string str)
|
{
|
text_Tip.text = str;//动态改变长度
|
yield return 10;
|
SetTipRect(str);//动态修改text长度需要等待计算完成
|
}
|
/// <summary>
|
/// 设置显示文字的长度
|
/// </summary>
|
/// <param name="str"></param>
|
private void SetTipRect(string str)
|
{
|
RectTransform textRect = text_Tip.GetComponent<RectTransform>();
|
image_Tip_Rect.sizeDelta = new Vector2(textRect.sizeDelta.x + 64, image_Tip_Rect.sizeDelta.y);
|
}
|
|
#endregion
|
|
#region 遮罩,以及按钮添加删除事件
|
/// <summary>
|
/// 抠出来一个区域
|
/// </summary>
|
/// <param name="target"></param>
|
void InitRectGuidance(Image target, float x, float y, Vector2 offect)
|
{
|
if (!guidance.gameObject.activeSelf)
|
{
|
guidance.gameObject.SetActive(true);
|
}
|
|
if (target.gameObject.name == "TowerBuyBtn")
|
{
|
guidance.InitForCamera(target, towerBuyBtnPos, x, y);
|
}
|
else if (target.gameObject.name == "SkillBtn")
|
{
|
guidance.InitForCamera(target, skillBtnPos, x, y);
|
}
|
else
|
{
|
guidance.InitForCamera(target, x, y, offect);
|
}
|
}
|
|
/// <summary>
|
/// 关闭抠图
|
/// </summary>
|
public void CloseGuidance()
|
{
|
guidance.gameObject.SetActive(false);
|
}
|
|
/// <summary>
|
/// 给按钮添加事件
|
/// </summary>
|
private void AddButtonListener(GameObject go, Action ac)
|
{
|
EventTriggerListener.GetListener(go).onClick += (go1) =>
|
{
|
ac();
|
};
|
|
}
|
|
/// <summary>
|
/// 移除事件
|
/// </summary>
|
/// <param name="go"></param>
|
private void RemoveButtonListener(GameObject go)
|
{
|
EventTriggerListener eventTriggerListener = EventTriggerListener.GetListener(go);
|
|
eventTriggerListener.RemoveListener(go);
|
}
|
|
private void DestoryButtonListener(GameObject go)
|
{
|
EventTriggerListener eventTriggerListener = EventTriggerListener.GetListener(go);
|
|
if (eventTriggerListener != null)
|
Destroy(eventTriggerListener);
|
}
|
|
#endregion
|
|
#region 拖动效果
|
RectTransform dragHandImg;//拖动标识手指
|
|
private void ShowDragPath(Vector2 startP, RectTransform endP)
|
{
|
if (!dragHandImg.gameObject.activeSelf)
|
{
|
dragHandImg.gameObject.SetActive(true);
|
dragHandImg.anchoredPosition = startP;
|
dragHandImg.DOMove(endP.position, 1).SetEase(Ease.InCubic).SetLoops(-1);
|
}
|
}
|
|
public void StopShowDragPath(bool isClose)
|
{
|
dragHandImg.DOKill();
|
if (isClose)
|
dragHandImg.gameObject.SetActive(false);
|
}
|
|
|
#endregion
|
|
}
|