备份CatanBuilding瘦身独立工程
This commit is contained in:
241
Assets/Scripts/EventWashing/Stuff/LongPressStuffBase.cs
Normal file
241
Assets/Scripts/EventWashing/Stuff/LongPressStuffBase.cs
Normal file
@@ -0,0 +1,241 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Events;
|
||||
|
||||
namespace game
|
||||
{
|
||||
public class LongPressStuffBase : MonoBehaviour
|
||||
{
|
||||
[Tooltip("物品ID")]
|
||||
public int ID = 0;
|
||||
|
||||
[Tooltip("需要消耗的时间")]
|
||||
[SerializeField] protected float m_ConsumeTime = 3f;
|
||||
|
||||
[Tooltip("是否需要呼吸变色功能,默认开启。")]
|
||||
public bool m_IsBreathing = true;
|
||||
|
||||
[Tooltip("需要改变颜色的渲染器")]
|
||||
public Renderer[] m_Renderers = null;
|
||||
|
||||
[Tooltip("吸气时间")]
|
||||
public float m_BreatheInTime = 1f;
|
||||
|
||||
[Tooltip("呼气时间")]
|
||||
public float m_BreatheOutTime = 1f;
|
||||
|
||||
[Tooltip("憋气时间")]
|
||||
public float m_HoldBreathTime = 2f;
|
||||
|
||||
[Tooltip("颜色")]
|
||||
public Color m_Color = Color.red;
|
||||
|
||||
#region 外部接口
|
||||
/// <summary>
|
||||
/// 进度
|
||||
/// </summary>
|
||||
public float Progress
|
||||
{
|
||||
get
|
||||
{
|
||||
if (m_Status == EventWashingActionStatus.Executing || m_Status == EventWashingActionStatus.Stopping)
|
||||
return m_CumulativeTime / m_ConsumeTime;
|
||||
else if (m_Status == EventWashingActionStatus.Ending)
|
||||
return 1f;
|
||||
return 0f;
|
||||
}
|
||||
}
|
||||
|
||||
public float CumulativeConsumeTime
|
||||
{
|
||||
get
|
||||
{
|
||||
if (m_CumulativeTime < 0f)
|
||||
{
|
||||
m_CumulativeTime = 0f;
|
||||
}
|
||||
else if (m_CumulativeTime > m_ConsumeTime)
|
||||
{
|
||||
m_CumulativeTime = m_ConsumeTime;
|
||||
}
|
||||
return m_CumulativeTime;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 启动操作
|
||||
/// </summary>
|
||||
/// <param name="overAction"></param>
|
||||
public virtual void StartAction(UnityAction<LongPressStuffBase> overAction)
|
||||
{
|
||||
m_Status = EventWashingActionStatus.Executing;
|
||||
m_OverAction = overAction;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 停止操作
|
||||
/// </summary>
|
||||
public virtual void StopAction()
|
||||
{
|
||||
m_Status = EventWashingActionStatus.Stopping;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 设置已经执行过的时间
|
||||
/// </summary>
|
||||
/// <param name="time"></param>
|
||||
public void SetHaveExecutedTime(float time)
|
||||
{
|
||||
m_CumulativeTime = time;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 设置结束
|
||||
/// </summary>
|
||||
public void SetOver()
|
||||
{
|
||||
m_CumulativeTime = m_ConsumeTime;
|
||||
}
|
||||
|
||||
public bool IsOver()
|
||||
{
|
||||
return m_Status == EventWashingActionStatus.Ending;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 材质球处理相关
|
||||
|
||||
private float m_Time = 0f;
|
||||
|
||||
private Color m_StartColor = Color.white;
|
||||
private Color m_GapColor = Color.white;
|
||||
|
||||
private int m_State = 0;
|
||||
|
||||
public virtual void StartBreathing()
|
||||
{
|
||||
m_IsBreathing = true;
|
||||
}
|
||||
public virtual void StopBreathing()
|
||||
{
|
||||
m_IsBreathing = false;
|
||||
}
|
||||
|
||||
private void InitMaterials()
|
||||
{
|
||||
if (m_Renderers == null) return;
|
||||
m_GapColor = m_Color - m_StartColor;
|
||||
}
|
||||
private void UpdateMaterials()
|
||||
{
|
||||
if (m_Renderers == null || !m_IsBreathing) return;
|
||||
|
||||
if (m_State == 0)
|
||||
{
|
||||
m_Time += Time.deltaTime;
|
||||
if (m_Time >= m_BreatheInTime)
|
||||
{
|
||||
m_Time = m_BreatheOutTime;
|
||||
m_State = 1;
|
||||
}
|
||||
}
|
||||
else if (m_State == 1)
|
||||
{
|
||||
m_Time -= Time.deltaTime;
|
||||
if (m_Time <= 0f)
|
||||
{
|
||||
m_Time = 0f;
|
||||
m_State = 2;
|
||||
}
|
||||
}
|
||||
else if (m_State == 2)
|
||||
{
|
||||
m_Time += Time.deltaTime;
|
||||
if (m_Time >= m_HoldBreathTime)
|
||||
{
|
||||
m_Time = 0f;
|
||||
m_State = 0;
|
||||
}
|
||||
}
|
||||
|
||||
Color color = Color.white;
|
||||
if (m_State == 0 || m_State == 1)
|
||||
{
|
||||
float scale = m_Time / m_BreatheInTime;
|
||||
color = m_StartColor + scale * m_GapColor;
|
||||
}
|
||||
|
||||
foreach (var renderer in m_Renderers)
|
||||
{
|
||||
int count = renderer.materials.Length;
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
Material material = renderer.materials[i];
|
||||
material.SetColor("_BaseColor", color);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 事件
|
||||
protected UnityAction<LongPressStuffBase> m_OverAction = null; // 结束事件
|
||||
#endregion
|
||||
|
||||
#region 状态&内部使用
|
||||
protected EventWashingActionStatus m_Status = EventWashingActionStatus.Invalid; // 状态
|
||||
protected float m_CumulativeTime = 0f; // 累计时间
|
||||
|
||||
protected EventWashingStuffType m_Type = 0; // 物品类型
|
||||
|
||||
public float ConsumeTime { get => m_ConsumeTime; }
|
||||
|
||||
public void SetStatus(EventWashingActionStatus status)
|
||||
{
|
||||
m_Status = status;
|
||||
}
|
||||
|
||||
protected virtual void UpdateState()
|
||||
{
|
||||
if (m_Status == EventWashingActionStatus.Executing)
|
||||
{
|
||||
m_CumulativeTime += Time.deltaTime;
|
||||
if (m_CumulativeTime >= m_ConsumeTime)
|
||||
{
|
||||
m_CumulativeTime = m_ConsumeTime;
|
||||
m_Status = EventWashingActionStatus.Ending;
|
||||
if (m_OverAction != null)
|
||||
{
|
||||
m_OverAction.Invoke(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 生命周期
|
||||
/// <summary>
|
||||
/// 初始化
|
||||
/// </summary>
|
||||
public virtual void InitStuff()
|
||||
{
|
||||
InitMaterials();
|
||||
}
|
||||
|
||||
// Start is called before the first frame update
|
||||
protected virtual void Start()
|
||||
{
|
||||
InitStuff();
|
||||
m_Status = EventWashingActionStatus.Invalid;
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
protected virtual void Update()
|
||||
{
|
||||
UpdateState();
|
||||
|
||||
UpdateMaterials();
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/EventWashing/Stuff/LongPressStuffBase.cs.meta
Normal file
11
Assets/Scripts/EventWashing/Stuff/LongPressStuffBase.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: cb0556fd9afa9364997da5ea6ae7eff7
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
79
Assets/Scripts/EventWashing/Stuff/StuffAssembling.cs
Normal file
79
Assets/Scripts/EventWashing/Stuff/StuffAssembling.cs
Normal file
@@ -0,0 +1,79 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using UnityEngine;
|
||||
|
||||
namespace game
|
||||
{
|
||||
public class StuffAssembling : LongPressStuffBase
|
||||
{
|
||||
[Tooltip("空置时所需材质球")]
|
||||
public Material m_UnoccupiedMaterial;
|
||||
|
||||
#region 材质球处理相关
|
||||
|
||||
private List<List<Material>> m_BackupMaterials = new List<List<Material>>();
|
||||
public void SwitchUnoccupiedMaterial()
|
||||
{
|
||||
if (m_UnoccupiedMaterial == null || m_Renderers == null) return;
|
||||
|
||||
int count = m_Renderers.Length;
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
var renderer = m_Renderers[i];
|
||||
var materials = renderer.sharedMaterials.ToList();
|
||||
|
||||
// 备份原始材质球
|
||||
List<Material> list = new List<Material>();
|
||||
int tmpCount = materials.Count;
|
||||
for (int j = 0; j < tmpCount; j++)
|
||||
{
|
||||
list.Add(materials[j]);
|
||||
}
|
||||
m_BackupMaterials.Add(list);
|
||||
|
||||
// 清空材质球
|
||||
materials.Clear();
|
||||
// 替换空置材质球
|
||||
materials.Add(m_UnoccupiedMaterial);
|
||||
|
||||
renderer.materials = materials.ToArray();
|
||||
}
|
||||
}
|
||||
|
||||
public void RestoreMaterial()
|
||||
{
|
||||
if (m_Renderers == null) return;
|
||||
|
||||
int count = m_Renderers.Length;
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
var renderer = m_Renderers[i];
|
||||
var materials = renderer.sharedMaterials.ToList();
|
||||
|
||||
// 清空材质球
|
||||
materials.Clear();
|
||||
|
||||
var list = m_BackupMaterials[i];
|
||||
int tmpCount = list.Count;
|
||||
// 换回备份材质球
|
||||
for(int j = 0;j < tmpCount; j++)
|
||||
{
|
||||
materials.Add((Material)list[j]);
|
||||
}
|
||||
renderer.materials = materials.ToArray();
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 生命周期
|
||||
public override void InitStuff()
|
||||
{
|
||||
base.InitStuff();
|
||||
m_Type = EventWashingStuffType.Assembling;
|
||||
|
||||
SwitchUnoccupiedMaterial();
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/EventWashing/Stuff/StuffAssembling.cs.meta
Normal file
11
Assets/Scripts/EventWashing/Stuff/StuffAssembling.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7ba5e72162738294a8f8536bb073fe9f
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
153
Assets/Scripts/EventWashing/Stuff/StuffBarnacle.cs
Normal file
153
Assets/Scripts/EventWashing/Stuff/StuffBarnacle.cs
Normal file
@@ -0,0 +1,153 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace game
|
||||
{
|
||||
public class StuffBarnacle : LongPressStuffBase
|
||||
{
|
||||
[Tooltip("循环特效")]
|
||||
[SerializeField]
|
||||
private ParticleSystem[] m_LoopEffects = null;
|
||||
|
||||
[Tooltip("循环特效时间")]
|
||||
[SerializeField]
|
||||
private float m_LoopTime = 1.0f;
|
||||
|
||||
[Tooltip("最后一击特效")]
|
||||
[SerializeField]
|
||||
private ParticleSystem[] m_FinalBlowEffects = null;
|
||||
|
||||
[Tooltip("最后一击特效时间")]
|
||||
[SerializeField]
|
||||
private float m_FinalBlowTime = 0.3f;
|
||||
|
||||
#region 外部接口
|
||||
public override void StopAction()
|
||||
{
|
||||
base.StopAction();
|
||||
|
||||
Exit1stStage();
|
||||
Exit2ndStage();
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 状态&内部使用
|
||||
private bool m_IsRunning2rd = false;
|
||||
private void Enter2ndStage()
|
||||
{
|
||||
m_IsBreathing = false;
|
||||
if (m_IsRunning2rd) return;
|
||||
m_IsRunning2rd = true;
|
||||
|
||||
int count = 0;
|
||||
if (m_FinalBlowEffects != null)
|
||||
{
|
||||
count = m_FinalBlowEffects.Length;
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
m_FinalBlowEffects[i].gameObject.SetActive(true);
|
||||
m_FinalBlowEffects[i].Play();
|
||||
}
|
||||
}
|
||||
|
||||
FishingYachtAct.Publish<EventWashingToolEnter2ndStageData>(new EventWashingToolEnter2ndStageData());
|
||||
}
|
||||
private void Exit2ndStage()
|
||||
{
|
||||
if (m_IsRunning2rd == false) return;
|
||||
|
||||
int count = 0;
|
||||
if (m_FinalBlowEffects != null)
|
||||
{
|
||||
count = m_FinalBlowEffects.Length;
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
m_FinalBlowEffects[i].Stop();
|
||||
m_FinalBlowEffects[i].gameObject.SetActive(false);
|
||||
}
|
||||
}
|
||||
FishingYachtAct.Publish<EventWashingToolExit2ndStageData>(new EventWashingToolExit2ndStageData());
|
||||
|
||||
m_IsRunning2rd = false;
|
||||
m_IsBreathing = true;
|
||||
}
|
||||
|
||||
private bool m_IsRunning1st = false;
|
||||
private void Enter1stStage()
|
||||
{
|
||||
m_IsBreathing = false;
|
||||
if (m_IsRunning1st) return;
|
||||
m_IsRunning1st = true;
|
||||
int count = 0;
|
||||
if (m_LoopEffects != null)
|
||||
{
|
||||
count = m_LoopEffects.Length;
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
m_LoopEffects[i].gameObject.SetActive(true);
|
||||
m_LoopEffects[i].Play();
|
||||
}
|
||||
|
||||
}
|
||||
FishingYachtAct.Publish<EventWashingToolEnter1stStageData>(new EventWashingToolEnter1stStageData());
|
||||
}
|
||||
private void Exit1stStage()
|
||||
{
|
||||
if (m_IsRunning1st == false) return;
|
||||
|
||||
int count = 0;
|
||||
if (m_LoopEffects != null)
|
||||
{
|
||||
count = m_LoopEffects.Length;
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
m_LoopEffects[i].Stop();
|
||||
m_LoopEffects[i].gameObject.SetActive(false);
|
||||
}
|
||||
}
|
||||
FishingYachtAct.Publish<EventWashingToolExit1stStageData>(new EventWashingToolExit1stStageData());
|
||||
|
||||
m_IsRunning1st = false;
|
||||
m_IsBreathing = true;
|
||||
}
|
||||
protected override void UpdateState()
|
||||
{
|
||||
if (m_Status == EventWashingActionStatus.Executing)
|
||||
{
|
||||
m_CumulativeTime += Time.deltaTime;
|
||||
if (m_CumulativeTime >= m_ConsumeTime)
|
||||
{
|
||||
Exit2ndStage();
|
||||
m_CumulativeTime = m_ConsumeTime;
|
||||
m_Status = EventWashingActionStatus.Ending;
|
||||
if (m_OverAction != null)
|
||||
{
|
||||
m_OverAction.Invoke(this);
|
||||
}
|
||||
}
|
||||
else if (m_CumulativeTime > m_LoopTime)
|
||||
{
|
||||
Exit1stStage();
|
||||
Enter2ndStage();
|
||||
}
|
||||
else if (m_CumulativeTime >= 0f)
|
||||
{
|
||||
Enter1stStage();
|
||||
}
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 生命周期
|
||||
public override void InitStuff()
|
||||
{
|
||||
base.InitStuff();
|
||||
m_Type = EventWashingStuffType.Barnacle;
|
||||
|
||||
m_ConsumeTime = m_LoopTime + m_FinalBlowTime;
|
||||
StopAction();
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/EventWashing/Stuff/StuffBarnacle.cs.meta
Normal file
11
Assets/Scripts/EventWashing/Stuff/StuffBarnacle.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c8def403aefb3ff4a8b91d80746d5378
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
33
Assets/Scripts/EventWashing/Stuff/StuffCleaningArea.cs
Normal file
33
Assets/Scripts/EventWashing/Stuff/StuffCleaningArea.cs
Normal file
@@ -0,0 +1,33 @@
|
||||
using PaintCore;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Events;
|
||||
|
||||
namespace game
|
||||
{
|
||||
[RequireComponent(typeof(Collider))]
|
||||
public class StuffCleaningArea : LongPressStuffBase
|
||||
{
|
||||
#region 外部接口
|
||||
public override void StartAction(UnityAction<LongPressStuffBase> overAction)
|
||||
{
|
||||
this.transform.GetComponent<Collider>().enabled = true;
|
||||
}
|
||||
|
||||
public override void StopAction()
|
||||
{
|
||||
this.transform.GetComponent<Collider>().enabled = false;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 生命周期
|
||||
public override void InitStuff()
|
||||
{
|
||||
base.InitStuff();
|
||||
|
||||
m_Type = EventWashingStuffType.CleaningArea;
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/EventWashing/Stuff/StuffCleaningArea.cs.meta
Normal file
11
Assets/Scripts/EventWashing/Stuff/StuffCleaningArea.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: dad6d7eb79f3ff943806763f29fc91ef
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
86
Assets/Scripts/EventWashing/Stuff/StuffTrash.cs
Normal file
86
Assets/Scripts/EventWashing/Stuff/StuffTrash.cs
Normal file
@@ -0,0 +1,86 @@
|
||||
using DG.Tweening;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Events;
|
||||
|
||||
namespace game
|
||||
{
|
||||
public class StuffTrash : LongPressStuffBase
|
||||
{
|
||||
private ToolForFollowerAndNormalPosition m_Cleaner;
|
||||
private float m_Distance;
|
||||
private float m_DisappearTime = 0.1f;
|
||||
|
||||
private bool m_Running = true;
|
||||
|
||||
private UnityAction<StuffTrash> m_OnCompleteAction = null; // 更新事件
|
||||
|
||||
#region 功能
|
||||
public void SetCleaner(ToolForFollowerAndNormalPosition cleaner, float distance, float disappearTime, UnityAction<StuffTrash> completeAction)
|
||||
{
|
||||
m_Cleaner = cleaner;
|
||||
m_Distance = distance;
|
||||
m_DisappearTime = disappearTime;
|
||||
m_OnCompleteAction = completeAction;
|
||||
m_Running = true;
|
||||
}
|
||||
|
||||
private void CheckDistance()
|
||||
{
|
||||
if (m_Cleaner == null) return;
|
||||
float distance = Vector3.Distance(this.transform.position, m_Cleaner.OperatingPoint);
|
||||
if (distance <= m_Distance)
|
||||
{
|
||||
var self = this.gameObject;
|
||||
//this.transform.DOKill();
|
||||
this.transform.DOMove(m_Cleaner.OperatingPoint, m_DisappearTime).SetEase(Ease.OutQuad).OnComplete(() =>
|
||||
{
|
||||
self.SetActive(false);
|
||||
});
|
||||
this.transform.DOLookAt(m_Cleaner.OperatingPoint, m_DisappearTime).SetEase(Ease.OutQuad);
|
||||
this.transform.DOScale(0.1f, m_DisappearTime).SetEase(Ease.Linear);
|
||||
|
||||
if (m_OnCompleteAction != null)
|
||||
{
|
||||
m_OnCompleteAction(this);
|
||||
}
|
||||
|
||||
//this.gameObject.SetActive(false);
|
||||
this.m_Status = EventWashingActionStatus.Ending;
|
||||
StopAction();
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 外部接口
|
||||
public override void StartAction(UnityAction<LongPressStuffBase> overAction)
|
||||
{
|
||||
//base.StartAction(overAction);
|
||||
m_Running = true;
|
||||
}
|
||||
public override void StopAction()
|
||||
{
|
||||
//base.StopAction();
|
||||
m_Running = false;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 生命周期
|
||||
public override void InitStuff()
|
||||
{
|
||||
base.InitStuff();
|
||||
m_Type = EventWashingStuffType.Trash;
|
||||
}
|
||||
|
||||
protected override void Update()
|
||||
{
|
||||
base.Update();
|
||||
if (m_Running)
|
||||
{
|
||||
CheckDistance();
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/EventWashing/Stuff/StuffTrash.cs.meta
Normal file
11
Assets/Scripts/EventWashing/Stuff/StuffTrash.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b69635a03c5ffba48b0d499c00aacbd1
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
17
Assets/Scripts/EventWashing/Stuff/StuffUnload.cs
Normal file
17
Assets/Scripts/EventWashing/Stuff/StuffUnload.cs
Normal file
@@ -0,0 +1,17 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace game
|
||||
{
|
||||
public class StuffUnload : LongPressStuffBase
|
||||
{
|
||||
#region 生命周期
|
||||
public override void InitStuff()
|
||||
{
|
||||
base.InitStuff();
|
||||
m_Type = EventWashingStuffType.Unload;
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/EventWashing/Stuff/StuffUnload.cs.meta
Normal file
11
Assets/Scripts/EventWashing/Stuff/StuffUnload.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8a139756a6bb2854bbb0a84395fceb18
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
95
Assets/Scripts/EventWashing/Stuff/StuffUnloadGlass.cs
Normal file
95
Assets/Scripts/EventWashing/Stuff/StuffUnloadGlass.cs
Normal file
@@ -0,0 +1,95 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace game
|
||||
{
|
||||
public class StuffUnloadGlass : StuffUnload
|
||||
{
|
||||
[Tooltip("循环特效时间")]
|
||||
[SerializeField]
|
||||
private float m_LoopTime = 1.0f;
|
||||
|
||||
[Tooltip("最后一击特效时间")]
|
||||
[SerializeField]
|
||||
private float m_FinalBlowTime = 0.3f;
|
||||
|
||||
#region 外部接口
|
||||
public override void StopAction()
|
||||
{
|
||||
base.StopAction();
|
||||
|
||||
Exit1stStage();
|
||||
Exit2ndStage();
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 状态&内部使用
|
||||
private bool m_IsRunning2rd = false;
|
||||
private void Enter2ndStage()
|
||||
{
|
||||
if (m_IsRunning2rd) return;
|
||||
m_IsRunning2rd = true;
|
||||
|
||||
FishingYachtAct.Publish<EventWashingToolEnter2ndStageData>(new EventWashingToolEnter2ndStageData());
|
||||
}
|
||||
private void Exit2ndStage()
|
||||
{
|
||||
if (m_IsRunning2rd == false) return;
|
||||
m_IsRunning2rd = false;
|
||||
FishingYachtAct.Publish<EventWashingToolExit2ndStageData>(new EventWashingToolExit2ndStageData());
|
||||
}
|
||||
|
||||
private bool m_IsRunning1st = false;
|
||||
private void Enter1stStage()
|
||||
{
|
||||
if (m_IsRunning1st) return;
|
||||
m_IsRunning1st = true;
|
||||
FishingYachtAct.Publish<EventWashingToolEnter1stStageData>(new EventWashingToolEnter1stStageData());
|
||||
}
|
||||
private void Exit1stStage()
|
||||
{
|
||||
if (m_IsRunning1st == false) return;
|
||||
m_IsRunning1st = false;
|
||||
FishingYachtAct.Publish<EventWashingToolExit1stStageData>(new EventWashingToolExit1stStageData());
|
||||
}
|
||||
protected override void UpdateState()
|
||||
{
|
||||
if (m_Status == EventWashingActionStatus.Executing)
|
||||
{
|
||||
m_CumulativeTime += Time.deltaTime;
|
||||
if (m_CumulativeTime >= m_ConsumeTime)
|
||||
{
|
||||
Exit2ndStage();
|
||||
m_CumulativeTime = m_ConsumeTime;
|
||||
m_Status = EventWashingActionStatus.Ending;
|
||||
if (m_OverAction != null)
|
||||
{
|
||||
m_OverAction.Invoke(this);
|
||||
}
|
||||
}
|
||||
else if (m_CumulativeTime > m_LoopTime)
|
||||
{
|
||||
Exit1stStage();
|
||||
Enter2ndStage();
|
||||
}
|
||||
else if (m_CumulativeTime >= 0f)
|
||||
{
|
||||
Enter1stStage();
|
||||
}
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 生命周期
|
||||
public override void InitStuff()
|
||||
{
|
||||
base.InitStuff();
|
||||
m_Type = EventWashingStuffType.UnloadGlass;
|
||||
|
||||
m_ConsumeTime = m_LoopTime + m_FinalBlowTime;
|
||||
StopAction();
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/EventWashing/Stuff/StuffUnloadGlass.cs.meta
Normal file
11
Assets/Scripts/EventWashing/Stuff/StuffUnloadGlass.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d98a4d0b4b3a0104c90f5fa01fe37931
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user