Commit 58ec07b1 authored by Gerard Gascón's avatar Gerard Gascón
Browse files

feat: hide title when game starts

parent 0bed7bbe
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -346,6 +346,8 @@ MonoBehaviour:
  m_EditorClassIdentifier: 
  ui: {fileID: 311490074}
  fadeDuration: 0.5
  titleImage: {fileID: 1127832730}
  titleFadeDuration: 1
--- !u!1 &379057220
GameObject:
  m_ObjectHideFlags: 0
@@ -380,7 +382,7 @@ RectTransform:
  m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
  m_AnchorMin: {x: 0, y: 1}
  m_AnchorMax: {x: 0, y: 1}
  m_AnchoredPosition: {x: 0, y: -7.7999}
  m_AnchoredPosition: {x: 0, y: -7.7999268}
  m_SizeDelta: {x: 122.1659, y: 51.509}
  m_Pivot: {x: 0, y: 1}
--- !u!114 &379057222
+4 −1
Original line number Diff line number Diff line
@@ -13,7 +13,10 @@ namespace View {
			Model = new Model(0);

			IExpressionInput input = FindObjectOfType<ExpressionInput>();
			ExpressionClick = new ExpressionClick(Model, input);
			IExpressionInput visibility = FindObjectOfType<UIVisibility>();
			IExpressionInput inputCollections = new ExpressionInputCollection(new[] { input, visibility });

			ExpressionClick = new ExpressionClick(Model, inputCollections);

			CustomInput = new CustomInput();
		}
+16 −0
Original line number Diff line number Diff line
using Presenter;

namespace View {
	public class ExpressionInputCollection : IExpressionInput {
		private readonly IExpressionInput[] _inputs;

		public ExpressionInputCollection(IExpressionInput[] inputs) {
			_inputs = inputs;
		}

		public void UpdateView(int score) {
			foreach (IExpressionInput input in _inputs)
				input.UpdateView(score);
		}
	}
}
 No newline at end of file
+3 −0
Original line number Diff line number Diff line
fileFormatVersion: 2
guid: ae095e86bb524331a6f001ba71000218
timeCreated: 1713195784
 No newline at end of file
+16 −6
Original line number Diff line number Diff line
using System;
using DG.Tweening;
using Presenter;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.UI;

namespace View {
	public class UIVisibility : MonoBehaviour {
	public class UIVisibility : MonoBehaviour, IExpressionInput {
		[SerializeField] private CanvasGroup ui;
		[SerializeField] private float fadeDuration = .5f;

		[Space]
		[SerializeField] private Image titleImage;
		[SerializeField] private float titleFadeDuration = 1f;

		private bool _wasVisible = true;
		private bool _titleVisible = true;
		private Tween _fadeTween;

		private void Update() {
			bool isPointerOver = EventSystem.current.IsPointerOverGameObject();

			if (_wasVisible && !isPointerOver) {
				_fadeTween?.Kill();
				_fadeTween = ui.DOFade(0, fadeDuration).SetDelay(5f);
				_wasVisible = false;
				return;
			}
			if (!_wasVisible && isPointerOver) {
			} else if (!_wasVisible && isPointerOver) {
				_fadeTween?.Kill();
				_fadeTween = ui.DOFade(1, fadeDuration);
				_wasVisible = true;
				return;
			}
		}

		public void UpdateView(int score) {
			if (!_titleVisible) return;
			_titleVisible = false;

			titleImage.DOFade(0, titleFadeDuration);
		}
	}
}
 No newline at end of file