fade out enemies

This commit is contained in:
Le Duc Anh
2025-11-25 14:02:07 +07:00
parent a164af248c
commit d016980696
12 changed files with 1649 additions and 34 deletions
@@ -8,18 +8,16 @@ Material:
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: "\u5251\u80CC\u72FC_0_skin"
m_Shader: {fileID: 4800000, guid: 933532a4fcc9baf4fa0491de14d08ed7, type: 3}
m_Shader: {fileID: -6465566751694194690, guid: d26dc91fe77d59a40968b97beab44055, type: 3}
m_Parent: {fileID: 0}
m_ModifiedSerializedProperties: 0
m_ValidKeywords:
- _ALPHATEST_ON
m_ValidKeywords: []
m_InvalidKeywords: []
m_LightmapFlags: 4
m_EnableInstancingVariants: 0
m_DoubleSidedGI: 0
m_CustomRenderQueue: 2450
stringTagMap:
RenderType: TransparentCutout
m_CustomRenderQueue: -1
stringTagMap: {}
disabledShaderPasses:
- MOTIONVECTORS
m_LockedProperties:
@@ -85,7 +83,9 @@ Material:
m_Ints: []
m_Floats:
- _AddPrecomputedVelocity: 0
- _Alpha: 1
- _AlphaClip: 1
- _AlphaThreshold: 0.005
- _AlphaToMask: 1
- _Blend: 0
- _BlendModePreserveSpecular: 1
@@ -105,6 +105,7 @@ Material:
- _Metallic: 0
- _OcclusionStrength: 1
- _Parallax: 0.005
- _QueueControl: 0
- _QueueOffset: 0
- _ReceiveShadows: 1
- _Smoothness: 0.5
@@ -8,24 +8,18 @@ Material:
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: "\u5C0F\u661F\u661F_0_skin"
m_Shader: {fileID: 4800000, guid: 933532a4fcc9baf4fa0491de14d08ed7, type: 3}
m_Shader: {fileID: -6465566751694194690, guid: d26dc91fe77d59a40968b97beab44055, type: 3}
m_Parent: {fileID: 0}
m_ModifiedSerializedProperties: 0
m_ValidKeywords:
- _ALPHAPREMULTIPLY_ON
- _ALPHATEST_ON
- _SURFACE_TYPE_TRANSPARENT
m_ValidKeywords: []
m_InvalidKeywords: []
m_LightmapFlags: 4
m_EnableInstancingVariants: 0
m_DoubleSidedGI: 0
m_CustomRenderQueue: 3000
stringTagMap:
RenderType: Transparent
m_CustomRenderQueue: -1
stringTagMap: {}
disabledShaderPasses:
- MOTIONVECTORS
- DepthOnly
- SHADOWCASTER
m_LockedProperties:
m_SavedProperties:
serializedVersion: 3
@@ -89,7 +83,9 @@ Material:
m_Ints: []
m_Floats:
- _AddPrecomputedVelocity: 0
- _Alpha: 1
- _AlphaClip: 1
- _AlphaThreshold: 0
- _AlphaToMask: 0
- _Blend: 0
- _BlendModePreserveSpecular: 1
@@ -109,6 +105,7 @@ Material:
- _Metallic: 0
- _OcclusionStrength: 1
- _Parallax: 0.005
- _QueueControl: 0
- _QueueOffset: 0
- _ReceiveShadows: 1
- _Smoothness: 0.5
@@ -8,18 +8,16 @@ Material:
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: "\u5154\u5E7C\u5E74_0_skin"
m_Shader: {fileID: 4800000, guid: 933532a4fcc9baf4fa0491de14d08ed7, type: 3}
m_Shader: {fileID: -6465566751694194690, guid: d26dc91fe77d59a40968b97beab44055, type: 3}
m_Parent: {fileID: 0}
m_ModifiedSerializedProperties: 0
m_ValidKeywords:
- _ALPHATEST_ON
m_ValidKeywords: []
m_InvalidKeywords: []
m_LightmapFlags: 4
m_EnableInstancingVariants: 0
m_DoubleSidedGI: 0
m_CustomRenderQueue: 2450
stringTagMap:
RenderType: TransparentCutout
m_CustomRenderQueue: -1
stringTagMap: {}
disabledShaderPasses:
- MOTIONVECTORS
m_LockedProperties:
@@ -85,15 +83,17 @@ Material:
m_Ints: []
m_Floats:
- _AddPrecomputedVelocity: 0
- _AlphaClip: 1
- _AlphaToMask: 1
- _Alpha: 1
- _AlphaClip: 0
- _AlphaThreshold: 0
- _AlphaToMask: 0
- _Blend: 0
- _BlendModePreserveSpecular: 1
- _BumpScale: 1
- _ClearCoatMask: 0
- _ClearCoatSmoothness: 0
- _Cull: 2
- _Cutoff: 0.001
- _Cutoff: 0
- _DetailAlbedoMapScale: 1
- _DetailNormalMapScale: 1
- _DstBlend: 0
@@ -105,8 +105,9 @@ Material:
- _Metallic: 0
- _OcclusionStrength: 1
- _Parallax: 0.005
- _QueueControl: 0
- _QueueOffset: 0
- _ReceiveShadows: 1
- _ReceiveShadows: 0
- _Smoothness: 0.5
- _SmoothnessTextureChannel: 0
- _SpecularHighlights: 1
@@ -21,18 +21,16 @@ Material:
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: "\u72FC_0_skin"
m_Shader: {fileID: 4800000, guid: 933532a4fcc9baf4fa0491de14d08ed7, type: 3}
m_Shader: {fileID: -6465566751694194690, guid: d26dc91fe77d59a40968b97beab44055, type: 3}
m_Parent: {fileID: 0}
m_ModifiedSerializedProperties: 0
m_ValidKeywords:
- _ALPHATEST_ON
m_ValidKeywords: []
m_InvalidKeywords: []
m_LightmapFlags: 4
m_EnableInstancingVariants: 0
m_DoubleSidedGI: 0
m_CustomRenderQueue: 2450
stringTagMap:
RenderType: TransparentCutout
m_CustomRenderQueue: -1
stringTagMap: {}
disabledShaderPasses:
- MOTIONVECTORS
m_LockedProperties:
@@ -98,7 +96,9 @@ Material:
m_Ints: []
m_Floats:
- _AddPrecomputedVelocity: 0
- _Alpha: 1
- _AlphaClip: 1
- _AlphaThreshold: 0
- _AlphaToMask: 1
- _Blend: 0
- _BlendModePreserveSpecular: 1
@@ -118,6 +118,7 @@ Material:
- _Metallic: 0
- _OcclusionStrength: 1
- _Parallax: 0.005
- _QueueControl: 0
- _QueueOffset: 0
- _ReceiveShadows: 1
- _Smoothness: 0.5
@@ -0,0 +1,63 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!21 &2100000
Material:
serializedVersion: 8
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: Shader Graphs_SimpleLitShader
m_Shader: {fileID: -6465566751694194690, guid: d26dc91fe77d59a40968b97beab44055, type: 3}
m_Parent: {fileID: 0}
m_ModifiedSerializedProperties: 0
m_ValidKeywords: []
m_InvalidKeywords: []
m_LightmapFlags: 2
m_EnableInstancingVariants: 0
m_DoubleSidedGI: 0
m_CustomRenderQueue: -1
stringTagMap: {}
disabledShaderPasses:
- MOTIONVECTORS
m_LockedProperties:
m_SavedProperties:
serializedVersion: 3
m_TexEnvs:
- _Albedo:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- unity_Lightmaps:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- unity_LightmapsInd:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- unity_ShadowMasks:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
m_Ints: []
m_Floats:
- _Alpha: 0
- _QueueControl: 0
- _QueueOffset: 0
m_Colors: []
m_BuildTextureStacks: []
m_AllowLocking: 1
--- !u!114 &2236772491388985537
MonoBehaviour:
m_ObjectHideFlags: 11
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: d0353a89b1f911e48b9e16bdc9f2e058, type: 3}
m_Name:
m_EditorClassIdentifier:
version: 10
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 7e4ab6931a4e19645a71bdfa4b4a6d69
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 2100000
userData:
assetBundleName:
assetBundleVariant:
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,10 @@
fileFormatVersion: 2
guid: d26dc91fe77d59a40968b97beab44055
ScriptedImporter:
internalIDToNameTable: []
externalObjects: {}
serializedVersion: 2
userData:
assetBundleName:
assetBundleVariant:
script: {fileID: 11500000, guid: 625f186215c104763be7675aa2d941aa, type: 3}
@@ -32,7 +32,7 @@ public class CECNPCMan : IMsgHandler
case long value when value == EC_MsgDef.MSG_NM_NPCMOVE: OnMsgNPCMove(Msg); break;
case long value when value == EC_MsgDef.MSG_NM_NPCSTOPMOVE: OnMsgNPCStopMove(Msg); break;
case long value when value == EC_MsgDef.MSG_NM_NPCRUNOUT: OnMsgNPCRunOut(Msg); break;
case long value when value == EC_MsgDef.MSG_NM_NPCDIED: OnMsgNPCDied(Msg); break;
case EC_MsgDef.MSG_NM_NPCDIED: OnMsgNPCDied(Msg); break;
case long value when value == EC_MsgDef.MSG_NM_NPCDISAPPEAR: OnMsgNPCDisappear(Msg); break;
case long value when value == EC_MsgDef.MSG_NM_NPCATKRESULT: TransmitMessage(Msg); break;
}
@@ -1,3 +1,5 @@
using System.Collections;
using System.Threading.Tasks;
using BrewMonster;
using BrewMonster.Managers;
using CSNetwork.GPDataType;
@@ -12,6 +14,8 @@ using UnityEngine;
public class CECObject : MonoBehaviour
{
protected static int ALPHA_HASH = Shader.PropertyToID("_Alpha");
protected Quaternion targetRotation;
protected Vector3 g_vAxisY = Vector3.up;
// Class ID
@@ -305,4 +309,27 @@ public class CECObject : MonoBehaviour
m_bAdjustOrient = true;
}
}
protected void FadeOut()
{
StartCoroutine(FadeOutCoroutine());
}
private IEnumerator FadeOutCoroutine()
{
var skinnedMeshRenderer = GetComponentInChildren<SkinnedMeshRenderer>();
if (skinnedMeshRenderer == null) yield break;
var material = skinnedMeshRenderer.sharedMaterial;
var newMaterial = new Material(material);
skinnedMeshRenderer.sharedMaterial = newMaterial;
// use for to fade out alpha
for (float alpha = 1f; alpha >= 0f; alpha -= 0.01f)
{
newMaterial.SetFloat(ALPHA_HASH, alpha);
yield return null;
}
}
}
@@ -658,6 +658,7 @@ public class CECNPC : CECObject
// No delay die, enter disappear process immediately
if (!bDelay)
Disappear();
StartWork((int)WorkType.WT_NORMAL, (int)WorkID.WORK_DEAD, m_dwStates);
@@ -666,6 +667,7 @@ public class CECNPC : CECObject
public void Disappear()
{
BMLogger.Log("CECNPC::Disappear");
FadeOut();
m_DisappearCnt.SetCounter(1);
PlayModelAction((int)NPCActionIndex.ACT_NPC_DISAPPEAR);
}
@@ -235,7 +235,7 @@ namespace CSNetwork
public static int MSG_NM_NPCINFO = 400; // NPC information, p1 - protocol object address
public static int MSG_NM_NPCMOVE = 401; // NPC move, p1 - data address
public static int MSG_NM_NPCRUNOUT = 402; // NPC run out of view area, p1 - data address
public static int MSG_NM_NPCDIED = 403; // NPC died, p1 - data address
public const int MSG_NM_NPCDIED = 403; // NPC died, p1 - data address
public static int MSG_NM_NPCDISAPPEAR = 404; // NPC disappear, p1 - data address
public static int MSG_NM_NPCCASTSKILL = 405; // NPC cast skill
public static int MSG_NM_NPCROOT = 406; // NPC is root