Steam lobby implemented
This commit is contained in:
@ -1,60 +1,52 @@
|
||||
using System.Collections;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using TMPro;
|
||||
|
||||
[ExecuteAlways]
|
||||
public class ObjectiveText : MonoBehaviour
|
||||
{
|
||||
|
||||
[SerializeField]
|
||||
public List<VisualObjectiveItemGUI> visualObjects;
|
||||
|
||||
[SerializeField]
|
||||
private Color inCompleteColor = Color.white;
|
||||
[SerializeField]
|
||||
private Color completeColor = Color.yellow;
|
||||
[SerializeField]
|
||||
private float speed;
|
||||
[SerializeField]
|
||||
private Animator animator;
|
||||
[SerializeField] public List<VisualObjectiveItemGUI> visualObjects;
|
||||
|
||||
[SerializeField] private Color inCompleteColor = Color.white;
|
||||
|
||||
[SerializeField] private Color completeColor = Color.yellow;
|
||||
|
||||
[SerializeField] private float speed;
|
||||
|
||||
[SerializeField] private Animator animator;
|
||||
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
private void Start()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
private void Update()
|
||||
{
|
||||
foreach(VisualObjectiveItemGUI item in visualObjects)
|
||||
{
|
||||
if (item.isComplete){
|
||||
item.icon.color = Color.Lerp(item.icon.color, completeColor, Time.deltaTime*speed);
|
||||
}
|
||||
foreach (var item in visualObjects)
|
||||
if (item.isComplete)
|
||||
item.icon.color = Color.Lerp(item.icon.color, completeColor, Time.deltaTime * speed);
|
||||
else
|
||||
{
|
||||
item.icon.color = Color.Lerp(item.icon.color,inCompleteColor, Time.deltaTime*speed);
|
||||
}
|
||||
}
|
||||
item.icon.color = Color.Lerp(item.icon.color, inCompleteColor, Time.deltaTime * speed);
|
||||
}
|
||||
|
||||
public void FadeOut()
|
||||
{
|
||||
animator.Play("FadeOut");
|
||||
}
|
||||
|
||||
public void FadeIn()
|
||||
{
|
||||
animator.Play("FadeIn");
|
||||
}
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
[Serializable]
|
||||
public class VisualObjectiveItemGUI
|
||||
{
|
||||
public TMP_Text text;
|
||||
public Image icon;
|
||||
public bool isComplete = false;
|
||||
|
||||
public bool isComplete;
|
||||
}
|
@ -1,60 +1,49 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using TMPro;
|
||||
|
||||
public class WaypointMarker : MonoBehaviour
|
||||
{
|
||||
public Image pointer;
|
||||
public Transform target;
|
||||
public TMP_Text distanceMarker;
|
||||
|
||||
private Vector2 offset;
|
||||
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
private void Start()
|
||||
{
|
||||
offset = distanceMarker.transform.position - pointer.transform.position;
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
private void Update()
|
||||
{
|
||||
float minX = pointer.GetPixelAdjustedRect().width / 2;
|
||||
float maxX = Screen.width - minX;
|
||||
float minY = pointer.GetPixelAdjustedRect().height / 2;
|
||||
float maxY = Screen.height - minY;
|
||||
var minX = pointer.GetPixelAdjustedRect().width / 2;
|
||||
var maxX = Screen.width - minX;
|
||||
var minY = pointer.GetPixelAdjustedRect().height / 2;
|
||||
var maxY = Screen.height - minY;
|
||||
|
||||
Vector2 pos = Camera.main.WorldToScreenPoint(target.position);
|
||||
|
||||
if (Vector3.Dot(target.position - Camera.main.transform.position, Camera.main.transform.forward) < 0)
|
||||
{
|
||||
//target is behind player
|
||||
if(pos.x < Screen.width / 2)
|
||||
{
|
||||
if (pos.x < Screen.width / 2)
|
||||
pos.x = maxX;
|
||||
}
|
||||
else
|
||||
{
|
||||
pos.x = minX;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
pos.x = Mathf.Clamp(pos.x, minX, maxX);
|
||||
pos.y = Mathf.Clamp(pos.y, minY, maxY);
|
||||
|
||||
pointer.transform.position = pos;
|
||||
distanceMarker.text = Mathf.RoundToInt(Vector3.Distance(Camera.main.transform.position, target.transform.position)).ToString() + " meters";
|
||||
distanceMarker.text =
|
||||
Mathf.RoundToInt(Vector3.Distance(Camera.main.transform.position, target.transform.position)) + " meters";
|
||||
if (pos.x < Screen.width / 2)
|
||||
{
|
||||
distanceMarker.transform.position = pos + offset;
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
distanceMarker.transform.position = pos - offset;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user