V3.3.0 MultiLevel功能创建完成

MultiLevel功能创建完成,play模式基本功能适配结束。下次再也不隔这么久commit一次了:(
This commit is contained in:
2023-09-08 07:15:24 +09:00
parent 5226f1dbbf
commit 203407693c
63 changed files with 2924 additions and 2384 deletions
+5 -5
View File
@@ -12,7 +12,7 @@ public class AgentController : MonoBehaviour
public GameObject environmentUIControlObj;
public GameObject targetControllerObj;
public GameObject HUDObj;
public Camera nowCam;
public Camera fpsCam;
[Header("GetAxis() Simulate")]
public float moveSpeed = 9.0f;
@@ -182,7 +182,7 @@ public class AgentController : MonoBehaviour
//相机在上下旋转移动时,相机方向不会随着移动,类似于低头和抬头,左右移动时,相机方向会随着向左向右移动,类似于向左向右看
//所以在控制相机向左向右旋转时,要保证和父物体一起转动
nowCam.transform.localRotation = Quaternion.Euler(yRotation, 0, 0);
fpsCam.transform.localRotation = Quaternion.Euler(yRotation, 0, 0);
//this.transform指这个CameraRotation的位置,localRotation指的是旋转轴
//transform.localRotation = Quaternion.Eular(x,y,z)控制旋转的时候,按照X-Y-Z轴的旋转顺规
//即以围绕X轴旋转x度,围绕Y轴旋转y度,围绕Z轴旋转z度
@@ -196,8 +196,8 @@ public class AgentController : MonoBehaviour
// ballistic 射击弹道处理,并返回获得reward
private float Ballistic(int shootState)
{
Vector3 point = new Vector3(nowCam.pixelWidth / 2, nowCam.pixelHeight / 2, 0);//发射位置
Ray ray = nowCam.ScreenPointToRay(point);
Vector3 point = new Vector3(fpsCam.pixelWidth / 2, fpsCam.pixelHeight / 2, 0);//发射位置
Ray ray = fpsCam.ScreenPointToRay(point);
RaycastHit hit;
// Debug.DrawRay(ray.origin, ray.direction * 100, Color.blue);
//按下鼠标左键
@@ -252,7 +252,7 @@ public class AgentController : MonoBehaviour
float nowReward = 0;
bool isFacingtoEnemy = false;
float enemyFacingDistance = 0f;
Ray ray = nowCam.ScreenPointToRay(new Vector3(nowCam.pixelWidth / 2, nowCam.pixelHeight / 2, 0));
Ray ray = fpsCam.ScreenPointToRay(new Vector3(fpsCam.pixelWidth / 2, fpsCam.pixelHeight / 2, 0));
if (targetCon.targetTypeInt == (int)SceneBlockContainer.Targets.Free)
{
//free mode
+4
View File
@@ -43,6 +43,8 @@ public class TargetController : MonoBehaviour
[SerializeField, Range(0f, 1f)] public float defenceProb = 0.2f;
[System.NonSerialized] public int targetTypeInt;
[System.NonSerialized] public int gotoLevelNum;
[System.NonSerialized] public int attackLevelNum;
public float[] targetState = new float[6];
public enum EndType
@@ -103,6 +105,8 @@ public class TargetController : MonoBehaviour
freeProb = 1 - attackProb - gotoProb - defenceProb;
targetNum = (int)SceneBlockContainer.Targets.Num;
gotoLevelNum = sceneBlockCon.scenePrefabSet.GetLevelNumber(SceneBlockContainer.Targets.Go);
attackLevelNum = sceneBlockCon.scenePrefabSet.GetLevelNumber(SceneBlockContainer.Targets.Attack);
if (freeProb < 0)
{
Debug.LogError("TargetController.Start: target percentage wrong");
+3
View File
@@ -1,12 +1,15 @@
using System.Collections;
using System.Collections.Generic;
using TMPro;
using UnityEngine;
public class LevelButton : MonoBehaviour
{
public int level;
public TextMeshProUGUI levelText;
public void Initialization(int level)
{
this.level = level;
levelText.text = "Level " + level.ToString();
}
}
+83 -10
View File
@@ -1,23 +1,96 @@
using System.Collections;
using DG.Tweening;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using UnityEngine;
using UnityEngine.UI;
public class LevelPanel : MonoBehaviour
{
public int levelNum = 6;
public float buttonHeight = 31;
private int levelNum = 0;
private float buttonHeight = 30;
public TargetUIController.PrimaryButtonType primaryButtonType;
public GameObject levelButtonPrefab;
public GameObject hudObj;
private TargetUIController targetUIController;
public Vector2 defaultPosition = Vector2.zero;
public Vector2 targetPosition = Vector2.zero;
public Vector2 defaultSize = Vector2.zero;
public Vector2 targetSize = Vector2.zero;
public bool isFolding = false;
public bool isExpanding = false;
public void Initialization(int levelNum,float buttonHeight = 31)
private List<Button> levelButtonList = new List<Button>();
public ReadOnlyCollection<Button> LevelButtonList
{
get { return levelButtonList.AsReadOnly(); }
}
/// <summary>
/// Initialize the level panel.
/// Set the level number, button height, default position and target position.
/// Create leve buttonInitialize the level buttons.
/// </summary>
public void InitLevelPanel(int levelNum, Button parentButton, float buttonHeight = 30)
{
targetUIController = hudObj.GetComponent<TargetUIController>();
// set level panel parameters
this.levelNum = levelNum;
this.buttonHeight = buttonHeight;
RectTransform rectTransform = GetComponent<RectTransform>();
rectTransform.sizeDelta = new Vector2(rectTransform.sizeDelta.x, levelNum * buttonHeight);
defaultSize = new Vector2(parentButton.GetComponent<RectTransform>().sizeDelta.x, 0); ;
defaultPosition = parentButton.GetComponent<RectTransform>().anchoredPosition;
targetSize = new Vector2(defaultSize.x, buttonHeight * levelNum);
targetPosition = new Vector2(-parentButton.GetComponent<RectTransform>().sizeDelta.x,
parentButton.GetComponent<RectTransform>().anchoredPosition.y + (levelNum - 1) * buttonHeight / 2);
// limit the target position is screen range
if (targetPosition.y > 0)
{
targetPosition.y = 0;
}
// create level buttons
for (int i = 0; i < levelNum; i++)
{
GameObject button = Instantiate(Resources.Load<GameObject>("Prefabs/LevelButton"), transform);
button.GetComponent<RectTransform>().anchoredPosition = new Vector2(0, -i * buttonHeight);
button.GetComponent<LevelButton>().Initialization(i);
GameObject newButton = Instantiate(levelButtonPrefab, transform);
levelButtonList.Add(newButton.GetComponent<Button>());
newButton.GetComponent<LevelButton>().Initialization(i);
newButton.GetComponent<Button>().onClick.AddListener(delegate { targetUIController.LevelButtonPressed(primaryButtonType, newButton.GetComponent<LevelButton>().level); });
}
// fold panel to default position immediately
FoldLevelPanel();
}
}
/// <summary>
/// fold the level panel.
/// </summary>
/// <param name="animeTime">fold animation time,0 without animation</param>
public void FoldLevelPanel(float animeTime = 0)
{
isFolding = true;
DOTween.To(() => gameObject.GetComponent<RectTransform>().anchoredPosition,
x => gameObject.GetComponent<RectTransform>().anchoredPosition = x,
defaultPosition,
animeTime).SetEase(Ease.OutCirc).Play().OnComplete(() => isFolding = false);
DOTween.To(() => gameObject.GetComponent<RectTransform>().sizeDelta,
x => gameObject.GetComponent<RectTransform>().sizeDelta = x,
defaultSize,
animeTime).SetEase(Ease.OutCirc).Play();
}
/// <summary>
/// expand the level panel.
/// </summary>
/// <param name="animeTime">expand animation time,0 without animation</param>
public void ExpandLevelPanel(float animeTime = 0)
{
isExpanding = true;
DOTween.To(() => gameObject.GetComponent<RectTransform>().anchoredPosition,
x => gameObject.GetComponent<RectTransform>().anchoredPosition = x,
targetPosition,
animeTime).SetEase(Ease.OutCirc).Play().OnComplete(() => isExpanding = false);
DOTween.To(() => gameObject.GetComponent<RectTransform>().sizeDelta,
x => gameObject.GetComponent<RectTransform>().sizeDelta = x,
targetSize,
animeTime).SetEase(Ease.OutCirc).Play();
}
}
+2 -2
View File
@@ -35,10 +35,10 @@ public class MessageBoxController : MonoBehaviour
// check messages and colors list length match
if (messageList.Count != colorList.Count)
{
// delete extra messages or add white color to extra messages
// delete extra colors or add white color to extra messages
if (messageList.Count > colorList.Count)
{
for (int i = 0; i < messageList.Count - colorList.Count; i++)
while(messageList.Count > colorList.Count)
{
colorList.Add(defaultColor);
}
@@ -0,0 +1,163 @@
using DG.Tweening;
using System.Collections.Generic;
using TMPro;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.UI;
public class TargetButtonActivateColorChanger : MonoBehaviour
{
public List<Button> clickableButton = new List<Button>();
public List<Button> unclickableButton = new List<Button>();
public Color32 normalTextColor = new Color32(236, 236, 236, 255);
public Color32 normalBGColor = new Color32(255, 255, 255, 0);
public Color32 highLightTextColor = new Color32(41, 41, 41, 230);
public Color32 highLightBGColor = new Color32(255, 255, 255, 103);
public Color32 pressedTextColor = new Color32(0, 0, 0, 240);
public Color32 pressedBGColor = new Color32(255, 255, 255, 160);
public Color32 disableTextColor = new Color32(180, 180, b: 180, 80);
public Color32 disableBGColor = new Color32(255, 255, b: 255, 0);
public float colorChangeSpeed = 0.1f;
public bool clickable = true;
// Start is called before the first frame update
private void Start()
{
foreach (Button btn in clickableButton)
{
InitializeEventTriggers(btn, true);
}
foreach (Button btn in unclickableButton)
{
InitializeEventTriggers(btn, false);
}
}
/// <summary>
/// Initializes the event triggers for a button to handle its interactive behavior.
/// </summary>
/// <param name="btn">The button object to initialize.</param>
/// <param name="isClickable">Indicates whether the button is clickable.</param>
private void InitializeEventTriggers(Button btn, bool isClickable)
{
EventTrigger eventTrigger = btn.GetComponent<EventTrigger>();
if (eventTrigger == null)
{
eventTrigger = btn.gameObject.AddComponent<EventTrigger>();
}
AddEventTrigger(eventTrigger, EventTriggerType.PointerEnter, (eventData) => OnPointerEnter(btn));
AddEventTrigger(eventTrigger, EventTriggerType.PointerExit, (eventData) => OnPointerExit(btn));
if (isClickable)
{
AddEventTrigger(eventTrigger, EventTriggerType.PointerDown, (eventData) => OnPointerDown(btn));
AddEventTrigger(eventTrigger, EventTriggerType.PointerUp, (eventData) => OnPointerUp(btn));
}
}
/// <summary>
/// Adds an event trigger entry to an event trigger.
/// </summary>
/// <param name="trigger">The event trigger object.</param>
/// <param name="type">The event trigger type.</param>
/// <param name="action">The event handler method to execute.</param>
private void AddEventTrigger(EventTrigger trigger, EventTriggerType type, UnityEngine.Events.UnityAction<BaseEventData> action)
{
EventTrigger.Entry entry = new EventTrigger.Entry();
entry.eventID = type;
entry.callback.AddListener(action);
trigger.triggers.Add(entry);
}
private void OnPointerEnter(Button btn)
{
if (btn.interactable)
{
btn.image.DOColor(highLightBGColor, colorChangeSpeed);
btn.GetComponentInChildren<TextMeshProUGUI>().DOColor(highLightTextColor, colorChangeSpeed);
}
}
private void OnPointerExit(Button btn)
{
if (btn.interactable)
{
btn.image.DOColor(normalBGColor, colorChangeSpeed);
btn.GetComponentInChildren<TextMeshProUGUI>().DOColor(normalTextColor, colorChangeSpeed);
}
}
private void OnPointerDown(Button btn)
{
if (btn.interactable)
{
btn.image.DOColor(pressedBGColor, colorChangeSpeed);
btn.GetComponentInChildren<TextMeshProUGUI>().DOColor(pressedTextColor, colorChangeSpeed);
}
}
private void OnPointerUp(Button btn)
{
if (btn.interactable)
{
btn.image.DOColor(highLightBGColor, colorChangeSpeed);
btn.GetComponentInChildren<TextMeshProUGUI>().DOColor(normalTextColor, colorChangeSpeed);
}
}
/// <summary>
/// Changes the interactable state of a button and modifies its color based on the state.
/// </summary>
/// <param name="btn">The button object to change the state and color of.</param>
/// <param name="changeTo">Indicates the interactable state to change to.</param>
public void ChangeInteractableColor(Button btn, bool changeTo)
{
btn.interactable = changeTo;
if (changeTo)
{
btn.image.DOColor(normalBGColor, colorChangeSpeed);
btn.GetComponentInChildren<TextMeshProUGUI>().DOColor(normalTextColor, colorChangeSpeed);
}
else
{
btn.image.DOColor(disableBGColor, colorChangeSpeed);
btn.GetComponentInChildren<TextMeshProUGUI>().DOColor(disableTextColor, colorChangeSpeed);
}
}
/// <summary>
/// Adds a button to the button list and initializes the button's event triggers based on its clickability.
/// </summary>
/// <param name="btn">The button object to add to the button list.</param>
/// <param name="clickable">Indicates whether the button is clickable.</param>
public void AddButtonToColorChangerButtonList(Button btn,bool clickable)
{
if (clickable)
{
clickableButton.Add(btn);
InitializeEventTriggers(btn, clickable);
}
else
{
unclickableButton.Add(btn);
InitializeEventTriggers(btn, clickable);
}
}
public void InitializeAllButtonColor()
{
foreach(Button btn in clickableButton)
{
btn.image.color = normalBGColor;
btn.GetComponentInChildren<TextMeshProUGUI>().color = normalTextColor;
}
foreach (Button btn in unclickableButton)
{
btn.image.color = disableBGColor;
btn.GetComponentInChildren<TextMeshProUGUI>().color = disableTextColor;
}
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 48f605c5c3d09384fa6b248789466476
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
+195 -31
View File
@@ -1,4 +1,7 @@
using System.Collections.Generic;
using System.Collections.ObjectModel;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.UI;
public class TargetUIController : MonoBehaviour
@@ -6,84 +9,245 @@ public class TargetUIController : MonoBehaviour
// Controller to control the UI of the target,
// select target type, select prefeb to set or sth.
public GameObject targetControllerObj;
public GameObject mouseSelectorObj;
public GameObject environmentUIObj;
public float levelButtonHeight = 30;
[Header("PrimaryButton")]
public Button clearGameButton;
public Button setEnemyButton;
public Button setAttackButton;
public Button setGotoButton;
public Button setFreeButton;
public Button setStayButton;
public int primaryButtonNumber = 6;
[Header("LevelPanel")]
public GameObject gotoLevelPanel;
public GameObject attackLevelPanel;
public float levelPanelAnimeTime = 0.2f;
private MouseInMap mouseInMapCon;
private EnvironmentUIControl envUICon;
private TargetController targetCon;
private MessageBoxController messageBoxController;
private TargetButtonActivateColorChanger buttonColorChanger;
public enum PrimaryButtonType
{ Goto, Attack, Free }
public delegate void PointerInOutUIEventDelegate(Button button, GameObject panel, BaseEventData eventData);
private void Start()
{
targetCon = targetControllerObj.GetComponent<TargetController>();
mouseInMapCon = mouseSelectorObj.GetComponent<MouseInMap>();
envUICon = environmentUIObj.GetComponent<EnvironmentUIControl>();
messageBoxController = GetComponent<MessageBoxController>();
buttonColorChanger = GetComponent<TargetButtonActivateColorChanger>();
gotoLevelPanel.GetComponent<LevelPanel>().InitLevelPanel(
targetCon.gotoLevelNum,
setGotoButton,
levelButtonHeight);
attackLevelPanel.GetComponent<LevelPanel>().InitLevelPanel(
targetCon.attackLevelNum,
setAttackButton,
levelButtonHeight);
AddLevelButtonToColorChanger(gotoLevelPanel);
AddLevelButtonToColorChanger(attackLevelPanel);
AddPointerEnterButtonTrigger(setGotoButton, gotoLevelPanel, PointerEnterButtonAction);
AddPointerEnterButtonTrigger(setAttackButton, attackLevelPanel, PointerEnterButtonAction);
AddPointerExitButtonTrigger(setGotoButton, gotoLevelPanel, PointerExitButtonAction);
AddPointerExitButtonTrigger(setAttackButton, attackLevelPanel, PointerExitButtonAction);
AddPointerExitLevelPanelTrigger(setGotoButton, gotoLevelPanel, PointerExitLevelPanelAction);
AddPointerExitLevelPanelTrigger(setAttackButton, attackLevelPanel, PointerExitLevelPanelAction);
buttonColorChanger.InitializeAllButtonColor();
ClearGamePressed();
}
public void LevelButtonPressed(PrimaryButtonType primaryButtonType, int level = 0)
{
switch (primaryButtonType)
{
case PrimaryButtonType.Goto:
SetGotoPressed(level);
break;
case PrimaryButtonType.Attack:
SetAttackPressed(level);
break;
default:
messageBoxController.PushMessage(new List<string> { "TargetUIController.LevelButtonPressed:", "Button Type Wrong, not level included button" },
new List<string> { messageBoxController.errorColor });
break;
}
}
// Clear Game Button Pressed, delete all enemies and targets
public void ClearGamePressed()
{
// Clear all enemies and targets. set gamemode to Stay mode
targetCon.StayModeChange();
mouseInMapCon.ChangeMouseMode(MouseInMap.MouseMode.Default);
// disable setStayButton and enable other buttons
setStayButton.interactable = false;
setAttackButton.interactable = true;
setGotoButton.interactable = true;
setFreeButton.interactable = true;
buttonColorChanger.ChangeInteractableColor(clearGameButton, true);
buttonColorChanger.ChangeInteractableColor(setEnemyButton, true);
buttonColorChanger.ChangeInteractableColor(setAttackButton, true);
buttonColorChanger.ChangeInteractableColor(setGotoButton, true);
buttonColorChanger.ChangeInteractableColor(setFreeButton, true);
buttonColorChanger.ChangeInteractableColor(setStayButton, false);
targetCon.PlayInitialize();
}
// Set Free Button Pressed, change Target mode to free mode
public void SetFreePressed()
{
mouseInMapCon.ChangeMouseMode(MouseInMap.MouseMode.Default);
targetCon.FreeModeChange();
buttonColorChanger.ChangeInteractableColor(setStayButton, true);
buttonColorChanger.ChangeInteractableColor(setAttackButton, true);
buttonColorChanger.ChangeInteractableColor(setGotoButton, true);
buttonColorChanger.ChangeInteractableColor(setFreeButton, false);
}
// Set Stay Button Pressed, change Target mode to stay mode
public void SetStayPressed()
{
mouseInMapCon.ChangeMouseMode(MouseInMap.MouseMode.Default);
targetCon.StayModeChange();
buttonColorChanger.ChangeInteractableColor(setStayButton, false);
buttonColorChanger.ChangeInteractableColor(setAttackButton, true);
buttonColorChanger.ChangeInteractableColor(setGotoButton, true);
buttonColorChanger.ChangeInteractableColor(setFreeButton, true);
}
// Set Enemy Button Pressed, change mouse mode to EnemySetMode
public void SetEnemyPressed()
{
mouseInMapCon.ChangeMouseMode(MouseInMap.MouseMode.EnemySet);
}
public void SetGotoPressed()
// Set Goto Button Pressed, change mouse mode to GotoSetMode
private void SetGotoPressed(int level)
{
mouseInMapCon.ChangeMouseMode(MouseInMap.MouseMode.GotoSet);
setStayButton.interactable = true;
setAttackButton.interactable = true;
setGotoButton.interactable = false;
setFreeButton.interactable = true;
mouseInMapCon.ChangeMouseMode(MouseInMap.MouseMode.GotoSet, level);
buttonColorChanger.ChangeInteractableColor(clearGameButton, true);
buttonColorChanger.ChangeInteractableColor(setEnemyButton, true);
buttonColorChanger.ChangeInteractableColor(setStayButton, true);
buttonColorChanger.ChangeInteractableColor(setAttackButton, true);
buttonColorChanger.ChangeInteractableColor(setGotoButton, true);
buttonColorChanger.ChangeInteractableColor(setFreeButton, true);
}
public void SetAttackPressed()
// Set Attack Button Pressed, change mouse mode to AttackSetMode
private void SetAttackPressed(int level)
{
mouseInMapCon.ChangeMouseMode(MouseInMap.MouseMode.AttackSet);
setStayButton.interactable = true;
setAttackButton.interactable = false;
setGotoButton.interactable = true;
setFreeButton.interactable = true;
mouseInMapCon.ChangeMouseMode(MouseInMap.MouseMode.AttackSet, level);
buttonColorChanger.ChangeInteractableColor(clearGameButton, true);
buttonColorChanger.ChangeInteractableColor(setEnemyButton, true);
buttonColorChanger.ChangeInteractableColor(setStayButton, true);
buttonColorChanger.ChangeInteractableColor(setAttackButton, true);
buttonColorChanger.ChangeInteractableColor(setGotoButton, true);
buttonColorChanger.ChangeInteractableColor(setFreeButton, true);
}
public void SetFreePressed()
/// <summary>
/// Adds level buttons from a level panel to the color changer, making them got interactable color.
/// </summary>
/// <param name="levelPanel">The level panel object containing the level buttons.</param>
private void AddLevelButtonToColorChanger(GameObject levelPanel)
{
mouseInMapCon.ChangeMouseMode(MouseInMap.MouseMode.Default);
targetCon.FreeModeChange();
setStayButton.interactable = true;
setAttackButton.interactable = true;
setGotoButton.interactable = true;
setFreeButton.interactable = false;
foreach(Button btn in levelPanel.GetComponent<LevelPanel>().LevelButtonList)
{
buttonColorChanger.AddButtonToColorChangerButtonList(btn,true);
}
}
public void SetStayPressed()
/// <summary>
/// sign up pointer enter event for button
/// </summary>
/// <param name="triggerButton">target button</param>
/// <param name="panel">target panel</param>
/// <param name="inAction">enter event trigered action</param>
private void AddPointerEnterButtonTrigger(Button triggerButton, GameObject panel, PointerInOutUIEventDelegate inAction)
{
mouseInMapCon.ChangeMouseMode(MouseInMap.MouseMode.Default);
targetCon.StayModeChange();
setStayButton.interactable = false;
setAttackButton.interactable = true;
setGotoButton.interactable = true;
setFreeButton.interactable = true;
EventTrigger.Entry inEntry = new EventTrigger.Entry();
inEntry.eventID = EventTriggerType.PointerEnter;
inEntry.callback.AddListener((eventData) => inAction(triggerButton, panel, eventData));
triggerButton.GetComponent<EventTrigger>().triggers.Add(inEntry);
}
public void ShowLevelMenu(GameObject levelPanel)
/// <summary>
/// sign up pointer exit event for button
/// </summary>
/// <param name="triggerButton">target button</param>
/// <param name="panel">target panel</param>
/// <param name="inAction">exit event trigered action</param>
private void AddPointerExitButtonTrigger(Button triggerButton, GameObject panel, PointerInOutUIEventDelegate outAction)
{
EventTrigger.Entry outEntry = new EventTrigger.Entry();
outEntry.eventID = EventTriggerType.PointerExit;
outEntry.callback.AddListener((eventData) => outAction(triggerButton, panel, eventData));
triggerButton.GetComponent<EventTrigger>().triggers.Add(outEntry);
}
/// <summary>
/// sign up pointer exit event for panel
/// </summary>
/// <param name="triggerButton">target button</param>
/// <param name="panel">target panel</param>
/// <param name="inAction">exit event trigered action</param>
private void AddPointerExitLevelPanelTrigger(Button triggerButton, GameObject panel, PointerInOutUIEventDelegate outAction)
{
EventTrigger.Entry entry = new EventTrigger.Entry();
entry.eventID = EventTriggerType.PointerExit;
entry.callback.AddListener((eventData) => outAction(triggerButton, panel, eventData));
panel.GetComponent<EventTrigger>().triggers.Add(entry);
}
/// <summary>
/// pointer enter event action for button
/// </summary>
/// <param name="button">target button</param>
/// <param name="panel">target panel</param>
/// <param name="baseEventData">EventTrigger Parameter</param>
private void PointerEnterButtonAction(Button button, GameObject panel, BaseEventData baseEventData)
{
panel.GetComponent<LevelPanel>().ExpandLevelPanel(levelPanelAnimeTime);
}
/// <summary>
/// pointer exit event action for button
/// </summary>
/// <param name="button">target button</param>
/// <param name="panel">target panel</param>
/// <param name="baseEventData">EventTrigger Parameter</param>
private void PointerExitButtonAction(Button button, GameObject panel, BaseEventData baseEventData)
{
bool pointerInPanel = RectTransformUtility.RectangleContainsScreenPoint(panel.GetComponent<RectTransform>(), Input.mousePosition);
if (!pointerInPanel)
{
panel.GetComponent<LevelPanel>().FoldLevelPanel(levelPanelAnimeTime);
}
}
/// <summary>
/// pointer enter event action for level panel
/// </summary>
/// <param name="button">target button</param>
/// <param name="panel">target panel</param>
/// <param name="baseEventData">EventTrigger Parameter</param>
private void PointerExitLevelPanelAction(Button button, GameObject panel, BaseEventData baseEventData)
{
bool pointerInButton = RectTransformUtility.RectangleContainsScreenPoint(button.GetComponent<RectTransform>(), Input.mousePosition);
if (!pointerInButton)
{
panel.GetComponent<LevelPanel>().FoldLevelPanel(levelPanelAnimeTime);
}
}
}
+6 -1
View File
@@ -1,4 +1,5 @@
using System.Collections.Generic;
using UnityEditor.PackageManager;
using UnityEngine;
[CreateAssetMenu(menuName = "All Scene Prefab Set")]
@@ -14,7 +15,7 @@ public class SceneBlocksSet : ScriptableObject
{
this.hudObj = hudObj;
messageBoxController = this.hudObj.GetComponent<MessageBoxController>();
for (int i = 0; i < 3; i++)
for (int i = 0; i < levels.Length; i++)
{
// initialize all level prefab set
levels[i].InitializeLevelsSet();
@@ -37,11 +38,13 @@ public class SceneBlocksSet : ScriptableObject
case SceneBlockContainer.Targets.Defence:
messageBoxController.PushMessage(new List<string> { "[ERROR]ScenePrefabSet.GetAllLevlePrefabSet:", " Defence Mode not ready!" },
new List<string> { messageBoxController.errorColor });
Debug.LogError("ScenePrefabSet.GetAllLevlePrefabSet:Defence Mode not ready!");
return levels[2];
default:
messageBoxController.PushMessage(new List<string> { "[ERROR]ScenePrefabSet.GetAllLevlePrefabSet:", " targetType not found!","tagetType = ",targetType.ToString() },
new List<string> { messageBoxController.errorColor });
Debug.LogError("ScenePrefabSet.GetAllLevlePrefabSet:targetType not found!");
return null;
}
}
@@ -53,6 +56,7 @@ public class SceneBlocksSet : ScriptableObject
{
messageBoxController.PushMessage(new List<string> { "[ERROR]ScenePrefabSet.GetSingleLevelPrefabSet:", " level out of range!","targetType = ",targetType.ToString(), "level = ",level.ToString()},
new List<string> { messageBoxController.errorColor });
Debug.LogError("ScenePrefabSet.GetSingleLevelPrefabSet:level out of range!");
return null;
}
return GetAllLevlePrefabSet(targetType).singleLevelSet[level];
@@ -65,6 +69,7 @@ public class SceneBlocksSet : ScriptableObject
{
messageBoxController.PushMessage(new List<string> { "[ERROR]ScenePrefabSet.GetPrefab:", " blockType out of range!","targetType = ",targetType.ToString(), "level = ",level.ToString(), "blockType = ",blockType.ToString()},
new List<string> { messageBoxController.errorColor });
Debug.LogError("ScenePrefabSet.GetPrefab:blockType out of range!");
return null;
}
return GetSingleLevelPrefabSet(targetType, level).prefabs[blockType];