_TheStrongestSnail/TheStrongestSnail/Assets/Scripts/Battle_Royale/BossContro.cs
2024-11-13 02:03:11 +08:00

70 lines
1.9 KiB
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class BossContro : MonoBehaviour
{
public Transform Parent;
public Transform originalParent;
public Transform BoosStartPos;
public static BossContro instance;
public Transform StartPos;
// Start is called before the first frame update
void Start()
{
instance = this;
originalParent = transform.parent;
}
public void MoveParent()
{
// 记录原始的父物体
// 将 childObject 设为新的 parentObject 的子节点,并放到最后一个位置
transform.SetParent(Parent);
transform.SetAsLastSibling();
}
public void ReturnParent()
{
// 需要时将 childObject 移回原始父物体,并设置为第一个子节点
transform.SetParent(originalParent);
transform.SetAsFirstSibling(); // 设置为第一个子节点
transform.position= StartPos.position;
BoosStartPos=StartPos;
}
public void BossMove()
{
int Index=Random.Range(0,5);
switch (Index)
{
case 0:
GetComponent<PlayerMove>().EndPos = GetComponent<PlayerMove>().TypeEndPos1;
break;
case 1:
GetComponent<PlayerMove>().EndPos = GetComponent<PlayerMove>().TypeEndPos2;
break;
case 2:
GetComponent<PlayerMove>().EndPos = GetComponent<PlayerMove>().TypeEndPos3;
break;
case 3:
GetComponent<PlayerMove>().EndPos = GetComponent<PlayerMove>().TypeEndPos4;
break;
case 4:
GetComponent<PlayerMove>().EndPos = GetComponent<PlayerMove>().TypeEndPos5;
break;
case 5:
GetComponent<PlayerMove>().EndPos = GetComponent<PlayerMove>().TypeEndPos6;
break;
}
//MoveParent();
GetComponent<PlayerMove>().StartMove();
}
}