This commit is contained in:
JA
2026-06-27 03:36:46 +08:00
parent aec4e97d27
commit 7a8d4a5d83
1215 changed files with 48271 additions and 146052 deletions

View File

@@ -1,11 +0,0 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class LevelUp : MonoBehaviour
{
private void OnTriggerEnter(Collider other)
{
UIManager.Instance.Show<UILevelUp>();
}
}

View File

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

View File

@@ -1,8 +0,0 @@
fileFormatVersion: 2
guid: 831a08ac5bb2de440acde27635619af9
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,8 +0,0 @@
fileFormatVersion: 2
guid: 12c2b15ec8c03cf48ae095dfbb940ab7
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,210 +0,0 @@
using Manager;
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.InputSystem;
public class PlayerControler : MonoBehaviour
{
[SerializeField] private InputActions inputActions;
[SerializeField] public Animator animator;
[SerializeField] private Rigidbody2D rb;
[SerializeField] private BoxCollider2D bc;
private CameraVR cameraVR;
[Header("正常速度")]
[SerializeField] private float normalSpeed;
Vector2 InputDir;//移动方向
public float dodgeCoolDown;//闪避Cd时间
public float dodgeSpeed;
private float dodge;
private bool isCanDodge;
private bool isWuDi;
public float wuDiTimer;
public CharacterCombat ch;
public CharacterHp info;
private void Awake()
{
inputActions = new InputActions();
cameraVR = GameObject.FindWithTag("Camera").GetComponentInChildren<CameraVR>();
}
private void Start()
{
inputActions.GamePlay.ComBa_01.started += this.Attack_01;
inputActions.GamePlay.ComBa_02.started += this.Attack_02;
inputActions.GamePlay.Dodge.started += this.Dodge;
inputActions.UI.Stop.started += this.OnStop;
inputActions.UI.Bag.started += this.OpenBag;
dodge = dodgeCoolDown;
isCanDodge = true;
ManagersMode.Poll.CreateGameObjectPoll("Timer", 10);
ManagersMode.Poll.CreateGameObjectPoll("BulletPoll", 3);
ManagersMode.Poll.CreateGameObjectPoll("EffectPoll", 2);
info.Init(ch);
}
private void Update()
{
if(ch.currentHp<=0)
{
UIManager.Instance.Show<UIGameOver>();
ch._animator.Play("die");
}
if(!animator.CheckAnimationTag("Roll"))
{
animator.speed = 1;
}
else
{
this.transform.Translate(InputDir*dodgeSpeed*0.01f);//闪避移动
}
CanDodge();
UseItem();
}
private void OnEnable()
{
inputActions.Enable();
}
private void OnDisable()
{
inputActions.Disable();
}
private void FixedUpdate()
{
if(!animator.CheckAnimationTag("Die"))
{
this.MoveController();
}
else
{
this.rb.velocity =Vector2.zero;
}
}
#region
private void MoveController()
{
InputDir = inputActions.GamePlay.Move.ReadValue<Vector2>().normalized;
animator.SetFloat("Horizontal", InputDir.x);
animator.SetFloat("Vertical", InputDir.y);
animator.SetFloat("Speed", InputDir.sqrMagnitude);
this.rb.velocity = InputDir * normalSpeed;
if (InputDir.x < 0)//向左
{
transform.localScale = new Vector3(1, 1, 1);
}
if (InputDir.x > 0)//向左
{
transform.localScale = new Vector3(-1, 1, 1);
}
}
private void OnStop(InputAction.CallbackContext obj)
{
UIManager.Instance.Show<UIGameOver>();
}
#endregion
/// <summary>
/// 角色攻击
/// </summary>
private void Attack_01(InputAction.CallbackContext obj)
{
animator.SetTrigger("Attack_01");
}
private void Attack_02(InputAction.CallbackContext obj)
{
animator.SetTrigger("Attack_02");
}
private bool CanDodge()
{
if(isCanDodge)
{
return true;
}
dodgeCoolDown -= Time.deltaTime;
if(dodgeCoolDown<=0)
{
isCanDodge = true;
dodgeCoolDown = dodge;
return true;
}
return false;
}
/// <summary>
/// 角色闪避
/// </summary>
private void Dodge(InputAction.CallbackContext obj)
{
//||animator.CheckAnimationTag("Hit")
if (!CanDodge())
{
return;
}
StartCoroutine(nameof(SetWuDi));//无敌状态
isCanDodge = false;
animator.speed = 1f;
if (InputDir.x!=0)
{
animator.Play("roll");
}
if (InputDir.y > 0)
{
animator.Play("roll-up");
}
if (InputDir.y < 0)
{
animator.Play("roll-down");
}
}
IEnumerator SetWuDi()
{
isWuDi = true;
yield return new WaitForSeconds(wuDiTimer);
isWuDi = false;
}
public bool GetIsDodge()
{
return isWuDi;
}
private void OpenBag(InputAction.CallbackContext obj)
{
UIManager.Instance.Show<UIBagInfo>();
}
public void UseItem()
{
if(Input.GetKeyDown(KeyCode.Alpha1))
{
PlayerInfo.Instance.BagMgr.UserItem(1, 1);//回血道具
}
}
}

View File

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

View File

@@ -1,154 +0,0 @@
using Managers;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UnityEngine;
public class PlayerInfo : Singleton<PlayerInfo>
{
public CharInfo info;
public Action OnUpdateBagInfo;
public Action OnUpdateMainUI;
public Action OnUpdateLevel;
public Action<LotteryType, float> OnUpdateAttrbute;
public Managers.BagManager BagMgr;
public void Init(CharInfo date)
{
info = date;
info.playerName = date.playerName;
info.Level = date.Level;
info.exp = date.exp;
info.maxHp = date.maxHp;
info.attack = date.attack;
info.testAttack = date.testAttack;
info.currentHp = date.currentHp;
info.currentMap = date.currentMap;
info.BagInfo = new Dictionary<int, int>();
info.UpInfo = new Dictionary<int, bool>();
for (int i = 0; i < date.BagKey.Count; i++)
{
info.BagInfo.Add(date.BagKey[i], date.BagValue[i]);
}
for (int i = 0; i < date.UpKey.Count; i++)
{
info.UpInfo.Add(date.UpKey[i], date.UpValue[i]);
}
//初始化管理器
BagMgr = new Managers.BagManager(this);
Debug.Log("数据读取完毕");
}
public void Resrt()
{
info.currentHp = info.maxHp; ;
info.testAttack = info.attack;
if(!info.BagInfo.ContainsKey(1))
{
info.BagInfo.Add(1,4);
}
else
{
info.BagInfo[1] = 4;
}
WriteBagInfo();
}
public void KeepData(float max, float current, float attack)
{
info.maxHp = max;
info.currentHp = current;
info.testAttack = attack;
}
public Sprite GetSprite(string path)
{
return Resloader.Load<Sprite>(path);
}
#region
public void AddHp(int num)
{
OnUpdateAttrbute?.Invoke(LotteryType.Hp, num);
}
public void AddMp(int num)
{
OnUpdateAttrbute?.Invoke(LotteryType.Mp, num);
}
public void AddAttack(int num)
{
OnUpdateAttrbute?.Invoke(LotteryType.Attack, num);
}
public void AddUpHp(int num)
{
OnUpdateAttrbute?.Invoke(LotteryType.UpHp, num);
}
public void AddUpMaxHp(int num)
{
OnUpdateAttrbute?.Invoke(LotteryType.UpMaxHp, num);
}
public void AddUpAttack(int num)
{
OnUpdateAttrbute?.Invoke(LotteryType.UpAttack, num);
}
#endregion
#region
public void LevelUp()
{
int need = NeedExp();
if (need < info.exp)
{
info.exp -= need;
info.Level++;
LevelUp();
SaveSystem.SaveDate(info.DatePath, info);
}
}
public int NeedExp()
{
int needExp;
return needExp = info.Level * (1000);
}
public void ItemLevel(LevelUpDefine item)
{
switch (item.type)
{
case LotteryType.UpMaxHp:
AddUpMaxHp(item.value);
break;
case LotteryType.UpAttack:
AddUpAttack(item.value);
break;
case LotteryType.UpHp:
AddUpHp(item.value);
break;
}
}
#endregion
//重写数据
public void WriteBagInfo()
{
info.BagKey.Clear();
info.BagValue.Clear();
foreach (var data in info.BagInfo)
{
info.BagKey.Add(data.Key);
info.BagValue.Add(data.Value);
}
}
}

View File

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