Merge branch 'develop' of bitbucket.org:usaya/popcorn into develop

This commit is contained in:
koya_15 2021-07-07 17:21:29 +09:00
commit d324ce7723
4 changed files with 25 additions and 12 deletions

View File

@ -62,7 +62,7 @@ public class CornManager : MonoBehaviour
cornArray[i] = corn;
corn.SetCornProperty(baseCornPopTime, cornBurntDuration);
cornGrowSpeed.Where(_ => !isCompleted).Subscribe(x =>
cornGrowSpeed.TakeWhile(_ => !isCompleted).Subscribe(x =>
{
// コーンが弾けた後はRedの場合のみ焦げ進行する
if (corn.Condition.Value == CornCondition.Simple && !isHot)
@ -93,8 +93,8 @@ public class CornManager : MonoBehaviour
.FirstOrDefault(x => !x.Contains(CornCondition.Seed))
.Subscribe(x =>
{
isCompleted = true;
cornGrowSpeed.Value = 0f;
isCompleted = true;
if (x.Count(c => c == CornCondition.Simple) == x.Count) // すべてのコーンがPopped
{
result.SetValueAndForceNotify(CornResult.Perfect);

View File

@ -5,14 +5,15 @@ public class Pan : MonoBehaviour
{
[SerializeField] private PanController controller;
[SerializeField] private float thrust;
private static readonly float deadZone = 0.1f;
private void OnTriggerStay2D(Collider2D other)
{
// Debug.Log(controller.Direction);
// 移動量が少ないときは動かない
// if (controller.Delta.magnitude >= 1f) Debug.Log(controller.Delta.magnitude);
var direct = 1f;
direct = controller.Delta.magnitude < 0.1f ? 0 : 1;
other.attachedRigidbody.AddForce(controller.Delta * thrust * direct, ForceMode2D.Impulse);
if (controller.Delta.magnitude < deadZone)
{
return;
}
other.attachedRigidbody.AddForce(controller.Delta * thrust, ForceMode2D.Impulse);
}
}

View File

@ -18,13 +18,17 @@ public class PanController : MonoBehaviour, IDragHandler, IBeginDragHandler
private Vector2 delta;
public Vector2 Delta => delta;
// Start is called before the first frame update
void Start()
void Awake()
{
firstPos = target.position;
prevPos = firstPos;
}
private void OnDisable()
{
delta = Vector2.zero;
}
// Update is called once per frame
void Update()
{
@ -34,6 +38,9 @@ public class PanController : MonoBehaviour, IDragHandler, IBeginDragHandler
delta = Vector2.zero;
}
prevPos = target.position;
#if UNITY_EDITOR
deltaString = $"delta: {delta.normalized} {delta.magnitude:F3}";
#endif
}
@ -45,9 +52,6 @@ public class PanController : MonoBehaviour, IDragHandler, IBeginDragHandler
// 移動範囲を制限
pos = targetBorder.bounds.ClosestPoint(pos);
delta = pos - targetPos;
#if UNITY_EDITOR
deltaString = $"delta: {delta.normalized} {delta.magnitude:F3}";
#endif
target.position = pos;
}
@ -58,4 +62,9 @@ public class PanController : MonoBehaviour, IDragHandler, IBeginDragHandler
offset = targetPos - Camera.main.ScreenToWorldPoint(new Vector3(eventData.position.x, eventData.position.y,
targetPos.z));
}
public void ResetTargetPosition()
{
target.position = firstPos;
}
}

View File

@ -93,15 +93,18 @@ public class ThermalControl : MonoBehaviour
temperature = 0f;
temperatureSpeed = 0f;
thermoMeter.SetScale(coldValue, hotValue);
panController.ResetTargetPosition();
}
public void StartMeter()
{
isMove = true;
panController.enabled = true;
}
public void StopMeter()
{
isMove = false;
panController.enabled = false;
}
}