フライパンの動きを同期
This commit is contained in:
parent
e600ed07b3
commit
a1c12b6e33
|
|
@ -168,7 +168,7 @@ MonoBehaviour:
|
||||||
m_Script: {fileID: 11500000, guid: 9389c53fc5fd43caaa8a8b9ac0a38cba, type: 3}
|
m_Script: {fileID: 11500000, guid: 9389c53fc5fd43caaa8a8b9ac0a38cba, type: 3}
|
||||||
m_Name:
|
m_Name:
|
||||||
m_EditorClassIdentifier:
|
m_EditorClassIdentifier:
|
||||||
thrust: 1
|
thrust: 0.01
|
||||||
--- !u!58 &1458261573237666836
|
--- !u!58 &1458261573237666836
|
||||||
CircleCollider2D:
|
CircleCollider2D:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
|
|
|
||||||
|
|
@ -238,6 +238,18 @@ RectTransform:
|
||||||
m_AnchoredPosition: {x: 0, y: 0}
|
m_AnchoredPosition: {x: 0, y: 0}
|
||||||
m_SizeDelta: {x: 100, y: 100}
|
m_SizeDelta: {x: 100, y: 100}
|
||||||
m_Pivot: {x: 0.5, y: 0.5}
|
m_Pivot: {x: 0.5, y: 0.5}
|
||||||
|
--- !u!114 &402129742 stripped
|
||||||
|
MonoBehaviour:
|
||||||
|
m_CorrespondingSourceObject: {fileID: 1453251556377932374, guid: b6b05cbc51c744ac2ad95a8b229d4ddd,
|
||||||
|
type: 3}
|
||||||
|
m_PrefabInstance: {fileID: 2137549891}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 0}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_EditorHideFlags: 0
|
||||||
|
m_Script: {fileID: 11500000, guid: 722195db1b0214a7ab110e4cf4c2a7ce, type: 3}
|
||||||
|
m_Name:
|
||||||
|
m_EditorClassIdentifier:
|
||||||
--- !u!1 &420543913
|
--- !u!1 &420543913
|
||||||
GameObject:
|
GameObject:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
|
|
@ -753,6 +765,7 @@ MonoBehaviour:
|
||||||
powerMeter: {fileID: 8786490829663474092}
|
powerMeter: {fileID: 8786490829663474092}
|
||||||
powerResultText: {fileID: 8786490830332208977}
|
powerResultText: {fileID: 8786490830332208977}
|
||||||
gameResultText: {fileID: 1003859323}
|
gameResultText: {fileID: 1003859323}
|
||||||
|
panController: {fileID: 402129742}
|
||||||
--- !u!4 &1870432534
|
--- !u!4 &1870432534
|
||||||
Transform:
|
Transform:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
|
|
@ -874,6 +887,11 @@ PrefabInstance:
|
||||||
m_Modification:
|
m_Modification:
|
||||||
m_TransformParent: {fileID: 0}
|
m_TransformParent: {fileID: 0}
|
||||||
m_Modifications:
|
m_Modifications:
|
||||||
|
- target: {fileID: 1453251556377932374, guid: b6b05cbc51c744ac2ad95a8b229d4ddd,
|
||||||
|
type: 3}
|
||||||
|
propertyPath: lerpTime
|
||||||
|
value: 17.89
|
||||||
|
objectReference: {fileID: 0}
|
||||||
- target: {fileID: 1453251556377932392, guid: b6b05cbc51c744ac2ad95a8b229d4ddd,
|
- target: {fileID: 1453251556377932392, guid: b6b05cbc51c744ac2ad95a8b229d4ddd,
|
||||||
type: 3}
|
type: 3}
|
||||||
propertyPath: m_Name
|
propertyPath: m_Name
|
||||||
|
|
@ -949,6 +967,16 @@ PrefabInstance:
|
||||||
propertyPath: m_LocalEulerAnglesHint.z
|
propertyPath: m_LocalEulerAnglesHint.z
|
||||||
value: 0
|
value: 0
|
||||||
objectReference: {fileID: 0}
|
objectReference: {fileID: 0}
|
||||||
|
- target: {fileID: 1453251556405238011, guid: b6b05cbc51c744ac2ad95a8b229d4ddd,
|
||||||
|
type: 3}
|
||||||
|
propertyPath: thrust
|
||||||
|
value: 3
|
||||||
|
objectReference: {fileID: 0}
|
||||||
|
- target: {fileID: 1453251557352552633, guid: b6b05cbc51c744ac2ad95a8b229d4ddd,
|
||||||
|
type: 3}
|
||||||
|
propertyPath: m_EdgeRadius
|
||||||
|
value: 0.63
|
||||||
|
objectReference: {fileID: 0}
|
||||||
- target: {fileID: 1760968235348138510, guid: b6b05cbc51c744ac2ad95a8b229d4ddd,
|
- target: {fileID: 1760968235348138510, guid: b6b05cbc51c744ac2ad95a8b229d4ddd,
|
||||||
type: 3}
|
type: 3}
|
||||||
propertyPath: m_Material
|
propertyPath: m_Material
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,6 @@ namespace MyGame.Scenes.Main
|
||||||
{
|
{
|
||||||
[SerializeField] private float thrust;
|
[SerializeField] private float thrust;
|
||||||
private PanController controller;
|
private PanController controller;
|
||||||
private int direct;
|
|
||||||
|
|
||||||
private void Start()
|
private void Start()
|
||||||
{
|
{
|
||||||
|
|
@ -18,7 +17,9 @@ namespace MyGame.Scenes.Main
|
||||||
{
|
{
|
||||||
// Debug.Log(controller.Direction);
|
// Debug.Log(controller.Direction);
|
||||||
// 移動量が少ないときは動かない
|
// 移動量が少ないときは動かない
|
||||||
direct = controller.Delta.magnitude < 0.1f ? 0 : 1;
|
// 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);
|
other.attachedRigidbody.AddForce(controller.Delta * thrust * direct, ForceMode2D.Impulse);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -8,45 +8,55 @@ using UnityEngine.EventSystems;
|
||||||
[RequireComponent(typeof(BoxCollider2D))]
|
[RequireComponent(typeof(BoxCollider2D))]
|
||||||
public class PanController : MonoBehaviour//, IDragHandler, IBeginDragHandler
|
public class PanController : MonoBehaviour//, IDragHandler, IBeginDragHandler
|
||||||
{
|
{
|
||||||
|
[SerializeField] private float lerpTime = 0.1f;
|
||||||
private Transform cacheTransform;
|
private Transform cacheTransform;
|
||||||
private Vector3 offset;
|
private Vector3 offset;
|
||||||
private readonly (float min, float max) borderX = (-4.1f, 4.1f);
|
private readonly (float min, float max) borderX = (-4.1f, 4.1f);
|
||||||
private readonly (float min, float max) borderY = (-4.1f, 4.1f);
|
private readonly (float min, float max) borderY = (-4.1f, 4.1f);
|
||||||
// private readonly float futonSpeedMagnificcation = 20f;
|
|
||||||
// public float FutonSpeed { get; private set; }
|
|
||||||
// public bool IsEnter { get; private set; }
|
|
||||||
private Vector2 direction;
|
private Vector2 direction;
|
||||||
public Vector2 Direction => direction;
|
// public Vector2 Direction => direction;
|
||||||
private Vector2 delta;
|
private Vector2 delta;
|
||||||
public Vector2 Delta => delta;
|
public Vector2 Delta => delta;
|
||||||
private Vector3 prevPos;
|
private Vector3 prevPos;
|
||||||
|
private float deltaTime = 0f;
|
||||||
|
private bool isMove;
|
||||||
|
|
||||||
// Start is called before the first frame update
|
// Start is called before the first frame update
|
||||||
void Start()
|
void Start()
|
||||||
{
|
{
|
||||||
cacheTransform = gameObject.transform;
|
cacheTransform = gameObject.transform;
|
||||||
prevPos = cacheTransform.position;
|
prevPos = cacheTransform.position;
|
||||||
|
deltaTime = 0.5f;
|
||||||
|
direction = Vector2.left;
|
||||||
|
target = transform.position + 1.5f / 2 * new Vector3(direction.x, direction.y, 0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Vector3 target;
|
||||||
// Update is called once per frame
|
// Update is called once per frame
|
||||||
void Update()
|
void Update()
|
||||||
{
|
{
|
||||||
// FutonSpeed = 0f;
|
|
||||||
// localPosを比較
|
|
||||||
// IsEnter = cacheTransform.localPosition.y >= clearLocalPosition.y;
|
|
||||||
|
|
||||||
// OnDragが更新されていない場合は方向をゼロにしたいがUpdateでゼロにすると使えなくなるため保留
|
// OnDragが更新されていない場合は方向をゼロにしたいがUpdateでゼロにすると使えなくなるため保留
|
||||||
if (cacheTransform.position == prevPos)
|
// if (cacheTransform.position == prevPos)
|
||||||
{
|
// {
|
||||||
direction = Vector2.zero;
|
// direction = Vector2.zero;
|
||||||
}
|
// }
|
||||||
prevPos = cacheTransform.position;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void OnEnable()
|
if (deltaTime >= 1f)
|
||||||
{
|
{
|
||||||
// FutonSpeed = 0f;
|
isMove = !isMove;
|
||||||
// IsEnter = false;
|
deltaTime = 0f;
|
||||||
|
}
|
||||||
|
if (!isMove && Mathf.Approximately(transform.position.x, target.x))
|
||||||
|
{
|
||||||
|
direction = direction * -1;
|
||||||
|
target = transform.position + 1.3f * new Vector3(direction.x, direction.y, 0f);
|
||||||
|
}
|
||||||
|
transform.position = Vector3.Lerp(transform.position, target, lerpTime * Time.deltaTime);
|
||||||
|
delta = cacheTransform.position - prevPos;
|
||||||
|
|
||||||
|
deltaTime += Time.deltaTime;
|
||||||
|
prevPos = cacheTransform.position;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OnDrag(PointerEventData eventData)
|
public void OnDrag(PointerEventData eventData)
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,7 @@ public class PopcornGameManager : MonoBehaviour
|
||||||
[SerializeField] private PowerMeter powerMeter;
|
[SerializeField] private PowerMeter powerMeter;
|
||||||
[SerializeField] private Text powerResultText;
|
[SerializeField] private Text powerResultText;
|
||||||
[SerializeField] private Text gameResultText;
|
[SerializeField] private Text gameResultText;
|
||||||
|
[SerializeField] private PanController panController;
|
||||||
|
|
||||||
private Action tapAction;
|
private Action tapAction;
|
||||||
private bool isProgress;
|
private bool isProgress;
|
||||||
|
|
@ -27,13 +28,16 @@ public class PopcornGameManager : MonoBehaviour
|
||||||
startingGuide.SetActive(true);
|
startingGuide.SetActive(true);
|
||||||
powerMeter.StopMove();
|
powerMeter.StopMove();
|
||||||
isProgress = false;
|
isProgress = false;
|
||||||
|
panController.enabled = false;
|
||||||
|
|
||||||
// タップしたら案内非表示&ゲーム開始
|
// タップしたら案内非表示&ゲーム開始
|
||||||
tapAction = () =>
|
tapAction = () =>
|
||||||
{
|
{
|
||||||
startingGuide.SetActive(false);
|
startingGuide.SetActive(false);
|
||||||
|
// panController.enabled = true;
|
||||||
GameStart();
|
GameStart();
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void GameStart()
|
private void GameStart()
|
||||||
|
|
@ -63,7 +67,8 @@ public class PopcornGameManager : MonoBehaviour
|
||||||
gameResultText.text = "失敗!";
|
gameResultText.text = "失敗!";
|
||||||
powerMeter.gameObject.SetActive(false);
|
powerMeter.gameObject.SetActive(false);
|
||||||
tapAction = () => { };
|
tapAction = () => { };
|
||||||
this.CallWaitForSeconds(1f, () =>
|
panController.enabled = false;
|
||||||
|
this.CallWaitForSeconds(2f, () =>
|
||||||
{
|
{
|
||||||
gameResultText.text = "タップでリスタート";
|
gameResultText.text = "タップでリスタート";
|
||||||
tapAction = () => {
|
tapAction = () => {
|
||||||
|
|
@ -81,7 +86,8 @@ public class PopcornGameManager : MonoBehaviour
|
||||||
gameResultText.text = "成功!";
|
gameResultText.text = "成功!";
|
||||||
powerMeter.gameObject.SetActive(false);
|
powerMeter.gameObject.SetActive(false);
|
||||||
tapAction = () => { };
|
tapAction = () => { };
|
||||||
this.CallWaitForSeconds(1f, () =>
|
panController.enabled = false;
|
||||||
|
this.CallWaitForSeconds(2f, () =>
|
||||||
{
|
{
|
||||||
gameResultText.text = "タップでリスタート";
|
gameResultText.text = "タップでリスタート";
|
||||||
tapAction = () => {
|
tapAction = () => {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue