Better ui and placement soon done
This commit is contained in:
parent
1a6280101f
commit
7cdf72cf24
|
@ -8,8 +8,8 @@ AnimatorStateTransition:
|
||||||
m_PrefabAsset: {fileID: 0}
|
m_PrefabAsset: {fileID: 0}
|
||||||
m_Name:
|
m_Name:
|
||||||
m_Conditions:
|
m_Conditions:
|
||||||
- m_ConditionMode: 1
|
- m_ConditionMode: 2
|
||||||
m_ConditionEvent: Close
|
m_ConditionEvent: IsOpen
|
||||||
m_EventTreshold: 0
|
m_EventTreshold: 0
|
||||||
m_DstStateMachine: {fileID: 0}
|
m_DstStateMachine: {fileID: 0}
|
||||||
m_DstState: {fileID: 2682460963827588746}
|
m_DstState: {fileID: 2682460963827588746}
|
||||||
|
@ -25,58 +25,6 @@ AnimatorStateTransition:
|
||||||
m_InterruptionSource: 0
|
m_InterruptionSource: 0
|
||||||
m_OrderedInterruption: 1
|
m_OrderedInterruption: 1
|
||||||
m_CanTransitionToSelf: 1
|
m_CanTransitionToSelf: 1
|
||||||
--- !u!1101 &-7641027645006483654
|
|
||||||
AnimatorStateTransition:
|
|
||||||
m_ObjectHideFlags: 1
|
|
||||||
m_CorrespondingSourceObject: {fileID: 0}
|
|
||||||
m_PrefabInstance: {fileID: 0}
|
|
||||||
m_PrefabAsset: {fileID: 0}
|
|
||||||
m_Name:
|
|
||||||
m_Conditions:
|
|
||||||
- m_ConditionMode: 1
|
|
||||||
m_ConditionEvent: Open
|
|
||||||
m_EventTreshold: 0
|
|
||||||
m_DstStateMachine: {fileID: 0}
|
|
||||||
m_DstState: {fileID: -2280432560819215181}
|
|
||||||
m_Solo: 0
|
|
||||||
m_Mute: 0
|
|
||||||
m_IsExit: 0
|
|
||||||
serializedVersion: 3
|
|
||||||
m_TransitionDuration: 0
|
|
||||||
m_TransitionOffset: 0
|
|
||||||
m_ExitTime: 0
|
|
||||||
m_HasExitTime: 0
|
|
||||||
m_HasFixedDuration: 0
|
|
||||||
m_InterruptionSource: 0
|
|
||||||
m_OrderedInterruption: 1
|
|
||||||
m_CanTransitionToSelf: 1
|
|
||||||
--- !u!1102 &-2280432560819215181
|
|
||||||
AnimatorState:
|
|
||||||
serializedVersion: 6
|
|
||||||
m_ObjectHideFlags: 1
|
|
||||||
m_CorrespondingSourceObject: {fileID: 0}
|
|
||||||
m_PrefabInstance: {fileID: 0}
|
|
||||||
m_PrefabAsset: {fileID: 0}
|
|
||||||
m_Name: FullOut
|
|
||||||
m_Speed: 1
|
|
||||||
m_CycleOffset: 0
|
|
||||||
m_Transitions:
|
|
||||||
- {fileID: 8958318208459601179}
|
|
||||||
m_StateMachineBehaviours: []
|
|
||||||
m_Position: {x: 50, y: 50, z: 0}
|
|
||||||
m_IKOnFeet: 0
|
|
||||||
m_WriteDefaultValues: 1
|
|
||||||
m_Mirror: 0
|
|
||||||
m_SpeedParameterActive: 0
|
|
||||||
m_MirrorParameterActive: 0
|
|
||||||
m_CycleOffsetParameterActive: 0
|
|
||||||
m_TimeParameterActive: 0
|
|
||||||
m_Motion: {fileID: 7400000, guid: a9f8f24edd1852c4e829d921b091c37d, type: 2}
|
|
||||||
m_Tag:
|
|
||||||
m_SpeedParameter:
|
|
||||||
m_MirrorParameter:
|
|
||||||
m_CycleOffsetParameter:
|
|
||||||
m_TimeParameter:
|
|
||||||
--- !u!1102 &-2135777584370832094
|
--- !u!1102 &-2135777584370832094
|
||||||
AnimatorState:
|
AnimatorState:
|
||||||
serializedVersion: 6
|
serializedVersion: 6
|
||||||
|
@ -88,7 +36,6 @@ AnimatorState:
|
||||||
m_Speed: 1
|
m_Speed: 1
|
||||||
m_CycleOffset: 0
|
m_CycleOffset: 0
|
||||||
m_Transitions:
|
m_Transitions:
|
||||||
- {fileID: -7641027645006483654}
|
|
||||||
- {fileID: -8896916857368744256}
|
- {fileID: -8896916857368744256}
|
||||||
m_StateMachineBehaviours: []
|
m_StateMachineBehaviours: []
|
||||||
m_Position: {x: 50, y: 50, z: 0}
|
m_Position: {x: 50, y: 50, z: 0}
|
||||||
|
@ -120,9 +67,6 @@ AnimatorStateMachine:
|
||||||
- serializedVersion: 1
|
- serializedVersion: 1
|
||||||
m_State: {fileID: -2135777584370832094}
|
m_State: {fileID: -2135777584370832094}
|
||||||
m_Position: {x: 240, y: 30, z: 0}
|
m_Position: {x: 240, y: 30, z: 0}
|
||||||
- serializedVersion: 1
|
|
||||||
m_State: {fileID: -2280432560819215181}
|
|
||||||
m_Position: {x: 490, y: 30, z: 0}
|
|
||||||
m_ChildStateMachines: []
|
m_ChildStateMachines: []
|
||||||
m_AnyStateTransitions: []
|
m_AnyStateTransitions: []
|
||||||
m_EntryTransitions: []
|
m_EntryTransitions: []
|
||||||
|
@ -142,14 +86,8 @@ AnimatorController:
|
||||||
m_Name: cocksex
|
m_Name: cocksex
|
||||||
serializedVersion: 5
|
serializedVersion: 5
|
||||||
m_AnimatorParameters:
|
m_AnimatorParameters:
|
||||||
- m_Name: Open
|
- m_Name: IsOpen
|
||||||
m_Type: 9
|
m_Type: 4
|
||||||
m_DefaultFloat: 0
|
|
||||||
m_DefaultInt: 0
|
|
||||||
m_DefaultBool: 0
|
|
||||||
m_Controller: {fileID: 9100000}
|
|
||||||
- m_Name: Close
|
|
||||||
m_Type: 9
|
|
||||||
m_DefaultFloat: 0
|
m_DefaultFloat: 0
|
||||||
m_DefaultInt: 0
|
m_DefaultInt: 0
|
||||||
m_DefaultBool: 0
|
m_DefaultBool: 0
|
||||||
|
@ -203,7 +141,7 @@ AnimatorStateTransition:
|
||||||
m_Name:
|
m_Name:
|
||||||
m_Conditions:
|
m_Conditions:
|
||||||
- m_ConditionMode: 1
|
- m_ConditionMode: 1
|
||||||
m_ConditionEvent: Open
|
m_ConditionEvent: IsOpen
|
||||||
m_EventTreshold: 0
|
m_EventTreshold: 0
|
||||||
m_DstStateMachine: {fileID: 0}
|
m_DstStateMachine: {fileID: 0}
|
||||||
m_DstState: {fileID: -2135777584370832094}
|
m_DstState: {fileID: -2135777584370832094}
|
||||||
|
@ -219,28 +157,3 @@ AnimatorStateTransition:
|
||||||
m_InterruptionSource: 0
|
m_InterruptionSource: 0
|
||||||
m_OrderedInterruption: 1
|
m_OrderedInterruption: 1
|
||||||
m_CanTransitionToSelf: 1
|
m_CanTransitionToSelf: 1
|
||||||
--- !u!1101 &8958318208459601179
|
|
||||||
AnimatorStateTransition:
|
|
||||||
m_ObjectHideFlags: 1
|
|
||||||
m_CorrespondingSourceObject: {fileID: 0}
|
|
||||||
m_PrefabInstance: {fileID: 0}
|
|
||||||
m_PrefabAsset: {fileID: 0}
|
|
||||||
m_Name:
|
|
||||||
m_Conditions:
|
|
||||||
- m_ConditionMode: 1
|
|
||||||
m_ConditionEvent: Close
|
|
||||||
m_EventTreshold: 0
|
|
||||||
m_DstStateMachine: {fileID: 0}
|
|
||||||
m_DstState: {fileID: 2682460963827588746}
|
|
||||||
m_Solo: 0
|
|
||||||
m_Mute: 0
|
|
||||||
m_IsExit: 0
|
|
||||||
serializedVersion: 3
|
|
||||||
m_TransitionDuration: 0.2
|
|
||||||
m_TransitionOffset: 0
|
|
||||||
m_ExitTime: 0
|
|
||||||
m_HasExitTime: 0
|
|
||||||
m_HasFixedDuration: 1
|
|
||||||
m_InterruptionSource: 0
|
|
||||||
m_OrderedInterruption: 1
|
|
||||||
m_CanTransitionToSelf: 1
|
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,3 +1,4 @@
|
||||||
|
using System;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
public class GameManager : MonoBehaviour
|
public class GameManager : MonoBehaviour
|
||||||
|
@ -8,8 +9,6 @@ public class GameManager : MonoBehaviour
|
||||||
public bool IsBuildMode = false;
|
public bool IsBuildMode = false;
|
||||||
private Tower selectedTower;
|
private Tower selectedTower;
|
||||||
|
|
||||||
public TowerInfo ShopSelectedTower;
|
|
||||||
|
|
||||||
public Tower SelectedTower { get { return selectedTower; } set {
|
public Tower SelectedTower { get { return selectedTower; } set {
|
||||||
if (selectedTower != null)
|
if (selectedTower != null)
|
||||||
selectedTower.TowerSelected(false);
|
selectedTower.TowerSelected(false);
|
||||||
|
@ -25,4 +24,26 @@ public class GameManager : MonoBehaviour
|
||||||
Destroy(Instance);
|
Destroy(Instance);
|
||||||
Instance = this;
|
Instance = this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void OnEnable()
|
||||||
|
{
|
||||||
|
MoneyManager.OnShopSelected += m_OnTowerShopSelected;
|
||||||
|
TowerPlacementManager.OnTowerPlaced += m_finishBuildmode;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnDisable()
|
||||||
|
{
|
||||||
|
MoneyManager.OnShopSelected -= m_OnTowerShopSelected;
|
||||||
|
TowerPlacementManager.OnTowerPlaced -= m_finishBuildmode;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void m_OnTowerShopSelected(TowerInfo info)
|
||||||
|
{
|
||||||
|
IsBuildMode = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void m_finishBuildmode(TowerInfo info)
|
||||||
|
{
|
||||||
|
IsBuildMode = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
using System;
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using TMPro;
|
using TMPro;
|
||||||
|
@ -11,6 +12,11 @@ public class MoneyManager : MonoBehaviour
|
||||||
public GameObject[] ShopButtons;
|
public GameObject[] ShopButtons;
|
||||||
public TMP_Text[] MoneyTexts;
|
public TMP_Text[] MoneyTexts;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Invoked when player selects tower from shop
|
||||||
|
/// </summary>
|
||||||
|
public static event Action<TowerInfo> OnShopSelected;
|
||||||
|
|
||||||
private void OnEnable()
|
private void OnEnable()
|
||||||
{
|
{
|
||||||
for (int i = 0; i < ShopButtons.Length; i++)
|
for (int i = 0; i < ShopButtons.Length; i++)
|
||||||
|
@ -35,7 +41,6 @@ public class MoneyManager : MonoBehaviour
|
||||||
{
|
{
|
||||||
Assert.AreNotEqual(index, -1, "Shop button not init-ed with index");
|
Assert.AreNotEqual(index, -1, "Shop button not init-ed with index");
|
||||||
|
|
||||||
GameManager.Instance.ShopSelectedTower = towerCollection.Towers[index];
|
OnShopSelected?.Invoke(towerCollection.Towers[index]);
|
||||||
GameManager.Instance.IsBuildMode = true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,26 +8,28 @@ using UnityEngine;
|
||||||
|
|
||||||
public class TowerPlacementManager : MonoBehaviour
|
public class TowerPlacementManager : MonoBehaviour
|
||||||
{
|
{
|
||||||
/// <summary>
|
public static TowerPlacementManager Instance;
|
||||||
/// Sender
|
|
||||||
/// </summary>
|
// Spawning grid events
|
||||||
public static event Action<TowerPlacementManager> OnSpawnGridRequested;
|
public static event Action<TowerPlacementManager> OnSpawnGridRequested;
|
||||||
public static event Action<TowerPlacementManager> OnGridDeleteRequested;
|
public static event Action<TowerPlacementManager> OnGridDeleteRequested;
|
||||||
public static TowerPlacementManager Instance;
|
|
||||||
|
// Placing tower
|
||||||
|
public static event Action<TowerInfo> OnTowerPlaced;
|
||||||
|
|
||||||
|
|
||||||
[Header("Debug")]
|
[Header("Debug")]
|
||||||
[SerializeField] private bool RebuildGrid = false;
|
[SerializeField] private bool RebuildGrid = false;
|
||||||
|
|
||||||
// Section: Mouse
|
// Section: Mouse
|
||||||
private SlotManager CurrentSelectedSlot;
|
private SlotManager CurrentSelectedSlot;
|
||||||
private SlotManager CurrentHovered; // Not implemented
|
|
||||||
|
|
||||||
private int CurrentRotation = 0; // 0, 1, 2, 3
|
private int CurrentRotation = 0; // 0, 1, 2, 3
|
||||||
|
|
||||||
private GameObject SilhouettedObject;
|
private GameObject SilhouettedObject;
|
||||||
|
private TowerInfo SelectedTowerInfo;
|
||||||
|
|
||||||
// Section: Debug
|
private GameObject SelectedTowerPrefab => SelectedTowerInfo.prefab;
|
||||||
public GameObject DebugTowerPrefab;
|
|
||||||
|
|
||||||
private void Start()
|
private void Start()
|
||||||
{
|
{
|
||||||
|
@ -59,12 +61,27 @@ public class TowerPlacementManager : MonoBehaviour
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void OnEnable()
|
||||||
|
{
|
||||||
|
MoneyManager.OnShopSelected += OnShopSelected;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnDisable()
|
||||||
|
{
|
||||||
|
MoneyManager.OnShopSelected -= OnShopSelected;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnShopSelected(TowerInfo info)
|
||||||
|
{
|
||||||
|
SelectedTowerInfo = info;
|
||||||
|
}
|
||||||
|
|
||||||
public void OnSlotClicked(SlotManager slot, GridManager grid, int x, int y)
|
public void OnSlotClicked(SlotManager slot, GridManager grid, int x, int y)
|
||||||
{
|
{
|
||||||
slot.gameObject.GetComponentInChildren<Renderer>().material.color = Color.blue;
|
slot.gameObject.GetComponentInChildren<Renderer>().material.color = Color.blue;
|
||||||
OnSelectSlot(slot);
|
OnSelectSlot(slot);
|
||||||
|
|
||||||
SpawnTowerAtSelected(DebugTowerPrefab);
|
SpawnTowerAtSelected(SelectedTowerPrefab);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Called when a slot is selected
|
// Called when a slot is selected
|
||||||
|
@ -94,13 +111,13 @@ public class TowerPlacementManager : MonoBehaviour
|
||||||
public void OnSlotHovered(SlotManager slot, GridManager grid, int x, int y)
|
public void OnSlotHovered(SlotManager slot, GridManager grid, int x, int y)
|
||||||
{
|
{
|
||||||
if (SilhouettedObject == null)
|
if (SilhouettedObject == null)
|
||||||
SilhouettedObject = ToSilhouette(DebugTowerPrefab);
|
SilhouettedObject = ToSilhouette(SelectedTowerPrefab);
|
||||||
|
|
||||||
// Sets tower rotation
|
// Sets tower rotation
|
||||||
Quaternion newRotation = Quaternion.AngleAxis(CurrentRotation * 90f, transform.up);
|
Quaternion newRotation = Quaternion.AngleAxis(CurrentRotation * 90f, transform.up);
|
||||||
SilhouettedObject.transform.localRotation = newRotation;
|
SilhouettedObject.transform.localRotation = newRotation;
|
||||||
|
|
||||||
Vector3 offset = DebugTowerPrefab.transform.position;
|
Vector3 offset = SelectedTowerPrefab.transform.position;
|
||||||
|
|
||||||
//SilhouettedObject.SetActive(true);
|
//SilhouettedObject.SetActive(true);
|
||||||
SilhouettedObject.transform.parent = slot.TowerSpawnPoint.transform;
|
SilhouettedObject.transform.parent = slot.TowerSpawnPoint.transform;
|
||||||
|
|
|
@ -1,53 +1,72 @@
|
||||||
|
using System;
|
||||||
|
using UnityEditor.PackageManager;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
using UnityEngine.EventSystems;
|
||||||
|
|
||||||
public class UIManager : MonoBehaviour
|
public class UIManager : MonoBehaviour
|
||||||
{
|
{
|
||||||
public Animator anim;
|
[SerializeField] private Animator anim;
|
||||||
public string animationCall;
|
[SerializeField] private EventTrigger OpenerTrigger;
|
||||||
|
[SerializeField] private EventTrigger CloseTrigger;
|
||||||
|
|
||||||
public GameObject activateGo;
|
private bool OpenerIsHovered = false;
|
||||||
public bool deactivateSelf;
|
private bool CloseIsHovered = false;
|
||||||
|
|
||||||
public UIManager affectedObj;
|
private bool CurrentShopState = false;
|
||||||
|
|
||||||
public bool count;
|
private void OnEnable()
|
||||||
|
|
||||||
public int maxCount = 1;
|
|
||||||
public int currentCount = 0;
|
|
||||||
|
|
||||||
|
|
||||||
private void Awake()
|
|
||||||
{
|
{
|
||||||
if(count)
|
// Subscribe to PointerEnter event
|
||||||
currentCount = 0;
|
EventTrigger.Entry pointerOpenerEnter = new EventTrigger.Entry();
|
||||||
}
|
pointerOpenerEnter.eventID = EventTriggerType.PointerEnter;
|
||||||
public void OnMouseEnter()
|
pointerOpenerEnter.callback.AddListener((data) => { OnOpenerEnter((PointerEventData)data); });
|
||||||
{
|
OpenerTrigger.triggers.Add(pointerOpenerEnter);
|
||||||
anim.SetTrigger(animationCall);
|
|
||||||
|
|
||||||
if (activateGo != null)
|
// Subscribe to PointerExit event
|
||||||
activateGo.SetActive(true);
|
EventTrigger.Entry pointerOpenerExit = new EventTrigger.Entry();
|
||||||
|
pointerOpenerExit.eventID = EventTriggerType.PointerExit;
|
||||||
|
pointerOpenerExit.callback.AddListener((data) => { OnOpenerExit((PointerEventData)data); });
|
||||||
|
OpenerTrigger.triggers.Add(pointerOpenerExit);
|
||||||
|
|
||||||
if (deactivateSelf)
|
// Subscribe to PointerEnter event
|
||||||
{
|
EventTrigger.Entry pointerCloseTriggerEnter = new EventTrigger.Entry();
|
||||||
gameObject.SetActive(false);
|
pointerCloseTriggerEnter.eventID = EventTriggerType.PointerEnter;
|
||||||
if (count)
|
pointerCloseTriggerEnter.callback.AddListener((data) => { OnCloseTriggerEnter((PointerEventData)data); });
|
||||||
ResetCount();
|
CloseTrigger.triggers.Add(pointerCloseTriggerEnter);
|
||||||
}
|
|
||||||
//gameObject.SetActive(false);
|
|
||||||
|
|
||||||
if (count)
|
// Subscribe to PointerExit event
|
||||||
currentCount++;
|
EventTrigger.Entry pointerCloseTriggerExit = new EventTrigger.Entry();
|
||||||
if (currentCount >= maxCount && count)
|
pointerCloseTriggerExit.eventID = EventTriggerType.PointerExit;
|
||||||
gameObject.SetActive(false);
|
pointerCloseTriggerExit.callback.AddListener((data) => { OnCloseTriggerExit((PointerEventData)data); });
|
||||||
|
CloseTrigger.triggers.Add(pointerCloseTriggerExit);
|
||||||
if (affectedObj != null && affectedObj.currentCount >= affectedObj.maxCount && affectedObj.count)
|
|
||||||
ResetCount();
|
|
||||||
}
|
|
||||||
public void ResetCount()
|
|
||||||
{
|
|
||||||
affectedObj.gameObject.SetActive(true);
|
|
||||||
affectedObj.currentCount = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void OnCloseTriggerEnter(PointerEventData data)
|
||||||
|
{
|
||||||
|
CloseIsHovered = true;
|
||||||
|
UpdateShopState();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnCloseTriggerExit(PointerEventData data)
|
||||||
|
{
|
||||||
|
CloseIsHovered = false;
|
||||||
|
UpdateShopState();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnOpenerEnter(PointerEventData data)
|
||||||
|
{
|
||||||
|
OpenerIsHovered = true;
|
||||||
|
UpdateShopState();
|
||||||
|
}
|
||||||
|
private void OnOpenerExit(PointerEventData data)
|
||||||
|
{
|
||||||
|
OpenerIsHovered = false;
|
||||||
|
UpdateShopState();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void UpdateShopState()
|
||||||
|
{
|
||||||
|
CurrentShopState = (CurrentShopState && !CloseIsHovered) || (OpenerIsHovered && !CloseIsHovered);
|
||||||
|
anim.SetBool("IsOpen", CurrentShopState);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue