93 lines
3.5 KiB
C#
93 lines
3.5 KiB
C#
|
|
using System;
|
||
|
|
using System.Collections;
|
||
|
|
using System.Collections.Generic;
|
||
|
|
using UnityEngine;
|
||
|
|
using UnityEngine.EventSystems;
|
||
|
|
|
||
|
|
public class InGameTouchInfo : MonoBehaviourSingletonTemplate<InGameTouchInfo>
|
||
|
|
{
|
||
|
|
private void Start()
|
||
|
|
{
|
||
|
|
//var uiel = UIEventListener.Get(transform.GetChild(0).gameObject);
|
||
|
|
//uiel.onClick += OnClick;
|
||
|
|
//uiel.onDrag += OnDrag;
|
||
|
|
//uiel.onPress += OnPress;
|
||
|
|
}
|
||
|
|
|
||
|
|
private void OnPress(GameObject go, bool state)
|
||
|
|
{
|
||
|
|
//// 마우스 위치를 화면 좌표에서 월드 좌표로 변환
|
||
|
|
//Vector3 worldPos = UICamera.mainCamera.ScreenToWorldPoint(Input.mousePosition);
|
||
|
|
|
||
|
|
//// 월드 좌표를 NGUI 좌표로 변환
|
||
|
|
//Vector3 localPos = tf_joystick.parent.InverseTransformPoint(worldPos);
|
||
|
|
|
||
|
|
//// 변환된 좌표를 조이스틱 위치로 설정
|
||
|
|
//tf_joystick.localPosition = localPos;
|
||
|
|
}
|
||
|
|
|
||
|
|
//public void OnClick(GameObject _go)
|
||
|
|
private void Update()
|
||
|
|
{
|
||
|
|
//if (InGameInfo.Ins.IsGameMode(eGameMode.Lobby)) return;
|
||
|
|
|
||
|
|
if (Input.GetMouseButtonDown(0))
|
||
|
|
{
|
||
|
|
//bool noAction = true;
|
||
|
|
Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
|
||
|
|
var hits = Physics.RaycastAll(ray);
|
||
|
|
for (int i = 0; i < hits.Length; i++)
|
||
|
|
{
|
||
|
|
switch (hits[i].collider.tag)
|
||
|
|
{
|
||
|
|
// 이동이 생겨서 터치로 아이템 먹는 거 제거 (대신 가까이 가면 먹음)
|
||
|
|
//case "DropItem":
|
||
|
|
// noAction = false;
|
||
|
|
// hits[i].collider.GetComponent<DropItem>().ItemTouch();
|
||
|
|
// break;
|
||
|
|
case "Mob":
|
||
|
|
//noAction = false;
|
||
|
|
MonsterSimpleInfo.Ins.Set(hits[i].collider.GetComponent<Actor>());
|
||
|
|
//MyValue.MyPC.Change_Target(true, hits[i].collider.GetComponent<Actor>());
|
||
|
|
break;
|
||
|
|
case "ChapterClear":
|
||
|
|
if (hits[i].collider.GetComponent<MapControlBase>().IsChapterClearCondition())
|
||
|
|
InGameInfo.Ins.Clear_Chapter();
|
||
|
|
break;
|
||
|
|
case "Stone":
|
||
|
|
if (hits[i].collider.GetComponent<StoneActor>() != null)
|
||
|
|
MyValue.MyPC.Change_Target(true, hits[i].collider.GetComponent<StoneActor>());
|
||
|
|
break;
|
||
|
|
default:
|
||
|
|
if (hits[i].collider.GetComponent<CarActor>() != null)
|
||
|
|
MyValue.MyPC.Change_Target(true, hits[i].collider.GetComponent<CarActor>());
|
||
|
|
break;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
//if (noAction)
|
||
|
|
//{
|
||
|
|
// if (Physics.Raycast(ray, out RaycastHit hit))
|
||
|
|
// {
|
||
|
|
// if (MyValue.MyPC.Check_Path(hit.point))
|
||
|
|
// {
|
||
|
|
// if (MyValue.MyPC.Run_Destination(hit.point, go_Mark))
|
||
|
|
// {
|
||
|
|
// go_Mark.transform.position = hit.point;
|
||
|
|
// go_Mark.SetActive(true);
|
||
|
|
// }
|
||
|
|
// }
|
||
|
|
// }
|
||
|
|
//}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
public void OnDrag(GameObject go, Vector2 delta)
|
||
|
|
{
|
||
|
|
//var x = Math.Abs(delta.x);
|
||
|
|
//if (x > 4f) m_RealCamera.Set_Axis(true, delta.x * 0.03f);
|
||
|
|
|
||
|
|
//var y = Math.Abs(delta.y);
|
||
|
|
//if (y > 4f) m_RealCamera.Set_Axis(false, delta.y * 0.01f);
|
||
|
|
}
|
||
|
|
}
|