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.
88 lines
2.9 KiB
88 lines
2.9 KiB
1 year ago
|
using System;
|
||
|
using UnityEngine;
|
||
|
using UniRx;
|
||
|
using HighlightPlus;
|
||
|
|
||
|
public class SourceController : MonoBehaviour
|
||
|
{
|
||
|
public CreationMode sourceMode;
|
||
|
private DateTime t1, t2;
|
||
|
public string OriginaName;
|
||
|
|
||
|
private void Start()
|
||
|
{
|
||
|
Observable.EveryLateUpdate()
|
||
|
.Subscribe(_ =>
|
||
|
{
|
||
|
if (MainMenu.Instance.MenuMode == MainMenuMode.周边水源)
|
||
|
{
|
||
|
if (gameObject == WaterSource.Instance.Selected)
|
||
|
GetComponent<HighlightEffect>().highlighted = true;
|
||
|
else
|
||
|
GetComponent<HighlightEffect>().highlighted = false;
|
||
|
}
|
||
|
if (MainMenu.Instance.MenuMode == MainMenuMode.行车路线)
|
||
|
{
|
||
|
switch (sourceMode)
|
||
|
{
|
||
|
case CreationMode.Single:
|
||
|
if (gameObject == DriveRoute.Instance.Selected)
|
||
|
GetComponent<HighlightEffect>().highlighted = true;
|
||
|
else
|
||
|
GetComponent<HighlightEffect>().highlighted = false;
|
||
|
break;
|
||
|
case CreationMode.Multipoint:
|
||
|
if (transform.parent.gameObject == DriveRoute.Instance.Selected)
|
||
|
{
|
||
|
foreach (Transform t in transform.parent)
|
||
|
t.gameObject.GetComponent<HighlightEffect>().highlighted = true;
|
||
|
}
|
||
|
else
|
||
|
GetComponent<HighlightEffect>().highlighted = false;
|
||
|
break;
|
||
|
}
|
||
|
|
||
|
}
|
||
|
}).AddTo(gameObject);
|
||
|
}
|
||
|
|
||
|
void OnMouseDown()
|
||
|
{
|
||
|
if (MainMenu.Instance.MenuMode == MainMenuMode.周边水源)
|
||
|
{
|
||
|
WaterSource.Instance.Selected = gameObject;
|
||
|
}
|
||
|
if (MainMenu.Instance.MenuMode == MainMenuMode.行车路线)
|
||
|
{
|
||
|
switch (sourceMode)
|
||
|
{
|
||
|
case CreationMode.Single:
|
||
|
DriveRoute.Instance.Selected = gameObject;
|
||
|
break;
|
||
|
case CreationMode.Multipoint:
|
||
|
DriveRoute.Instance.Selected = transform.parent.gameObject;
|
||
|
break;
|
||
|
}
|
||
|
|
||
|
}
|
||
|
|
||
|
t2 = DateTime.Now;
|
||
|
if (t2 - t1 < new TimeSpan(0, 0, 0, 0, 500))
|
||
|
{
|
||
|
OnEditName();
|
||
|
}
|
||
|
|
||
|
t1 = t2;
|
||
|
}
|
||
|
void OnEditName()
|
||
|
{
|
||
|
UIManager.Instance.Show<SourceNamePanel>(SetInfo);
|
||
|
}
|
||
|
|
||
|
private void SetInfo()
|
||
|
{
|
||
|
UIManager.Instance.GetView<SourceNamePanel>().NameInput.text= transform.Find("info").GetComponent<TextMesh>().text;
|
||
|
UIManager.Instance.GetView<SourceNamePanel>().SourceObject = gameObject;
|
||
|
}
|
||
|
}
|