143 lines
4.1 KiB
C#
143 lines
4.1 KiB
C#
using System;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using EPOOutline;
|
|
using UnityEngine;
|
|
using UnityEngine.XR;
|
|
|
|
public class PuzzleItem : MonoBehaviour
|
|
{
|
|
public int id;
|
|
|
|
public Outlinable[] outliner;
|
|
|
|
public bool IsFly => _isFly;
|
|
|
|
private Vector3 _startPos;
|
|
private Vector3 _startEulerAngles;
|
|
|
|
public bool isSelect;
|
|
private bool _isFly;
|
|
public void Start()
|
|
{
|
|
_startPos=transform.position;
|
|
_startEulerAngles = transform.eulerAngles;
|
|
isSelect = false;
|
|
_isFly = false;
|
|
HideOutline();
|
|
}
|
|
|
|
private void Update()
|
|
{
|
|
if(_isFly)
|
|
return;
|
|
// foreach (var item in outliner)
|
|
// {
|
|
// item.enabled = isSelect;
|
|
// }
|
|
if(GameManager.Ins.taskManager.tasks[3].isEnd)
|
|
return;
|
|
if (GameLocal.Ins.place == Place.Hunan_Hengyang_Zhuhui_Dongzhoudao_nei
|
|
||GameLocal.Ins.place == Place.Henan_Xinxiang_Wandaguangchang_Shinei
|
|
|
|
|| GameLocal.Ins.place == Place.Company1Floor
|
|
||GameLocal.Ins.place == Place.Jiangsu_Xvzhou_Fengxian_Wuyueguangchang
|
|
||GameLocal.Ins.place == Place.Jiangsu_Xvzhou_Suning_Guangchang
|
|
||GameLocal.Ins.place == Place.Jiangsu_Xvzhou_Guolou_Oulebao_2
|
|
||GameLocal.Ins.place == Place.Chongqing_Yuzhong_Hongyadong_Xiakexing_shiwan
|
|
||GameLocal.Ins.place == Place.Ningxia_Yinchuan_Jinfeng_XinhualianGuangchang
|
|
||GameLocal.Ins.place == Place.Hunan_Zhuzhou_Wanda_Shennongcheng_Chaowanshe
|
|
)//»»½Ç¶È
|
|
{
|
|
if (isSelect)
|
|
{
|
|
|
|
var rayLine = GameManager.Ins.playerRightHand.ray.GetComponent<LineRenderer>();
|
|
var followZ = transform.position.x;
|
|
transform.position = new Vector3(followZ, rayLine.GetPosition(1).y, rayLine.GetPosition(1).z);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (isSelect)
|
|
{
|
|
|
|
var rayLine = GameManager.Ins.playerRightHand.ray.GetComponent<LineRenderer>();
|
|
var followZ = transform.position.z;
|
|
transform.position = new Vector3(rayLine.GetPosition(1).x, rayLine.GetPosition(1).y, followZ);
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
public void StartFly()
|
|
{
|
|
StartCoroutine(FlyStartPos());
|
|
}
|
|
|
|
public void StartFlyTarget(Vector3 endPos,Vector3 endEulerAngles)
|
|
{
|
|
StartCoroutine(FlyEndPos(endPos, endEulerAngles));
|
|
}
|
|
|
|
IEnumerator FlyEndPos(Vector3 endPos,Vector3 endEulerAngles)
|
|
{
|
|
_isFly = true;
|
|
bool isToStartPos=false;
|
|
while (!isToStartPos)
|
|
{
|
|
transform.position=Vector3.Lerp(transform.position,endPos,Time.deltaTime);
|
|
transform.eulerAngles=Vector3.Lerp(transform.eulerAngles,endEulerAngles,Time.deltaTime);
|
|
yield return null;
|
|
if (Vector3.Distance(transform.position, endPos) < 0.1f)
|
|
{
|
|
transform.position=endPos;
|
|
transform.eulerAngles=endEulerAngles;
|
|
isToStartPos=true;
|
|
}
|
|
}
|
|
_isFly = false;
|
|
isSelect = false;
|
|
|
|
}
|
|
|
|
IEnumerator FlyStartPos()
|
|
{
|
|
_isFly = true;
|
|
bool isToStartPos=false;
|
|
while (!isToStartPos)
|
|
{
|
|
transform.position=Vector3.Lerp(transform.position,_startPos,Time.deltaTime);
|
|
transform.eulerAngles=Vector3.Lerp(transform.eulerAngles,_startEulerAngles,Time.deltaTime);
|
|
yield return null;
|
|
if (Vector3.Distance(transform.position, _startPos) < 0.1f)
|
|
{
|
|
transform.position=_startPos;
|
|
transform.eulerAngles=_startEulerAngles;
|
|
isToStartPos=true;
|
|
}
|
|
}
|
|
GetComponent<BoxCollider>().enabled = true;
|
|
_isFly = false;
|
|
isSelect = false;
|
|
}
|
|
|
|
public void ShowOutline()
|
|
{
|
|
foreach (var item in outliner)
|
|
{
|
|
item.enabled = true;
|
|
}
|
|
}
|
|
|
|
public void HideOutline()
|
|
{
|
|
if(isSelect)
|
|
return;
|
|
foreach (var item in outliner)
|
|
{
|
|
item.enabled = false;
|
|
}
|
|
}
|
|
}
|