You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
119 lines
3.9 KiB
119 lines
3.9 KiB
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
using Level12;
|
|
using UnityEngine.EventSystems;
|
|
using System;
|
|
|
|
namespace Level23
|
|
{
|
|
public class Level23 : MonoBehaviour
|
|
{
|
|
public GameObject carObj,carobjTip,carobj3Tip;
|
|
public GameObject tipsUI,endTipsUI,huiseUI, zhi1obj, zhi2obj;
|
|
public Button offBtn, okBtn, backBtn,tipOkBtn;
|
|
public Button noAnswOkBtn, noAnswQxBtn;
|
|
Vector3 newPos = new Vector3(-0.16f, 0, -0.33f);
|
|
Vector3 newrRotation = new Vector3(103.1f, 0, 0);
|
|
public bool isDrag=false;
|
|
private Vector3 posOffset;
|
|
private Vector3 screenPoint;
|
|
private Vector3 offset;
|
|
bool isEnd = false;
|
|
bool[] answerbool = { false, false };
|
|
// Start is called before the first frame update
|
|
void Start()
|
|
{
|
|
offBtn.onClick.AddListener(delegate ()
|
|
{
|
|
offBtn.interactable = false;
|
|
carObj.transform.localPosition = newPos;
|
|
carObj.transform.localEulerAngles = newrRotation;
|
|
huiseUI.SetActive(true);
|
|
carobjTip.SetActive(true);
|
|
isDrag = true;
|
|
answerbool[0] = true;
|
|
});
|
|
okBtn.onClick.AddListener(delegate ()
|
|
{
|
|
if (isEnd)
|
|
{
|
|
endTipsUI.SetActive(true);
|
|
GameRoot.SubmitOprerationAnswer(23, 1, answerbool);
|
|
}
|
|
else
|
|
tipsUI.SetActive(true);
|
|
|
|
});
|
|
backBtn.onClick.AddListener(delegate ()
|
|
{
|
|
GameRoot.ReturnMenu();
|
|
});
|
|
tipOkBtn.onClick.AddListener(delegate ()
|
|
{
|
|
GameRoot.SubmitPassState(23, true);
|
|
GameRoot.ReturnMenu();
|
|
});
|
|
noAnswOkBtn.onClick.AddListener(delegate ()
|
|
{
|
|
isEnd = true;
|
|
tipsUI.SetActive(false);
|
|
});
|
|
noAnswQxBtn.onClick.AddListener(delegate ()
|
|
{
|
|
tipsUI.SetActive(false);
|
|
});
|
|
//UIEventListener.Get(zhi1obj).onDrag = OnDrag;
|
|
//UIEventListener.Get(zhi1obj).onBeginDrag = OnBeginDrag;
|
|
//UIEventListener.Get(zhi1obj).onEndDrag = OnEndDrag;
|
|
}
|
|
|
|
private void OnEndDrag(PointerEventData eventData)
|
|
{
|
|
posOffset = Vector3.zero;
|
|
isDrag = false;
|
|
}
|
|
|
|
private void OnBeginDrag(PointerEventData eventData)
|
|
{
|
|
Vector3 vPos = new Vector3();
|
|
if (RectTransformUtility.ScreenPointToWorldPointInRectangle(zhi1obj.GetComponent<RectTransform>() , eventData.position, Camera.main, out vPos))
|
|
{
|
|
posOffset = zhi1obj.transform.position - vPos;
|
|
}
|
|
isDrag = true;
|
|
}
|
|
|
|
private void OnDrag(PointerEventData eventData)
|
|
{
|
|
if (isDrag)
|
|
{
|
|
Vector3 pos;
|
|
if (RectTransformUtility.ScreenPointToWorldPointInRectangle(zhi1obj.GetComponent<RectTransform>(), eventData.position, Camera.main, out pos))
|
|
{
|
|
zhi1obj.transform.position = pos + posOffset;
|
|
zhi1obj.GetComponent<RectTransform>().position = offset + pos;
|
|
}
|
|
}
|
|
else if (eventData.button == PointerEventData.InputButton.Right)
|
|
{
|
|
//Rotation();
|
|
}
|
|
}
|
|
|
|
string currentDragName;
|
|
public void SetZhiModel(string objName)
|
|
{
|
|
currentDragName = objName;
|
|
if (currentDragName.Equals("icon1"))
|
|
zhi1obj.SetActive(true);
|
|
else
|
|
zhi2obj.SetActive(true);
|
|
carobj3Tip.SetActive(true);
|
|
isDrag = false;
|
|
isEnd = true;
|
|
answerbool[1] = true;
|
|
}
|
|
}
|
|
} |