add
This commit is contained in:
parent
06dc46ce1e
commit
5ce54b749f
@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8793aaca69ae59144b8d5ec239fdd04e
|
||||
guid: 0b07641f067dea24bad40a2dae6ca16a
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
@ -55,8 +55,8 @@ public class Fun : Base
|
||||
/// <param name="objects"></param>
|
||||
public void poisoning(object[] objects)
|
||||
{
|
||||
Palye targetAudience = (Palye)objects[0];
|
||||
Palye myPalye = (Palye)objects[1];
|
||||
Role targetAudience = (Role)objects[0];
|
||||
Role myPalye = (Role)objects[1];
|
||||
Debug.Log("触发中毒");
|
||||
Debug.Log(myPalye.name);
|
||||
}
|
||||
@ -66,10 +66,10 @@ public class Fun : Base
|
||||
/// <param name="objects"></param>
|
||||
public void bloodLoss(object[] objects)//目标,伤害值,攻击类型,使用者
|
||||
{
|
||||
Palye targetAudience = (Palye)objects[0];
|
||||
Role targetAudience = (Role)objects[0];
|
||||
float harm = (float)objects[1];
|
||||
DamageType damageType = (DamageType)objects[2];
|
||||
Palye UserObj = (Palye)objects[3];
|
||||
Role UserObj = (Role)objects[3];
|
||||
|
||||
|
||||
float finalDamage = harm;
|
176
Role/Role.cs
Normal file
176
Role/Role.cs
Normal file
@ -0,0 +1,176 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Threading.Tasks;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using Debug = UnityEngine.Debug;
|
||||
|
||||
/// <summary>
|
||||
/// 角色基类,玩家处理事件
|
||||
/// </summary>
|
||||
[ExecuteInEditMode]
|
||||
public class Role : Fun
|
||||
{
|
||||
[Header("血量")] public float hp = 100f;//血量
|
||||
[Header("掉落")] public float gold = 10f;
|
||||
public float Hp
|
||||
{
|
||||
get => hp;
|
||||
set
|
||||
{
|
||||
hp = value;
|
||||
if (hp <= 0)
|
||||
{
|
||||
die();
|
||||
//if (Progress_Display.Instance == null) return;
|
||||
|
||||
//Progress_Display.Instance.huadongClick(gold);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[Header("物理护甲")] public int physicalArmor = 10;//物理护甲
|
||||
[Header("魔法护甲")] public int magicArmor = 5;//魔法护甲
|
||||
|
||||
public List<BUff> buffList = new List<BUff>();
|
||||
[Header("导航组件")] public SimplePathfindingDoTween Navigation;
|
||||
|
||||
[System.Serializable ]
|
||||
public class AnimationList//动画list
|
||||
{
|
||||
//[Header("动画是否循环")] public bool isloop = false;
|
||||
[Header("动画图片")] public List<Sprite> value; // 字典的值
|
||||
[Header("角色动画帧数间隔(毫秒)")] public int CharacterAnimationFrameInterval = 50;
|
||||
}
|
||||
[Header("角色动画")] public List<AnimationList> AnimationTree = new List<AnimationList>();
|
||||
[Header("角色动画播放")] public int animationHighlight = 0;
|
||||
[Header("角色精灵位置")] public SpriteRenderer spriteRenderer;
|
||||
[Header("角色Image位置")] public Image image;
|
||||
public delegate void AnimationItem(int AnimationItem);
|
||||
public event AnimationItem OnAnimationStart;
|
||||
public event AnimationItem OnAnimationIng;
|
||||
public event AnimationItem OnAnimationEnd;
|
||||
[Header("动画是否正常播放")] public bool isAnimationPlay = false;//动画是否正常播放
|
||||
|
||||
|
||||
async void Start()
|
||||
{
|
||||
if (Application.isPlaying)
|
||||
{
|
||||
UpdateBuff();
|
||||
}
|
||||
updateAnimation();
|
||||
}
|
||||
/// <summary>
|
||||
/// 角色动画更新
|
||||
/// </summary>
|
||||
public async void updateAnimation()
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
//if (AnimationTree.Count == 0)
|
||||
//{
|
||||
// isAnimationPlay = false;
|
||||
// return;
|
||||
//}
|
||||
//isAnimationPlay = true;
|
||||
if (animationHighlight > AnimationTree.Count)
|
||||
{
|
||||
animationHighlight = AnimationTree.Count - 1;
|
||||
Debug.Log("=---");
|
||||
}
|
||||
else if (animationHighlight < 0) {
|
||||
animationHighlight = 0;
|
||||
}
|
||||
EditorUtility.SetDirty(this);
|
||||
Debug.Log(animationHighlight > AnimationTree.Count);
|
||||
Debug.Log(animationHighlight);
|
||||
List<Sprite> LightSprite = AnimationTree[animationHighlight].value;
|
||||
if (LightSprite == null )
|
||||
{
|
||||
//isAnimationPlay = false;
|
||||
return;
|
||||
};
|
||||
OnAnimationStart?.Invoke(animationHighlight);
|
||||
foreach (Sprite sprite in LightSprite)
|
||||
{
|
||||
if (image != null)
|
||||
{
|
||||
image.sprite = sprite;
|
||||
}
|
||||
else if (spriteRenderer != null)
|
||||
{
|
||||
spriteRenderer.sprite = sprite;
|
||||
}
|
||||
if (animationHighlight > 0 && animationHighlight < AnimationTree.Count)
|
||||
{
|
||||
OnAnimationIng?.Invoke(animationHighlight);
|
||||
await Task.Delay(AnimationTree[animationHighlight].CharacterAnimationFrameInterval);
|
||||
}
|
||||
|
||||
}
|
||||
OnAnimationEnd?.Invoke(animationHighlight);
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 角色死亡
|
||||
/// </summary>
|
||||
public virtual void die()
|
||||
{
|
||||
if (Application.isPlaying)
|
||||
{
|
||||
Destroy(gameObject);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 单位更新buff
|
||||
/// </summary>
|
||||
async void UpdateBuff()//单位buff更新
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
List<BUff> deleteArr = new List<BUff>();
|
||||
foreach (BUff buffItem in buffList)
|
||||
{
|
||||
if (buffItem.executionInterval <= 0)
|
||||
{
|
||||
buffItem.executionInterval = buffItem.executionInterval_max;
|
||||
buffItem.Funaction.Invoke(buffItem.value);
|
||||
}
|
||||
|
||||
buffItem.executionInterval -= 0.1f;
|
||||
buffItem.timeLeft -= 0.1f;
|
||||
if (buffItem.timeLeft <= 0)
|
||||
{
|
||||
deleteArr.Add(buffItem);
|
||||
|
||||
}
|
||||
}
|
||||
foreach (BUff item in deleteArr)
|
||||
{
|
||||
buffList.Remove(item);
|
||||
}
|
||||
await Task.Delay(100);//buff检测最小时间0.1秒执行一次
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// 如果启用 MonoBehaviour,则每个固定帧速率的帧都将调用此函数
|
||||
private void FixedUpdate()
|
||||
{
|
||||
//if (!isAnimationPlay)
|
||||
//{
|
||||
// updateAnimation();
|
||||
//}
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c02b3c0b40de2c84c8cd8d2edb52f70d
|
||||
guid: c596dfec7e7bbd240b33b61a885ae327
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
8
Role/move.meta
Normal file
8
Role/move.meta
Normal file
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5a90bc70d7f021046bed1c96e97b8064
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
8
Role/move/2D.meta
Normal file
8
Role/move/2D.meta
Normal file
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 80ad65f0cc14aa046820d7cef0c0b529
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
36
Role/move/2D/SimplePathfindingDoTween.cs
Normal file
36
Role/move/2D/SimplePathfindingDoTween.cs
Normal file
@ -0,0 +1,36 @@
|
||||
|
||||
using UnityEngine;
|
||||
using DG.Tweening; // 引入DoTween命名空间
|
||||
|
||||
public class SimplePathfindingDoTween : Fun
|
||||
{
|
||||
public Transform[] waypoints; // 预设的路径点
|
||||
public float moveDuration = 1f; // 每个点之间的移动时长
|
||||
|
||||
private int currentWaypointIndex = 0; // 当前路径点的索引
|
||||
|
||||
//void Start()
|
||||
//{
|
||||
// // 让角色开始移动到第一个路径点
|
||||
// MoveToNextWaypoint();
|
||||
//}
|
||||
|
||||
void MoveToNextWaypoint(GameObject gameObject)
|
||||
{
|
||||
if (currentWaypointIndex < waypoints.Length)
|
||||
{
|
||||
// 获取下一个路径点
|
||||
Transform targetWaypoint = waypoints[currentWaypointIndex];
|
||||
|
||||
// 使用DoTween实现平滑移动到目标位置
|
||||
gameObject.transform.DOMove(targetWaypoint.position, moveDuration)
|
||||
.OnComplete(() => MoveToNextWaypoint(gameObject)); // 移动完成后继续到下一个路径点
|
||||
|
||||
currentWaypointIndex++; // 更新路径点索引
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.Log("到达终点!");
|
||||
}
|
||||
}
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: cf7c464bd7bdfcc4db645246bf4529ec
|
||||
guid: 28012bb73bbdd3a4f881dda28759bfa4
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
16
base/base.cs
16
base/base.cs
@ -11,20 +11,24 @@ using UnityEngine.UI;
|
||||
public class Base : MonoBehaviour
|
||||
{
|
||||
private List<string> LoadClassName = new List<string>() { "ImageLoader" , "Global" };//写入需要全局自动实例化的类
|
||||
public Button retbutton;
|
||||
public GameObject ClosureObj;
|
||||
[Header("关闭窗口的按钮")] public Button retbutton;
|
||||
[Header("需要关闭的窗口")] public GameObject ClosureObj;
|
||||
public static GameObject GlobalObj;
|
||||
/// <summary>
|
||||
///初始化
|
||||
/// </summary>
|
||||
private void Awake()
|
||||
{
|
||||
Application.targetFrameRate = Mathf.RoundToInt(55f); // ÉèÖÃÄ¿±êÖ¡ÂÊ
|
||||
initializeGlobal();
|
||||
if (retbutton != null)
|
||||
if (Application.isPlaying)
|
||||
{
|
||||
retbutton.onClick.AddListener(() => CancelOnClick(retbutton, ClosureObj));
|
||||
Application.targetFrameRate = Mathf.RoundToInt(55f); // 设置目标帧率
|
||||
initializeGlobal();
|
||||
if (retbutton != null)
|
||||
{
|
||||
retbutton.onClick.AddListener(() => CancelOnClick(retbutton, ClosureObj));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
/// <summary>
|
||||
|
18
test/test.cs
18
test/test.cs
@ -1,18 +0,0 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class test : Base
|
||||
{
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
@ -1,20 +0,0 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class test1 : Base
|
||||
{
|
||||
// Start is called before the first frame update
|
||||
async void Start()
|
||||
{
|
||||
GetComponent<Image>().sprite = await GlobalObj.GetComponent<ImageLoader>().LoadImageAsync("https://fantasymonster-app.oss-cn-hangzhou.aliyuncs.com/goods/mall/c7860d8909194d479b6f27ccb922e863.png");
|
||||
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user