OldBlueWater/BlueWater/Assets/02.Scripts/CombatOnGui.cs
NTG b021b6ba6b Combat씬 보완하기
+ 우측 상단에 개발자 모드 Toggle 기능 추가
+ 전투 플레이어의 HpBar 추가
+ 전투 플레이어가 공격 시 이펙트 추가
+ 승회님 포레스트 맵에 잡몹 추가
+ 승회님 2D 나무 sorting Layer 플레이어와 동일하게 변경
+ 코뿔소 스킬마다 넉백 효과 짧고 굵게 변경
+ 코뿔소 돌진 스킬 넉백 로직 변경
+ 코뿔소 지진 스킬 이펙트 추가
+ StylizedAllEffect 에셋 추가
2024-02-19 20:40:16 +09:00

144 lines
5.9 KiB
C#

using System;
using Sirenix.OdinInspector;
using UnityEngine;
// ReSharper disable once CheckNamespace
namespace BlueWaterProject
{
public class CombatOnGui : MonoBehaviour
{
[Title("컴포넌트")]
[SerializeField] private PhysicsMovement combatPlayerMovement;
[SerializeField] private CombatLight combatLight;
[SerializeField] private BossPortal[] bossPortal;
[Title("GUI 옵션")]
[SerializeField] private bool showGUI = true;
[SerializeField] private int guiTextSize = 28;
private float prevForwardSlopeAngle;
private bool toggle = true;
private void OnGUI()
{
if (Application.isPlaying == false) return;
var yPos = 5f;
var newToggleState = GUI.Toggle(new Rect(Screen.width - 100f, yPos, 150f, 30f), toggle, "Developer");
if (newToggleState != toggle)
{
toggle = newToggleState;
showGUI = !showGUI;
}
if (!showGUI) return;
if (!enabled) return;
GUIStyle labelStyle = GUI.skin.label;
labelStyle.normal.textColor = Color.yellow;
labelStyle.fontSize = Math.Max(guiTextSize, 20);
prevForwardSlopeAngle = combatPlayerMovement.MyCurrentValue.forwardSlopeAngle == -90f
? prevForwardSlopeAngle
: combatPlayerMovement.MyCurrentValue.forwardSlopeAngle;
var oldColor = GUI.color;
GUI.color = new Color(0f, 0f, 0f, 0.5f);
GUI.Box(new Rect(40, 40, 420, 240), "");
GUI.color = oldColor;
GUILayout.BeginArea(new Rect(50, 50, 1000, 500));
GUILayout.Label($"Ground Height : {Mathf.Min(combatPlayerMovement.MyCurrentValue.groundDistance, 99.99f): 00.00}",
labelStyle);
GUILayout.Label($"Slope Angle(Ground) : {combatPlayerMovement.MyCurrentValue.groundSlopeAngle: 00.00}", labelStyle);
GUILayout.Label($"Slope Angle(Forward) : {prevForwardSlopeAngle: 00.00}", labelStyle);
GUILayout.Label($"Allowed Slope Angle : {combatPlayerMovement.MyMovementOption.maxSlopeAngle: 00.00}", labelStyle);
GUILayout.Label($"Current Speed Mag : {combatPlayerMovement.MyCurrentValue.horizontalVelocity.magnitude: 00.00}",
labelStyle);
GUILayout.EndArea();
float sWidth = Screen.width;
float sHeight = Screen.height;
GUIStyle RTLabelStyle = GUI.skin.label;
RTLabelStyle.fontSize = 20;
RTLabelStyle.normal.textColor = Color.green;
oldColor = GUI.color;
GUI.color = new Color(1f, 1f, 1f, 0.5f);
GUI.Box(new Rect(sWidth - 355f, 25f, 340f, 80f), "");
GUI.color = oldColor;
yPos = 30f;
GUI.Label(new Rect(sWidth - 350f, yPos, 150f, 30f), $"Speed : {combatPlayerMovement.MyMovementOption.moveSpeed: 00.00}",
RTLabelStyle);
combatPlayerMovement.MyMovementOption.moveSpeed = GUI.HorizontalSlider(new Rect(sWidth - 180f, yPos + 10f, 160f, 20f),
combatPlayerMovement.MyMovementOption.moveSpeed, 1f, 10f);
yPos += 20f;
GUI.Label(new Rect(sWidth - 350f, yPos, 150f, 30f), $"Max Slope : {combatPlayerMovement.MyMovementOption.maxSlopeAngle: 00}",
RTLabelStyle);
combatPlayerMovement.MyMovementOption.maxSlopeAngle = (int)GUI.HorizontalSlider(
new Rect(sWidth - 180f, yPos + 10f, 160f, 20f), combatPlayerMovement.MyMovementOption.maxSlopeAngle, 1f, 75f);
yPos += 20f;
GUI.Label(new Rect(sWidth - 350f, yPos, 180f, 30f), $"TimeScale : {Time.timeScale: 0.00}",
RTLabelStyle);
Time.timeScale = GUI.HorizontalSlider(
new Rect(sWidth - 180f, yPos + 10f, 160f, 20f), Time.timeScale, 0f, 1f);
Time.fixedDeltaTime = 0.02f * Time.timeScale;
yPos = 130f;
var buttonWidth = 200f;
var buttonHeight = 30f;
var buttonSpacing = 35f;
var buttonStyle = GUI.skin.button;
buttonStyle.fontSize = 15;
var spawnPosition = combatPlayerMovement.MyComponents.spawnPosition;
for (var i = 0; i < spawnPosition.Length; i++)
{
if (GUI.Button(new Rect(sWidth - 350f, yPos, buttonWidth, buttonHeight), spawnPosition[i].name, buttonStyle))
{
SpawnPlayer(spawnPosition[i].position);
}
yPos += buttonSpacing;
}
buttonWidth = 80f;
buttonHeight = 30f;
yPos = 10f;
if (GUI.Button(new Rect(sWidth - 550f, yPos, buttonWidth, buttonHeight), "Base", buttonStyle))
{
combatLight.CurrentTimeOfDay = CombatLight.TimeOfDay.BASE;
}
if (GUI.Button(new Rect(sWidth - 450f, yPos, buttonWidth, buttonHeight), "Afternoon", buttonStyle))
{
combatLight.CurrentTimeOfDay = CombatLight.TimeOfDay.AFTERNOON;
}
yPos += 40f;
if (GUI.Button(new Rect(sWidth - 550f, yPos, buttonWidth, buttonHeight), "Sunset", buttonStyle))
{
combatLight.CurrentTimeOfDay = CombatLight.TimeOfDay.SUNSET;
}
if (GUI.Button(new Rect(sWidth - 450f, yPos, buttonWidth, buttonHeight), "Night", buttonStyle))
{
combatLight.CurrentTimeOfDay = CombatLight.TimeOfDay.NIGHT;
}
labelStyle.fontSize = Math.Max(guiTextSize, 20);
}
private void SpawnPlayer(Vector3 position)
{
combatPlayerMovement.Move(position);
foreach (var element in bossPortal)
{
element.ResetPortal();
}
}
}
}