Merge branch 'ui-animation'
This commit is contained in:
82
Assets/Scripts/UI/AppSwitcher.cs
Normal file
82
Assets/Scripts/UI/AppSwitcher.cs
Normal file
@@ -0,0 +1,82 @@
|
||||
using UnityEngine;
|
||||
using SkiaSharp.Unity;
|
||||
using Input;
|
||||
using AppleHills.Core;
|
||||
using UnityEngine.Events;
|
||||
|
||||
public class AppSwitcher : MonoBehaviour
|
||||
{
|
||||
|
||||
public TextAsset iconIdle;
|
||||
public TextAsset iconEstablish;
|
||||
public TextAsset rainbowEstablish;
|
||||
public TextAsset rainbowRemove;
|
||||
public GameObject rainbow;
|
||||
public GameObject icon;
|
||||
public GameObject gameLayoutContainer;
|
||||
public GameObject exitButton;
|
||||
|
||||
private SkottiePlayerV2 iconPlayer;
|
||||
private SkottiePlayerV2 rainbowPlayer;
|
||||
private Animator animator;
|
||||
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
iconPlayer = icon.GetComponentInChildren<SkottiePlayerV2>();
|
||||
rainbowPlayer = rainbow.GetComponentInChildren<SkottiePlayerV2>();
|
||||
animator = GetComponent<Animator>();
|
||||
}
|
||||
|
||||
public void OpenAppSwitcher()
|
||||
{
|
||||
//Activate players
|
||||
rainbow.SetActive(true);
|
||||
gameLayoutContainer.SetActive(true);
|
||||
|
||||
// Play establishing animations
|
||||
rainbowPlayer.LoadAnimation(rainbowEstablish.text);
|
||||
rainbowPlayer.PlayAnimation(false);
|
||||
rainbowPlayer.loop = false;
|
||||
gameLayoutContainer.SetActive(true);
|
||||
animator.Play("GamesReveal");
|
||||
|
||||
// Show the exit button
|
||||
exitButton.SetActive(true);
|
||||
|
||||
// Set input mode to UI
|
||||
QuickAccess.Instance.PlayerController.InterruptMoveTo();
|
||||
InputManager.Instance.SetInputMode(InputMode.UI);
|
||||
|
||||
rainbowPlayer.OnAnimationFinished += AnimFinished;
|
||||
}
|
||||
|
||||
public void CloseAppSwitcher()
|
||||
{
|
||||
rainbowPlayer.resetAfterFinished = true;
|
||||
rainbowPlayer.LoadAnimation(rainbowRemove.text);
|
||||
rainbowPlayer.PlayAnimation(false);
|
||||
rainbowPlayer.loop = false;
|
||||
animator.Play("GamesHide");
|
||||
|
||||
// Set input mode to game and ui
|
||||
InputManager.Instance.SetInputMode(InputMode.GameAndUI);
|
||||
|
||||
// Hide the exit button
|
||||
exitButton.SetActive(false);
|
||||
}
|
||||
|
||||
public void GamesHiddenAnimationEvent()
|
||||
{
|
||||
rainbow.SetActive(false);
|
||||
gameLayoutContainer.SetActive(false);
|
||||
|
||||
}
|
||||
|
||||
private void AnimFinished(string str)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
2
Assets/Scripts/UI/AppSwitcher.cs.meta
Normal file
2
Assets/Scripts/UI/AppSwitcher.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: bac6124b3ada8a048a0b87a729a22312
|
||||
Reference in New Issue
Block a user