This commit is contained in:
GL 2024-12-20 21:42:02 +08:00
parent bfd3ffcd8d
commit 6fa9e38562
8 changed files with 255 additions and 27 deletions

View File

@ -0,0 +1,104 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1 &1091443316701177648
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 660602218193290689}
- component: {fileID: 762876158176410263}
- component: {fileID: 4303165778035962172}
m_Layer: 0
m_Name: Bing
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &660602218193290689
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1091443316701177648}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: -2.391, y: -0.135, z: 0}
m_LocalScale: {x: 0.15529104, y: 0.15529104, z: 0.15529104}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!212 &762876158176410263
SpriteRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1091443316701177648}
m_Enabled: 1
m_CastShadows: 0
m_ReceiveShadows: 0
m_DynamicOccludee: 1
m_StaticShadowCaster: 0
m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
m_RayTracingMode: 0
m_RayTraceProcedural: 0
m_RenderingLayerMask: 1
m_RendererPriority: 0
m_Materials:
- {fileID: 10754, guid: 0000000000000000f000000000000000, type: 0}
m_StaticBatchInfo:
firstSubMesh: 0
subMeshCount: 0
m_StaticBatchRoot: {fileID: 0}
m_ProbeAnchor: {fileID: 0}
m_LightProbeVolumeOverride: {fileID: 0}
m_ScaleInLightmap: 1
m_ReceiveGI: 1
m_PreserveUVs: 0
m_IgnoreNormalsForChartDetection: 0
m_ImportantGI: 0
m_StitchLightmapSeams: 1
m_SelectedEditorRenderState: 0
m_MinimumChartSize: 4
m_AutoUVMaxDistance: 0.5
m_AutoUVMaxAngle: 89
m_LightmapParameters: {fileID: 0}
m_SortingLayerID: 0
m_SortingLayer: 0
m_SortingOrder: 0
m_Sprite: {fileID: 21300000, guid: 2b550a2055708b54a8609c17a089281c, type: 3}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_FlipX: 0
m_FlipY: 0
m_DrawMode: 0
m_Size: {x: 1, y: 1}
m_AdaptiveModeThreshold: 0.5
m_SpriteTileMode: 0
m_WasSpriteAssigned: 1
m_MaskInteraction: 0
m_SpriteSortPoint: 0
--- !u!114 &4303165778035962172
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1091443316701177648}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: a7361a599e01f924eb9bd42480cf7ade, type: 3}
m_Name:
m_EditorClassIdentifier:
Crole: {fileID: 0}
bullet: {fileID: 0}
attackTime: 0
attackAllTime: 3
lifeTime: 3

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: b9df638c9cb3bfe43acb042655fd517e
PrefabImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -4819,8 +4819,13 @@ MonoBehaviour:
role: {fileID: 0}
attackObj: {fileID: 0}
myBulletType: 0
bulletAttributes: 3
bulletMoveType: 0
BulletDeadTimer: 10
animator: {fileID: 0}
IsMove: 1
Collider2D: {fileID: 0}
effectPre: {fileID: 1091443316701177648, guid: b9df638c9cb3bfe43acb042655fd517e, type: 3}
--- !u!210 &6519243243911487068
SortingGroup:
m_ObjectHideFlags: 0

View File

@ -5839,7 +5839,7 @@ MonoBehaviour:
Prefab: {fileID: 4703411402065954783, guid: aac4ad2c72526a54691494dd54e115a6, type: 3}
SpawnLocation: {fileID: 734893407}
GenerationInterval: 15
GenerationIntervalOfOne: 1
GenerationIntervalOfOne: 3
GenerateQuantityMax: 20
GenerateQuantity: 5
deadNumber: 0

@ -1 +1 @@
Subproject commit 1e50006cf9e2a255ad0ae6c91abbef15075f7dd6
Subproject commit 8fec6273a4346583fb36152f04a9a9ac7c7f00dc

View File

@ -0,0 +1,55 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Bing : MonoBehaviour
{
public enemy Crole; // 角色对象,用来扣血
public Bullet bullet; // 子弹脚本
private float lastDamageTime = 0; // 上一次扣血的时间
private float lastDamageAllTime = 0; // 上一次灼烧效果的总时间
[Header("灼烧扣血间隔")]
public float attackTime; // 扣血的间隔时间
[Header("冰总时间")]
public float attackAllTime = 3; // 扣血的持续时间
[Header("冰消失时间")]
public float lifeTime = 3f; // 火焰的持续时间,默认 5 秒
private float spawnTime; // 记录火焰生成的时间
void Start()
{
Debug.Log("-------------------------");
spawnTime = Time.time; // 记录火焰对象的生成时间
Crole = transform.parent.GetComponent<enemy>();
}
void Update()
{
// 判断是否超过火焰存在的最大时间
if (Time.time - spawnTime > lifeTime)
{
Destroy(gameObject); // 超过时间后销毁物体
return; // 直接返回,不再执行后面的灼烧逻辑
}
// 这里可以加上灼烧的具体逻辑,比如伤害的扣除等
if (Crole != null && bullet != null)
{
// 进行灼烧扣血操作
if (Time.time - lastDamageAllTime > attackAllTime || lastDamageAllTime == 0)
{
if (Time.time - lastDamageTime > attackTime || attackTime == 0)
{
// 执行伤害逻辑
Crole.bloodLoss(new object[] { Crole, bullet.role.Attack + bullet.bulletData.attack, bullet.attackObj.damageTyp, bullet.role });
Debug.Log("灼烧扣血");
lastDamageTime = Time.time;
}
lastDamageAllTime = Time.time;
}
}
}
}

View File

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

View File

@ -8,76 +8,122 @@ public class enemy : Role
[Header("移动速度")] public float moveSpeed;
[HideInInspector]
public float harmNumber=0;//伤害
public float harmNumber = 0; // 伤害
public float HarmNumber
{
get=> harmNumber;
get => harmNumber;
set
{
harmNumber=value;
Debug.Log(enemyId+"总伤害"+ harmNumber );
harmNumber = value;
Debug.Log(enemyId + "总伤害" + harmNumber);
}
}
private float originalMoveSpeed; // 记录初始的移动速度
private float slowDownTime = 0f; // 记录减速开始时间
private bool isSlowed = false; // 标记是否处于减速状态
public override void Start()
{
base.Start();
//
//moveSpeed += Random.Range(-0.5f,0.5f);
originalMoveSpeed = moveSpeed; // 保存初始移动速度
if (camp == Camp.Enemy)
{
if (AnimationTree!=null)
if (AnimationTree != null)
{
AnimationTree[0].CharacterAnimationFrameInterval = (int)(36/moveSpeed) ;
AnimationTree[0].CharacterAnimationFrameInterval = (int)(36 / moveSpeed);
}
//开始移动
Init(InitEnenyData.instance.GetRandomWaypoints());
}
}
public void Init(waypoints _waypoints)
{
base.Navigation.waypoints = _waypoints;
//开始移动
Navigation.MoveToNextWaypoint(this.gameObject,moveSpeed);
//开始移动
Navigation.MoveToNextWaypoint(this.gameObject, moveSpeed);
}
public override void die()
{
base.die();
if (Application.isPlaying)
{
{
// 将当前敌人对象放入死亡池
if (SpawnPool.intance != null )
if (SpawnPool.intance != null)
{
SkillBox.instance.AddExperience(6,this.gameObject.transform);
SkillBox.instance.AddExperience(6, this.gameObject.transform);
}
UIContorl.instance.Killnumber += 1;
}
}
private void OnTriggerEnter2D(Collider2D collision)
{
// Debug.Log("进入范围检测");
// 进入范围检测
if (this.camp == Camp.Enemy && collision.tag == "House")
{
UIContorl.instance.Hp -= 1;
Destroy(this.gameObject);
}
}
// 减速并在指定时间后恢复原速度
public void SlowDown(float slowFactor, float duration)
{
if (!isSlowed)
{
Debug.Log("减速------------------------");
// 临时设置减速后的速度
moveSpeed *= slowFactor;
// 如果有动画控制,更新动画速度
if (AnimationTree != null)
{
AnimationTree[0].CharacterAnimationFrameInterval = (int)(36 / moveSpeed);
}
Navigation.ChangeSpeed(slowFactor, duration);
// 标记减速状态
isSlowed = true;
// 记录减速开始时间
slowDownTime = Time.time;
}
}
void Update()
{
if (isSlowed)
{
// 检查减速时间是否到了
if (Time.time - slowDownTime >= 3f) // 3秒后恢复原速度
{
// 恢复初始速度
moveSpeed = originalMoveSpeed;
// 恢复动画速度
if (AnimationTree != null)
{
foreach (var anim in AnimationTree)
{
anim.CharacterAnimationFrameInterval = (int)(36 / moveSpeed);
}
}
// 取消减速状态
isSlowed = false;
}
}
}
}