73 lines
1.7 KiB
C#
73 lines
1.7 KiB
C#
using System;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using DragonLi.Core;
|
|
using Mirror;
|
|
using UnityEngine;
|
|
using Valheim;
|
|
|
|
public class Badge : MonoBehaviour
|
|
{
|
|
public bool isRotate;
|
|
|
|
public bool isFly;
|
|
|
|
private bool _isEnd;
|
|
|
|
public void Init(bool curIsRotate)
|
|
{
|
|
isRotate=curIsRotate;
|
|
CoroutineTaskManager.Instance.WaitSecondTodo(() =>
|
|
{
|
|
isFly = true;
|
|
MonoSingleton<CoroutineTaskManager>.Instance.WaitSecondTodo(() =>
|
|
{
|
|
if(_isEnd)
|
|
return;
|
|
_isEnd = true;
|
|
GameManager.Ins.ShowPetWorld();
|
|
NetworkServer.Destroy(gameObject);
|
|
},6f);
|
|
}, 6f);
|
|
_isEnd = false;
|
|
}
|
|
private void Update()
|
|
{
|
|
if (isRotate&&!isFly)
|
|
transform.Rotate(0, 50 * Time.deltaTime, 0);
|
|
if (isFly)
|
|
{
|
|
Fly();
|
|
}
|
|
}
|
|
|
|
private void OnTriggerEnter(Collider other)
|
|
{
|
|
if (other.CompareTag("Weapon")|| other.CompareTag("Player"))
|
|
{
|
|
NetworkServer.Destroy(gameObject);
|
|
if(_isEnd)
|
|
return;
|
|
_isEnd = true;
|
|
GameManager.Ins.ShowPetWorld();
|
|
}
|
|
}
|
|
|
|
public void Fly()
|
|
{
|
|
transform.localScale=Vector3.one*0.5f;
|
|
Vector3 newPos = MRNetworkManager.Ins.roomSlots[0].transform.position;
|
|
newPos.y = 0.8f;
|
|
transform.position = Vector3.MoveTowards(transform.position, newPos, 4f * Time.deltaTime);
|
|
if ( Vector3.Distance(transform.position, newPos) < 0.3f)
|
|
{
|
|
|
|
if(_isEnd)
|
|
return;
|
|
_isEnd = true;
|
|
GameManager.Ins.ShowPetWorld();
|
|
NetworkServer.Destroy(gameObject);
|
|
}
|
|
}
|
|
}
|