using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System;
using Cysharp.Threading.Tasks;
using UniRx;
using HoloMonApp.CommonSpace;
using HoloMonApp.DataFormatSpace;
using HoloMonApp.FieldOfVisionSpace;
namespace HoloMonApp.ModeLogicSpace
{
public class HoloMonModeLogicLookAround : MonoBehaviour, HoloMonModeLogicInterface
{
<summary>
</summary>
[SerializeField, Tooltip("モードロジック共通情報")]
private HoloMonModeLogicCommon p_ModeLogicCommon = new HoloMonModeLogicCommon();
<summary>
</summary>
<returns></returns>
public bool CurrentRunAwaitFlg()
{
return p_ModeLogicCommon.RunAwaitFlg;
}
<summary>
</summary>
public async UniTask<ModeLogicResult> RunModeAsync(ModeLogicSetting a_ModeLogicSetting)
{
p_ModeLogicCommon.SaveCommonSetting(a_ModeLogicSetting);
EnableSetting();
HoloMonActionModeStatus status = await p_ModeLogicCommon.RunModeAsync();
return new ModeLogicResult(status, new ModeLogicLookAroundReturn(p_FindedObject));
}
<summary>
</summary>
public void CancelMode()
{
DisableSetting();
p_ModeLogicCommon.CancelMode();
}
<summary>
</summary>
private void StopMode(HoloMonActionModeStatus a_StopModeStatus)
{
DisableSetting();
p_ModeLogicCommon.StopMode(a_StopModeStatus);
}
<summary>
</summary>
public bool TransmissionInterrupt(InterruptInformation a_InterruptInfo)
{
bool isProcessed = false;
switch (a_InterruptInfo.HoloMonInterruptType)
{
case HoloMonInterruptType.FindVision:
InterruptFindVisionData interruptFindVisionData = a_InterruptInfo.InterruptFindVisionData;
isProcessed = CheckFindVision(interruptFindVisionData.ObjectWrap);
break;
default:
break;
}
return isProcessed;
}
<summary>
</summary>
private ModeLogicLookAroundData p_Data => p_ModeLogicCommon.ModeLogicSetting.ModeLogicLookAroundData;
<summary>
</summary>
bool p_SeachFlg = false;
<summary>
</summary>
private GameObject p_FindedObject;
<summary>
</summary>
IDisposable p_ActionEndTrigger;
<summary>
</summary>
private bool EnableSetting()
{
p_ModeLogicCommon.ReferenceAnimation.StartLookAroundMode();
p_SeachFlg = (p_Data.SearchObjectUnderstandType != ObjectUnderstandType.Nothing);
p_ActionEndTrigger?.Dispose();
p_ActionEndTrigger = p_ModeLogicCommon.ReferenceAnimation.AnimationTrigger
.OnStateUpdateAsObservable()
.Where(onStateInfo => !onStateInfo.Animator.IsInTransition(onStateInfo.LayerIndex))
.Where(onStateInfo => onStateInfo.StateInfo.normalizedTime > 0.95)
.Take(1)
.Subscribe(_ =>
{
if (p_Data.SearchObjectUnderstandType != ObjectUnderstandType.Nothing)
{
Debug.Log("LookAroundEnd Missing : " + p_Data.SearchObjectUnderstandType.ToString());
StopMode(HoloMonActionModeStatus.Missing);
}
else
{
Debug.Log("LookAroundEnd Achievement : " + p_Data.SearchObjectUnderstandType.ToString());
StopMode(HoloMonActionModeStatus.Achievement);
}
})
.AddTo(this);
return true;
}
<summary>
</summary>
private bool DisableSetting()
{
p_ModeLogicCommon.ReferenceAnimation.ReturnStandbyMode();
p_ActionEndTrigger?.Dispose();
p_SeachFlg = false;
return true;
}
<summary>
</summary>
private bool CheckFindVision(VisionObjectWrap a_FindObjectWrap)
{
bool isProcessed = false;
if (a_FindObjectWrap.CurrentFeatures().ObjectUnderstandType == p_Data.SearchObjectUnderstandType)
{
p_ModeLogicCommon.ExternalEnviroment.ExternalEmotionUI.ExclamationStartAsync();
p_FindedObject = a_FindObjectWrap.Object;
Debug.Log("LookAroundEnd Achievement : " + p_Data.SearchObjectUnderstandType.ToString());
StopMode(HoloMonActionModeStatus.Achievement);
isProcessed = true;
}
return isProcessed;
}
}
}