update
This commit is contained in:
@@ -23,6 +23,7 @@ public class NetworkTrail : NetworkBehaviour
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
public float trailLength;
|
||||
void Update()
|
||||
{
|
||||
if(isServer){
|
||||
@@ -32,9 +33,25 @@ public class NetworkTrail : NetworkBehaviour
|
||||
}else{
|
||||
|
||||
}
|
||||
trailLength = GetTrailLength();
|
||||
// Debug.Log(GetTrailLength());
|
||||
}
|
||||
|
||||
public float GetTrailLength(){
|
||||
Vector3[] m_positions = new Vector3[trail.positionCount];
|
||||
trail.GetPositions(m_positions);
|
||||
if(m_positions.Length < 2){
|
||||
Debug.Log("Trail is empty?");
|
||||
return 0;
|
||||
}
|
||||
|
||||
float distance = 0;
|
||||
for(int i = 1; i < m_positions.Length;i++){
|
||||
distance += Vector2.Distance(m_positions[i-1], m_positions[i]);
|
||||
}
|
||||
|
||||
return distance;
|
||||
}
|
||||
[ClientRpc]
|
||||
void RpcUpdatePositions(Vector3[] Positions){
|
||||
if(!enableValidation){return;}
|
||||
|
||||
@@ -29,7 +29,7 @@ public class TutorialManager : MonoBehaviour
|
||||
|
||||
async void StartSequence(TutorialScreen[] list){
|
||||
skipped=false;
|
||||
btn_skip.gameObject.SetActive(true);
|
||||
// btn_skip.gameObject.SetActive(true);
|
||||
foreach(GameObject item in itemsToDisableWhileInTuto){
|
||||
item.SetActive(false);
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ using System.Threading.Tasks;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Events;
|
||||
using UnityEngine.EventSystems;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class TutorialScreen : MonoBehaviour
|
||||
@@ -12,59 +13,84 @@ public class TutorialScreen : MonoBehaviour
|
||||
public Button btn_next;
|
||||
public Button[] additional_next_buttons;
|
||||
public int delayBeforeAppear;
|
||||
public bool hideNextButtonOnStart=true;
|
||||
public bool hideNextButtonOnStart = true;
|
||||
public UnityEvent OnNextClicked;
|
||||
|
||||
Dictionary<TMP_Text, string> messages;
|
||||
|
||||
void Awake(){
|
||||
void Awake()
|
||||
{
|
||||
btn_next.onClick.AddListener(OnNextButton);
|
||||
foreach(Button btn in additional_next_buttons){
|
||||
foreach (Button btn in additional_next_buttons)
|
||||
{
|
||||
btn.onClick.AddListener(OnNextButton);
|
||||
}
|
||||
|
||||
EventTrigger.Entry entry = new EventTrigger.Entry();
|
||||
entry.eventID = EventTriggerType.PointerDown;
|
||||
entry.callback.AddListener((eventData) => { SkipText(); });
|
||||
|
||||
GetComponent<EventTrigger>().triggers.Add(entry);
|
||||
|
||||
}
|
||||
|
||||
public void Show(){
|
||||
public void Show()
|
||||
{
|
||||
gameObject.SetActive(true);
|
||||
ShowTexts();
|
||||
}
|
||||
|
||||
async void ShowTexts(){
|
||||
if(hideNextButtonOnStart){btn_next.gameObject.SetActive(false);}
|
||||
bool textSkipped = false;
|
||||
async void ShowTexts()
|
||||
{
|
||||
if (hideNextButtonOnStart) { btn_next.gameObject.SetActive(false); }
|
||||
int typewriteDelay = 0;
|
||||
if(messages == null){
|
||||
if (messages == null)
|
||||
{
|
||||
messages = new Dictionary<TMP_Text, string>();
|
||||
TMP_Text[] texts = messageParent.GetComponentsInChildren<TMP_Text>();
|
||||
foreach(TMP_Text text in texts){
|
||||
foreach (TMP_Text text in texts)
|
||||
{
|
||||
messages.Add(text, text.text.Replace("{Player}", DBmanager.username));
|
||||
text.text = "";
|
||||
}
|
||||
}
|
||||
foreach(KeyValuePair<TMP_Text, string> message in messages){
|
||||
message.Key.text="";
|
||||
Debug.Log(message.Value);
|
||||
for(int i=0; i < message.Value.Length; i++){
|
||||
message.Key.text+=message.Value.ToCharArray()[i];
|
||||
if(typewriteDelay< 4){
|
||||
typewriteDelay++;
|
||||
}else{
|
||||
AudioManager.instnace.TypeWriter();
|
||||
typewriteDelay=0;
|
||||
}
|
||||
await Task.Delay(20);
|
||||
foreach (KeyValuePair<TMP_Text, string> message in messages)
|
||||
{
|
||||
message.Key.text = "";
|
||||
Debug.Log(message.Value);
|
||||
for (int i = 0; i < message.Value.Length; i++)
|
||||
{
|
||||
message.Key.text += message.Value.ToCharArray()[i];
|
||||
if (typewriteDelay < 4)
|
||||
{
|
||||
typewriteDelay++;
|
||||
}
|
||||
await Task.Delay(500);
|
||||
else
|
||||
{
|
||||
AudioManager.instnace.TypeWriter();
|
||||
typewriteDelay = 0;
|
||||
}
|
||||
if(!textSkipped){await Task.Delay(20);}
|
||||
}
|
||||
|
||||
await Task.Delay(250);
|
||||
}
|
||||
|
||||
textSkipped=false;
|
||||
btn_next.gameObject.SetActive(true);
|
||||
}
|
||||
|
||||
public void Hide(){
|
||||
void SkipText()
|
||||
{
|
||||
textSkipped=true;
|
||||
}
|
||||
|
||||
public void Hide()
|
||||
{
|
||||
gameObject.SetActive(false);
|
||||
}
|
||||
|
||||
public void OnNextButton(){
|
||||
public void OnNextButton()
|
||||
{
|
||||
OnNextClicked.Invoke();
|
||||
Debug.Log("Next button clicked");
|
||||
TutorialManager.NextClicked();
|
||||
|
||||
Reference in New Issue
Block a user