This commit is contained in:
shurongsen 2024-12-09 18:01:59 +08:00
parent 98a4ed6480
commit d3f6d3b850
19 changed files with 8826 additions and 7069 deletions

View File

@ -29,8 +29,8 @@ Transform:
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 4703411402065954783}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: -1.3, y: 6.81, z: 0}
m_LocalScale: {x: 0.26, y: 0.26, z: 0.26}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 1
m_Children:
- {fileID: 4703411402469012868}
@ -171,7 +171,7 @@ BoxCollider2D:
m_IsTrigger: 1
m_UsedByEffector: 0
m_UsedByComposite: 0
m_Offset: {x: 0.00000020861626, y: 0.23581672}
m_Offset: {x: 0.004774332, y: 0.15206861}
m_SpriteTilingProperty:
border: {x: 0, y: 0, z: 0, w: 0}
pivot: {x: 0, y: 0}
@ -182,7 +182,7 @@ BoxCollider2D:
adaptiveTiling: 0
m_AutoTiling: 0
serializedVersion: 2
m_Size: {x: 1.6737638, y: 3.156044}
m_Size: {x: 0.60209894, y: 0.9280739}
m_EdgeRadius: 0
--- !u!50 &7795976296569843979
Rigidbody2D:
@ -261,9 +261,9 @@ Transform:
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 4703411402842800732}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 4.43, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_LocalPosition: {x: 0, y: 1.25, z: 0}
m_LocalScale: {x: 0.26, y: 0.26, z: 0.26}
m_ConstrainProportionsScale: 1
m_Children: []
m_Father: {fileID: 4703411402065954782}
m_RootOrder: 1
@ -309,7 +309,7 @@ SpriteRenderer:
m_SortingLayerID: 0
m_SortingLayer: 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_FlipX: 0
m_FlipY: 0

View File

@ -25,8 +25,8 @@ Transform:
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 8433650274046349753}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 1.4, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_LocalPosition: {x: 0, y: 0.4, z: 0}
m_LocalScale: {x: 0.2, y: 0.2, z: 0.2}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 8433650275485930555}
@ -73,7 +73,7 @@ SpriteRenderer:
m_SortingLayerID: 0
m_SortingLayer: 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_FlipX: 0
m_FlipY: 0
@ -148,7 +148,7 @@ CircleCollider2D:
m_UsedByComposite: 0
m_Offset: {x: 0, y: 0}
serializedVersion: 2
m_Radius: 5
m_Radius: 3
--- !u!1 &8433650275485930554
GameObject:
m_ObjectHideFlags: 0
@ -178,7 +178,7 @@ Transform:
m_GameObject: {fileID: 8433650275485930554}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
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_Children:
- {fileID: 8433650274814453345}
@ -323,3 +323,4 @@ MonoBehaviour:
m_Name:
m_EditorClassIdentifier:
tower: {fileID: 0}
Tag: tower

File diff suppressed because it is too large Load Diff

View 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

View 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();
}
}

View File

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

View 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();
}
}

View File

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

View File

@ -1,5 +1,6 @@
using System.Collections;
using System.Collections.Generic;
using System.Threading.Tasks;
using UnityEngine;
using UnityEngine.UI;
@ -9,37 +10,35 @@ public class StopBtn : MonoBehaviour
public Image stopImage;
public Button stopBtn;
public GameObject panelPrefab;
int number;
// Start is called before the first frame update
void Start()
{
GameSatrt();
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()
{
number++;
if (number %2 != 0)
{
startImage.gameObject.SetActive(false);
stopImage.gameObject.SetActive(true);
UIContorl.instance.StopTimer();
}
else
{
startImage.gameObject.SetActive(true);
stopImage.gameObject.SetActive(false);
UIContorl.instance.StartTimer();
}
void GameStop()
{
startImage.gameObject.SetActive(true);
stopImage.gameObject.SetActive(false);
}
// Update is called once per frame
void Update()
void GameSatrt()
{
startImage.gameObject.SetActive(false);
stopImage.gameObject.SetActive(true);
}
}

View File

@ -24,8 +24,9 @@ public class UIContorl : MonoBehaviour
if (instance != null) return;
instance = this;
FightBtn.onClick.AddListener(FightClick);
StartTimer();//²âÊÔ
FightBtn.onClick.AddListener(FightClick);
Battle_Time.text = "00:00";
StopTimer();
}

View 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();
});
}
}
}

View File

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

View File

@ -27,6 +27,7 @@ public class cardContorl : MonoBehaviour, IBeginDragHandler, IDragHandler, IEndD
[HideInInspector]
public GameObject mY;
private Vector3 startPos;//记录一开始的位置
//private SpriteAniation spriteAniation;
@ -42,25 +43,24 @@ public class cardContorl : MonoBehaviour, IBeginDragHandler, IDragHandler, IEndD
//spriteAniation.enabled = false;
}
// 拖拽开始
public void OnBeginDrag(PointerEventData eventData)
{
//this.recordParent = this.transform.parent;
mY = Instantiate(mengyaoPrefab,PrefabParent.transform);
mY = Instantiate(mengyaoPrefab);
Vector3 mousePosition = Input.mousePosition;
// 将鼠标屏幕坐标转换为世界坐标
mousePosition = camera.ScreenToWorldPoint(new Vector3(mousePosition.x, mousePosition.y, 0));
// 将物体的位置更新为鼠标的位置
mY.transform.position = mousePosition;
mY.transform.position = mousePosition;
this.transform.SetParent(canvas.transform);
//throw new System.NotImplementedException();
}
// 拖拽中
public void OnDrag(PointerEventData eventData)
@ -90,6 +90,8 @@ public class cardContorl : MonoBehaviour, IBeginDragHandler, IDragHandler, IEndD
Destroy(mY.GetComponent<cardPlace>());
this.enabled = false;
cardBox.instance.ChangeInPlaceNumber(1);
mask.SetActive(true);
}
else

View File

@ -6,6 +6,7 @@ public class cardPlace : MonoBehaviour
{
private Transform parent;
public GameObject tower;
public string Tag;
public bool isInTrigger { get; set; }
// Start is called before the first frame update
@ -19,33 +20,24 @@ public class cardPlace : MonoBehaviour
private void OnTriggerEnter2D(Collider2D collision)
{
if (!isInTrigger)
if (!isInTrigger&& collision.tag.Equals(Tag))
{
//Debug.Log("物体第一次进入触发器");
isInTrigger = true;
tower = collision.gameObject;
}
}
private void OnTriggerExit2D(Collider2D collision)
{
if (isInTrigger)
if (isInTrigger&&collision.tag.Equals(Tag))
{
//Debug.Log("物体退出触发器");
isInTrigger = false;
tower = null;
}
}
private void OnTriggerStay2D(Collider2D collision)
{
// 仅在物体持续在触发器内时,执行某些操作
if (isInTrigger)
{
//Debug.Log("物体持续在触发器内");
// 在这里进行物体持续在触发器内时的操作
//this.transform.SetParent(collision.transform);
tower = collision.gameObject;
}
}
}

View File

@ -9,6 +9,7 @@ public class enemy : Role
base.Start();
if (camp == Camp.Enemy)
{
//开始移动
Navigation.MoveToNextWaypoint(this.gameObject);
}
}

View 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
}
}

View File

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