_TheStrongestSnail/TheStrongestSnail/Assets/Scripts/Battle_Royale/BossContro.cs

127 lines
3.7 KiB
C#

using DG.Tweening;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class BossContro : MonoBehaviour
{
public Transform Parent;
public Transform originalParent;
public Transform BoosStartPos;
//public static BossContro instance;
public Transform StartPos;
public Animator BossAni;//boos动画
public bool IsLeft;
public int HouseId;//房间编号
public Transform BoosHouse;//boos房间
public AllHouseContro allHouseContro;
public GameObject bg;
public Vector2 OrPos;
public Allother allother;
private Vector3 originalScale; // 保存原始大小
// Start is called before the first frame update
void Start()
{
//instance = this;
originalParent = transform.parent;
OrPos = transform.GetComponent<RectTransform>().anchoredPosition;
originalScale=transform.localScale;
}
public void Zoomout()//缩小
{
Image image = GetComponent<Image>();
image.rectTransform.DOScale(0.9f, 0.5f).SetEase(Ease.Linear);
}
public void ReplySize()//恢复大小
{
Image image = GetComponent<Image>();
image.rectTransform.DOScale(originalScale, 0.5f).SetEase(Ease.Linear);
}
public void MoveParent()
{
// 记录原始的父物体
// 将 childObject 设为新的 parentObject 的子节点,并放到最后一个位置
transform.SetParent(Parent);
transform.SetAsLastSibling();
}
public void ReturnParent()
{
ReplySize();
// 需要时将 childObject 移回原始父物体,并设置为第一个子节点
transform.SetParent(originalParent);
transform.SetAsFirstSibling(); // 设置为第一个子节点
Vector3 RePos = StartPos.position;
transform.GetComponent<RectTransform>().anchoredPosition = OrPos;
BoosStartPos=StartPos;
//allHouseContro.CloseBoosDoor(BoosHouse.GetComponent<HouseBtn>());
//Tools.MoveUpOrDwon(transform.parent.GetComponent<HouseBtn>().door, -270);//关门
}
public void BossMove(int Index)
{
Debug.Log("===========--------------");
foreach (HouseBtn item in allHouseContro.HouseBtnList)
{
Debug.Log(item.roomNo.ToString() + "|" + Index.ToString());
if (item.roomNo == Index)
{
GetComponent<PlayerMove>().EndPos = item.post.transform;
}
}
//GetComponent<PlayerMove>().TypeEndPos1
//switch (Index)
//{
// case 1:
// GetComponent<PlayerMove>().EndPos = GetComponent<PlayerMove>().TypeEndPos1;
// break;
// case 2:
// GetComponent<PlayerMove>().EndPos = GetComponent<PlayerMove>().TypeEndPos2;
// break;
// case 3:
// GetComponent<PlayerMove>().EndPos = GetComponent<PlayerMove>().TypeEndPos3;
// break;
// case 4:
// GetComponent<PlayerMove>().EndPos = GetComponent<PlayerMove>().TypeEndPos4;
// break;
// case 5:
// GetComponent<PlayerMove>().EndPos = GetComponent<PlayerMove>().TypeEndPos5;
// break;
// case 6:
// GetComponent<PlayerMove>().EndPos = GetComponent<PlayerMove>().TypeEndPos6;
// break;
// case 0:
// GetComponent<PlayerMove>().EndPos = GetComponent<PlayerMove>().TypeEndPos0;
// break;
//}
//MoveParent();
BossAni.SetInteger("State", 1); // 动画转为移动
GetComponent<PlayerMove>().StartMove(); // 开始移动
//Tools.MoveUpOrDwon(transform.parent.GetComponent<HouseBtn>().door, 270, () => {
//});
}
}