using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System;
namespace DisComputer
{
///
/// 双向寄存器
///
public class TwoWayUnit : BasicUnit
{
public override void Start()
{
base.Start();
}
public override void Active(params object[] data)
{
}
///
/// 主动接受激活
///
///
public void ReceiveActive(string val,Action finish=null)
{
ShakeUnit();
if(!string.IsNullOrEmpty(val))
SetInfoTxt(val);
finish?.Invoke();
}
///
/// 箭头指向执行激活
///
///
///
///
public void ArrowActive(int dirId,string val,Action finish=null)
{
if(dirId == 0)
progressArrows[1].SetArrowZero();
else
progressArrows[0].SetArrowZero();
ShowArrow(dirId, true,() =>
{
if(!string.IsNullOrEmpty(val))
SetInfoTxt(val);
ShakeUnit();
finish?.Invoke();
});
}
///
/// 自身发射箭头执行
///
///
///
///
public void SelfActiveArrow(int dirId, string val, Action finish = null)
{
if (dirId == 0)
progressArrows[1].SetArrowZero();
else
progressArrows[0].SetArrowZero();
if (!string.IsNullOrEmpty(val))
SetInfoTxt(val);
ShakeUnit();
ShowArrow(dirId, true, () =>
{
finish?.Invoke();
});
}
public override void RewindUnit()
{
base.RewindUnit();
if (progressArrows != null && progressArrows.Count > 0)
{
foreach (var item in progressArrows)
{
item.SetArrowZero();
}
}
}
}
}