This commit is contained in:
JA
2026-06-20 19:34:23 +08:00
parent e5031c0068
commit d442805c3f
4136 changed files with 514641 additions and 0 deletions

View File

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

View File

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

View File

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

View File

@@ -0,0 +1,26 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 938875dffea6bb64195bcefab599ba64, type: 3}
m_Name: BA_Comba_01
m_EditorClassIdentifier:
abilityName: head-smash
abilityID: 0
abilityCDTime: 7
abilityClass: 0
abilityVFX: {fileID: 8300000, guid: 745ff6d9880e7e54ca173e5230018748, type: 3}
abilityIsDone: 0
abilityDistance: 0
maxAbilityCount: 0
abilityOffest:
- {x: -1.5, y: 0.5}
- {x: 1.5, y: 0.5}
- {x: 0, y: 0.5}

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 98a239d9069b5b64faf5841e97cce79a
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 11400000
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,12 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
[CreateAssetMenu(fileName = "BA_Comba_01", menuName = "Ability/BossA/Comba_01")]
public class BA_Comba_01 : CombatAblilityBase
{
public override void UpdateAblity(Transform target = null)
{
}
}

View File

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

View File

@@ -0,0 +1,25 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 39a345fbb2ba60549bc7be5a613d7fe3, type: 3}
m_Name: BA_Comba_02
m_EditorClassIdentifier:
abilityName: trunk-strike
abilityID: 1
abilityCDTime: 5
abilityClass: 1
abilityVFX: {fileID: 0}
abilityIsDone: 0
abilityDistance: 0
maxAbilityCount: 10
abilityOffest: []
g: {fileID: 5407042768625737065, guid: 883a2a6d0f356484093e8aaf8fc28de9, type: 3}
p: {fileID: 0}

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 1e98ec405a8f8bd47a5c3aefeb8add8f
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 11400000
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,24 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
[CreateAssetMenu(fileName = "BA_Comba_02", menuName = "Ability/BossA/Comba_02")]
public class BA_Comba_02 : CombatAblilityBase
{
public GameObject g;
public GameObject p;
public override void UpdateAblity(Transform target = null)
{
if (!this.ai.isYuancheng)
return;
if (currentAbilityCount>=0)
{
currentAbilityCount--;
p = GameObject.Find("BulletFire");
GameObject go = Instantiate(g);
go.transform.position = p.transform.localPosition;
go.GetComponent<BulletObject>().Init(p);
}
}
}

View File

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

View File

@@ -0,0 +1,24 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 731be78ab51c1cf4d8d0b91962d058a0, type: 3}
m_Name: BA_Comba_03
m_EditorClassIdentifier:
abilityName: Ba_Comba_03
abilityID: 2
abilityCDTime: 8
abilityClass: 0
abilityVFX: {fileID: 0}
abilityIsDone: 0
abilityDistance: 0
maxAbilityCount: 0
abilityOffest:
- {x: 0, y: 0}

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 6db587830d2a5ff4ea96be28bccf951d
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 11400000
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,22 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
[CreateAssetMenu(fileName = "BA_Comba_03", menuName = "Ability/BossA/Comba_03")]
public class BA_Comba_03 : CombatAblilityBase
{
float timer = 0;
public override void UpdateAblity(Transform target = null)
{
if (_animator.CheckAnimationTag("Attack_out")||_animator.CheckAnimationTag("Die")||_animator.CheckAnimationTag("summon"))
{
return;
}
timer += Time.deltaTime;
if(timer>=2f)
{
this.ai.transform.root.transform.position = target.position;
timer = 0;
}
}
}

View File

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

View File

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

View File

@@ -0,0 +1,24 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 0bea07483ceab4842b793a021aad4c51, type: 3}
m_Name: Comba_01
m_EditorClassIdentifier:
abilityName: Comba_01
abilityID: 0
abilityCDTime: 10
abilityClass: 0
abilityVFX: {fileID: 8300000, guid: b908de737b26207469006f83fe09ee1e, type: 3}
abilityIsDone: 0
abilityDistance: 3
maxAbilityCount: 0
abilityOffest:
- {x: -2.6, y: 1}

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 59208d2b3fbaa8e4b9c91c99092f106e
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 11400000
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,13 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
[CreateAssetMenu(fileName = "Comba_01", menuName = "Ability/m_2/Comba_01")]
public class Comba_01 : CombatAblilityBase
{
public override void UpdateAblity(Transform target = null)
{
}
}

View File

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

View File

@@ -0,0 +1,24 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 6676841996372f24788e8af0050c9e53, type: 3}
m_Name: Comba_02
m_EditorClassIdentifier:
abilityName: Comba_02
abilityID: 1
abilityCDTime: 12
abilityClass: 0
abilityVFX: {fileID: 8300000, guid: 745ff6d9880e7e54ca173e5230018748, type: 3}
abilityIsDone: 0
abilityDistance: 3
maxAbilityCount: 0
abilityOffest:
- {x: -2.5, y: 1}

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 733b0aea8b566e24681247a79093393a
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 11400000
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,12 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
[CreateAssetMenu(fileName = "Comba_02", menuName = "Ability/m_2/Comba_02")]
public class Comba_02 : CombatAblilityBase
{
public override void UpdateAblity(Transform target = null)
{
}
}

View File

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

View File

@@ -0,0 +1,24 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 9e2bd46305452774887ab58c9ddeef07, type: 3}
m_Name: Comba_03
m_EditorClassIdentifier:
abilityName: Comba_03
abilityID: 2
abilityCDTime: 6
abilityClass: 0
abilityVFX: {fileID: 8300000, guid: 745ff6d9880e7e54ca173e5230018748, type: 3}
abilityIsDone: 0
abilityDistance: 1
maxAbilityCount: 0
abilityOffest:
- {x: -1, y: 0.6}

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: eae12eefbdbcc8540bf10c9d846d1683
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 11400000
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,12 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
[CreateAssetMenu(fileName = "Comba_03", menuName = "Ability/m_2/Comba_03")]
public class Comba_03 : CombatAblilityBase
{
public override void UpdateAblity(Transform target = null)
{
}
}

View File

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

View File

@@ -0,0 +1,24 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 81b457857b635f442bd5f6113faac597, type: 3}
m_Name: Comba_04
m_EditorClassIdentifier:
abilityName: Comba_04
abilityID: 3
abilityCDTime: 6
abilityClass: 0
abilityVFX: {fileID: 0}
abilityIsDone: 0
abilityDistance: 1
maxAbilityCount: 0
abilityOffest:
- {x: -1, y: 0.6}

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: ec38341ed27661a42992dce9719b0399
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 11400000
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,12 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
[CreateAssetMenu(fileName = "Comba_04", menuName = "Ability/m_2/Comba_04")]
public class Comba_04 : CombatAblilityBase
{
public override void UpdateAblity(Transform target = null)
{
}
}

View File

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

View File

@@ -0,0 +1,86 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class BulletObject : MonoBehaviour
{
private bool initialied = false;
[SerializeField] private Vector2 startPos;
private Vector2 midPos;
private float percent = 0;
private float percentSpeed = 0;
[SerializeField] private float speed = 25;
private Vector2 lastTargetPos;
// Update is called once per frame
void FixedUpdate()
{
if (initialied )
{
percent += percentSpeed * Time.deltaTime;
if (percent >= 1)
{
percent = 1;
}
transform.position = UnityExpandFunction.Bezier(percent, startPos, midPos, lastTargetPos);
}
if(transform.position==new Vector3(lastTargetPos.x, lastTargetPos.y,0))
{
Destroy(this.gameObject);
}
}
public void Init(GameObject parent)
{
GameObject player = GameObject.FindGameObjectWithTag("Player");
if(player!=null)
{
lastTargetPos = player.transform.position;
startPos = parent.transform.position+new Vector3(Random.Range(0,2), Random.Range(0, 2),0);
midPos = GetMiddlePostion(parent.transform.position, lastTargetPos);
percentSpeed = speed / (lastTargetPos - startPos).magnitude;
transform.position = startPos;
percent = 0;
initialied = true;
}
}
/// <summary>
/// ÖÐÐĵã
/// </summary>
/// <param name="a"></param>
/// <param name="b"></param>
/// <returns></returns>
private Vector2 GetMiddlePostion(Vector2 a, Vector2 b)
{
Vector2 m = Vector2.Lerp(a,b,0.1f);
Vector2 normal = Vector2.Perpendicular(a-b).normalized;
float rd = Random.Range(-2f,2f);
float curveRatio = 15f;//Æ«ÒÆÖµ
return m + (a - b).normalized * curveRatio * rd * normal;
}
private void OnTriggerEnter2D(Collider2D collision)
{
if(collision.CompareTag("Player"))
{
if (collision.gameObject.GetComponentInChildren<CombaSystem>()._animator.CheckAnimationTag("Roll"))
return;
Debug.Log("»÷ÖÐ");
collision.gameObject.GetComponentInChildren<CombaSystem>().TakeDamage(20);
}
}
}

View File

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

View File

@@ -0,0 +1,69 @@
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class CombaSystem : MonoBehaviour
{
public Animator _animator;
public AudioSource _audio;
public AudioClip _summerClip;
[Header("近战攻击")]
[SerializeField] protected Vector2 attackSize = new Vector2();
[SerializeField] protected Vector2 AttackAreaPos;
[Header("判定偏移")]
[SerializeField] protected float offsetX = 1f;
[SerializeField] protected float offsetY = 1f;
[SerializeField,Header("检测层级")] protected List<LayerMask> layerMasks;
public float maxHp = 1800;
public float currentHp;
[Header("攻击")]
public float attack = 50;
public Action<float> OnHit;
protected bool isDie = false;
protected virtual void Awake()
{
currentHp = maxHp;
}
public virtual void MelleeAttackAnimEvent()
{
Debug.Log("ATTACK");
AttackAreaPos = transform.position;
AttackAreaPos.x += offsetX;
AttackAreaPos.y += offsetY;
offsetX = this.transform.parent.localScale.x < 0 ? Mathf.Abs(offsetX) : -Mathf.Abs(offsetX);
}
protected void OnDrawGizmos()
{
Gizmos.color = Color.red;
Gizmos.DrawWireCube(AttackAreaPos, attackSize);
}
public bool GetIsDie()
{
return isDie;
}
#region
//收到攻击
public virtual void TakeDamage(string hitName, float attack)
{
}
public virtual void TakeDamage(float attack)
{
}
public virtual void TakeDamage()
{
}
#endregion
}

View File

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

View File

@@ -0,0 +1,92 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public enum AblityClass
{
MelleeAttack,
YuanChenAttack
}
public abstract class CombatAblilityBase : ScriptableObject
{
[SerializeField, Header("技能名称")] protected string abilityName;
[SerializeField, Header("技能ID")] protected int abilityID;
[SerializeField, Header("技能CD")] protected float abilityCDTime;
[SerializeField, Header("技能类型")] protected AblityClass abilityClass;
[SerializeField, Header("技能音效")] protected AudioClip abilityVFX;
[SerializeField, Header("技能可用")] protected bool abilityIsDone;
[SerializeField, Header("技能释放距离")] protected float abilityDistance;
[SerializeField, Header("技能个数")] protected int maxAbilityCount=0;
protected int currentAbilityCount = 0;
[SerializeField, Header("技能释放偏移")] protected List<Vector2> abilityOffest;
private Transform pollName;
protected BossAI ai;
protected Animator _animator;
public abstract void UpdateAblity(Transform target=null);
public void UseAblity(CombatAblilityBase ablility)
{
pollName = GameObject.Find("TimerRoot").transform;
abilityIsDone = false;
//开始计时
string timerPath = "Perfab/Timer";
GameObject timer = Resloader.Load<GameObject>(timerPath);//寻找预制体
GameObject go = Instantiate(timer, pollName);
if(ablility.abilityClass==AblityClass.MelleeAttack)
{
go.GetComponent<Timer>().CreateTime(ablility.GetAbliltyCD(), () => ablility.abilityIsDone = true, false);
}
else if (ablility.abilityClass == AblityClass.YuanChenAttack)
{
go.GetComponent<Timer>().CreateTime(ablility.GetAbliltyCD(), () => { ablility.abilityIsDone = true;
ablility.currentAbilityCount = maxAbilityCount;
}, false);
}
}
public void Init(BossAI boss,Animator ani)
{
ai = boss;
_animator = ani;
abilityIsDone = true;
currentAbilityCount = maxAbilityCount;
}
public bool GetAbliltyIsDone()
{
return abilityIsDone;
}
public void SetAbliltyIsDone(bool isDone)
{
abilityIsDone = isDone;
}
public AblityClass GetAbliltyClass()
{
return abilityClass;
}
public string GetAbliltyName()
{
return abilityName;
}
public float GetAbliltyCD()
{
return abilityCDTime;
}
public float GetAbliltyDis()
{
return abilityDistance;
}
public List<Vector2> GetAbliltyOffest()
{
return abilityOffest;
}
public AudioClip GetAbliltyVFX()
{
return abilityVFX;
}
}

View File

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

View File

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

View File

@@ -0,0 +1,20 @@
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public enum CharacterType
{
Npc,
Player,
}
[Serializable]
public class DialogNode
{
public int npcID;
public int ToId;
public CharacterType type;
public string characterName;
public Sprite characterSprite;
[TextArea]
public string dialog;
}

View File

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

View File

@@ -0,0 +1,123 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: a8ce42ca11e4651489ab01075c11226c, type: 3}
m_Name: Dialogue
m_EditorClassIdentifier:
dialogNode:
- npcID: 0
ToId: 0
type: 0
characterName: "\u5927\u767D\u7F8A"
characterSprite: {fileID: 21300000, guid: 6c9534d590f8fe84da19aeca85f376d8, type: 3}
dialog: "\u4F60\u597D\u554A\uFF0C\u5C11\u5E74\uFF01\uFF01"
- npcID: 0
ToId: 0
type: 1
characterName: "\u73A9\u5BB6"
characterSprite: {fileID: 21300000, guid: cf242bc813f581f438f1c1e8d464145a, type: 3}
dialog: "\u5582\uFF01\u4F60\u662F\u4E2A\u4EC0\u4E48\u73A9\u610F\uFF1F"
- npcID: 0
ToId: 0
type: 0
characterName: "\u5927\u767D\u7F8A"
characterSprite: {fileID: 21300000, guid: 6c9534d590f8fe84da19aeca85f376d8, type: 3}
dialog: "\u7B2C\u4E00\uFF0C\u6211\u4E0D\u53EB\u5582\uFF0C\u7B2C\u4E8C\uFF0C\u6211\u4E0D\u662F\u73A9\u610F"
- npcID: 0
ToId: 0
type: 0
characterName: "\u5927\u767D\u7F8A"
characterSprite: {fileID: 21300000, guid: 6c9534d590f8fe84da19aeca85f376d8, type: 3}
dialog: "\u4F60\u53EF\u4EE5\u53EB\u6211\u5927\u767D\u7F8A"
- npcID: 0
ToId: 0
type: 1
characterName: "\u73A9\u5BB6"
characterSprite: {fileID: 21300000, guid: cf242bc813f581f438f1c1e8d464145a, type: 3}
dialog: "\u597D\u7684\uFF0C\u5927\u767D\u7F8A\u3002\u63A5\u4E0B\u6765\u6211\u8981\u5E72\u561B\uFF1F\uFF1F\uFF1F"
- npcID: 0
ToId: 0
type: 0
characterName: "\u5927\u767D\u7F8A"
characterSprite: {fileID: 21300000, guid: 6c9534d590f8fe84da19aeca85f376d8, type: 3}
dialog: "\u5F53\u7136\u662F\u4E0D\u65AD\u6218\u6597\u4E86\uFF0C\u56E0\u4E3A\uFF0C\u6218\u6597\uFF01\uFF01\u723D\uFF01\uFF01\uFF01"
- npcID: 0
ToId: 0
type: 1
characterName: "\u73A9\u5BB6"
characterSprite: {fileID: 21300000, guid: cf242bc813f581f438f1c1e8d464145a, type: 3}
dialog: "\u53EF\u662F\u6211\u4E0D\u4F1A\u6218\u6597\uFF01\uFF01\uFF01"
- npcID: 0
ToId: 0
type: 0
characterName: "\u5927\u767D\u7F8A"
characterSprite: {fileID: 21300000, guid: 6c9534d590f8fe84da19aeca85f376d8, type: 3}
dialog: "\u65E0\u59A8\uFF0C\u6211\u6765\u6559\u4F60\u3002"
- npcID: 0
ToId: 0
type: 0
characterName: "\u5927\u767D\u7F8A"
characterSprite: {fileID: 21300000, guid: 6c9534d590f8fe84da19aeca85f376d8, type: 3}
dialog: "AWSD\u79FB\u52A8\uFF0C\u9F20\u6807\u653B\u51FB\uFF0CLshift\u7FFB\u6EDA\u95EA\u907F"
- npcID: 0
ToId: 0
type: 0
characterName: "\u5927\u767D\u7F8A"
characterSprite: {fileID: 21300000, guid: 6c9534d590f8fe84da19aeca85f376d8, type: 3}
dialog: "Tab\u6253\u5F00\u80CC\u5305\uFF0C1\u559D\u836F\u56DE\u8840\uFF0CEsc\u4F60\u61C2\u7684"
- npcID: 0
ToId: 0
type: 0
characterName: "\u5927\u767D\u7F8A"
characterSprite: {fileID: 21300000, guid: 6c9534d590f8fe84da19aeca85f376d8, type: 3}
dialog: "\u5927\u6982\u5C31\u8FD9\u4E9B\uFF0C\u4E0A\u5427\uFF0C\u5C11\u5E74\uFF01\uFF01\uFF01"
- npcID: 0
ToId: 0
type: 1
characterName: "\u73A9\u5BB6"
characterSprite: {fileID: 21300000, guid: cf242bc813f581f438f1c1e8d464145a, type: 3}
dialog: "\uFF1F\uFF1F\uFF1F"
- npcID: 0
ToId: 0
type: 0
characterName: "\u5927\u767D\u7F8A"
characterSprite: {fileID: 21300000, guid: 6c9534d590f8fe84da19aeca85f376d8, type: 3}
dialog: "\u597D\u4E86\uFF0C\u4F60\u5DF2\u7ECF\u662F\u4E2A\u6210\u719F\u7684\u52C7\u58EB\u4E86\u3002\u4E0A\u5427\uFF01\uFF01\uFF01"
- npcID: 1
ToId: 0
type: 0
characterName: "\u5929\u68AF\u5546\u4EBA"
characterSprite: {fileID: 21300000, guid: 5a38bec081c255c4a9cecabc8fbdca11, type: 3}
dialog: "\u4F60\u597D\uFF0C\u9A9A\u5E74\u90CE\uFF01\uFF01"
- npcID: 1
ToId: 0
type: 0
characterName: "\u5929\u68AF\u5546\u4EBA"
characterSprite: {fileID: 21300000, guid: 5a38bec081c255c4a9cecabc8fbdca11, type: 3}
dialog: "\u5728\u6211\u8FD9\u91CC\u53EF\u4EE5\u901A\u8FC7\u6C38\u6052\u4E4B\u5FC3\u5E2E\u52A9\u4F60\u6C38\u4E45\u63D0\u5347\u5C5E\u6027\uFF01\uFF01"
- npcID: 1
ToId: 0
type: 0
characterName: "\u5929\u68AF\u5546\u4EBA"
characterSprite: {fileID: 21300000, guid: 5a38bec081c255c4a9cecabc8fbdca11, type: 3}
dialog: "\u6BCF\u6B21\u51FB\u8D25\u654C\u4EBA\u540E\u4F60\u90FD\u80FD\u83B7\u5F97\u6C38\u6052\u4E4B\u5FC3"
- npcID: 1
ToId: 0
type: 0
characterName: "\u5929\u68AF\u5546\u4EBA"
characterSprite: {fileID: 21300000, guid: 5a38bec081c255c4a9cecabc8fbdca11, type: 3}
dialog: "\u4E0D\u65AD\u5347\u7EA7\u4E4B\u540E\u4F60\u5C31\u80FD\u780D\u74DC\u5207\u83DC\u4E86"
- npcID: 1
ToId: 0
type: 0
characterName: "\u5929\u68AF\u5546\u4EBA"
characterSprite: {fileID: 21300000, guid: 5a38bec081c255c4a9cecabc8fbdca11, type: 3}
dialog: "\u52AA\u529B\u5427\uFF0C\u9A9A\u5E74\uFF01\uFF01\uFF01"

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 22ec8072504f82a448da685ce9ed9af0
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 11400000
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,13 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
[CreateAssetMenu(fileName ="Dialogue")]
public class Dialogue : ScriptableObject
{
public DialogNode[] dialogNode;
}

View File

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

View File

@@ -0,0 +1,95 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class DialogueSystem : MonoBehaviour
{
[SerializeField] private Dialogue dialogue;
[SerializeField] private GameObject dialogBox;
[SerializeField] private Text dialog;
[SerializeField] private Text characterName;
[SerializeField] private Image characterSprite;
[SerializeField] private CharacterType type;
private int index;
private bool isInTurn;
private int npcId;
public Dictionary<int, List<DialogNode>> dialogNodes = new Dictionary<int, List<DialogNode>>();
private void Awake()
{
foreach (var dia in dialogue.dialogNode)
{
if (!dialogNodes.ContainsKey(dia.npcID))
{
dialogNodes.Add(dia.npcID,new List<DialogNode> { dia});
}
else
{
dialogNodes[dia.npcID].Add(dia);
}
}
}
void Update()
{
if (Input.GetKeyDown(KeyCode.E) && isInTurn)
{
Play();
}
}
private void OnTriggerEnter2D(Collider2D collision)
{
if (collision.CompareTag("Npc"))
{
Debug.Log("aaa");
isInTurn = true;
npcId = collision.GetComponent<UITip>().GetNpcId();
}
}
private void OnTriggerExit2D(Collider2D collision)
{
if (collision.CompareTag("Npc"))
{
Debug.Log("bbb");
isInTurn = false;
index = 0;
dialogBox.SetActive(false);
}
}
void Play()
{
dialogBox.SetActive(true);
DialogNode node = dialogNodes[npcId][Mathf.Clamp(index++, 0, dialogNodes[npcId].Count - 1)];
if (index - 1 == dialogNodes[npcId].Count)
{
dialog.text = "抱歉,我很忙,你可以找一下事情做";
}
else
{
dialog.text = node.dialog;
}
characterName.text = node.characterName;
characterSprite.overrideSprite = node.characterSprite;
if (index - 1 == dialogNodes[npcId].Count)
{
dialog.text = null;
dialogBox.SetActive(false);
}
}
}

View File

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

View File

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

View File

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

View File

@@ -0,0 +1,337 @@
using Manager;
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class BossAI : CombaSystem
{
//基本信息类
public BossInfo _info;
Rigidbody2D rb;
//玩家信息,待优化
PlayerControler player;
CharacterCombat characterCombat;
private Transform currentTarget;
//玩家与敌人的距离方向
private float dis;
private Vector2 dir;
[Header("追击与攻击距离")]
public float cheseDistance = 3f;
public float attackDistance = 0.8f;
[SerializeField, Header("技能搭配")] private List<CombatAblilityBase> abilitys = new List<CombatAblilityBase>();
private CombatAblilityBase currentAblity;
//判断偏移
private List<Vector2> ablityOff;
//攻击段数
private int attackCount;
//计时器
public GameObject timer;
public bool isBegin = false;
List<CombatAblilityBase> tempAb = new List<CombatAblilityBase>();//可用技能组
int ran;//技能组索引
CameraVR cameraVR;
public bool isYuancheng=false;
protected override void Awake()
{
base.Awake();
_animator = GetComponentInChildren<Animator>();
rb = GetComponentInParent<Rigidbody2D>();
currentTarget = GameObject.FindWithTag("Player").transform;
_info = GetComponentInParent<BossInfo>();
foreach (var ab in abilitys)
{
ab.Init(this,_animator);
}
}
private void Update()
{
if (!_animator.CheckAnimationTag("summon")&&isBegin)
{
if (!isDie) //死亡或咆哮状态的时候不会进行攻击
{
MoveBoss();
}
}
}
private void FixedUpdate()
{
if (currentAblity != null)
{
currentAblity.UpdateAblity(currentTarget);
}
}
private void MoveBoss()
{
if (_animator.CheckAnimationTag("Wake"))
return;
if (_animator.CheckAnimationTag("hit") || _animator.CheckAnimationTag("Attack")||_animator.CheckAnimationTag("Attack_out"))
{
return;
}
if (currentTarget == null)
return;
LockTarget(currentTarget);
dis = Vector2.Distance(currentTarget.position, transform.position);
if (dis < cheseDistance)
{
rb.velocity = Vector2.zero;
//近战
if (dis < attackDistance)
{
//_animator.Play("attack-charge");
currentAblity = GetAblity(AblityClass.MelleeAttack);
if (currentAblity != null)
{
//SoundManager.Instance.PlayEffect(_audio, currentAblity.GetAbliltyVFX());
_animator.Play(currentAblity.GetAbliltyName());
currentAblity.UseAblity(currentAblity);
}
return;
}
//远程
else
{
currentAblity = GetAblity(AblityClass.YuanChenAttack);
if (currentAblity != null)
{
//SoundManager.Instance.PlayEffect(_audio, currentAblity.GetAbliltyVFX());
_animator.Play(currentAblity.GetAbliltyName());
currentAblity.UseAblity(currentAblity);
}
return;
}
}
else
{
if (!_info.isCanMove)
return;
_animator.Play("run");
rb.velocity = dir * _info._moveSpeed;
}
}
private void LockTarget(Transform target)
{
if (!_info.isLockTarget)
return;
dir = (target.position - transform.position).normalized;
if(_info.isFix)
{
Fix(dir);
}
}
private void Fix(Vector2 dir)
{
if (dir.x < 0)
{
transform.root.localScale = new Vector3(1, 1, 1);
}
if (dir.x > 0)
{
transform.root.localScale = new Vector3(-1, 1, 1);
}
}
public void Yuancheng()
{
isYuancheng = true;
}
public void OnCloseYuancheng()
{
isYuancheng = false;
}
public void TeleportEvent()
{
if (currentTarget == null) return;
transform.root.transform.position = currentTarget.transform.position;
}
/// <summary>
/// 近战攻击
/// </summary>
public override void MelleeAttackAnimEvent()
{
if (currentAblity != null)
{
AttackAreaPos = transform.position;
ablityOff = currentAblity.GetAbliltyOffest();
AttackAreaPos.x += ablityOff[attackCount].x;
AttackAreaPos.y += ablityOff[attackCount].y;
attackCount++;
if (attackCount >= ablityOff.Count)
{
attackCount = 0;
}
if (_info.isCanMove)
{
AttackAreaPos.x = this.transform.parent.localScale.x < 0 ? Mathf.Abs(offsetX) : -Mathf.Abs(offsetX);
}
}
else
{
base.MelleeAttackAnimEvent();
}
Collider2D[] hitColliders = Physics2D.OverlapBoxAll(AttackAreaPos, attackSize, 0, layerMasks[0]);
if(currentAblity!=null&&currentAblity.GetAbliltyVFX()!=null)
{
SoundManager.Instance.PlayEffect(_audio, currentAblity.GetAbliltyVFX());
}
foreach (Collider2D hitInfo in hitColliders)
{
player = hitInfo.GetComponent<PlayerControler>();
if (player != null && player.GetIsDodge())
{
Debug.Log("玩家无敌");
_animator.speed = 0;
StartCoroutine(ScalTime(1f));
return;
}
characterCombat = hitInfo.GetComponentInChildren<CharacterCombat>();
//if(characterCombat._animator.CheckAnimationTag("Roll"))
//{
// //无敌闪避
// _animator.speed = 0;
// StartCoroutine(ScalTime(1f));
// return;
//}
characterCombat.TakeDamage(attack);
Debug.Log("玩家受伤");
}
}
IEnumerator ScalTime(float timer)
{
yield return new WaitForSeconds(timer);
_animator.speed = 1;
}
public override void TakeDamage(string aniName, float attack)
{
if (isDie || _animator.CheckAnimationTag("summon")||_animator.CheckAnimationTag("Wake"))//咆哮不会被攻击
return;
Debug.Log("被玩家攻击" + _info.attackedCount);
_info.attackedCount++;//耐力次数增加
if (_info.attackedCount > _info.maxAttackedCount)
{
_info.attackedCount = 0;//重新计数
_animator.Play("summon");
if(_summerClip!=null)
{
SoundManager.Instance.PlayEffect(_audio,_summerClip);
}
//吼叫
//摄像机震动
cameraVR=UnityExpandFunction.GetCamera();
if (cameraVR != null)
{
cameraVR.ShakeCamera(1f, 5);
}
//回血
currentHp += 200;
if (currentHp >= maxHp)
currentHp = maxHp;
OnHit?.Invoke(currentHp);
return;
}
//受伤
currentHp -= attack;//血量减少
OnHit?.Invoke(currentHp);//执行受伤事件血量UI减少
if (currentHp <= 0)
{
isDie = true;
return;
}
if(_animator.CheckAnimationTag("Attack"))
{
return;
}
_animator.Play(aniName);
}
private CombatAblilityBase GetAblity(AblityClass ablity)
{
tempAb.Clear();
foreach (var ab in abilitys)
{
if (ab.GetAbliltyIsDone() && ab.GetAbliltyClass() == ablity)
{
tempAb.Add(ab);
}
}
if(tempAb.Count==0)
{
return null;
}
ran = UnityEngine.Random.Range(0,tempAb.Count);
if (tempAb[ran] != null)
return tempAb[ran];
return null;
}
public void SetBegin(bool b)
{
isBegin = b;
//开始
_animator.Play("sleeping");
UIManager.Instance.Show<UIEnterScene>().InitInfo(_info.bossHead, _info.bossName);
}
private void OnDrawGizmosSelected()
{
Gizmos.color = Color.yellow;
Gizmos.DrawWireSphere(transform.position, cheseDistance);
Gizmos.color = Color.red;
Gizmos.DrawWireSphere(transform.position, attackDistance);
}
}

View File

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

View File

@@ -0,0 +1,28 @@
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class BossInfo : MonoBehaviour
{
[Header("名字与头像")]
public string bossName;
public Sprite bossHead;
[Header("失衡最大次数")]
public int maxAttackedCount;
[Header("被攻击次数")]
public int attackedCount=0;
//是否允许锁定目标
[Header("索敌")]
public bool isLockTarget;
[Header("移动")]
public bool isCanMove;
[Header("翻转")]
public bool isFix;
[Header("移动速度")]
public float _moveSpeed;
}

View File

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

View File

@@ -0,0 +1,64 @@
//using System;
//using System.Collections;
//using System.Collections.Generic;
//using UnityEngine;
//using UnityEngine.Events;
//普通怪物
//public class Enemy : CharacterManager
//{
// [Header("距离")]
// public float cheseDistance = 3f;
// public float attackDistance = 0.8f;
// public UnityEvent<Vector2> OnMoveInput;
// public Action OnAttack;
// private Transform player;
// //玩家与敌人的距离方向
// private float dis;
// private Vector2 dir;
// private void Awake()
// {
// player = GameObject.FindWithTag("Player").transform;
// }
// private void Update()
// {
// if (player == null)
// return;
// dis = Vector2.Distance(player.position,transform.position);
// if(dis<cheseDistance)
// {
// //追击
// if(dis<=attackDistance)
// {
// OnMoveInput?.Invoke(Vector2.zero);
// //攻击
// OnAttack?.Invoke();
// }
// else
// {
// dir = player.position - transform.position;
// OnMoveInput?.Invoke(dir.normalized);
// }
// }
// else
// {
// OnMoveInput?.Invoke(Vector2.zero);//放弃追击
// }
// }
// private void OnDrawGizmosSelected()
// {
// Gizmos.color = Color.yellow;
// Gizmos.DrawWireSphere(transform.position,cheseDistance);
// Gizmos.color = Color.red;
// Gizmos.DrawWireSphere(transform.position, attackDistance);
// }
//}

View File

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

View File

@@ -0,0 +1,142 @@
//using System.Collections;
//using System.Collections.Generic;
//using UnityEngine;
//using System;
//using Manager;
//普通怪物
//public class EnemyController : MonoBehaviour
//{
// public GameObject attackVFX;
// [Header("移动速度")] public float currentSpeed;
// [Header("攻击")]
// [SerializeField] private bool isAttack = true;
// [SerializeField] private float attackCollDuration = 1;
// private bool isDead=false;
// public Vector2 MoveInput
// {
// get;set;
// }
// private Enemy enemy;
// private Rigidbody2D rb;
// private SpriteRenderer sr;
// private Animator animator;
// private Collider2D colliderEnemy;
// [Header("攻击,间隔")]
// public float attackDamage = 20;
// public float attackDuration = 1.5f;
// public LayerMask playerLayer;
// private void Awake()
// {
// rb = transform.parent.GetComponent<Rigidbody2D>();
// colliderEnemy = transform.parent.GetComponent<Collider2D>();
// sr = GetComponent<SpriteRenderer>();
// animator = GetComponent<Animator>();
// enemy = transform.parent.GetComponent<Enemy>();
// }
// private void Start()
// {
// enemy.OnAttack += OnAttack;
// }
// private void FixedUpdate()
// {
// if(!isDead)
// {
// OnMove();
// }
// SetAnimation();
// }
// private void OnMove()
// {
// if (MoveInput.magnitude > 0.1f && currentSpeed > 0)
// {
// rb.velocity = MoveInput * currentSpeed;
// if(MoveInput.x<0)
// {
// sr.flipX = false;
// }
// if (MoveInput.x > 0)
// {
// sr.flipX = true;
// }
// }
// else
// {
// rb.velocity = Vector2.zero;
// }
// }
// void OnAttack()
// {
// if(isAttack)
// {
// isAttack = false;
// StartCoroutine(nameof(AttackCoroutine));
// }
// }
// IEnumerator AttackCoroutine()
// {
// animator.SetTrigger("Attack");
// yield return new WaitForSeconds(attackCollDuration);
// isAttack = true;
// }
// public void EnemyHurt()
// {
// animator.SetTrigger("Hurt");
// }
// public void EnemyDead()
// {
// rb.velocity = Vector2.zero;
// isDead = true;
// colliderEnemy.enabled = false;
// }
// void SetAnimation()
// {
// animator.SetBool("isWalk",MoveInput.magnitude>0);
// animator.SetBool("isDead", isDead);
// }
// public void DestoryEnemy()
// {
// Destroy(transform.parent.gameObject);
// }
// public void MelleeAttackAnimEvent()
// {
// Collider2D[] hitColliders = Physics2D.OverlapCircleAll(transform.position, enemy.attackDistance, playerLayer);
// foreach (Collider2D hitInfo in hitColliders)
// {
// hitInfo.transform.root.GetComponentInChildren<CharacterCombat>().TakeDamage();
// }
// }
// public void YuanChengAttackAnimEvent(string name)
// {
// Collider2D[] hitColliders = Physics2D.OverlapCircleAll(transform.position, enemy.attackDistance, playerLayer);
// foreach (Collider2D hitInfo in hitColliders)
// {
// GameObject go=Instantiate(attackVFX,transform.position,Quaternion.identity);
// go.AddComponent<VFXMove>();
// }
// }
// public void Protected(string name)
// {
// string monster = "Perfab/Monsters/" + name;
// UnityEngine.Object go =Resloader.Load<GameObject>(monster);
// if(go!=null)
// {
// GameObject m= (GameObject)Instantiate(go,transform.root);
// }
// }
//}

View File

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

View File

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

View File

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

View File

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

View File

@@ -0,0 +1,30 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class CameraMove : MonoBehaviour
{
private Transform player;
void Start()
{
player = GameObject.FindGameObjectWithTag("Player").transform;
}
void Update()
{
//RaycastHit[] hits;
//hits = Physics.RaycastAll(ray, Mathf.Infinity, badMask);
//for (int i = 0; i < hits.Length; i++)
//{
// Debug.Log(hits[i].collider.gameObject.name);
//}
//Debug.Log(hits.Length);
if (player!=null)
{
transform.position = new Vector3(player.position.x, player.position.y - 11, player.position.z);
}
}
}

View File

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

View File

@@ -0,0 +1,63 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Cinemachine;
public class CameraVR : MonoBehaviour
{
private CinemachineVirtualCamera _cinemachineVirtualCamera;
private CinemachineBasicMultiChannelPerlin _multiChannelPerlin;
//当前持续时间
private float _shakeTime;
//总时间
private float _shakeTimeTotal;
//强度
private float _shakeIntensity;
private void Awake()
{
_cinemachineVirtualCamera = GetComponent<CinemachineVirtualCamera>();
_multiChannelPerlin = _cinemachineVirtualCamera.GetCinemachineComponent<CinemachineBasicMultiChannelPerlin>();
}
// Update is called once per frame
void Update()
{
if (_shakeTime > 0)
{
_shakeTime -= Time.deltaTime;
_multiChannelPerlin.m_AmplitudeGain = Mathf.Lerp(0, _shakeIntensity, _shakeTime / _shakeTimeTotal);
}
}
/// <summary>
/// 抖动
/// </summary>
/// <param name="Time">抖动时间</param>
/// <param name="Intensity">强度</param>
public void ShakeCamera(float time, float intensity)
{
if (_cinemachineVirtualCamera != null)
{
_shakeTimeTotal = time;
_shakeIntensity = intensity;
_shakeTime = _shakeTimeTotal;
_multiChannelPerlin.m_AmplitudeGain = _shakeIntensity;
}
}
private void OnDrawGizmos()
{
Ray ray = new Ray(transform.position, transform.forward);
Gizmos.color = Color.blue;
Gizmos.DrawRay(ray);
}
}

View File

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

View File

@@ -0,0 +1,44 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Destructeable : MonoBehaviour
{
public GameObject destoryVFX;
public GameObject big;
public GameObject small;
private bool isDestory=false;
public float reTiem = 5;
public void OnDestoryObject()
{
if (isDestory)
return;
if (destoryVFX != null)
{
Instantiate(destoryVFX,transform.position,transform.rotation);
}
big.SetActive(false);
SmallActive(true);
isDestory = true;
StartCoroutine(nameof(DestoryTime));
}
IEnumerator DestoryTime()
{
yield return new WaitForSeconds(reTiem);
big.SetActive(true);
SmallActive(false);
}
private void SmallActive(bool active)
{
if (small != null)
{
small.SetActive(active);
isDestory = false;
}
}
}

View File

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

View File

@@ -0,0 +1,44 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Door : MonoBehaviour
{
public Animator _ani;
public BoxCollider2D bx;
public bool isOpen=false;
public GameObject boss;
private void Awake()
{
_ani = GetComponentInChildren<Animator>();
bx = GetComponent<BoxCollider2D>();
boss = GameObject.FindWithTag("Boss");
}
private void Update()
{
if(isOpen)
{
Debug.Log("¿ªÃÅ");
_ani.Play("activate");
StartCoroutine(nameof(Open));
}
}
private void OnCollisionEnter2D(Collision2D collision)
{
if (collision.gameObject.CompareTag("Player")&&!isOpen)
{
UIManager.Instance.Show<UIOpen>();
}
}
private IEnumerator Open()
{
yield return new WaitForSeconds(7f);
bx.isTrigger = true;
boss.GetComponentInChildren<BossAI>().SetBegin(true);
isOpen=false;
this.gameObject.SetActive(false);
}
}

View File

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

View File

@@ -0,0 +1,30 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class FacingCamera : MonoBehaviour
{
Transform[] childs;
private Transform cameraMain;
private void Awake()
{
cameraMain = GameObject.FindGameObjectWithTag("Camera").transform;
}
void Start()
{
childs = new Transform[transform.childCount];
for (int i = 0; i < transform.childCount; i++)
{
childs[i] = transform.GetChild(i);
}
}
void Update()
{
for (int i = 0; i < childs.Length; i++)
{
childs[i].rotation = cameraMain.rotation;
}
}
}

View File

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

View File

@@ -0,0 +1,48 @@
using Manager;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Teleport : MonoBehaviour
{
public BossAI m;
public bool isBattle;
private void Awake()
{
if(isBattle)
{
m = GameObject.FindWithTag("Boss").GetComponentInChildren<BossAI>();
}
}
private void OnTriggerEnter2D(Collider2D collision)
{
if(isBattle)
{
if (m.GetIsDie() && collision.CompareTag("Player"))
{
Debug.Log("传送");
//保存玩家信息
CharacterCombat cm = collision.gameObject.GetComponentInChildren<CharacterCombat>();
PlayerInfo.Instance.KeepData(cm.maxHp, cm.currentHp, cm.attack);
UIManager.Instance.Show<UILoad>();
return;
}
}
else
{
if (collision.CompareTag("Player"))
{
Debug.Log("传送");
//保存玩家信息
CharacterCombat cm = collision.gameObject.GetComponentInChildren<CharacterCombat>();
PlayerInfo.Instance.KeepData(cm.maxHp,cm.currentHp,cm.attack);
UIManager.Instance.Show<UILoad>();
return;
}
}
}
}

View File

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

View File

@@ -0,0 +1,31 @@
using Spine;
using Spine.Unity;
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Tree : CombaSystem
{
private SkeletonAnimation skelet;
private Spine.AnimationState animationState;
protected override void Awake()
{
skelet = GetComponent<SkeletonAnimation>();
animationState = skelet.AnimationState;
//¶¯×÷Íê³ÉºóµÄ»Øµ÷
animationState.Complete += OnIdle;
}
private void OnIdle(TrackEntry trackEntry)
{
TrackEntry entry = skelet.AnimationState.SetAnimation(0, "animation", true);
}
public override void TakeDamage()
{
TrackEntry entry = skelet.AnimationState.SetAnimation(0, "hit", false);
}
}

View File

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

View File

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

View File

@@ -0,0 +1,155 @@
using Manager;
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class CharacterCombat : CombaSystem
{
[Header("音效")]
public AudioSource audioSource;
public PlayerControler controler;
[Header("特效")]
public GameObject effect;
CameraVR cameraVR;
protected override void Awake()
{
maxHp = PlayerInfo.Instance.info.maxHp;
currentHp = PlayerInfo.Instance.info.currentHp;
attack = PlayerInfo.Instance.info.testAttack;
audioSource = transform.root.GetComponentInChildren<AudioSource>();
_animator = GetComponent<Animator>();
PlayerInfo.Instance.OnUpdateAttrbute += OnChangeAttrbute;
}
private void OnDisable()
{
PlayerInfo.Instance.OnUpdateAttrbute -= OnChangeAttrbute;
}
public override void MelleeAttackAnimEvent()
{
base.MelleeAttackAnimEvent();
Collider2D[] hitColliders = Physics2D.OverlapBoxAll(AttackAreaPos,attackSize,0,layerMasks[0]);
Collider2D[] destructiveColliders = Physics2D.OverlapBoxAll(AttackAreaPos, attackSize, 0,layerMasks[1]);
Collider2D[] treeColliders = Physics2D.OverlapBoxAll(AttackAreaPos, attackSize, 0, layerMasks[2]);
foreach (Collider2D hitInfo in hitColliders)
{
if(hitInfo.tag=="Enemy")
{//小怪
}
if (hitInfo.tag == "Boss")
{
hitInfo.GetComponentInChildren<BossAI>().TakeDamage("hurt-front",GetAttack());
if (_summerClip != null)
SoundManager.Instance.PlayEffect(_audio, _summerClip);
//加入卡肉,特效
if(effect!=null)
{
GameObject go = Instantiate(effect);
go.transform.position = hitInfo.transform.position + new Vector3(0,4,0);
//开始计时
string timerPath = "Perfab/Timer";
GameObject timer = Resloader.Load<GameObject>(timerPath);//寻找预制体
GameObject time = Instantiate(timer);
time.GetComponent<Timer>().CreateTime(0.2f, () =>
{
ManagersMode.Poll.UnSpwan("EffectPoll", effect.name, go);
}, false);
}
cameraVR = UnityExpandFunction.GetCamera();
if (cameraVR != null)
{
cameraVR.ShakeCamera(0.5f, 2);
}
}
}
foreach (Collider2D hitInfo in destructiveColliders)
{
}
foreach (Collider2D hitInfo in treeColliders)//数目
{
Debug.Log("攻击树木");
hitInfo.GetComponentInChildren<Tree>().TakeDamage();
}
}
//受伤
public override void TakeDamage(float atk)
{
currentHp -= atk;
OnHit?.Invoke(currentHp);//UI显示
if(currentHp<=0)
{
//死亡
return;
}
_animator.Play("hurt");
}
private void OnChangeAttrbute(LotteryType type, float value)
{
switch (type)
{
case LotteryType.Hp:
currentHp += value;
if(currentHp>=maxHp)
{
currentHp = maxHp;
}
OnHit?.Invoke(currentHp);
break;
case LotteryType.Mp:
maxHp += value;
OnHit?.Invoke(currentHp);
break;
case LotteryType.Attack:
attack += value;
OnHit?.Invoke(currentHp);
break;
case LotteryType.UpMaxHp:
PlayerInfo.Instance.info.maxHp += value;
maxHp += value;
OnHit?.Invoke(currentHp);
break;
case LotteryType.UpHp:
Date.Instance.ItemDate[1].value += (int)value;
OnHit?.Invoke(currentHp);
break;
case LotteryType.UpAttack:
PlayerInfo.Instance.info.attack += value;
attack += value;
OnHit?.Invoke(currentHp);
break;
default:break;
}
}
/// <summary>
/// 攻击力量
/// </summary>
/// <returns></returns>
public float GetAttack()
{
return attack + (PlayerInfo.Instance.info.Level * 10);
}
}

View File

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

View File

@@ -0,0 +1,210 @@
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

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

View File

@@ -0,0 +1,154 @@
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

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

View File

@@ -0,0 +1,33 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Item
{
public int Id { get; set; }
public string ItemName { get; set; }
public string Descripte;
public ItemClass type;
public LotteryType lotteryType;
public string Path { get; set; }
public int value;
public void UseItem(Item item)
{
switch(item.lotteryType)
{
case LotteryType.Hp:
Debug.LogFormat("UseItem:[{0}],AddHp {1}",item.Id,item.value);
PlayerInfo.Instance.AddHp(item.value);
break;
case LotteryType.Attack:
Debug.LogFormat("UseItem:[{0}],AddAttack {1}", item.Id,value);
PlayerInfo.Instance.AddAttack(item.value);
break;
case LotteryType.Mp:
Debug.LogFormat("UseItem:[{0}],AddMp {1}", item.Id,item.value);
PlayerInfo.Instance.AddMp(item.value);
break;
}
}
}

View File

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

View File

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

View File

@@ -0,0 +1,82 @@
using Managers;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.UI;
public class LevelItem : MonoBehaviour, IPointerClickHandler
{
public int LevelId;
public int PreId;//前置节点
public Text need;
public Text activeText;
private void Awake()
{
foreach (var date in Date.Instance.UpDate)
{
if (date.UpId == LevelId)
{
if(PlayerInfo.Instance.info.UpValue[date.UpId])
{
activeText.text = "已激活";
need.gameObject.SetActive(false);
}
else
{
activeText.text = "未激活";
need.text = date.useNum.ToString();
}
}
}
}
public void OnPointerClick(PointerEventData eventData)
{
foreach (var date in Date.Instance.UpDate)
{
if (date.UpId == LevelId&&!PlayerInfo.Instance.info.UpInfo[date.UpId])
{
if(CheckUp(LevelId))
{
if(!PlayerInfo.Instance.info.BagInfo.ContainsKey(date.userId))
{
Debug.Log("所用道具不足");
return;
}
if(PlayerInfo.Instance.info.BagInfo[date.userId]>=date.useNum)
{
PlayerInfo.Instance.BagMgr.UserItem(date.userId, date.useNum);
PlayerInfo.Instance.ItemLevel(date);
activeText.text = "已激活";
need.gameObject.SetActive(false);
//保存数据
PlayerInfo.Instance.info.UpValue[date.UpId] = true;
PlayerInfo.Instance.info.UpInfo[date.UpId] = PlayerInfo.Instance.info.UpValue[date.UpId];
SaveSystem.SaveDate(PlayerInfo.Instance.info.DatePath, PlayerInfo.Instance.info);
return;
}
Debug.Log("所用道具不足");
return;
}
Debug.Log("前置条件没有升级");
}
}
}
bool CheckUp(int id)
{
if(id==0)
{
return true;
}
if(!PlayerInfo.Instance.info.UpValue[Date.Instance.UpDate[id].PreId])
{
return false;
}
return true;
}
}

View File

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

View File

@@ -0,0 +1,17 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class LevelUpDefine
{
public int UpId;
public int PreId;
public string UpName;
public bool Active;
public string Descripet;
public int userId;
public int useNum;
public LotteryType type;
public int value;
}

View File

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

View File

@@ -0,0 +1,7 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class UILevelUp : UIWindow
{
}

View File

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

View File

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

View File

@@ -0,0 +1,72 @@
using Manager;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public enum LotteryType
{
None,
Hp,
Mp,
Attack,
UpHp,//Ôö¼Ó»ØÑª
UpMaxHp,//Ôö¼Ó×î´óѪÁ¿
UpAttack,//
}
public class UILottery : UIWindow
{
//public AvtarInfo avtar;
public string lotterytype;
public float lotteryvalue;
public LotteryType LotteryTypes;
public CombaSystem ch;
public void OnClickLotteryType(string type)
{
//SoundManager.Instance.PlaySound(SoundDefine.ButtonClick);
ch = GameObject.FindWithTag("Player").GetComponentInChildren<CombaSystem>();
Debug.Log("Lottery");
lotterytype = type;
if (lotterytype=="Hp")
{
LotteryTypes = LotteryType.Hp;
}
else if (lotterytype=="Mp")
{
LotteryTypes = LotteryType.Mp;
}
else if (lotterytype=="Attack")
{
LotteryTypes = LotteryType.Attack;
}
CheckLottery();
}
public void OnClickLotteryValue(float value)
{
lotteryvalue = value;
}
public void CheckLottery()
{
switch (LotteryTypes)
{
case LotteryType.Hp:
ch.currentHp += lotteryvalue;
ch.OnHit?.Invoke(ch.currentHp);
break;
case LotteryType.Mp:
ch.maxHp += lotteryvalue;
ch.OnHit?.Invoke(ch.currentHp);
break;
case LotteryType.Attack:
ch.attack += lotteryvalue;
ch.OnHit?.Invoke(ch.currentHp);
break;
}
Destroy(this.gameObject);
}
}

View File

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

View File

@@ -0,0 +1,30 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class UITip : UIWindow
{
public GameObject tip;
public int id;
private void OnTriggerEnter2D(Collider2D collision)
{
if(collision.CompareTag("Player"))
{
tip.SetActive(true);
if(id==1)//Éý¼¶Npc
{
UIManager.Instance.Show<UILevelUp>();
}
}
}
private void OnTriggerExit2D(Collider2D collision)
{
if (collision.CompareTag("Player"))
{
tip.SetActive(false);
}
}
public int GetNpcId() => id;
}

View File

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

View File

@@ -0,0 +1,34 @@
using Manager;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class UIlottertOpen : MonoBehaviour
{
private Animator animator;
private bool isOpen=true;
private void Awake()
{
animator = GetComponentInChildren<Animator>();
}
private void OnTriggerStay2D(Collider2D collision)
{
if (Input.GetKeyDown(KeyCode.E)&&isOpen)
{
Debug.Log("Open Box");
isOpen = false;
animator.Play("Box");
SoundManager.Instance.PlaySound(SoundDefine.BoxOpen);
StartCoroutine(nameof(Open));
}
}
private void OnTriggerExit2D(Collider2D collision)
{
StopCoroutine(nameof(Open));
}
IEnumerator Open()
{
yield return new WaitForSeconds(1.2f);
UIManager.Instance.Show<UILottery>();
}
}

View File

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

View File

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

View File

@@ -0,0 +1,86 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UnityEngine;
namespace Managers
{
public class BagManager
{
PlayerInfo Owner;
public BagManager(PlayerInfo owner)
{
this.Owner = owner;
}
public void AddItem(int key, int value)
{
if (Owner == null) return;
if (Owner.info.BagInfo.ContainsKey(key))
{
Owner.info.BagInfo[key] = Owner.info.BagInfo[key] + value;
}
else
{
Owner.info.BagInfo.Add(key, value);
}
Owner.OnUpdateBagInfo?.Invoke();
Owner.OnUpdateMainUI?.Invoke();
}
public void UserItem(int id, int num)
{
if (Owner == null) return;
if (Owner.info.BagInfo.ContainsKey(id))
{
foreach (var item in Date.Instance.ItemDate)//测试使用道具
{
if (item.Id == id && item.type == ItemClass.User)
{
if(Remove(item,num))
{
Debug.Log("使用道具");
item.UseItem(item);
}
}
if(item.Id == id && item.type == ItemClass.Up)
{
Remove(item, num);
}
}
}
else
{
Debug.LogError("道具缺失");
return;
}
}
private bool Remove(Item item,int num)
{
if (Owner.info.BagInfo[item.Id] < num)
{
Debug.LogFormat("UserItem [{0}] count Insufficient", item.ItemName);
return false;
}
Owner.info.BagInfo[item.Id] = Owner.info.BagInfo[item.Id] - num;//背包减少
if (Owner.info.BagInfo[item.Id] <= 0)
{
Owner.info.BagInfo.Remove(item.Id);
}
Owner.OnUpdateBagInfo?.Invoke();
Owner.OnUpdateMainUI?.Invoke();
Owner.WriteBagInfo();
//保存数据
//Debug.Log(Owner.info.BagValue[item.Id]);
SaveSystem.SaveDate(Owner.info.DatePath, Owner.info);
return true;
}
}
}

View File

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

Some files were not shown because too many files have changed in this diff Show More