리플레이 코드 수정
500마리 아직 버겁지만 이젠 돌아는 간다
This commit is contained in:
parent
0e4d33c341
commit
cd59821b0e
|
|
@ -11,7 +11,7 @@ GameObject:
|
|||
- component: {fileID: 8354061827391739510}
|
||||
- component: {fileID: 8460095861745857899}
|
||||
- component: {fileID: 5965616281446492719}
|
||||
m_Layer: 6
|
||||
m_Layer: 7
|
||||
m_Name: Foot
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
|
|
@ -307,7 +307,7 @@ GameObject:
|
|||
- component: {fileID: 1806536103398767836}
|
||||
- component: {fileID: 4853694680767308140}
|
||||
- component: {fileID: 1591313861624791812}
|
||||
m_Layer: 0
|
||||
m_Layer: 7
|
||||
m_Name: Hang
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
|
|
|
|||
|
|
@ -256,7 +256,7 @@ GameObject:
|
|||
- component: {fileID: 7944902203221672218}
|
||||
- component: {fileID: 6414477000461253142}
|
||||
- component: {fileID: 6481877445078531268}
|
||||
m_Layer: 0
|
||||
m_Layer: 6
|
||||
m_Name: Hang
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
|
|
|
|||
|
|
@ -70,6 +70,7 @@ public class PlayerMovement : MonoBehaviour
|
|||
{
|
||||
isHanging = false;
|
||||
_rigidbody2D.bodyType = RigidbodyType2D.Dynamic;
|
||||
transform.parent = null;
|
||||
}
|
||||
|
||||
private void HangingObject()
|
||||
|
|
|
|||
|
|
@ -4,50 +4,30 @@ using System.Collections.Generic;
|
|||
public class GhostController : MonoBehaviour
|
||||
{
|
||||
private PlayerMovement _playerMovement;
|
||||
private Queue<InputFrame> inputFrames;
|
||||
|
||||
private bool isPlaying = false;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
_playerMovement = GetComponent<PlayerMovement>();
|
||||
}
|
||||
|
||||
public void Init(List<InputFrame> recordedData)
|
||||
public void GhostRunInput(InputFrame inputFrame)
|
||||
{
|
||||
inputFrames = new Queue<InputFrame>(recordedData);
|
||||
isPlaying = true;
|
||||
}
|
||||
|
||||
private void FixedUpdate()
|
||||
{
|
||||
if (!isPlaying)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (inputFrames.Count > 0)
|
||||
{
|
||||
InputFrame frame = inputFrames.Dequeue();
|
||||
|
||||
_playerMovement.SetMoveInput(new Vector2(frame.moveX, 0));
|
||||
|
||||
if (frame.isJumpPressed)
|
||||
_playerMovement.SetMoveInput(new Vector2(inputFrame.moveX, 0));
|
||||
if (inputFrame.isJumpPressed)
|
||||
{
|
||||
_playerMovement.TryJump();
|
||||
}
|
||||
|
||||
if (frame.isHangPressed)
|
||||
if (inputFrame.isHangPressed)
|
||||
{
|
||||
_playerMovement.TryHang();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_playerMovement.SetMoveInput(Vector2.zero);
|
||||
isPlaying = false;
|
||||
|
||||
// 제거할지 아니면 멈출지 고민해보기? ㅋㅋ
|
||||
}
|
||||
public void StopGhost()
|
||||
{
|
||||
GhostRunInput(new InputFrame(0f, false, false));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
|
|
@ -13,10 +14,13 @@ public class RecordingManager : MonoBehaviour
|
|||
public Transform spawnPoint;
|
||||
|
||||
private List<List<InputFrame>> allRecordedFrames = new List<List<InputFrame>>();
|
||||
private List<ActiveGhost> activeGhostList = new List<ActiveGhost>();
|
||||
|
||||
private InputRecorder currentPlayerRecorder;
|
||||
private GameObject currentPlayer;
|
||||
private List<GameObject> ghostList = new List<GameObject>();
|
||||
private int currentReplayIndex;
|
||||
|
||||
private bool isPlaying = false;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
|
|
@ -35,38 +39,85 @@ public class RecordingManager : MonoBehaviour
|
|||
PlayerAllRecord();
|
||||
}
|
||||
|
||||
private void FixedUpdate()
|
||||
{
|
||||
if (!isPlaying)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
for (int i = 0; i < activeGhostList.Count; i++)
|
||||
{
|
||||
ActiveGhost ghost = activeGhostList[i];
|
||||
|
||||
if (currentReplayIndex < ghost.recordedFrames.Count)
|
||||
{
|
||||
ghost.controller.GhostRunInput(ghost.recordedFrames[currentReplayIndex]);
|
||||
}
|
||||
else
|
||||
{
|
||||
ghost.controller.StopGhost();
|
||||
}
|
||||
}
|
||||
currentReplayIndex++;
|
||||
}
|
||||
|
||||
public void PlayerAllRecord()
|
||||
{
|
||||
isPlaying = true;
|
||||
currentReplayIndex = 0;
|
||||
|
||||
currentPlayer = Instantiate(playerPrefab, spawnPoint.position, Quaternion.identity);
|
||||
currentPlayerRecorder = currentPlayer.GetComponent<InputRecorder>();
|
||||
currentPlayerRecorder.StartRecording();
|
||||
|
||||
activeGhostList.Clear();
|
||||
|
||||
if (!(allRecordedFrames.Count > 0))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
foreach (var record in allRecordedFrames)
|
||||
{
|
||||
for(int i = 0 ;i < 500; i++)
|
||||
{
|
||||
GameObject ghost = Instantiate(ghostPrefab, spawnPoint.position, Quaternion.identity);
|
||||
ghostList.Add(ghost);
|
||||
ghost.GetComponent<GhostController>().Init(record);
|
||||
GhostController ghostController = ghost.GetComponent<GhostController>();
|
||||
|
||||
ActiveGhost addedGhost = new ActiveGhost();
|
||||
addedGhost.controller = ghostController;
|
||||
addedGhost.recordedFrames = record;
|
||||
|
||||
activeGhostList.Add(addedGhost);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void StopPlayingRecord()
|
||||
{
|
||||
isPlaying = false;
|
||||
|
||||
currentPlayerRecorder.StopRecording();
|
||||
List<InputFrame> inputFrames = currentPlayerRecorder.GetInputFrames();
|
||||
|
||||
allRecordedFrames.Add(inputFrames);
|
||||
|
||||
Destroy(currentPlayer);
|
||||
|
||||
foreach (GameObject ghost in ghostList)
|
||||
foreach (var ghost in activeGhostList)
|
||||
{
|
||||
Destroy(ghost);
|
||||
Destroy(ghost.controller.gameObject);
|
||||
}
|
||||
activeGhostList.Clear();
|
||||
|
||||
Invoke("PlayerAllRecord", 1f);
|
||||
}
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
public class ActiveGhost
|
||||
{
|
||||
public GhostController controller;
|
||||
public List<InputFrame> recordedFrames;
|
||||
}
|
||||
|
|
|
|||
BIN
ProfilerCaptures/tmp_2026-02-02_08-37-54.bc7
Normal file
BIN
ProfilerCaptures/tmp_2026-02-02_08-37-54.bc7
Normal file
Binary file not shown.
BIN
ProfilerCaptures/tmp_2026-02-02_08-37-54.data
Normal file
BIN
ProfilerCaptures/tmp_2026-02-02_08-37-54.data
Normal file
Binary file not shown.
BIN
ProfilerCaptures/tmp_2026-02-02_08-37-54.highlights
Normal file
BIN
ProfilerCaptures/tmp_2026-02-02_08-37-54.highlights
Normal file
Binary file not shown.
BIN
ProfilerCaptures/tmp_2026-02-02_08-37-54.png
Normal file
BIN
ProfilerCaptures/tmp_2026-02-02_08-37-54.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.3 KiB |
BIN
ProfilerCaptures/tmp_2026-02-02_08-38-07.bc7
Normal file
BIN
ProfilerCaptures/tmp_2026-02-02_08-38-07.bc7
Normal file
Binary file not shown.
BIN
ProfilerCaptures/tmp_2026-02-02_08-38-07.data
Normal file
BIN
ProfilerCaptures/tmp_2026-02-02_08-38-07.data
Normal file
Binary file not shown.
BIN
ProfilerCaptures/tmp_2026-02-02_08-38-07.highlights
Normal file
BIN
ProfilerCaptures/tmp_2026-02-02_08-38-07.highlights
Normal file
Binary file not shown.
BIN
ProfilerCaptures/tmp_2026-02-02_08-38-07.png
Normal file
BIN
ProfilerCaptures/tmp_2026-02-02_08-38-07.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.3 KiB |
Loading…
Reference in New Issue
Block a user