2024-11-08 18:21:41 +08:00
|
|
|
using System;
|
|
|
|
using System.Collections;
|
|
|
|
using System.Collections.Generic;
|
2024-11-21 09:35:48 +08:00
|
|
|
using cfg;
|
|
|
|
using DG.Tweening;
|
2024-11-29 21:37:01 +08:00
|
|
|
using Spine.Unity;
|
2024-11-21 09:35:48 +08:00
|
|
|
using TMPro;
|
2024-11-08 18:21:41 +08:00
|
|
|
using UnityEngine;
|
|
|
|
using UnityEngine.UI;
|
2024-11-21 09:35:48 +08:00
|
|
|
using Random = UnityEngine.Random;
|
2024-11-08 18:21:41 +08:00
|
|
|
|
|
|
|
public class TourPanel : MonoBehaviour
|
|
|
|
{
|
|
|
|
[SerializeField] private Slider[] _sliders;
|
2024-11-13 16:56:37 +08:00
|
|
|
[SerializeField] private RectTransform[] _sliderTra;
|
2024-11-21 09:35:48 +08:00
|
|
|
[SerializeField] private RectTransform[] _rectTrans;
|
2024-11-29 21:37:01 +08:00
|
|
|
[SerializeField] private GameObject[] mapIcon;
|
2024-11-21 09:35:48 +08:00
|
|
|
[SerializeField] private RectTransform randomParent;
|
2024-11-13 16:56:37 +08:00
|
|
|
[SerializeField] private RectTransform endTransform;
|
2024-11-29 21:37:01 +08:00
|
|
|
[SerializeField] private RectTransform targtsTransform;
|
2024-11-21 09:35:48 +08:00
|
|
|
[SerializeField] private RectTransform playerMove;
|
|
|
|
[SerializeField] private RectTransform startPoint;
|
|
|
|
[SerializeField] private GameObject eventObj;
|
2024-11-29 21:37:01 +08:00
|
|
|
[SerializeField] private TextMeshProUGUI eventTitle;
|
2024-12-18 16:12:31 +08:00
|
|
|
[SerializeField] private Text eventText1;
|
|
|
|
[SerializeField] private Text eventText2;
|
2024-11-29 21:37:01 +08:00
|
|
|
[SerializeField] private GameObject event1Video;
|
|
|
|
[SerializeField] private GameObject event2Video;
|
2024-11-26 15:44:50 +08:00
|
|
|
[SerializeField] private Button eventButton1;
|
|
|
|
[SerializeField] private Button eventButton2;
|
|
|
|
[SerializeField] private Button close;
|
|
|
|
[SerializeField] private Button settingButton;
|
|
|
|
[SerializeField] private Button audioButton;
|
|
|
|
[SerializeField] private Button soundEffectsButton;
|
2024-11-21 09:35:48 +08:00
|
|
|
[SerializeField] private float timeScale = 1;
|
2024-11-13 16:56:37 +08:00
|
|
|
[SerializeField] private int testLangh;
|
2024-11-21 09:35:48 +08:00
|
|
|
[SerializeField] private float[] lengh = new float[4];
|
2024-11-26 15:44:50 +08:00
|
|
|
[SerializeField] private float lenght = 5000;
|
2024-11-21 09:35:48 +08:00
|
|
|
[SerializeField] private bool playing = false;
|
|
|
|
[SerializeField] private TextItem _textItem;
|
|
|
|
[SerializeField] private EventSystem _travelEvent;
|
|
|
|
[SerializeField] private TextMeshProUGUI speedText;
|
|
|
|
[SerializeField] private TextMeshProUGUI timeText;
|
|
|
|
[SerializeField] private TextMeshProUGUI pointsText;
|
|
|
|
[SerializeField] private List<NodeEventData> _eventlist = new List<NodeEventData>();
|
2024-11-26 15:44:50 +08:00
|
|
|
[SerializeField] private GameObject settingObj;
|
2024-11-21 09:35:48 +08:00
|
|
|
private List<GameObject> _randomList = new List<GameObject>();
|
2024-11-26 15:44:50 +08:00
|
|
|
private List<TaskEvent> events;
|
2024-11-21 09:35:48 +08:00
|
|
|
private int maxIndex = 0;
|
|
|
|
private float nowLenght = 0;
|
|
|
|
private float nowTime = 0;
|
2024-11-26 15:44:50 +08:00
|
|
|
private float moveTime;
|
2024-11-21 09:35:48 +08:00
|
|
|
|
|
|
|
|
2024-11-26 15:44:50 +08:00
|
|
|
private float speed;
|
|
|
|
private float points;
|
2024-11-21 09:35:48 +08:00
|
|
|
private float pointsRatio;
|
|
|
|
private float pointsNow = 0;
|
|
|
|
private float textTime=0;
|
2024-11-26 15:44:50 +08:00
|
|
|
private bool targets = false;
|
|
|
|
private float targtsLanght;
|
2024-11-21 09:35:48 +08:00
|
|
|
#if UNITY_EDITOR
|
2024-11-13 16:56:37 +08:00
|
|
|
[InspectorButton]
|
2024-11-21 09:35:48 +08:00
|
|
|
#endif
|
2024-11-13 16:56:37 +08:00
|
|
|
public void Test()
|
2024-11-08 18:21:41 +08:00
|
|
|
{
|
2024-11-21 09:35:48 +08:00
|
|
|
|
2024-11-13 16:56:37 +08:00
|
|
|
}
|
2024-11-21 09:35:48 +08:00
|
|
|
|
|
|
|
public void StartVoid()
|
2024-11-13 16:56:37 +08:00
|
|
|
{
|
2024-11-21 09:35:48 +08:00
|
|
|
BoxDebug.Log("开始旅行界面");
|
|
|
|
lengh[0] = (_rectTrans[1].position - _rectTrans[0].position).magnitude;
|
|
|
|
lengh[1] = (_rectTrans[2].position - _rectTrans[1].position).magnitude;
|
|
|
|
lengh[2] = (_rectTrans[3].position - _rectTrans[2].position).magnitude;
|
|
|
|
lengh[3] = (_rectTrans[0].position - _rectTrans[3].position).magnitude;
|
|
|
|
var levelData = JsonTab.Instance.tables.Level.Get(GameManager.ins.level);
|
2024-11-26 15:44:50 +08:00
|
|
|
lenght = levelData.Length;
|
|
|
|
targtsLanght = (float)levelData.Length * ((float)levelData.Target / 10000);
|
|
|
|
targets = true;
|
|
|
|
events = new List<TaskEvent>();
|
|
|
|
events.Add(addTaskEvent(levelData.Maintasks));
|
|
|
|
foreach (var taskID in levelData.Additionaltasks)
|
|
|
|
{
|
|
|
|
events.Add(addTaskEvent(taskID));
|
|
|
|
}
|
|
|
|
|
2024-11-21 09:35:48 +08:00
|
|
|
_eventlist = new List<NodeEventData>();
|
|
|
|
for (var i = 0; i < levelData.Nodelocation.Count; i++)
|
2024-11-08 18:21:41 +08:00
|
|
|
{
|
2024-11-21 09:35:48 +08:00
|
|
|
var data = new NodeEventData();
|
2024-11-26 15:44:50 +08:00
|
|
|
data.lenght = ((float)levelData.Nodelocation[i])/100*lenght;
|
2024-11-21 09:35:48 +08:00
|
|
|
_eventlist.Add(data);
|
|
|
|
}
|
|
|
|
|
|
|
|
for (int i = 0; i < levelData.Eventgroupid.Count; i++)
|
|
|
|
{
|
|
|
|
_eventlist[i].eventTeamID = levelData.Eventgroupid[i];
|
|
|
|
}
|
|
|
|
|
|
|
|
for (int i = 0; i < _eventlist.Count; i++)
|
|
|
|
{
|
|
|
|
_eventlist[i].eventID = GetEventID(_eventlist[i].eventTeamID);
|
2024-11-26 15:44:50 +08:00
|
|
|
_eventlist[i].eventIDvideo = GetEventVideoID(_eventlist[i].eventTeamID);
|
2024-11-21 09:35:48 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
for (int i = 0; i < _randomList.Count; i++)
|
|
|
|
{
|
|
|
|
Destroy(_randomList[i]);
|
|
|
|
}
|
|
|
|
_randomList.Clear();
|
|
|
|
for (var i = 0; i < _eventlist.Count; i++)
|
|
|
|
{
|
|
|
|
var obj = Instantiate(endTransform.gameObject, randomParent);
|
2024-11-26 15:44:50 +08:00
|
|
|
var data = JsonTab.Instance.tables.Eventgroup.Get(_eventlist[i].eventTeamID);
|
|
|
|
obj.GetComponent<Image>().sprite=Resources.Load<Sprite>("Icon/"+data.Icon);
|
2024-11-29 21:37:01 +08:00
|
|
|
obj.GetComponentInChildren<SkeletonGraphic>().Skeleton.SetSkin(data.Icon == "shijian" ? "box" : "coffer");
|
|
|
|
obj.GetComponentInChildren<SkeletonGraphic>().Skeleton.SetSlotsToSetupPose();
|
2024-11-21 09:35:48 +08:00
|
|
|
_randomList.Add(obj);
|
|
|
|
Move(obj.transform, _eventlist[i].lenght);
|
|
|
|
}
|
2024-11-29 21:37:01 +08:00
|
|
|
var chapterData = JsonTab.Instance.tables.Chapter.Get(DataManager.chapter);
|
|
|
|
for (int i = 0; i < chapterData.Contain.Count; i++)
|
|
|
|
{
|
|
|
|
if (DataManager.LevelOpen(chapterData.Contain[i])||chapterData.Contain[i]==GameManager.ins.level)
|
|
|
|
{
|
|
|
|
// mapIcon[i].SetActive(true);
|
|
|
|
mapIcon[i].GetComponent<Image>().color = Color.white;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// mapIcon[i].SetActive(false);
|
|
|
|
mapIcon[i].GetComponent<Image>().color = Color.gray;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Move(targtsTransform,targtsLanght);
|
2024-11-26 15:44:50 +08:00
|
|
|
InitDisplayData();
|
|
|
|
}
|
|
|
|
|
|
|
|
private void InitDisplayData()
|
|
|
|
{
|
2024-11-21 09:35:48 +08:00
|
|
|
BoxDebug.Log("初始化设置数据");
|
|
|
|
maxIndex = 0;
|
|
|
|
nowLenght = 0;
|
|
|
|
playerMove.position = startPoint.position;
|
|
|
|
moveTime = ItemSystem.ins.moveTime;
|
|
|
|
nowTime = 0;
|
|
|
|
textTime = 0;
|
|
|
|
timeText.text = Math.Round(moveTime - nowTime,1).ToString();
|
|
|
|
speed = ItemSystem.ins.speed;
|
|
|
|
speedText.text = speed.ToString();
|
|
|
|
points = ItemSystem.ins.points;
|
|
|
|
pointsNow = 0;
|
2024-11-26 15:44:50 +08:00
|
|
|
eventText1.text = "";
|
2024-11-21 09:35:48 +08:00
|
|
|
playing = true;
|
|
|
|
eventObj.SetActive(false);
|
|
|
|
}
|
|
|
|
|
2024-11-26 15:44:50 +08:00
|
|
|
private TaskEvent addTaskEvent(int id)
|
|
|
|
{
|
|
|
|
var data = JsonTab.Instance.tables.Task.Get(id);
|
|
|
|
TaskEvent taskEvent = new TaskEvent();
|
|
|
|
taskEvent.Action = new Action[7];
|
|
|
|
taskEvent.id = id;
|
|
|
|
taskEvent.type = data.Tasktype;
|
|
|
|
taskEvent.Action[data.Tasktype] = () =>
|
|
|
|
{
|
|
|
|
GameManager.ins.taskSystem.Event(taskEvent.id,nowTime);
|
|
|
|
};
|
|
|
|
return taskEvent;
|
|
|
|
}
|
|
|
|
|
|
|
|
private void TaskEvent(int index)
|
|
|
|
{
|
|
|
|
foreach (var task in events)
|
|
|
|
{
|
|
|
|
if (task.type==index)
|
|
|
|
{
|
|
|
|
GameManager.ins.taskSystem.Event(task.id,nowTime);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-11-21 09:35:48 +08:00
|
|
|
public void Move(Transform point,float savelengh)
|
|
|
|
{
|
2024-11-26 15:44:50 +08:00
|
|
|
var floatLenght=savelengh/lenght*MaxLengh();
|
|
|
|
if (floatLenght>MaxLengh())
|
2024-11-21 09:35:48 +08:00
|
|
|
{
|
2024-11-26 15:44:50 +08:00
|
|
|
floatLenght = MaxLengh();
|
2024-11-21 09:35:48 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
int index = 0;
|
|
|
|
for (int i = 0; i < lengh.Length; i++)
|
|
|
|
{
|
2024-11-26 15:44:50 +08:00
|
|
|
if (floatLenght-lengh[i]>0)
|
2024-11-13 16:56:37 +08:00
|
|
|
{
|
2024-11-26 15:44:50 +08:00
|
|
|
floatLenght -= lengh[i];
|
2024-11-13 16:56:37 +08:00
|
|
|
index++;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
break;
|
|
|
|
}
|
2024-11-08 18:21:41 +08:00
|
|
|
}
|
2024-11-21 09:35:48 +08:00
|
|
|
switch (index)
|
|
|
|
{
|
|
|
|
case 0:
|
2024-11-26 15:44:50 +08:00
|
|
|
point.position = _rectTrans[0].position + ((_rectTrans[1].position - _rectTrans[0].position)*(floatLenght/lengh[0]));
|
2024-11-21 09:35:48 +08:00
|
|
|
break;
|
|
|
|
case 1:
|
2024-11-26 15:44:50 +08:00
|
|
|
point.position = _rectTrans[1].position + ((_rectTrans[2].position - _rectTrans[1].position)*(floatLenght/lengh[1]));
|
2024-11-21 09:35:48 +08:00
|
|
|
break;
|
|
|
|
case 2:
|
2024-11-26 15:44:50 +08:00
|
|
|
point.position = _rectTrans[2].position + ((_rectTrans[3].position - _rectTrans[2].position)*(floatLenght/lengh[2]));
|
2024-11-21 09:35:48 +08:00
|
|
|
break;
|
|
|
|
case 3:
|
2024-11-26 15:44:50 +08:00
|
|
|
point.position = _rectTrans[3].position + ((_rectTrans[0].position - _rectTrans[3].position)*(floatLenght/lengh[3]));
|
2024-11-21 09:35:48 +08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public int GetEventID(int id)
|
|
|
|
{
|
|
|
|
var data = JsonTab.Instance.tables.Eventgroup.Get(id);
|
|
|
|
List<BEventtype> list = new List<BEventtype>();
|
2024-11-26 15:44:50 +08:00
|
|
|
foreach (var eventID in data.Eventgroup1)
|
2024-11-21 09:35:48 +08:00
|
|
|
{
|
|
|
|
var levelData=JsonTab.Instance.tables.Eventtype.Get(eventID);
|
|
|
|
list.Add(levelData);
|
|
|
|
}
|
2024-11-13 16:56:37 +08:00
|
|
|
|
2024-11-21 09:35:48 +08:00
|
|
|
int maxLenght = 0;
|
|
|
|
foreach (var eID in list)
|
|
|
|
{
|
|
|
|
maxLenght += eID.Weight;
|
|
|
|
}
|
|
|
|
|
|
|
|
int randomLenght = Random.Range(0, maxLenght);
|
|
|
|
int index = 0;
|
|
|
|
foreach (var bleng in list)
|
|
|
|
{
|
|
|
|
if (randomLenght-bleng.Weight>0)
|
|
|
|
{
|
|
|
|
randomLenght -= bleng.Weight;
|
|
|
|
index++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return list[index].ID;
|
|
|
|
}
|
2024-11-26 15:44:50 +08:00
|
|
|
public int GetEventVideoID(int id)
|
|
|
|
{
|
|
|
|
var data = JsonTab.Instance.tables.Eventgroup.Get(id);
|
|
|
|
List<BEventtype> list = new List<BEventtype>();
|
|
|
|
foreach (var eventID in data.Eventgroup2)
|
|
|
|
{
|
|
|
|
var levelData=JsonTab.Instance.tables.Eventtype.Get(eventID);
|
|
|
|
list.Add(levelData);
|
|
|
|
}
|
2024-11-21 09:35:48 +08:00
|
|
|
|
2024-11-26 15:44:50 +08:00
|
|
|
int maxLenght = 0;
|
|
|
|
foreach (var eID in list)
|
|
|
|
{
|
|
|
|
maxLenght += eID.Weight;
|
|
|
|
}
|
|
|
|
|
|
|
|
int randomLenght = Random.Range(0, maxLenght);
|
|
|
|
int index = 0;
|
|
|
|
foreach (var bleng in list)
|
|
|
|
{
|
|
|
|
if (randomLenght-bleng.Weight>0)
|
|
|
|
{
|
|
|
|
randomLenght -= bleng.Weight;
|
|
|
|
index++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return list[index].ID;
|
|
|
|
}
|
2024-11-21 09:35:48 +08:00
|
|
|
public float LenghRatio()
|
|
|
|
{
|
2024-11-26 15:44:50 +08:00
|
|
|
return MaxLengh() / lenght;
|
2024-11-21 09:35:48 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
public float MaxLengh()
|
|
|
|
{
|
|
|
|
return lengh[0] + lengh[1] + lengh[2] + lengh[3];
|
2024-11-13 16:56:37 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
private void SetPanel(RectTransform point,float langh)
|
|
|
|
{
|
|
|
|
var newLangh = langh;
|
|
|
|
var index = 0;
|
|
|
|
for (var i = 0; i < _sliders.Length; i++)
|
|
|
|
{
|
|
|
|
if (newLangh > _sliders[i].maxValue)
|
|
|
|
{
|
|
|
|
newLangh -= _sliders[i].maxValue;
|
|
|
|
index++;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
var endPoint = newLangh / _sliders[index].maxValue;
|
|
|
|
point.parent = _sliderTra[index];
|
|
|
|
point.rotation = Quaternion.identity;
|
|
|
|
point.anchorMax = new Vector2(endPoint,1);
|
|
|
|
point.anchorMin = new Vector2(endPoint, 0);
|
|
|
|
point.anchoredPosition = new Vector2(0, 0);
|
2024-11-08 18:21:41 +08:00
|
|
|
}
|
|
|
|
private void Awake()
|
|
|
|
{
|
|
|
|
// JsonTab.Instance.tables.Level.Get()
|
|
|
|
}
|
|
|
|
// Start is called before the first frame update
|
|
|
|
void Start()
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2024-11-21 09:35:48 +08:00
|
|
|
private void OnEnable()
|
|
|
|
{
|
2024-11-26 15:44:50 +08:00
|
|
|
eventButton1.onClick.AddListener(ButtonEvent1);
|
|
|
|
eventButton2.onClick.AddListener(ButtonEvent2);
|
|
|
|
close.onClick.AddListener(CloseUI);
|
|
|
|
settingButton.onClick.AddListener(SetSettingsObj);
|
|
|
|
audioButton.onClick.AddListener(AudioEvent);
|
|
|
|
soundEffectsButton.onClick.AddListener(SoundEffects);
|
|
|
|
settingObj.SetActive(false);
|
2024-11-21 09:35:48 +08:00
|
|
|
}
|
|
|
|
|
2024-11-08 18:21:41 +08:00
|
|
|
// Update is called once per frame
|
|
|
|
void Update()
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
2024-11-21 09:35:48 +08:00
|
|
|
|
|
|
|
private void OnDisable()
|
|
|
|
{
|
2024-11-26 15:44:50 +08:00
|
|
|
eventButton1.onClick.RemoveListener(ButtonEvent1);
|
|
|
|
eventButton2.onClick.RemoveListener(ButtonEvent2);
|
|
|
|
close.onClick.RemoveListener(CloseUI);
|
|
|
|
settingButton.onClick.RemoveListener(SetSettingsObj);
|
|
|
|
audioButton.onClick.RemoveListener(AudioEvent);
|
|
|
|
soundEffectsButton.onClick.RemoveListener(SoundEffects);
|
|
|
|
}
|
|
|
|
public void CloseUI()
|
|
|
|
{
|
|
|
|
MainPanel.ins.ClosePanelEvent();
|
|
|
|
GameManager.ins.soundSystem.EventAudio();
|
|
|
|
}
|
|
|
|
private void AudioEvent()
|
|
|
|
{
|
|
|
|
GameManager.ins.soundSystem.StopAudioSource();
|
|
|
|
}
|
|
|
|
|
|
|
|
private void SoundEffects()
|
|
|
|
{
|
|
|
|
GameManager.ins.soundSystem.EventAudioSource();
|
|
|
|
}
|
|
|
|
private void SetSettingsObj()
|
|
|
|
{
|
|
|
|
settingObj.SetActive(!settingObj.activeSelf);
|
|
|
|
}
|
|
|
|
private void ButtonEvent1()
|
|
|
|
{
|
|
|
|
ButtonEvent(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
private void ButtonEvent2()
|
|
|
|
{
|
|
|
|
ButtonEvent(2);
|
2024-11-21 09:35:48 +08:00
|
|
|
}
|
|
|
|
|
2024-11-26 15:44:50 +08:00
|
|
|
private void ButtonEvent(int index)
|
2024-11-21 09:35:48 +08:00
|
|
|
{
|
2024-12-18 11:12:52 +08:00
|
|
|
var id = index == 1 ? _eventlist[0].eventID : _eventlist[0].eventIDvideo;
|
|
|
|
if (JsonTab.Instance.tables.Eventtype.Get(id).Advertisement==1)
|
|
|
|
{
|
|
|
|
AdMgr.Instance.ShowAd((a) =>
|
|
|
|
{
|
|
|
|
BoxDebug.Log("video");
|
|
|
|
GameManager.ins.soundSystem.EventAudio();
|
|
|
|
_travelEvent.EventID(index==1? _eventlist[0].eventID:_eventlist[0].eventIDvideo,lenght*JsonTab.Instance.tables.Level.Get(GameManager.ins.level).Target/10000, ref nowLenght,ref speed,ref moveTime,ref points,ref pointsRatio);
|
|
|
|
BoxDebug.Log(_eventlist[0].eventID+" "+5000*JsonTab.Instance.tables.Level.Get(GameManager.ins.level).Target/10000+" "+nowLenght+" "+speed+" "+points+" "+pointsRatio);
|
|
|
|
speedText.text = speed.ToString();
|
|
|
|
RemoveEventList();
|
|
|
|
playing = true;
|
|
|
|
eventObj.SetActive(false);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
GameManager.ins.soundSystem.EventAudio();
|
|
|
|
_travelEvent.EventID(index==1? _eventlist[0].eventID:_eventlist[0].eventIDvideo,lenght*JsonTab.Instance.tables.Level.Get(GameManager.ins.level).Target/10000, ref nowLenght,ref speed,ref moveTime,ref points,ref pointsRatio);
|
|
|
|
BoxDebug.Log(_eventlist[0].eventID+" "+5000*JsonTab.Instance.tables.Level.Get(GameManager.ins.level).Target/10000+" "+nowLenght+" "+speed+" "+points+" "+pointsRatio);
|
|
|
|
speedText.text = speed.ToString();
|
|
|
|
RemoveEventList();
|
|
|
|
playing = true;
|
|
|
|
eventObj.SetActive(false);
|
|
|
|
}
|
2024-11-21 09:35:48 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
private void FixedUpdate()
|
|
|
|
{
|
|
|
|
if (!playing)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
2024-11-29 21:37:01 +08:00
|
|
|
nowLenght += Time.fixedDeltaTime*speed;
|
|
|
|
BoxDebug.Log(nowLenght);
|
2024-11-26 15:44:50 +08:00
|
|
|
|
2024-11-29 21:37:01 +08:00
|
|
|
nowTime += Time.fixedDeltaTime;
|
|
|
|
textTime += Time.fixedDeltaTime;
|
|
|
|
pointsNow += Time.fixedDeltaTime * ((float)points);
|
2024-11-21 09:35:48 +08:00
|
|
|
pointsText.text = Math.Round(pointsNow, 0).ToString();
|
|
|
|
timeText.text = Math.Round(moveTime - nowTime,1).ToString();
|
2024-11-26 15:44:50 +08:00
|
|
|
GameManager.ins.SaveNowLenght(nowLenght);
|
2024-11-21 09:35:48 +08:00
|
|
|
if (textTime > 5)
|
|
|
|
{
|
|
|
|
textTime = 0;
|
|
|
|
var levelData = JsonTab.Instance.tables.Level.Get(GameManager.ins.level).TextID;
|
|
|
|
var textTeamData = JsonTab.Instance.tables.DisplayTxtTeam.Get(levelData);
|
|
|
|
int index = Random.Range(0, textTeamData.Name.Count);
|
|
|
|
_textItem.SaveOnText(textTeamData.Name[index]);
|
|
|
|
}
|
2024-11-26 15:44:50 +08:00
|
|
|
|
|
|
|
if (targets&&nowLenght>targtsLanght)
|
|
|
|
{
|
|
|
|
TaskEvent(5);
|
|
|
|
}
|
2024-11-21 09:35:48 +08:00
|
|
|
if (nowTime>moveTime)
|
|
|
|
{
|
2024-12-17 13:37:43 +08:00
|
|
|
if (nowLenght>targtsLanght)
|
|
|
|
{
|
|
|
|
DataManager.SetPointsData(GameManager.ins.level,(int)pointsNow);
|
|
|
|
TaskEvent(1);
|
|
|
|
TaskEvent(3);
|
|
|
|
TaskEvent(6);
|
|
|
|
BoxDebug.Log("到达终点");
|
|
|
|
nowLenght = MaxLengh();
|
|
|
|
DataManager.SetLevelOpen(GameManager.ins.level,true);
|
|
|
|
MainPanel.ins.Win();
|
|
|
|
GameManager.ins.soundSystem.WinAudio();
|
|
|
|
playing = false;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
DataManager.SetPointsData(GameManager.ins.level,(int)pointsNow);
|
|
|
|
TaskEvent(1);
|
|
|
|
BoxDebug.Log("时间用完旅行结束");
|
|
|
|
playing = false;
|
|
|
|
GameManager.ins.soundSystem.LoseAudio();
|
|
|
|
MainPanel.ins.Lose();
|
|
|
|
}
|
2024-11-21 09:35:48 +08:00
|
|
|
}
|
2024-11-26 15:44:50 +08:00
|
|
|
if (nowLenght>=lenght)
|
2024-11-21 09:35:48 +08:00
|
|
|
{
|
2024-11-26 15:44:50 +08:00
|
|
|
DataManager.SetPointsData(GameManager.ins.level,(int)pointsNow);
|
|
|
|
TaskEvent(1);
|
|
|
|
TaskEvent(2);
|
|
|
|
TaskEvent(3);
|
|
|
|
TaskEvent(6);
|
2024-11-21 09:35:48 +08:00
|
|
|
BoxDebug.Log("到达终点");
|
|
|
|
nowLenght = MaxLengh();
|
2024-11-21 10:26:47 +08:00
|
|
|
DataManager.SetLevelOpen(GameManager.ins.level,true);
|
2024-11-26 15:44:50 +08:00
|
|
|
MainPanel.ins.Win();
|
|
|
|
GameManager.ins.soundSystem.WinAudio();
|
2024-11-21 09:35:48 +08:00
|
|
|
playing = false;
|
|
|
|
}
|
|
|
|
Move(playerMove, nowLenght);
|
|
|
|
foreach (var data in _eventlist)
|
|
|
|
{
|
|
|
|
if (data.lenght<nowLenght)
|
|
|
|
{
|
|
|
|
playing = false;
|
|
|
|
eventObj.gameObject.SetActive(true);
|
2024-11-29 21:37:01 +08:00
|
|
|
eventTitle.text = JsonTab.Instance.tables.DisplayTxt.Get(JsonTab.Instance.tables.Eventgroup.Get(data.eventTeamID).EventDescribe).Text.Replace("/n","\n");
|
|
|
|
eventText1.text = JsonTab.Instance.tables.DisplayTxt.Get(JsonTab.Instance.tables.Eventtype.Get(data.eventID).Describe).Text.Replace("/n","\n");
|
2024-11-26 15:44:50 +08:00
|
|
|
|
2024-11-29 21:37:01 +08:00
|
|
|
eventText2.text = JsonTab.Instance.tables.DisplayTxt.Get(JsonTab.Instance.tables.Eventtype.Get(data.eventIDvideo).Describe).Text.Replace("/n","\n");
|
|
|
|
event1Video.SetActive(JsonTab.Instance.tables.Eventtype.Get(data.eventID).Advertisement==1);
|
|
|
|
event2Video.SetActive(JsonTab.Instance.tables.Eventtype.Get(data.eventIDvideo).Advertisement==1);
|
2024-11-21 09:35:48 +08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-11-26 15:44:50 +08:00
|
|
|
public void AddTime(int time)
|
|
|
|
{
|
|
|
|
moveTime += time;
|
|
|
|
playing = true;
|
|
|
|
}
|
|
|
|
|
2024-11-21 09:35:48 +08:00
|
|
|
private void RemoveEventList()
|
|
|
|
{
|
|
|
|
for (int i = _eventlist.Count-1; i >= 0; i--)
|
|
|
|
{
|
|
|
|
if (_eventlist[i].lenght < nowLenght)
|
|
|
|
{
|
|
|
|
_eventlist.Remove(_eventlist[i]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2024-11-08 18:21:41 +08:00
|
|
|
}
|
2024-11-21 09:35:48 +08:00
|
|
|
|
|
|
|
public class NodeEventData
|
|
|
|
{
|
|
|
|
public float lenght;
|
|
|
|
public int eventTeamID;
|
|
|
|
public int eventID;
|
2024-11-26 15:44:50 +08:00
|
|
|
public int eventIDvideo;
|
|
|
|
}
|
|
|
|
|
|
|
|
public class TaskEvent
|
|
|
|
{
|
|
|
|
public int id = 0;
|
|
|
|
public int type = -1;
|
|
|
|
public Action[] Action=new Action[5];
|
2024-11-21 09:35:48 +08:00
|
|
|
}
|