всякое новое дерьмо, уже не важно
This commit is contained in:
@@ -43,6 +43,9 @@ public class GameSystem : MonoBehaviour
|
||||
|
||||
public async void LoadScene(string sceneName)
|
||||
{
|
||||
if(mainMenu.gameObject.activeSelf)
|
||||
mainMenu.Hide();
|
||||
|
||||
mainMenu.UpdateLocationMenu(locationsName[sceneName]);
|
||||
|
||||
try
|
||||
|
||||
@@ -69,7 +69,7 @@ public class QRCodeReader : MonoBehaviour
|
||||
scaleY = camTexture.videoVerticallyMirrored ? -1f : 1f;
|
||||
rawImage.rectTransform.localScale = new Vector3(1f, scaleY, 1f);
|
||||
}
|
||||
else if(Application.platform == RuntimePlatform.IPhonePlayer)
|
||||
else
|
||||
{
|
||||
ratio = (float)camTexture.height / (float)camTexture.width;
|
||||
rawImage.rectTransform.localScale = new Vector3(1f, -1f, 1f);
|
||||
|
||||
+37
-9
@@ -15,23 +15,37 @@ public class Train : MonoBehaviour
|
||||
private List<Material> materials = new();
|
||||
private float effectDuration = .4f;
|
||||
|
||||
public Tween anim;
|
||||
|
||||
void OnEnable()
|
||||
{
|
||||
var uiMenu = FindObjectOfType<UIMainMenu>();
|
||||
uiMenu.currentTrain = this;
|
||||
uiMenu.AbleToUseTrainButtons(false);
|
||||
|
||||
if(materials.Count == 0)
|
||||
{
|
||||
materials = GetComponent<MeshRenderer>().materials.ToList();
|
||||
var materialsInChildren = gameObject.transform
|
||||
.GetChild(0)
|
||||
.GetComponent<MeshRenderer>()
|
||||
.materials.ToList();
|
||||
var materialsInChildren = new List<Material>();
|
||||
for(int i = 0; i < transform.childCount; i++)
|
||||
{
|
||||
var childMaterials = transform.GetChild(i)
|
||||
.GetComponent<MeshRenderer>()
|
||||
.materials;
|
||||
|
||||
foreach(var item in childMaterials)
|
||||
{
|
||||
materials.Add(item);
|
||||
}
|
||||
}
|
||||
|
||||
foreach(var mat in materialsInChildren)
|
||||
materials.Add(mat);
|
||||
}
|
||||
|
||||
foreach(var mat in materials)
|
||||
mat.SetFloat("_EffectPosition", -5);
|
||||
|
||||
if(!useEffect)
|
||||
{
|
||||
SetEffect(true);
|
||||
@@ -46,10 +60,18 @@ public class Train : MonoBehaviour
|
||||
transform.localPosition.y,
|
||||
startPosition);
|
||||
|
||||
transform.DOLocalMoveZ(-16, speed)
|
||||
.SetEase(Ease.OutSine);
|
||||
anim = transform.DOLocalMoveZ(-16, speed)
|
||||
.SetEase(Ease.OutSine)
|
||||
.OnComplete(() =>
|
||||
{
|
||||
Debug.Log("tut now");
|
||||
uiMenu.AbleToUseTrainButtons(true);
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
SetEffect(true);
|
||||
}
|
||||
else SetEffect(true);
|
||||
}
|
||||
|
||||
public async void Hide()
|
||||
@@ -82,11 +104,11 @@ public class Train : MonoBehaviour
|
||||
|
||||
IEnumerator SetEffectRoutine(bool isShow)
|
||||
{
|
||||
float startPosition = isShow ? -5 : 3;
|
||||
float startPosition = isShow ? -5 : 4;
|
||||
float currentValue = startPosition;
|
||||
float endPosition = 0;
|
||||
|
||||
if(isShow) endPosition = 3;
|
||||
if(isShow) endPosition = 4;
|
||||
else endPosition = -5;
|
||||
|
||||
float progress = 0;
|
||||
@@ -112,6 +134,12 @@ public class Train : MonoBehaviour
|
||||
.SetFloat("_EffectPosition", endPosition);
|
||||
}
|
||||
|
||||
if(isShow && useEffect)
|
||||
{
|
||||
FindObjectOfType<UIMainMenu>()
|
||||
.AbleToUseTrainButtons(true);
|
||||
}
|
||||
|
||||
if(!isShow && useEffect)
|
||||
gameObject.SetActive(false);
|
||||
}
|
||||
|
||||
@@ -13,11 +13,13 @@ public class UIMainMenu : UICanvas
|
||||
public Image aboutTrainButton;
|
||||
public Train currentTrain { get; set; }
|
||||
|
||||
Tween tween;
|
||||
|
||||
public void ShowAboutTrainButton()
|
||||
{
|
||||
aboutTrainButton.gameObject.SetActive(true);
|
||||
aboutTrainButton.color = new Color(1, 1, 1, 0);
|
||||
aboutTrainButton.DOFade(.7f, 10f);
|
||||
tween = aboutTrainButton.DOFade(.7f, 10f);
|
||||
}
|
||||
|
||||
void Update()
|
||||
@@ -29,6 +31,8 @@ public class UIMainMenu : UICanvas
|
||||
|
||||
public void UpdateLocationMenu(Location location)
|
||||
{
|
||||
ResetButtons();
|
||||
|
||||
switch(location)
|
||||
{
|
||||
case(Location.AprelevkaDepo):
|
||||
@@ -57,12 +61,24 @@ public class UIMainMenu : UICanvas
|
||||
}
|
||||
}
|
||||
|
||||
public void AbleToUseTrainButtons(bool isAbleToUse)
|
||||
{
|
||||
Debug.Log("tut: " + isAbleToUse);
|
||||
|
||||
foreach(var button in trainButtons)
|
||||
button.ableToUse = isAbleToUse;
|
||||
}
|
||||
|
||||
public void ResetButtons()
|
||||
{
|
||||
foreach(var button in trainButtons)
|
||||
button.Unselect();
|
||||
button.Reset();
|
||||
|
||||
aboutTrainButton.gameObject.SetActive(false);
|
||||
|
||||
if(currentTrain == null) return;
|
||||
|
||||
currentTrain.anim.Kill();
|
||||
currentTrain = null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,8 +16,9 @@ public class UITrainButton : MonoBehaviour, IPointerClickHandler
|
||||
public bool isSelected { get; private set; }
|
||||
|
||||
LocomotionHandler locomotionHandler;
|
||||
public bool ableToUse = true;
|
||||
|
||||
void Start()
|
||||
void Awake()
|
||||
{
|
||||
buttonBase = GetComponent<Image>();
|
||||
unselectedColor = buttonBase.color;
|
||||
@@ -25,7 +26,7 @@ public class UITrainButton : MonoBehaviour, IPointerClickHandler
|
||||
|
||||
public void Select()
|
||||
{
|
||||
if(isSelected) return;
|
||||
if(isSelected || !ableToUse) return;
|
||||
|
||||
if(locomotionHandler == null)
|
||||
locomotionHandler = FindObjectOfType<LocomotionHandler>();
|
||||
@@ -42,11 +43,26 @@ public class UITrainButton : MonoBehaviour, IPointerClickHandler
|
||||
|
||||
locomotionHandler.ShowTrain(trainType);
|
||||
buttonBase.DOColor(selectedColor, .2f);
|
||||
|
||||
isSelected = true;
|
||||
}
|
||||
|
||||
public void Reset()
|
||||
{
|
||||
isSelected = false;
|
||||
ableToUse = true;
|
||||
|
||||
try
|
||||
{
|
||||
buttonBase.color = unselectedColor;
|
||||
}
|
||||
catch {}
|
||||
}
|
||||
|
||||
public void Unselect()
|
||||
{
|
||||
if(!isSelected) return;
|
||||
|
||||
buttonBase.DOColor(Color.white, .2f);
|
||||
isSelected = false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user