92 lines
2.7 KiB
C#
92 lines
2.7 KiB
C#
using BrewMonster.Network;
|
|
using BrewMonster.Utils;
|
|
using UnityEngine;
|
|
|
|
namespace BrewMonster.Scripts
|
|
{
|
|
public class EC_HPWorkPick : CECHPWork
|
|
{
|
|
protected CECCounter m_TimeCnt; // Pick time counter
|
|
protected bool m_bIsGather;
|
|
protected int m_gatherItemID;
|
|
public EC_HPWorkPick(CECHPWorkMan pWorkMan) : base(Host_work_ID.WORK_PICKUP, pWorkMan)
|
|
{
|
|
m_dwMask = Work_mask.MASK_PICKUP;
|
|
m_dwTransMask = Work_mask.MASK_STAND | Work_mask.MASK_MOVETOPOS;
|
|
m_TimeCnt = new CECCounter();
|
|
m_TimeCnt.SetPeriod(500);
|
|
Reset();
|
|
}
|
|
public void SetGather(bool bGather, int gatherItemID){
|
|
m_bIsGather = bGather;
|
|
m_gatherItemID = gatherItemID;
|
|
}
|
|
public bool IsGather() { return m_bIsGather; }
|
|
|
|
// Reset work
|
|
public sealed override void Reset()
|
|
{
|
|
base.Reset();
|
|
m_TimeCnt.Reset();
|
|
}
|
|
|
|
// Copy work data
|
|
public override bool CopyData(CECHPWork pWork)
|
|
{
|
|
if (!base.CopyData(pWork))
|
|
return false;
|
|
|
|
EC_HPWorkPick pSrc = (EC_HPWorkPick)pWork;
|
|
|
|
m_bIsGather = pSrc.m_bIsGather;
|
|
m_gatherItemID = pSrc.m_gatherItemID;
|
|
|
|
m_TimeCnt.SetPeriod(pSrc.m_TimeCnt.GetPeriod());
|
|
m_TimeCnt.SetCounter(pSrc.m_TimeCnt.GetCounter());
|
|
|
|
return true;
|
|
}
|
|
|
|
// On first tick
|
|
protected override void OnFirstTick()
|
|
{
|
|
if (IsGather())
|
|
{
|
|
m_pHost.PlayAction((int)PLAYER_ACTION_TYPE.ACT_PICKUP, EC_ElementDataHelper.GetGatherStartActionConfig(m_gatherItemID) >0);
|
|
m_pHost.PlayAction((int)PLAYER_ACTION_TYPE.ACT_PICKUP_LOOP, EC_ElementDataHelper.GetGatherLoopActionConfig(m_gatherItemID), false, 200, true);
|
|
}
|
|
else
|
|
{
|
|
m_pHost.PlayAction((int)PLAYER_ACTION_TYPE.ACT_PICKUP_MATTER);
|
|
m_pHost.PlayAction((int)PLAYER_ACTION_TYPE.ACT_STAND, false, 200, true);
|
|
}
|
|
}
|
|
|
|
// Work is cancel
|
|
public override void Cancel()
|
|
{
|
|
base.Cancel();
|
|
if( !IsGather() )
|
|
{
|
|
// AP_ActionEvent(AP_EVENT_PICKUPOK);
|
|
// BMLogger.LogError("Cancel Work pick?");
|
|
}
|
|
}
|
|
|
|
// Tick routine
|
|
public override bool Tick(float dwDeltaTime)
|
|
{
|
|
float dwRealTime = EC_Game.GetRealTickTime();
|
|
|
|
base.Tick(dwRealTime);
|
|
|
|
if (!IsGather() && m_TimeCnt.IncCounter(dwRealTime))
|
|
{
|
|
m_bFinished = true;
|
|
}
|
|
|
|
return true;
|
|
}
|
|
}
|
|
}
|