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;//宝箱面板
///
/// 抠图脚本
///
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();
tipsUI = transform.Find("Tips").gameObject;
tipsUI.transform.SetAsLastSibling();//把tips放在最下面
charForeach = tipsUI.GetComponent();
boxPanel = transform.Find("BoxPanel").GetComponent();
//生成抠图面板
GameObject go = Instantiate(Resources.Load("GuideFile/RectGuidance_Panel"), this.transform);
if (go != null)
{
go.transform.SetSiblingIndex(1);
guidance = go.GetComponent();
guidance.gameObject.SetActive(false);
}
else
{
Debug.LogError("遮罩生成失败了");
}
//购买按钮
towerBuyBtn = GameObject.Find("UICamera/BottomCanvas/Panel/TowerBuyBtn");
RectTransform tmpTs = towerBuyBtn.GetComponent();
RectTransform canvasUI = transform.parent.parent.GetComponent();
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();
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();
text_Tip = image_Tip_Rect.transform.Find("Text").GetComponent();
SetRimActive(false);
float a = 0.06666667f;
float b = canvasUI.localScale.x;
float tmpScale = a / b;
wood1 = transform.Find("Image_Wood1").GetComponent();
wood1.GetComponent().anchoredPosition *= tmpScale;
wood1PS1 = wood1.transform.Find("Mu/Particle System").GetComponent();
//wood1PS2 = wood1.transform.Find("Mu_02/Particle System").GetComponent();
wood2 = transform.Find("Image_Wood2").GetComponent();
wood2.GetComponent().anchoredPosition *= tmpScale;
wood2PS1 = wood2.transform.Find("Mu/Particle System").GetComponent();
//wood2PS2 = wood2.transform.Find("Mu_02/Particle System").GetComponent();
wood1.gameObject.SetActive(false);
wood2.gameObject.SetActive(false);
fire = transform.Find("Image_Fire").GetComponent();
fire.GetComponent().anchoredPosition *= tmpScale;
firePS1 = fire.transform.Find("Huo/Particle System").GetComponent();
//firePS2 = fire.transform.Find("Huo_02/Particle System").GetComponent();
fire.gameObject.SetActive(false);
water = transform.Find("Image_Water").GetComponent();
water.GetComponent().anchoredPosition *= tmpScale;
waterPS1 = water.transform.Find("Shui/Particle System").GetComponent();
//waterPS2 = water.transform.Find("Shui_02/Particle System").GetComponent();
water.gameObject.SetActive(false);
towerPos = transform.Find("Image_TowerPos").GetComponent();
towerPos.GetComponent().anchoredPosition *= tmpScale;
towerPos.Init(wood1);
towerPos.enabled = false;
towerPos2 = transform.Find("Image_TowerPos2").GetComponent();
towerPos2.GetComponent().anchoredPosition *= tmpScale;
towerPos2.Init(fire);
towerPos2.enabled = false;
towerPos3 = transform.Find("Image_TowerPos3").GetComponent();
towerPos3.GetComponent().anchoredPosition *= tmpScale;
towerPos3.Init(water);
towerPos3.enabled = false;
dragHandImg = transform.Find("ImageHand").GetComponent();
dragHandImg.gameObject.SetActive(false);
warningImg = transform.Find("Image_Warning").GetComponent();
warningImg.gameObject.SetActive(false);
boxPanel = transform.Find("BoxPanel").GetComponent();
skillBtn = GameObject.Find("UICamera/BottomCanvas/Panel/Energy/FireSkillBg/SkillBtn").GetComponent