备份CatanBuilding瘦身独立工程
This commit is contained in:
133
Assets/Scripts/EventWashing/WashingGame/WashingGameAssembling.cs
Normal file
133
Assets/Scripts/EventWashing/WashingGame/WashingGameAssembling.cs
Normal file
@@ -0,0 +1,133 @@
|
||||
using cfg;
|
||||
using DG.Tweening;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace game
|
||||
{
|
||||
public class WashingGameAssembling : WashingGameRemove
|
||||
{
|
||||
#region 状态相关
|
||||
protected Transform m_OriginalTransform;
|
||||
private LongPressStuffBase m_NewItem;
|
||||
|
||||
protected override void OperatedItemExecuteOverAction(LongPressStuffBase stuffBase)
|
||||
{
|
||||
// 道具飞回展示区
|
||||
m_Tool.MoveToExhibition();
|
||||
|
||||
m_CurOperatedItem.StopAction();
|
||||
|
||||
m_OriginalTransform = m_CurOperatedItem.transform;
|
||||
m_NewItem = m_CurOperatedItem;
|
||||
|
||||
m_CurOperatedItem.gameObject.SetActive(false);
|
||||
m_CurOperatedItem = null;
|
||||
m_Status = EventWashingActionStatus.Ending;
|
||||
|
||||
NewItemFallOff();
|
||||
|
||||
int count = m_OperatedItems.Count;
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
if (stuffBase == m_OperatedItems[i])
|
||||
{
|
||||
m_DataManager.WashingData.StepItems[i] = 1f;
|
||||
break;
|
||||
}
|
||||
}
|
||||
m_DataManager.SyncData();
|
||||
}
|
||||
|
||||
private void NewItemFallOff()
|
||||
{
|
||||
m_NewItem.transform.position = m_NewItem.transform.position + new Vector3(0f, m_BouncingDistance, 0f);
|
||||
m_NewItem.gameObject.SetActive(true);
|
||||
|
||||
m_NewItem.transform.GetComponent<Collider>().enabled = false;
|
||||
|
||||
((StuffAssembling)m_NewItem).RestoreMaterial();
|
||||
((StuffAssembling)m_NewItem).StopBreathing();
|
||||
|
||||
var tmp = m_NewItem;
|
||||
|
||||
m_NewItem.transform.DOMoveY(m_NewItem.transform.position.y - m_BouncingDistance, m_BouncingTime).SetEase(Ease.OutQuad).OnComplete(() =>
|
||||
{
|
||||
tmp = null;
|
||||
|
||||
m_Status = EventWashingActionStatus.Ending;
|
||||
|
||||
if (OperatedItemProgress >= 0.999f)
|
||||
{
|
||||
if (m_DataManager != null)
|
||||
{
|
||||
m_DataManager.WashingData.Percent = 1f;
|
||||
m_DataManager.WashingData.IsOver = true;
|
||||
m_DataManager.SyncData();
|
||||
}
|
||||
FishingYachtAct.Publish<EventWashingConclusionData>(new EventWashingConclusionData());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 数据处理
|
||||
protected override void SyncGameData()
|
||||
{
|
||||
if (m_DataManager == null) return;
|
||||
EventWashingData washingData = m_DataManager.WashingData;
|
||||
|
||||
bool syncData = false;
|
||||
int count = m_OperatedItems.Count;
|
||||
if (washingData.StepItems.Count == 0 && washingData.Percent == 0f && washingData.IsOver == false)
|
||||
{
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
washingData.StepItems.Add(0f);
|
||||
}
|
||||
syncData = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
if (washingData.StepItems.Count == i)
|
||||
{
|
||||
washingData.StepItems.Add(0f);
|
||||
m_OperatedItems[i].SetHaveExecutedTime(0f);
|
||||
m_OperatedItems[i].gameObject.SetActive(true);
|
||||
syncData = true;
|
||||
}
|
||||
else if (washingData.StepItems[i] >= 1f)
|
||||
{
|
||||
m_OperatedItems[i].SetHaveExecutedTime(m_OperatedItems[i].ConsumeTime);
|
||||
//if (!washingData.IsOver)
|
||||
//{
|
||||
// m_OperatedItems[i].gameObject.SetActive(false);
|
||||
//}
|
||||
((StuffAssembling)m_OperatedItems[i]).RestoreMaterial();
|
||||
((StuffAssembling)m_OperatedItems[i]).StopBreathing();
|
||||
}
|
||||
else
|
||||
{
|
||||
m_OperatedItems[i].SetHaveExecutedTime(washingData.StepItems[i] * m_OperatedItems[i].ConsumeTime);
|
||||
m_OperatedItems[i].gameObject.SetActive(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (syncData) m_DataManager.SyncData();
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 生命周期
|
||||
public override void InitGame(string name)
|
||||
{
|
||||
base.InitGame(name);
|
||||
this.m_GameType = EventWashingOperation.Installing;
|
||||
this.m_Status = EventWashingActionStatus.Invalid;
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user