로프 반동, FPS UI 표시 추가
This commit is contained in:
parent
07f331862a
commit
b1afc0b171
|
|
@ -293,6 +293,7 @@ RectTransform:
|
|||
m_ConstrainProportionsScale: 0
|
||||
m_Children:
|
||||
- {fileID: 1157925016}
|
||||
- {fileID: 1471101855}
|
||||
m_Father: {fileID: 0}
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
m_AnchorMin: {x: 0, y: 0}
|
||||
|
|
@ -667,6 +668,100 @@ Transform:
|
|||
m_Children: []
|
||||
m_Father: {fileID: 0}
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!1 &1471101854
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 1471101855}
|
||||
- component: {fileID: 1471101857}
|
||||
- component: {fileID: 1471101856}
|
||||
- component: {fileID: 1471101858}
|
||||
m_Layer: 5
|
||||
m_Name: FpsText
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!224 &1471101855
|
||||
RectTransform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1471101854}
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children: []
|
||||
m_Father: {fileID: 285871627}
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
m_AnchorMin: {x: 1, y: 1}
|
||||
m_AnchorMax: {x: 1, y: 1}
|
||||
m_AnchoredPosition: {x: -110, y: -45}
|
||||
m_SizeDelta: {x: 160, y: 30}
|
||||
m_Pivot: {x: 0.5, y: 0.5}
|
||||
--- !u!114 &1471101856
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1471101854}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 5f7201a12d95ffc409449d95f23cf332, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier: UnityEngine.UI::UnityEngine.UI.Text
|
||||
m_Material: {fileID: 0}
|
||||
m_Color: {r: 0, g: 0, b: 0, a: 1}
|
||||
m_RaycastTarget: 1
|
||||
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
|
||||
m_Maskable: 1
|
||||
m_OnCullStateChanged:
|
||||
m_PersistentCalls:
|
||||
m_Calls: []
|
||||
m_FontData:
|
||||
m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0}
|
||||
m_FontSize: 40
|
||||
m_FontStyle: 1
|
||||
m_BestFit: 0
|
||||
m_MinSize: 1
|
||||
m_MaxSize: 100
|
||||
m_Alignment: 2
|
||||
m_AlignByGeometry: 0
|
||||
m_RichText: 1
|
||||
m_HorizontalOverflow: 1
|
||||
m_VerticalOverflow: 1
|
||||
m_LineSpacing: 1
|
||||
m_Text: 'fps : 60'
|
||||
--- !u!222 &1471101857
|
||||
CanvasRenderer:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1471101854}
|
||||
m_CullTransparentMesh: 1
|
||||
--- !u!114 &1471101858
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1471101854}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 0b7b9ee9f8858004c8defe87c1d6f448, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier: Assembly-CSharp::UpdateFpsUI
|
||||
fps: 0
|
||||
fpsText: {fileID: 1471101856}
|
||||
--- !u!1 &1712523066
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
|
|
|
|||
94
Assets/Scripts/LevelManager.cs
Normal file
94
Assets/Scripts/LevelManager.cs
Normal file
|
|
@ -0,0 +1,94 @@
|
|||
using System.Collections;
|
||||
using UnityEngine;
|
||||
using UnityEngine.SceneManagement;
|
||||
|
||||
public class LevelManager : MonoBehaviour
|
||||
{
|
||||
public static LevelManager instance;
|
||||
|
||||
public enum GameState { Ready, Playing, GameOver}
|
||||
|
||||
public GameState CurrentGameState { get; private set; }
|
||||
public Transform CameraTarget { get; private set; }
|
||||
|
||||
[SerializeField] private float timeLimit;
|
||||
[SerializeField] private int replayCounts;
|
||||
|
||||
[SerializeField] private Transform cheesePosition;
|
||||
[SerializeField] private Transform playerPosition;
|
||||
|
||||
private float currentTimer;
|
||||
|
||||
|
||||
|
||||
void Awake()
|
||||
{
|
||||
DontDestroyOnLoad(gameObject);
|
||||
if (instance == null)
|
||||
{
|
||||
instance = this;
|
||||
}
|
||||
else
|
||||
{
|
||||
Destroy(gameObject);
|
||||
}
|
||||
}
|
||||
|
||||
void Start()
|
||||
{
|
||||
StartCoroutine(LevelStart());
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if (CurrentGameState == GameState.Playing)
|
||||
{
|
||||
UpdateTimer();
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateTimer()
|
||||
{
|
||||
currentTimer += Time.deltaTime;
|
||||
if(currentTimer > timeLimit)
|
||||
{
|
||||
replayCounts--;
|
||||
if (replayCounts > 0)
|
||||
{
|
||||
RecordingManager.instance.StopPlayingRecord();
|
||||
}
|
||||
else
|
||||
{
|
||||
CurrentGameState = GameState.GameOver;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void InitTimer()
|
||||
{
|
||||
currentTimer = 0;
|
||||
}
|
||||
|
||||
private IEnumerator LevelStart()
|
||||
{
|
||||
CurrentGameState = GameState.Ready;
|
||||
yield return new WaitForSeconds(1f);
|
||||
|
||||
CameraTarget = cheesePosition;
|
||||
yield return new WaitForSeconds(2f);
|
||||
|
||||
CameraTarget = playerPosition;
|
||||
yield return new WaitForSeconds(1f);
|
||||
CurrentGameState = GameState.Playing;
|
||||
}
|
||||
|
||||
public void OnTakeCheese()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private void LoadNextLevel()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -98,13 +98,14 @@ public class PlayerMovement : MonoBehaviour
|
|||
{
|
||||
isHanging = false;
|
||||
_rigidbody2D.bodyType = RigidbodyType2D.Dynamic;
|
||||
hangingWallRigidBody = null;
|
||||
if (hangingWallCollider != null)
|
||||
{
|
||||
Physics2D.IgnoreCollision(_collider2D, hangingWallCollider, false);
|
||||
hangingWallCollider = null;
|
||||
}
|
||||
transform.SetParent(null, true);
|
||||
_rigidbody2D.linearVelocity = hangingWallRigidBody.linearVelocity * 4;
|
||||
hangingWallRigidBody = null;
|
||||
}
|
||||
|
||||
private void HangingObject()
|
||||
|
|
|
|||
31
Assets/Scripts/UpdateFpsUI.cs
Normal file
31
Assets/Scripts/UpdateFpsUI.cs
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class UpdateFpsUI : MonoBehaviour
|
||||
{
|
||||
private Text fpsText;
|
||||
|
||||
private float frameCount = 0;
|
||||
private float deltaTime = 0f;
|
||||
private float fps = 0f;
|
||||
|
||||
void Start()
|
||||
{
|
||||
fpsText = transform.GetComponent<Text>();
|
||||
}
|
||||
|
||||
void Update()
|
||||
{
|
||||
Debug.Log("Test");
|
||||
frameCount++;
|
||||
deltaTime += Time.unscaledDeltaTime;
|
||||
if (deltaTime > 1)
|
||||
{
|
||||
fps = frameCount / deltaTime;
|
||||
fpsText.text = $"fps : {Mathf.Round(fps)}";
|
||||
|
||||
frameCount = 0;
|
||||
deltaTime = 0f;
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user