1.5
This commit is contained in:
parent
98a4ed6480
commit
d3f6d3b850
@ -29,8 +29,8 @@ Transform:
|
|||||||
m_PrefabAsset: {fileID: 0}
|
m_PrefabAsset: {fileID: 0}
|
||||||
m_GameObject: {fileID: 4703411402065954783}
|
m_GameObject: {fileID: 4703411402065954783}
|
||||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||||
m_LocalPosition: {x: -1.3, y: 6.81, z: 0}
|
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||||
m_LocalScale: {x: 0.26, y: 0.26, z: 0.26}
|
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||||
m_ConstrainProportionsScale: 1
|
m_ConstrainProportionsScale: 1
|
||||||
m_Children:
|
m_Children:
|
||||||
- {fileID: 4703411402469012868}
|
- {fileID: 4703411402469012868}
|
||||||
@ -171,7 +171,7 @@ BoxCollider2D:
|
|||||||
m_IsTrigger: 1
|
m_IsTrigger: 1
|
||||||
m_UsedByEffector: 0
|
m_UsedByEffector: 0
|
||||||
m_UsedByComposite: 0
|
m_UsedByComposite: 0
|
||||||
m_Offset: {x: 0.00000020861626, y: 0.23581672}
|
m_Offset: {x: 0.004774332, y: 0.15206861}
|
||||||
m_SpriteTilingProperty:
|
m_SpriteTilingProperty:
|
||||||
border: {x: 0, y: 0, z: 0, w: 0}
|
border: {x: 0, y: 0, z: 0, w: 0}
|
||||||
pivot: {x: 0, y: 0}
|
pivot: {x: 0, y: 0}
|
||||||
@ -182,7 +182,7 @@ BoxCollider2D:
|
|||||||
adaptiveTiling: 0
|
adaptiveTiling: 0
|
||||||
m_AutoTiling: 0
|
m_AutoTiling: 0
|
||||||
serializedVersion: 2
|
serializedVersion: 2
|
||||||
m_Size: {x: 1.6737638, y: 3.156044}
|
m_Size: {x: 0.60209894, y: 0.9280739}
|
||||||
m_EdgeRadius: 0
|
m_EdgeRadius: 0
|
||||||
--- !u!50 &7795976296569843979
|
--- !u!50 &7795976296569843979
|
||||||
Rigidbody2D:
|
Rigidbody2D:
|
||||||
@ -261,9 +261,9 @@ Transform:
|
|||||||
m_PrefabAsset: {fileID: 0}
|
m_PrefabAsset: {fileID: 0}
|
||||||
m_GameObject: {fileID: 4703411402842800732}
|
m_GameObject: {fileID: 4703411402842800732}
|
||||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||||
m_LocalPosition: {x: 0, y: 4.43, z: 0}
|
m_LocalPosition: {x: 0, y: 1.25, z: 0}
|
||||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
m_LocalScale: {x: 0.26, y: 0.26, z: 0.26}
|
||||||
m_ConstrainProportionsScale: 0
|
m_ConstrainProportionsScale: 1
|
||||||
m_Children: []
|
m_Children: []
|
||||||
m_Father: {fileID: 4703411402065954782}
|
m_Father: {fileID: 4703411402065954782}
|
||||||
m_RootOrder: 1
|
m_RootOrder: 1
|
||||||
@ -309,7 +309,7 @@ SpriteRenderer:
|
|||||||
m_SortingLayerID: 0
|
m_SortingLayerID: 0
|
||||||
m_SortingLayer: 0
|
m_SortingLayer: 0
|
||||||
m_SortingOrder: 0
|
m_SortingOrder: 0
|
||||||
m_Sprite: {fileID: 21300000, guid: 2a9c43eb111cab3499a539e031a452fc, type: 3}
|
m_Sprite: {fileID: 21300000, guid: 57d35e7424996004e851d5648c055617, type: 3}
|
||||||
m_Color: {r: 1, g: 1, b: 1, a: 1}
|
m_Color: {r: 1, g: 1, b: 1, a: 1}
|
||||||
m_FlipX: 0
|
m_FlipX: 0
|
||||||
m_FlipY: 0
|
m_FlipY: 0
|
||||||
|
@ -25,8 +25,8 @@ Transform:
|
|||||||
m_PrefabAsset: {fileID: 0}
|
m_PrefabAsset: {fileID: 0}
|
||||||
m_GameObject: {fileID: 8433650274046349753}
|
m_GameObject: {fileID: 8433650274046349753}
|
||||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||||
m_LocalPosition: {x: 0, y: 1.4, z: 0}
|
m_LocalPosition: {x: 0, y: 0.4, z: 0}
|
||||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
m_LocalScale: {x: 0.2, y: 0.2, z: 0.2}
|
||||||
m_ConstrainProportionsScale: 0
|
m_ConstrainProportionsScale: 0
|
||||||
m_Children: []
|
m_Children: []
|
||||||
m_Father: {fileID: 8433650275485930555}
|
m_Father: {fileID: 8433650275485930555}
|
||||||
@ -73,7 +73,7 @@ SpriteRenderer:
|
|||||||
m_SortingLayerID: 0
|
m_SortingLayerID: 0
|
||||||
m_SortingLayer: 0
|
m_SortingLayer: 0
|
||||||
m_SortingOrder: 0
|
m_SortingOrder: 0
|
||||||
m_Sprite: {fileID: 21300000, guid: c7f9e1c4f70d9144082368f6f4d63848, type: 3}
|
m_Sprite: {fileID: 21300000, guid: 3d9fbac889d5ad5409d8a8bb65c7ba3a, type: 3}
|
||||||
m_Color: {r: 1, g: 1, b: 1, a: 1}
|
m_Color: {r: 1, g: 1, b: 1, a: 1}
|
||||||
m_FlipX: 0
|
m_FlipX: 0
|
||||||
m_FlipY: 0
|
m_FlipY: 0
|
||||||
@ -148,7 +148,7 @@ CircleCollider2D:
|
|||||||
m_UsedByComposite: 0
|
m_UsedByComposite: 0
|
||||||
m_Offset: {x: 0, y: 0}
|
m_Offset: {x: 0, y: 0}
|
||||||
serializedVersion: 2
|
serializedVersion: 2
|
||||||
m_Radius: 5
|
m_Radius: 3
|
||||||
--- !u!1 &8433650275485930554
|
--- !u!1 &8433650275485930554
|
||||||
GameObject:
|
GameObject:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
@ -178,7 +178,7 @@ Transform:
|
|||||||
m_GameObject: {fileID: 8433650275485930554}
|
m_GameObject: {fileID: 8433650275485930554}
|
||||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||||
m_LocalPosition: {x: 0, y: 0, z: 0}
|
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||||
m_LocalScale: {x: 0.2, y: 0.2, z: 0.2}
|
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||||
m_ConstrainProportionsScale: 1
|
m_ConstrainProportionsScale: 1
|
||||||
m_Children:
|
m_Children:
|
||||||
- {fileID: 8433650274814453345}
|
- {fileID: 8433650274814453345}
|
||||||
@ -323,3 +323,4 @@ MonoBehaviour:
|
|||||||
m_Name:
|
m_Name:
|
||||||
m_EditorClassIdentifier:
|
m_EditorClassIdentifier:
|
||||||
tower: {fileID: 0}
|
tower: {fileID: 0}
|
||||||
|
Tag: tower
|
||||||
|
4990
meng_yao/Assets/Prefabs/ui/Beat_ZanTing.prefab
Normal file
4990
meng_yao/Assets/Prefabs/ui/Beat_ZanTing.prefab
Normal file
File diff suppressed because it is too large
Load Diff
7
meng_yao/Assets/Prefabs/ui/Beat_ZanTing.prefab.meta
Normal file
7
meng_yao/Assets/Prefabs/ui/Beat_ZanTing.prefab.meta
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 81ac41c28357eb345a2c8c57084c4da3
|
||||||
|
PrefabImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
85
meng_yao/Assets/script/A_Fight/BaseUI.cs
Normal file
85
meng_yao/Assets/script/A_Fight/BaseUI.cs
Normal file
@ -0,0 +1,85 @@
|
|||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using UnityEngine;
|
||||||
|
using UnityEngine.UI;
|
||||||
|
using DG.Tweening;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
public class BaseUI :Base
|
||||||
|
{
|
||||||
|
[Header("父类自动的panel,按需要给,在生成的时候自动有动画")]
|
||||||
|
public GameObject _panel;
|
||||||
|
|
||||||
|
public List<Button> BTNs = new List<Button>();
|
||||||
|
public virtual async Task showPanel(GameObject panel)
|
||||||
|
{
|
||||||
|
if (panel == null)
|
||||||
|
{
|
||||||
|
Debug.LogError("panel==null");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
panel.transform.localScale = new Vector3(0.5f, 0.5f, 0.5f);
|
||||||
|
panel.transform.DOScale(1f, 0.5f);
|
||||||
|
await Task.Delay(500);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addEventPopUp(string Details, float time = 5f)//添加弹窗
|
||||||
|
{
|
||||||
|
GameObject prefab = Resources.Load<GameObject>("base/EventPopUp");
|
||||||
|
prefab.GetComponent<EventPopUp>().time = time;
|
||||||
|
Canvas canvas = GetComponentInParent<Canvas>();
|
||||||
|
prefab.GetComponent<EventPopUp>().text = Details;
|
||||||
|
Instantiate(prefab, canvas.transform);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 注册按钮并设置响应事件
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="btn">按钮</param>
|
||||||
|
/// <param name="action">事件</param>
|
||||||
|
public void RegisterButton(Button btn, UnityEngine.Events.UnityAction action)
|
||||||
|
{
|
||||||
|
if (btn != null && action != null)
|
||||||
|
{
|
||||||
|
btn.onClick.AddListener(action);
|
||||||
|
BTNs.Add(btn); // 将按钮加入到按钮组
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Debug.LogError("Button or action is null!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 注销按钮响应事件
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="btn">按钮</param>
|
||||||
|
/// <param name="action">事件</param>
|
||||||
|
public void UnregisterButton(Button btn, UnityEngine.Events.UnityAction action)
|
||||||
|
{
|
||||||
|
if (btn != null && action != null)
|
||||||
|
{
|
||||||
|
btn.onClick.RemoveListener(action);
|
||||||
|
BTNs.Remove(btn); // 从按钮组中移除按钮
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 注销所有按钮的响应事件并清空按钮组
|
||||||
|
/// </summary>
|
||||||
|
public void UnregisterAllButtons()
|
||||||
|
{
|
||||||
|
foreach (Button btn in BTNs)
|
||||||
|
{
|
||||||
|
if (btn != null)
|
||||||
|
{
|
||||||
|
// 取消所有事件监听
|
||||||
|
btn.onClick.RemoveAllListeners();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 清空按钮组
|
||||||
|
BTNs.Clear();
|
||||||
|
}
|
||||||
|
}
|
11
meng_yao/Assets/script/A_Fight/BaseUI.cs.meta
Normal file
11
meng_yao/Assets/script/A_Fight/BaseUI.cs.meta
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 4b489e4812aaf48438d7964a61deeae5
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
36
meng_yao/Assets/script/A_Fight/Beat_ZanTing.cs
Normal file
36
meng_yao/Assets/script/A_Fight/Beat_ZanTing.cs
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
public class Beat_ZanTing:BaseUI
|
||||||
|
{
|
||||||
|
[Header("¹Ø±Õ°´Å¥,¹Ø±ÕµÄÃæ°å")] public GameObject panel;
|
||||||
|
private async void Start()
|
||||||
|
{
|
||||||
|
await showPanel(_panel);
|
||||||
|
|
||||||
|
RegisterButton(BTNs[0], async () => {
|
||||||
|
gameGlobal.GameRecovery();
|
||||||
|
await ButtonClickAnimationAsync(BTNs[0].gameObject);
|
||||||
|
Destroy(panel);
|
||||||
|
});
|
||||||
|
|
||||||
|
RegisterButton(BTNs[1], async() => {
|
||||||
|
gameGlobal.GameRecovery();
|
||||||
|
await ButtonClickAnimationAsync(BTNs[1].gameObject);
|
||||||
|
gameGlobal.GameExit();
|
||||||
|
});
|
||||||
|
|
||||||
|
RegisterButton(BTNs[2], async () => {
|
||||||
|
gameGlobal.GameRecovery();
|
||||||
|
await ButtonClickAnimationAsync(BTNs[2].gameObject);
|
||||||
|
Destroy(panel);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void OnDisable()
|
||||||
|
{
|
||||||
|
UnregisterAllButtons();
|
||||||
|
}
|
||||||
|
}
|
11
meng_yao/Assets/script/A_Fight/Beat_ZanTing.cs.meta
Normal file
11
meng_yao/Assets/script/A_Fight/Beat_ZanTing.cs.meta
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: e98ac44f18450a84db660bef8c89bf90
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
@ -1,5 +1,6 @@
|
|||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Threading.Tasks;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEngine.UI;
|
using UnityEngine.UI;
|
||||||
|
|
||||||
@ -9,37 +10,35 @@ public class StopBtn : MonoBehaviour
|
|||||||
public Image stopImage;
|
public Image stopImage;
|
||||||
public Button stopBtn;
|
public Button stopBtn;
|
||||||
|
|
||||||
|
public GameObject panelPrefab;
|
||||||
|
|
||||||
int number;
|
int number;
|
||||||
// Start is called before the first frame update
|
// Start is called before the first frame update
|
||||||
void Start()
|
void Start()
|
||||||
{
|
{
|
||||||
|
GameSatrt();
|
||||||
stopBtn = GetComponent<Button>();
|
stopBtn = GetComponent<Button>();
|
||||||
stopBtn.onClick.AddListener(StopClick);
|
stopBtn.onClick.AddListener(async ()=>{
|
||||||
|
GameStop();
|
||||||
|
|
||||||
|
GameObject.Instantiate(panelPrefab,GameObject.Find("Canvas").transform);
|
||||||
|
await Task.Delay(500);
|
||||||
|
gameGlobal.GameStop();
|
||||||
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void StopClick()
|
|
||||||
{
|
void GameStop()
|
||||||
number++;
|
|
||||||
if (number %2 != 0)
|
|
||||||
{
|
|
||||||
startImage.gameObject.SetActive(false);
|
|
||||||
stopImage.gameObject.SetActive(true);
|
|
||||||
UIContorl.instance.StopTimer();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
startImage.gameObject.SetActive(true);
|
startImage.gameObject.SetActive(true);
|
||||||
stopImage.gameObject.SetActive(false);
|
stopImage.gameObject.SetActive(false);
|
||||||
UIContorl.instance.StartTimer();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GameSatrt()
|
||||||
}
|
|
||||||
|
|
||||||
// Update is called once per frame
|
|
||||||
void Update()
|
|
||||||
{
|
{
|
||||||
|
startImage.gameObject.SetActive(false);
|
||||||
|
stopImage.gameObject.SetActive(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -25,7 +25,8 @@ public class UIContorl : MonoBehaviour
|
|||||||
instance = this;
|
instance = this;
|
||||||
|
|
||||||
FightBtn.onClick.AddListener(FightClick);
|
FightBtn.onClick.AddListener(FightClick);
|
||||||
StartTimer();//²âÊÔ
|
Battle_Time.text = "00:00";
|
||||||
|
StopTimer();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
36
meng_yao/Assets/script/A_Fight/cardBox.cs
Normal file
36
meng_yao/Assets/script/A_Fight/cardBox.cs
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using UnityEngine;
|
||||||
|
using UnityEngine.UI;
|
||||||
|
|
||||||
|
public class cardBox : MonoBehaviour
|
||||||
|
{
|
||||||
|
public static cardBox instance;
|
||||||
|
[Header("萌妖数量")] public int mengyaoNumber=0;
|
||||||
|
[HideInInspector] public int inPlaceNumber=0;
|
||||||
|
[Header("开始按钮obj")] public GameObject btnObj;
|
||||||
|
|
||||||
|
private void Awake()
|
||||||
|
{
|
||||||
|
instance = this;
|
||||||
|
if (btnObj==null)
|
||||||
|
{
|
||||||
|
Debug.LogError("btnObj==null");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
btnObj.SetActive(false);
|
||||||
|
}
|
||||||
|
public void ChangeInPlaceNumber(int number)
|
||||||
|
{
|
||||||
|
inPlaceNumber += number;
|
||||||
|
if (inPlaceNumber== mengyaoNumber)
|
||||||
|
{
|
||||||
|
gameGlobal.GameStart();
|
||||||
|
Debug.Log("布置完成");
|
||||||
|
btnObj.SetActive(true);
|
||||||
|
btnObj.GetComponent<Button>().onClick.AddListener(() => {
|
||||||
|
gameGlobal.GamePlay();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
11
meng_yao/Assets/script/A_Fight/cardBox.cs.meta
Normal file
11
meng_yao/Assets/script/A_Fight/cardBox.cs.meta
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 36d8b1f23f0ec174594a18d38154925d
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
@ -27,6 +27,7 @@ public class cardContorl : MonoBehaviour, IBeginDragHandler, IDragHandler, IEndD
|
|||||||
|
|
||||||
[HideInInspector]
|
[HideInInspector]
|
||||||
public GameObject mY;
|
public GameObject mY;
|
||||||
|
|
||||||
private Vector3 startPos;//记录一开始的位置
|
private Vector3 startPos;//记录一开始的位置
|
||||||
|
|
||||||
//private SpriteAniation spriteAniation;
|
//private SpriteAniation spriteAniation;
|
||||||
@ -42,13 +43,15 @@ public class cardContorl : MonoBehaviour, IBeginDragHandler, IDragHandler, IEndD
|
|||||||
//spriteAniation.enabled = false;
|
//spriteAniation.enabled = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// 拖拽开始
|
// 拖拽开始
|
||||||
public void OnBeginDrag(PointerEventData eventData)
|
public void OnBeginDrag(PointerEventData eventData)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
//this.recordParent = this.transform.parent;
|
|
||||||
mY = Instantiate(mengyaoPrefab,PrefabParent.transform);
|
mY = Instantiate(mengyaoPrefab);
|
||||||
Vector3 mousePosition = Input.mousePosition;
|
Vector3 mousePosition = Input.mousePosition;
|
||||||
|
|
||||||
// 将鼠标屏幕坐标转换为世界坐标
|
// 将鼠标屏幕坐标转换为世界坐标
|
||||||
@ -58,9 +61,6 @@ public class cardContorl : MonoBehaviour, IBeginDragHandler, IDragHandler, IEndD
|
|||||||
mY.transform.position = mousePosition;
|
mY.transform.position = mousePosition;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
this.transform.SetParent(canvas.transform);
|
|
||||||
//throw new System.NotImplementedException();
|
|
||||||
}
|
}
|
||||||
// 拖拽中
|
// 拖拽中
|
||||||
public void OnDrag(PointerEventData eventData)
|
public void OnDrag(PointerEventData eventData)
|
||||||
@ -90,6 +90,8 @@ public class cardContorl : MonoBehaviour, IBeginDragHandler, IDragHandler, IEndD
|
|||||||
Destroy(mY.GetComponent<cardPlace>());
|
Destroy(mY.GetComponent<cardPlace>());
|
||||||
|
|
||||||
this.enabled = false;
|
this.enabled = false;
|
||||||
|
|
||||||
|
cardBox.instance.ChangeInPlaceNumber(1);
|
||||||
mask.SetActive(true);
|
mask.SetActive(true);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -6,6 +6,7 @@ public class cardPlace : MonoBehaviour
|
|||||||
{
|
{
|
||||||
private Transform parent;
|
private Transform parent;
|
||||||
public GameObject tower;
|
public GameObject tower;
|
||||||
|
public string Tag;
|
||||||
public bool isInTrigger { get; set; }
|
public bool isInTrigger { get; set; }
|
||||||
|
|
||||||
// Start is called before the first frame update
|
// Start is called before the first frame update
|
||||||
@ -19,33 +20,24 @@ public class cardPlace : MonoBehaviour
|
|||||||
|
|
||||||
private void OnTriggerEnter2D(Collider2D collision)
|
private void OnTriggerEnter2D(Collider2D collision)
|
||||||
{
|
{
|
||||||
if (!isInTrigger)
|
if (!isInTrigger&& collision.tag.Equals(Tag))
|
||||||
{
|
{
|
||||||
//Debug.Log("物体第一次进入触发器");
|
//Debug.Log("物体第一次进入触发器");
|
||||||
isInTrigger = true;
|
isInTrigger = true;
|
||||||
|
tower = collision.gameObject;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnTriggerExit2D(Collider2D collision)
|
private void OnTriggerExit2D(Collider2D collision)
|
||||||
{
|
{
|
||||||
if (isInTrigger)
|
if (isInTrigger&&collision.tag.Equals(Tag))
|
||||||
{
|
{
|
||||||
//Debug.Log("物体退出触发器");
|
//Debug.Log("物体退出触发器");
|
||||||
|
|
||||||
isInTrigger = false;
|
isInTrigger = false;
|
||||||
|
tower = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnTriggerStay2D(Collider2D collision)
|
|
||||||
{
|
|
||||||
// 仅在物体持续在触发器内时,执行某些操作
|
|
||||||
if (isInTrigger)
|
|
||||||
{
|
|
||||||
//Debug.Log("物体持续在触发器内");
|
|
||||||
// 在这里进行物体持续在触发器内时的操作
|
|
||||||
//this.transform.SetParent(collision.transform);
|
|
||||||
tower = collision.gameObject;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -9,6 +9,7 @@ public class enemy : Role
|
|||||||
base.Start();
|
base.Start();
|
||||||
if (camp == Camp.Enemy)
|
if (camp == Camp.Enemy)
|
||||||
{
|
{
|
||||||
|
//开始移动
|
||||||
Navigation.MoveToNextWaypoint(this.gameObject);
|
Navigation.MoveToNextWaypoint(this.gameObject);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
64
meng_yao/Assets/script/A_Fight/gameGlobal.cs
Normal file
64
meng_yao/Assets/script/A_Fight/gameGlobal.cs
Normal file
@ -0,0 +1,64 @@
|
|||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
public class gameGlobal : Base
|
||||||
|
{
|
||||||
|
public delegate void GameItem();
|
||||||
|
public event GameItem OnGameInit;
|
||||||
|
public event GameItem OnGameStart;
|
||||||
|
public event GameItem OnGamePlay;
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 游戏初始化
|
||||||
|
/// </summary>
|
||||||
|
public static void GameInit()
|
||||||
|
{
|
||||||
|
Base.GlobalObj.GetComponent<gameGlobal>().OnGameInit?.Invoke();
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 游戏可以开始,准备完成
|
||||||
|
/// </summary>
|
||||||
|
public static void GameStart()
|
||||||
|
{
|
||||||
|
Base.GlobalObj.GetComponent<gameGlobal>().OnGameStart?.Invoke();
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 游戏进行
|
||||||
|
/// </summary>
|
||||||
|
public static void GamePlay()
|
||||||
|
{
|
||||||
|
Base.GlobalObj.GetComponent<gameGlobal>().OnGamePlay?.Invoke();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 游戏暂停
|
||||||
|
/// </summary>
|
||||||
|
public static void GameStop()
|
||||||
|
{
|
||||||
|
Time.timeScale = 0f;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 游戏恢复
|
||||||
|
/// </summary>
|
||||||
|
public static void GameRecovery()
|
||||||
|
{
|
||||||
|
Time.timeScale = 1f;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 游戏退出
|
||||||
|
/// </summary>
|
||||||
|
public static void GameExit()
|
||||||
|
{
|
||||||
|
|
||||||
|
Application.Quit();
|
||||||
|
|
||||||
|
// 如果在编辑器中测试退出游戏效果
|
||||||
|
#if UNITY_EDITOR
|
||||||
|
UnityEditor.EditorApplication.isPlaying = false; // 在编辑器中停止游戏
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
}
|
11
meng_yao/Assets/script/A_Fight/gameGlobal.cs.meta
Normal file
11
meng_yao/Assets/script/A_Fight/gameGlobal.cs.meta
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: f8d3b5b0e732d264e98661c1084a68bf
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
Loading…
Reference in New Issue
Block a user