Added async chests animations

This commit is contained in:
Jakub Sztuba 2022-12-29 00:56:54 +01:00
parent 7577aa269c
commit 1b7825ab20
15 changed files with 263 additions and 37 deletions

View File

@ -126,6 +126,7 @@
<Compile Include="Assets\Scripts\REFACTORING\Models\Item\ItemData.cs" />
<Compile Include="Assets\Scripts\REFACTORING\Models\Panel\Slot\ItemSlot.cs" />
<Compile Include="Assets\healthText.cs" />
<Compile Include="Assets\Animations\Chests\ChestAnimation.cs" />
<Compile Include="Assets\Scripts\REFACTORING\Models\Item\EquippableItem\EquippableItem.cs" />
<Compile Include="Assets\Scripts\REFACTORING\Application\Shared\Manager\UI\Panel\WarehousePanel\WarehousePanelController.cs" />
<Compile Include="Assets\Scripts\PlayerPosition.cs" />

View File

@ -0,0 +1,40 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class ChestAnimation : MonoBehaviour
{
[SerializeField] public GameObject chest;
private Animator m_Animator;
bool isTrigerred = false;
// Start is called before the first frame update
void Start()
{
m_Animator = gameObject.GetComponent<Animator>();
chest = gameObject; // set object on current GameObject
}
private bool beingHandled = false;
private static bool Opening;
private static bool Closing;
private IEnumerator OpenChestWithAnimation()
{
beingHandled = true;
// process pre-yield
m_Animator.SetTrigger("OpenIt");
yield return new WaitForSeconds( 0.4f );
m_Animator.ResetTrigger("OpenIt");
// process post-yield
beingHandled = false;
}
// Update is called once per frame
void Update()
{
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 7151affbee5fd5443aeac959e4ef9331
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -28,7 +28,6 @@ Transform:
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 4669568061092186073}
m_RootOrder: 0
@ -73,6 +72,7 @@ GameObject:
- component: {fileID: 4669568061092186078}
- component: {fileID: 4669568061092186079}
- component: {fileID: 2962987939110705530}
- component: {fileID: 2546385265061015204}
m_Layer: 0
m_Name: Gold Chest
m_TagString: Untagged
@ -90,7 +90,6 @@ Transform:
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 58.59589, y: 32.941498, z: 20}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children:
- {fileID: 8363154141198799061}
m_Father: {fileID: 0}
@ -107,7 +106,6 @@ SpriteRenderer:
m_CastShadows: 0
m_ReceiveShadows: 0
m_DynamicOccludee: 1
m_StaticShadowCaster: 0
m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
@ -193,3 +191,22 @@ MonoBehaviour:
chestModel: {fileID: 4669568061092186072}
ChestType: 2
Content: []
--- !u!95 &2546385265061015204
Animator:
serializedVersion: 3
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 4669568061092186072}
m_Enabled: 1
m_Avatar: {fileID: 0}
m_Controller: {fileID: 9100000, guid: a95209a8090661b429e3a7057efecd57, type: 2}
m_CullingMode: 0
m_UpdateMode: 0
m_ApplyRootMotion: 0
m_LinearVelocityBlending: 0
m_WarningMessage:
m_HasTransformHierarchy: 1
m_AllowConstantClipSamplingOptimization: 1
m_KeepAnimatorControllerStateOnDisable: 0

View File

@ -28,7 +28,6 @@ Transform:
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 5754902894522036728}
m_RootOrder: 0
@ -73,6 +72,7 @@ GameObject:
- component: {fileID: 5754902894522036731}
- component: {fileID: 5754902894522036730}
- component: {fileID: 1539754125081080905}
- component: {fileID: 2621439303561408325}
m_Layer: 0
m_Name: Prize Chest
m_TagString: Untagged
@ -90,7 +90,6 @@ Transform:
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 16, y: 51.2, z: 18.195854}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children:
- {fileID: 584661738}
m_Father: {fileID: 0}
@ -107,7 +106,6 @@ SpriteRenderer:
m_CastShadows: 0
m_ReceiveShadows: 0
m_DynamicOccludee: 1
m_StaticShadowCaster: 0
m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
@ -193,3 +191,22 @@ MonoBehaviour:
chestModel: {fileID: 5754902894522036729}
ChestType: 3
Content: []
--- !u!95 &2621439303561408325
Animator:
serializedVersion: 3
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 5754902894522036729}
m_Enabled: 1
m_Avatar: {fileID: 0}
m_Controller: {fileID: 9100000, guid: 5a1cb06ea2da76043b87dc47570a8e31, type: 2}
m_CullingMode: 0
m_UpdateMode: 0
m_ApplyRootMotion: 0
m_LinearVelocityBlending: 0
m_WarningMessage:
m_HasTransformHierarchy: 1
m_AllowConstantClipSamplingOptimization: 1
m_KeepAnimatorControllerStateOnDisable: 0

View File

@ -29,7 +29,6 @@ Transform:
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 5754902894522036728}
m_RootOrder: 0
@ -96,6 +95,7 @@ GameObject:
- component: {fileID: 5754902894522036731}
- component: {fileID: 5754902894522036730}
- component: {fileID: 1539754125081080905}
- component: {fileID: -5583331179158830126}
m_Layer: 0
m_Name: Prize
m_TagString: Untagged
@ -113,7 +113,6 @@ Transform:
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 16, y: 51.2, z: 18.195854}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children:
- {fileID: 584661738}
m_Father: {fileID: 0}
@ -130,7 +129,6 @@ SpriteRenderer:
m_CastShadows: 0
m_ReceiveShadows: 0
m_DynamicOccludee: 1
m_StaticShadowCaster: 0
m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
@ -216,3 +214,22 @@ MonoBehaviour:
chestModel: {fileID: 5754902894522036729}
ChestType: 3
Content: []
--- !u!95 &-5583331179158830126
Animator:
serializedVersion: 3
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 5754902894522036729}
m_Enabled: 1
m_Avatar: {fileID: 0}
m_Controller: {fileID: 9100000, guid: 5a1cb06ea2da76043b87dc47570a8e31, type: 2}
m_CullingMode: 0
m_UpdateMode: 0
m_ApplyRootMotion: 0
m_LinearVelocityBlending: 0
m_WarningMessage:
m_HasTransformHierarchy: 1
m_AllowConstantClipSamplingOptimization: 1
m_KeepAnimatorControllerStateOnDisable: 0

View File

@ -13,6 +13,7 @@ GameObject:
- component: {fileID: 3972494989842158583}
- component: {fileID: 3972494989842158582}
- component: {fileID: 6216344267889095310}
- component: {fileID: 1515226974721611062}
m_Layer: 0
m_Name: Wooden Chest
m_TagString: Untagged
@ -30,7 +31,6 @@ Transform:
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: -8.45, y: -3.9, z: 10}
m_LocalScale: {x: 1, y: 1, z: 2}
m_ConstrainProportionsScale: 0
m_Children:
- {fileID: 2040639819227648951}
m_Father: {fileID: 0}
@ -47,7 +47,6 @@ SpriteRenderer:
m_CastShadows: 0
m_ReceiveShadows: 0
m_DynamicOccludee: 1
m_StaticShadowCaster: 0
m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
@ -159,6 +158,25 @@ MonoBehaviour:
chestModel: {fileID: 3972494989842158579}
ChestType: 0
Content: []
--- !u!95 &1515226974721611062
Animator:
serializedVersion: 3
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3972494989842158579}
m_Enabled: 1
m_Avatar: {fileID: 0}
m_Controller: {fileID: 9100000, guid: fce3c85ba17349e4798d785023c01ae5, type: 2}
m_CullingMode: 0
m_UpdateMode: 0
m_ApplyRootMotion: 0
m_LinearVelocityBlending: 0
m_WarningMessage:
m_HasTransformHierarchy: 1
m_AllowConstantClipSamplingOptimization: 1
m_KeepAnimatorControllerStateOnDisable: 0
--- !u!1 &6979447088390353274
GameObject:
m_ObjectHideFlags: 0
@ -187,7 +205,6 @@ Transform:
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 0.5}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 3972494989842158580}
m_RootOrder: 0

View File

@ -13,6 +13,7 @@ GameObject:
- component: {fileID: 3972494989842158583}
- component: {fileID: 3972494989842158582}
- component: {fileID: 6216344267889095310}
- component: {fileID: -3452854508351898312}
m_Layer: 0
m_Name: Wooden
m_TagString: Untagged
@ -30,7 +31,6 @@ Transform:
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: -8.45, y: -3.9, z: 10}
m_LocalScale: {x: 1, y: 1, z: 2}
m_ConstrainProportionsScale: 0
m_Children:
- {fileID: 3343843920455804694}
m_Father: {fileID: 0}
@ -47,7 +47,6 @@ SpriteRenderer:
m_CastShadows: 0
m_ReceiveShadows: 0
m_DynamicOccludee: 1
m_StaticShadowCaster: 0
m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
@ -159,6 +158,25 @@ MonoBehaviour:
chestModel: {fileID: 3972494989842158579}
ChestType: 0
Content: []
--- !u!95 &-3452854508351898312
Animator:
serializedVersion: 3
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3972494989842158579}
m_Enabled: 1
m_Avatar: {fileID: 0}
m_Controller: {fileID: 9100000, guid: fce3c85ba17349e4798d785023c01ae5, type: 2}
m_CullingMode: 0
m_UpdateMode: 0
m_ApplyRootMotion: 0
m_LinearVelocityBlending: 0
m_WarningMessage:
m_HasTransformHierarchy: 1
m_AllowConstantClipSamplingOptimization: 1
m_KeepAnimatorControllerStateOnDisable: 0
--- !u!1 &5564756746198341403
GameObject:
m_ObjectHideFlags: 0
@ -188,7 +206,6 @@ Transform:
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 0.5}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 3972494989842158580}
m_RootOrder: 0

View File

@ -29982,7 +29982,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 7d979e870b57ddc469af22153ab86c9f, type: 3}
m_Name:
m_EditorClassIdentifier:
musicSlider: {fileID: 0}
musicSlider: {fileID: 182615359}
--- !u!114 &1275369262
MonoBehaviour:
m_ObjectHideFlags: 0
@ -29995,7 +29995,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 82139d862c485054da5412c4c0f4d926, type: 3}
m_Name:
m_EditorClassIdentifier:
volumeSlider: {fileID: 0}
volumeSlider: {fileID: 654061995}
--- !u!4 &1275369263
Transform:
m_ObjectHideFlags: 0

View File

@ -3,6 +3,8 @@ using UnityEngine;
public class ChestController : MonoBehaviour
{
public void Update()
{
}

View File

@ -1,10 +1,19 @@
using System;
using System.Collections.Generic;
using UnityEngine;
using System.Threading.Tasks;
[Serializable]
public abstract class UIBaseManager<T> : MonoBehaviour, ManagerInterface<T>
{
private Animator animator;
void Start()
{
animator = GetComponent<Animator>();
}
public static UIBaseManager<T> Instance { get; protected set; }
@ -31,18 +40,60 @@ public abstract class UIBaseManager<T> : MonoBehaviour, ManagerInterface<T>
}
}
public void Update()
//public GameObject Chest1 = GameObject.Find("Gold Chest");
public async void Update()
{
if (Input.GetKeyDown(keyToOpen))
{
if (!DynamicPanel)
{
//condition to be near to the chest
if (ChestUIManager.Instance.CurrentChestName != null && ChestUIManager.Instance.CurrentChestName != "")
{
//delay using async Yield and triggering chests to start open animation
var end = Time.time + 0.3;
animateOpening();
while (Time.time < end)
{
await System.Threading.Tasks.Task.Yield();
}
}
this.OpenPanel();
}
else
{
this.ClosePanel();
var end2 = Time.time + 0.1;
while (Time.time < end2)
{
await System.Threading.Tasks.Task.Yield();
}
animateClosing();
end2 = Time.time + 0.3;
while (Time.time < end2)
{
await System.Threading.Tasks.Task.Yield();
}
resettriggers();
}
}
if (ChestUIManager.Instance.CurrentChestName == null || ChestUIManager.Instance.CurrentChestName == "")
{
var end2 = Time.time + 0.1;
while (Time.time < end2)
{
await System.Threading.Tasks.Task.Yield();
}
animateClosing();
end2 = Time.time + 0.3;
while (Time.time < end2)
{
await System.Threading.Tasks.Task.Yield();
}
resettriggers();
}
}
@ -56,6 +107,39 @@ public abstract class UIBaseManager<T> : MonoBehaviour, ManagerInterface<T>
//DynamicPanel = dynamicPanelController;
}
private async void animateOpening()
{
GameObject.Find("Gold Chest").GetComponent<Animator>().SetTrigger("OpenIt");
GameObject.Find("Prize Chest").GetComponent<Animator>().SetTrigger("OpenIt");
GameObject.Find("Wodden Chest").GetComponent<Animator>().SetTrigger("OpenIt");
}
private async void animateClosing()
{
GameObject.Find("Gold Chest").GetComponent<Animator>().ResetTrigger("OpenIt");
GameObject.Find("Prize Chest").GetComponent<Animator>().ResetTrigger("OpenIt");
GameObject.Find("Wodden Chest").GetComponent<Animator>().ResetTrigger("OpenIt");
GameObject.Find("Gold Chest").GetComponent<Animator>().SetTrigger("CloseIt");
GameObject.Find("Prize Chest").GetComponent<Animator>().SetTrigger("CloseIt");
GameObject.Find("Wodden Chest").GetComponent<Animator>().SetTrigger("CloseIt");
}
private async void resettriggers()
{
var end3 = Time.time + 0.0;
while (Time.time < end3)
{
await System.Threading.Tasks.Task.Yield();
}
GameObject.Find("Gold Chest").GetComponent<Animator>().ResetTrigger("CloseIt");
GameObject.Find("Prize Chest").GetComponent<Animator>().ResetTrigger("CloseIt");
GameObject.Find("Wodden Chest").GetComponent<Animator>().ResetTrigger("CloseIt");
GameObject.Find("Wodden Chest").GetComponent<Animator>().SetTrigger("reactivate");
GameObject.Find("Prize Chest").GetComponent<Animator>().SetTrigger("reactivate");
GameObject.Find("Gold Chest").GetComponent<Animator>().SetTrigger("reactivate");
}
public virtual bool OpenPanel()
{
Console.WriteLine("Panel opened");
@ -74,7 +158,6 @@ public abstract class UIBaseManager<T> : MonoBehaviour, ManagerInterface<T>
DynamicPanel.name = uiPanelTemplate.name;
SetupPanel();
return true;
}
@ -85,7 +168,6 @@ public abstract class UIBaseManager<T> : MonoBehaviour, ManagerInterface<T>
try
{
Destroy(DynamicPanel);
return true;
} catch (Exception ex) { Debug.LogError(ex.Message); }

View File

@ -26,6 +26,7 @@ public class ChestUIManager : UIBaseManager<Chest>
}
}
public override bool OpenPanel()
{
if (CurrentChestName == null || CurrentChestName == "")

View File

@ -43,6 +43,8 @@ public class ShopUIManager : UIBaseManager<Shop>
return false;
}
// Open additionals panels
if (!InventoryUIManager.Instance.GetPanelStatus()) InventoryUIManager.Instance.OpenPanel();

View File

@ -0,0 +1,2 @@
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
<s:Boolean x:Key="/Default/UserDictionary/Words/=Wodden/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>

View File

@ -12,29 +12,29 @@ EditorUserSettings:
value: 22424703114646680e0b0227036c7c151b12163e2d3a3f7e38271427fb
flags: 0
RecentlyUsedScenePath-2:
value: 22424703114646680e0b0227036c6c111b07142f1f2b233e2867083debf42d
flags: 0
RecentlyUsedScenePath-3:
value: 22424703114646680e0b0227036c68190c160a2e042733232867083debf42d
flags: 0
RecentlyUsedScenePath-4:
value: 22424703114646680e0b0227036c7c1102161b25212a357e38271427fb
flags: 0
RecentlyUsedScenePath-5:
RecentlyUsedScenePath-3:
value: 22424703114646680e0b0227036c791904040c1c25242a312a2c5326ece92021
flags: 0
RecentlyUsedScenePath-6:
value: 22424703114646680e0b0227036c7c1100123d24383a273e2e2c5326ece92021
flags: 0
RecentlyUsedScenePath-7:
RecentlyUsedScenePath-4:
value: 22424703114646680e0b0227036c70050204112e291f2f2a2c3b1920caef212be7a923e7ee2e26
flags: 0
RecentlyUsedScenePath-8:
RecentlyUsedScenePath-5:
value: 22424703114646680e0b0227036c761e1821112620292135633c133af6f9
flags: 0
RecentlyUsedScenePath-9:
RecentlyUsedScenePath-6:
value: 22424703114646680e0b0227036c72111f1958072926337e38271427fb
flags: 0
RecentlyUsedScenePath-7:
value: 22424703114646680e0b0227036c68190c160a2e042733232867083debf42d
flags: 0
RecentlyUsedScenePath-8:
value: 22424703114646680e0b0227036c6c111b07142f1f2b233e2867083debf42d
flags: 0
RecentlyUsedScenePath-9:
value: 22424703114646680e0b0227036c7c1100123d24383a273e2e2c5326ece92021
flags: 0
vcSharedLogLevel:
value: 0d5e400f0650
flags: 0