2024-10-23 17:55:55 +08:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections;
|
|
|
|
|
using System.Collections.Generic;
|
2024-11-21 09:35:48 +08:00
|
|
|
|
using System.Linq;
|
|
|
|
|
using cfg;
|
2024-12-18 11:12:52 +08:00
|
|
|
|
using TTSDK;
|
2024-12-20 18:19:39 +08:00
|
|
|
|
using TTSDK.UNBridgeLib.LitJson;
|
2024-11-08 18:21:41 +08:00
|
|
|
|
// using Unity.VisualScripting;
|
2024-10-23 17:55:55 +08:00
|
|
|
|
using UnityEngine;
|
2024-10-24 16:54:32 +08:00
|
|
|
|
using Random = UnityEngine.Random;
|
2024-10-23 17:55:55 +08:00
|
|
|
|
|
|
|
|
|
public class GameManager : MonoBehaviour
|
|
|
|
|
{
|
|
|
|
|
public static GameManager ins;
|
2024-11-26 15:44:50 +08:00
|
|
|
|
public TaskSystem taskSystem;
|
|
|
|
|
public SoundSystem soundSystem;
|
2024-11-05 18:15:49 +08:00
|
|
|
|
private JsonTab _tab;
|
2024-10-24 16:54:32 +08:00
|
|
|
|
public bool start;
|
2024-10-23 17:55:55 +08:00
|
|
|
|
public Camera mainCamera;
|
2024-11-29 21:37:01 +08:00
|
|
|
|
public int ChapterId => chapterId;
|
|
|
|
|
private int chapterId;
|
2024-11-08 18:21:41 +08:00
|
|
|
|
public int level => levelID;
|
|
|
|
|
private int levelID;
|
2024-11-26 15:44:50 +08:00
|
|
|
|
public float NowLenght => nowLenght;
|
|
|
|
|
private float nowLenght=0;
|
2024-10-23 17:55:55 +08:00
|
|
|
|
public List<ItemData> itemDatas;
|
2024-10-24 16:54:32 +08:00
|
|
|
|
public List<ItemData> itemDatas1;
|
|
|
|
|
public List<ItemData> itemDatas2;
|
2024-11-04 17:29:11 +08:00
|
|
|
|
public List<RandomItemData> list;
|
2024-12-18 15:31:01 +08:00
|
|
|
|
public float NowTime => nowTime;
|
2024-12-04 17:26:27 +08:00
|
|
|
|
private float nowTime=0;
|
2024-12-18 11:12:52 +08:00
|
|
|
|
public bool firstPlay = true;
|
2024-11-26 15:44:50 +08:00
|
|
|
|
[SerializeField] public AssetData _data;
|
|
|
|
|
#if UNITY_EDITOR
|
2024-11-21 10:26:47 +08:00
|
|
|
|
[InspectorButton]
|
2024-11-26 15:44:50 +08:00
|
|
|
|
#endif
|
2024-11-21 10:26:47 +08:00
|
|
|
|
private void PlayerPrefsClear()
|
|
|
|
|
{
|
|
|
|
|
PlayerPrefs.DeleteAll();
|
|
|
|
|
}
|
|
|
|
|
|
2024-10-31 17:38:26 +08:00
|
|
|
|
public ItemObj seletObj
|
|
|
|
|
{
|
|
|
|
|
get { return seletItem; }
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
seletItem = value;
|
|
|
|
|
if (seletUnlock!=null)
|
|
|
|
|
{
|
|
|
|
|
seletUnlock.transform.position = MapManager.ins.lockParent.position;
|
|
|
|
|
seletUnlock = null;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private ItemObj seletItem;
|
|
|
|
|
|
|
|
|
|
public UnLockGrid seletUnlock
|
|
|
|
|
{
|
|
|
|
|
get { return seletLockObj; }
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
seletLockObj = value;
|
|
|
|
|
if (seletObj != null)
|
|
|
|
|
{
|
|
|
|
|
ItemSystem.ins.GetGridsRest(seletObj.startGrid, seletObj);
|
|
|
|
|
seletObj = null;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
private UnLockGrid seletLockObj;
|
2024-10-23 17:55:55 +08:00
|
|
|
|
public Grid stopGrid;
|
|
|
|
|
private Vector3 oldvec;
|
2024-10-24 16:54:32 +08:00
|
|
|
|
public int index = 2;
|
2024-10-23 17:55:55 +08:00
|
|
|
|
[SerializeField] private float scale=0.2f;
|
|
|
|
|
private void Awake()
|
|
|
|
|
{
|
2024-12-18 11:12:52 +08:00
|
|
|
|
TT.InitSDK((code, env) =>
|
|
|
|
|
{
|
|
|
|
|
ins = this;
|
|
|
|
|
_tab = new JsonTab();
|
|
|
|
|
_tab.InitData();
|
|
|
|
|
_data.InitData();
|
|
|
|
|
firstPlay = true;
|
2024-12-21 14:11:17 +08:00
|
|
|
|
TT.ReportAnalytics<string>("a10101");
|
|
|
|
|
DotData.ins.SendEvent("a10101","");
|
2024-12-18 11:12:52 +08:00
|
|
|
|
MainPanel.ins.ClosePanelEvent();
|
|
|
|
|
});
|
2024-12-20 18:19:39 +08:00
|
|
|
|
TT.SendToTAQ(new JsonData
|
|
|
|
|
{
|
|
|
|
|
["event_type"] = "active"
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
TT.SendToTAQ(new JsonData
|
|
|
|
|
{
|
|
|
|
|
["event_type"] = "next_day_open"
|
|
|
|
|
});
|
2024-10-23 17:55:55 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void Start()
|
|
|
|
|
{
|
2024-10-24 16:54:32 +08:00
|
|
|
|
|
2024-10-23 17:55:55 +08:00
|
|
|
|
}
|
|
|
|
|
|
2024-11-26 15:44:50 +08:00
|
|
|
|
public void SaveNowLenght(float lenght)
|
|
|
|
|
{
|
|
|
|
|
nowLenght = lenght;
|
|
|
|
|
}
|
2024-11-29 21:37:01 +08:00
|
|
|
|
public void ResetPack(List<RandomItemData> random,Action action)
|
2024-10-24 16:54:32 +08:00
|
|
|
|
{
|
|
|
|
|
start = true;
|
|
|
|
|
index = 2;
|
2024-11-05 18:15:49 +08:00
|
|
|
|
// var indexID = Random.Range(0, 4);
|
2024-11-04 17:29:11 +08:00
|
|
|
|
// switch (indexID)
|
|
|
|
|
// {
|
|
|
|
|
// case 0:
|
|
|
|
|
// ItemSystem.ins.InitItem(itemDatas);
|
|
|
|
|
// break;
|
|
|
|
|
// case 1:
|
|
|
|
|
// ItemSystem.ins.InitItem(itemDatas1);
|
|
|
|
|
// break;
|
|
|
|
|
// case 2:
|
|
|
|
|
// ItemSystem.ins.InitItem(itemDatas2);
|
|
|
|
|
// break;
|
|
|
|
|
// default:
|
|
|
|
|
// ItemSystem.ins.InitItem(itemDatas);
|
|
|
|
|
// break;
|
|
|
|
|
// }
|
2024-11-29 21:37:01 +08:00
|
|
|
|
StartCoroutine(ItemSystem.ins.RandomItem(random, () =>
|
|
|
|
|
{
|
|
|
|
|
action.Invoke();
|
|
|
|
|
MapManager.ins.PlayBoxOpen();
|
|
|
|
|
MapManager.ins.ResetLockGrid();
|
|
|
|
|
ItemSystem.ins.ResetItemOrder();
|
2024-12-18 11:12:52 +08:00
|
|
|
|
|
2024-11-29 21:37:01 +08:00
|
|
|
|
}));
|
|
|
|
|
|
2024-11-21 09:35:48 +08:00
|
|
|
|
}
|
|
|
|
|
|
2024-11-26 15:44:50 +08:00
|
|
|
|
public void ResetLevel(int id,Action action)
|
2024-11-21 09:35:48 +08:00
|
|
|
|
{
|
2024-11-26 15:44:50 +08:00
|
|
|
|
StartCoroutine(ResetIE(id, action));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
IEnumerator ResetIE(int id,Action action)
|
|
|
|
|
{
|
2024-11-29 21:37:01 +08:00
|
|
|
|
BoxDebug.Log("开始关卡,当前关卡id:" +id);
|
2024-11-21 09:35:48 +08:00
|
|
|
|
var data = JsonTab.Instance.tables.Level.Get(id);
|
|
|
|
|
BoxDebug.Log("关卡数据" + data);
|
|
|
|
|
levelID = id;
|
|
|
|
|
var itemData = JsonTab.Instance.tables.RandomProp.Get(data.ItemList);
|
|
|
|
|
BoxDebug.Log("关卡随机道具表数据" +itemData);
|
|
|
|
|
var maxTypeweight = 0;
|
|
|
|
|
foreach (var weight in itemData.Typeweight)
|
|
|
|
|
{
|
|
|
|
|
maxTypeweight += weight;
|
|
|
|
|
}
|
2024-11-26 15:44:50 +08:00
|
|
|
|
yield return null;
|
2024-11-21 09:35:48 +08:00
|
|
|
|
BoxDebug.Log("道具总权重"+maxTypeweight);
|
|
|
|
|
var maxLevelWeight=0;
|
|
|
|
|
foreach (var weight in itemData.Levelweight)
|
|
|
|
|
{
|
|
|
|
|
maxLevelWeight += weight;
|
|
|
|
|
}
|
2024-11-26 15:44:50 +08:00
|
|
|
|
yield return null;
|
2024-11-21 09:35:48 +08:00
|
|
|
|
BoxDebug.Log("等级总权重"+maxLevelWeight);
|
|
|
|
|
|
|
|
|
|
int[] propNum = new int[itemData.Typeweight.Count];
|
|
|
|
|
for (int i = 0; i < itemData.Typeweight.Count; i++)
|
|
|
|
|
{
|
|
|
|
|
float a = (float)itemData.Typeweight[i] / (float)maxTypeweight;
|
|
|
|
|
propNum[i] = (int)(itemData.Grids * a);
|
|
|
|
|
BoxDebug.Log("道具类型"+itemData.Propid[i]+"的数量为:"+propNum);
|
|
|
|
|
}
|
2024-11-26 15:44:50 +08:00
|
|
|
|
yield return null;
|
2024-11-21 09:35:48 +08:00
|
|
|
|
List<RandomItemData> randomItemlist = new List<RandomItemData>();
|
|
|
|
|
for (int i = 0; i < propNum.Length; i++)
|
|
|
|
|
{
|
|
|
|
|
var num = propNum[i];
|
|
|
|
|
for (int j = 0; j < itemData.Levelweight.Count; j++)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
float a = (float)itemData.Levelweight[j] / (float)maxLevelWeight;
|
|
|
|
|
var levelNum = (int)(num*a);
|
|
|
|
|
RandomItemData randomItemData = new RandomItemData();
|
|
|
|
|
randomItemData.num = levelNum;
|
|
|
|
|
randomItemData.level = j+1;
|
|
|
|
|
var itemID = (from bProp in JsonTab.Instance.tables.Prop.DataList where bProp.PropType == itemData.Propid[i] && bProp.Proplevel == j + 1 select bProp.ID).FirstOrDefault();
|
|
|
|
|
|
|
|
|
|
randomItemData.itemID = itemID;
|
|
|
|
|
var propData = JsonTab.Instance.tables.Prop.DataList.FirstOrDefault(bProp => bProp.PropType == itemData.Propid[i]);
|
|
|
|
|
|
|
|
|
|
randomItemData.item = ItemSystem.ins.itemObj(propData.Preform);
|
|
|
|
|
randomItemlist.Add(randomItemData);
|
|
|
|
|
BoxDebug.Log("道具id:"+randomItemData.itemID+",数量"+randomItemData.num+",等级"+randomItemData.level);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
list = randomItemlist;
|
2024-11-29 21:37:01 +08:00
|
|
|
|
ResetPack(list,action);
|
|
|
|
|
MapManager.ins.InitLockData();
|
2024-11-26 15:44:50 +08:00
|
|
|
|
MapManager.ins.RandomUnlock();
|
2024-12-18 11:12:52 +08:00
|
|
|
|
videoBo = true;
|
2024-11-26 15:44:50 +08:00
|
|
|
|
yield return null;
|
2024-12-04 17:26:27 +08:00
|
|
|
|
nowTime = 0;
|
2024-10-24 16:54:32 +08:00
|
|
|
|
}
|
|
|
|
|
|
2024-12-18 11:12:52 +08:00
|
|
|
|
public bool VideoBo => videoBo;
|
|
|
|
|
private bool videoBo = false;
|
|
|
|
|
|
|
|
|
|
public void OpenVideoLock()
|
|
|
|
|
{
|
|
|
|
|
videoBo = true;
|
|
|
|
|
MainPanel.ins.ResetPackLockButtonRest();
|
|
|
|
|
}
|
2024-10-24 16:54:32 +08:00
|
|
|
|
public void PackEvent()
|
|
|
|
|
{
|
|
|
|
|
index--;
|
|
|
|
|
if (index<=0)
|
|
|
|
|
{
|
|
|
|
|
bool win = true;
|
|
|
|
|
foreach (var item in ItemSystem.ins.itemObjs)
|
|
|
|
|
{
|
|
|
|
|
if (item.type==GridType.wait)
|
|
|
|
|
{
|
|
|
|
|
win = false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
start = false;
|
2024-10-29 15:22:32 +08:00
|
|
|
|
MapManager.ins.PlayBoxClose();
|
2024-11-21 09:35:48 +08:00
|
|
|
|
MainPanel.ins.StartTourPanel();
|
2024-12-17 13:37:43 +08:00
|
|
|
|
nowTime = 0;
|
2024-10-24 16:54:32 +08:00
|
|
|
|
return;
|
|
|
|
|
}
|
2024-10-29 15:22:32 +08:00
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
MapManager.ins.PlayBoxClose(()=>
|
|
|
|
|
{
|
|
|
|
|
MapManager.ins.PlayBoxOpen();
|
|
|
|
|
});
|
|
|
|
|
}
|
2024-10-24 16:54:32 +08:00
|
|
|
|
|
|
|
|
|
ItemSystem.ins.PackItem();
|
|
|
|
|
}
|
2024-11-29 21:37:01 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// 刷新背包获得道具数据
|
|
|
|
|
/// </summary>
|
2024-11-21 09:35:48 +08:00
|
|
|
|
public void ResetPropattributes()
|
|
|
|
|
{
|
|
|
|
|
ItemSystem.ins.ResetPropattributes();
|
|
|
|
|
MainPanel.ins.ResetPropattributes();
|
|
|
|
|
}
|
2024-10-23 17:55:55 +08:00
|
|
|
|
private void Update()
|
|
|
|
|
{
|
2024-12-17 13:37:43 +08:00
|
|
|
|
if (start)
|
|
|
|
|
{
|
|
|
|
|
nowTime += Time.deltaTime;
|
|
|
|
|
if (nowTime>=300)
|
|
|
|
|
{
|
|
|
|
|
index=0;
|
|
|
|
|
PackEvent();
|
|
|
|
|
}
|
|
|
|
|
}
|
2024-10-23 17:55:55 +08:00
|
|
|
|
if (Input.GetMouseButtonDown(0))
|
|
|
|
|
{
|
|
|
|
|
oldvec = Input.mousePosition;
|
|
|
|
|
}
|
|
|
|
|
if (Input.GetMouseButtonUp(0))
|
|
|
|
|
{
|
2024-11-04 17:29:11 +08:00
|
|
|
|
if (seletUnlock!=null )
|
2024-10-23 17:55:55 +08:00
|
|
|
|
{
|
2024-11-04 17:29:11 +08:00
|
|
|
|
if (stopGrid!=null&& MapManager.ins.UnLockOpen(stopGrid,seletUnlock.openData))
|
|
|
|
|
{
|
|
|
|
|
MapManager.ins.LockRayRest(stopGrid, seletUnlock.openData,out var bo);
|
2024-11-26 15:44:50 +08:00
|
|
|
|
soundSystem.PlaceAudio();
|
2024-12-16 18:25:45 +08:00
|
|
|
|
MapManager.ins.ResetRayLockGrid();
|
|
|
|
|
MapManager.ins.LockAddData();
|
2024-12-18 11:12:52 +08:00
|
|
|
|
MapManager.ins.CloseUnlock();
|
|
|
|
|
videoBo = false;
|
|
|
|
|
MainPanel.ins.ResetPackLockButtonRest();
|
2024-12-16 18:25:45 +08:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
MapManager.ins.ResetRayLockGrid();
|
|
|
|
|
MapManager.ins.ResetUnlock();
|
2024-11-04 17:29:11 +08:00
|
|
|
|
}
|
2024-11-21 09:35:48 +08:00
|
|
|
|
seletUnlock = null;
|
2024-10-31 17:38:26 +08:00
|
|
|
|
}
|
2024-11-26 15:44:50 +08:00
|
|
|
|
if (seletObj!= null)
|
2024-10-31 17:38:26 +08:00
|
|
|
|
{
|
2024-11-21 09:35:48 +08:00
|
|
|
|
BoxDebug.Log(stopGrid);
|
|
|
|
|
BoxDebug.Log(stopGrid.GetItemObj());
|
2024-11-26 15:44:50 +08:00
|
|
|
|
if (stopGrid!= null && stopGrid.GetItemObj()!= null&& stopGrid.GetItemObj()!=seletObj)
|
2024-10-23 17:55:55 +08:00
|
|
|
|
{
|
2024-11-04 17:29:11 +08:00
|
|
|
|
ItemSystem.ins.ItemLevelUp(stopGrid.GetItemObj(), seletObj);
|
2024-11-26 15:44:50 +08:00
|
|
|
|
ItemSystem.ins.ResetWaitGrid();
|
2024-10-23 17:55:55 +08:00
|
|
|
|
}
|
2024-11-04 17:29:11 +08:00
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (MapManager.ins.openSave(stopGrid,seletObj))
|
|
|
|
|
{
|
|
|
|
|
foreach (var grid in seletObj._grids)
|
|
|
|
|
{
|
|
|
|
|
switch (grid.Type)
|
|
|
|
|
{
|
|
|
|
|
case GridType.box:
|
|
|
|
|
grid.item = null;
|
|
|
|
|
break;
|
|
|
|
|
case GridType.wait:
|
2024-11-21 09:35:48 +08:00
|
|
|
|
grid.Remove(seletObj);
|
2024-11-04 17:29:11 +08:00
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
throw new ArgumentOutOfRangeException();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
seletObj.startGrid = stopGrid;
|
2024-11-26 15:44:50 +08:00
|
|
|
|
soundSystem.PlaceAudio();
|
2024-11-04 17:29:11 +08:00
|
|
|
|
ItemSystem.ins.GetGridsRest(seletObj.startGrid, seletObj);
|
2024-11-26 15:44:50 +08:00
|
|
|
|
ItemSystem.ins.ResetWaitGrid();
|
2024-11-04 17:29:11 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (seletObj!=null)
|
|
|
|
|
{
|
|
|
|
|
ItemSystem.ins.SetPosition(seletObj, seletObj.startGrid);
|
|
|
|
|
}
|
2024-10-23 17:55:55 +08:00
|
|
|
|
|
2024-11-04 17:29:11 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ItemSystem.ins.ResetItemOrder();
|
|
|
|
|
stopGrid = null;
|
|
|
|
|
seletObj = null;
|
2024-12-28 18:48:02 +08:00
|
|
|
|
// if (ItemSystem.ins.WaitGridIsNull())
|
|
|
|
|
// {
|
|
|
|
|
// StartCoroutine(ItemSystem.ins.AddNewItem());
|
|
|
|
|
// }
|
2024-11-04 17:29:11 +08:00
|
|
|
|
MapManager.ins.ResetAnimation();
|
2024-11-21 09:35:48 +08:00
|
|
|
|
ResetPropattributes();
|
2024-10-23 17:55:55 +08:00
|
|
|
|
}
|
2024-11-04 17:29:11 +08:00
|
|
|
|
|
2024-10-31 17:38:26 +08:00
|
|
|
|
|
2024-11-04 17:29:11 +08:00
|
|
|
|
|
2024-10-29 15:22:32 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (seletObj!=null)
|
|
|
|
|
{
|
|
|
|
|
Ray rays = mainCamera.ScreenPointToRay(Input.mousePosition);
|
|
|
|
|
RaycastHit hits;
|
|
|
|
|
if (Physics.Raycast(rays, out hits))
|
|
|
|
|
{
|
|
|
|
|
//射线检测,第三个参数可根据需求设置或不设置,具体看api;
|
|
|
|
|
Physics.Raycast(rays, out hits, 500000);
|
|
|
|
|
Vector3 mousePos = hits.point+seletObj.mouseDev;
|
|
|
|
|
if (MapManager.ins.GetRegionGridType(mousePos,out var type))
|
|
|
|
|
{
|
|
|
|
|
MapManager.ins.RegionGrid(mousePos, type, out var grid);
|
|
|
|
|
if (stopGrid!=grid)
|
|
|
|
|
{
|
|
|
|
|
stopGrid = grid;
|
|
|
|
|
MapManager.ins.RegionGridBack(stopGrid, seletObj.itemSize.x+stopGrid.X, seletObj.itemSize.y+stopGrid.Y);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2024-10-23 17:55:55 +08:00
|
|
|
|
}
|
2024-10-31 17:38:26 +08:00
|
|
|
|
|
|
|
|
|
if (seletUnlock!=null)
|
|
|
|
|
{
|
|
|
|
|
Ray rays = mainCamera.ScreenPointToRay(Input.mousePosition);
|
|
|
|
|
RaycastHit hits;
|
|
|
|
|
if (Physics.Raycast(rays, out hits))
|
|
|
|
|
{
|
|
|
|
|
//射线检测,第三个参数可根据需求设置或不设置,具体看api;
|
|
|
|
|
Physics.Raycast(rays, out hits, 500000);
|
|
|
|
|
Vector3 mousePos = hits.point + seletUnlock.mouseDev;
|
|
|
|
|
if (MapManager.ins.GetRegionGridType(mousePos,out var type))
|
|
|
|
|
{
|
|
|
|
|
MapManager.ins.RegionGrid(mousePos, type, out var grid);
|
2024-11-29 21:37:01 +08:00
|
|
|
|
BoxDebug.Log(stopGrid+" "+ grid);
|
2024-10-31 17:38:26 +08:00
|
|
|
|
if (stopGrid!=grid)
|
|
|
|
|
{
|
|
|
|
|
stopGrid = grid;
|
2024-11-04 17:29:11 +08:00
|
|
|
|
MapManager.ins.RayToutchGrid(stopGrid, seletUnlock.openData);
|
2024-10-31 17:38:26 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2024-10-24 16:54:32 +08:00
|
|
|
|
if (Input.GetMouseButton(0) && seletObj!=null&& start)
|
2024-10-23 17:55:55 +08:00
|
|
|
|
{
|
|
|
|
|
Ray ray = mainCamera.ScreenPointToRay(Input.mousePosition);
|
|
|
|
|
RaycastHit hit;
|
|
|
|
|
//射线检测,第三个参数可根据需求设置或不设置,具体看api;
|
|
|
|
|
Physics.Raycast(ray, out hit, 500000);
|
|
|
|
|
Vector3 mousePos = hit.point;
|
|
|
|
|
seletObj.transform.position = mousePos;
|
|
|
|
|
}
|
|
|
|
|
|
2024-11-04 17:29:11 +08:00
|
|
|
|
if (Input.GetMouseButton(0) && seletUnlock!= null && start)
|
|
|
|
|
{
|
|
|
|
|
Ray ray = mainCamera.ScreenPointToRay(Input.mousePosition);
|
|
|
|
|
RaycastHit hit;
|
|
|
|
|
//射线检测,第三个参数可根据需求设置或不设置,具体看api;
|
|
|
|
|
Physics.Raycast(ray, out hit, 500000);
|
|
|
|
|
Vector3 mousePos = hit.point;
|
|
|
|
|
seletUnlock.transform.position = mousePos;
|
|
|
|
|
}
|
2024-10-23 17:55:55 +08:00
|
|
|
|
}
|
|
|
|
|
}
|