Skip to content

Commit

Permalink
chore:refactoring and radial change
Browse files Browse the repository at this point in the history
  • Loading branch information
jihu0331 committed Dec 18, 2024
1 parent 9210441 commit 86a8fdc
Show file tree
Hide file tree
Showing 7 changed files with 50 additions and 41 deletions.
12 changes: 11 additions & 1 deletion Assets/SWPPT3/Scenes/Start.unity
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ PrefabInstance:
- target: {fileID: 4594056758955674281, guid: d79180819b10a49f88d89a3e3c2f6d2c,
type: 3}
propertyPath: m_IsActive
value: 1
value: 0
objectReference: {fileID: 0}
- target: {fileID: 4594056758955674282, guid: d79180819b10a49f88d89a3e3c2f6d2c,
type: 3}
Expand Down Expand Up @@ -1690,6 +1690,11 @@ PrefabInstance:
propertyPath: _onTryingOptionStatusChanged.m_PersistentCalls.m_Calls.Array.data[0].m_Arguments.m_ObjectArgumentAssemblyTypeName
value: UnityEngine.Object, UnityEngine
objectReference: {fileID: 0}
- target: {fileID: 2777941070604438708, guid: d75084c0538324141925deab3531a83d,
type: 3}
propertyPath: m_IsActive
value: 1
objectReference: {fileID: 0}
- target: {fileID: 3373383851121577288, guid: d75084c0538324141925deab3531a83d,
type: 3}
propertyPath: m_AnchorMax.x
Expand Down Expand Up @@ -1735,6 +1740,11 @@ PrefabInstance:
propertyPath: m_IsActive
value: 1
objectReference: {fileID: 0}
- target: {fileID: 4744774116367588981, guid: d75084c0538324141925deab3531a83d,
type: 3}
propertyPath: m_IsActive
value: 0
objectReference: {fileID: 0}
- target: {fileID: 4924722160105393931, guid: d75084c0538324141925deab3531a83d,
type: 3}
propertyPath: m_Name
Expand Down
1 change: 0 additions & 1 deletion Assets/SWPPT3/Scripts/Main/Manager/GameManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ public GameState GameState
{
if (gameState != value)
{
Debug.Log($"{gameState} {value}");
gameState = value;
HandleGameStateChanged(gameState);
}
Expand Down
9 changes: 1 addition & 8 deletions Assets/SWPPT3/Scripts/Main/PlayerLogic/State/MetalState.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,7 @@ public class MetalState : PlayerState
{
public override void InteractWithProp(Player player, PropBase obstacle)
{
if (false)
{
obstacle.InteractWithPlayer();
}
else
{
base.InteractWithProp(player, obstacle);
}
base.InteractWithProp(player, obstacle);
}
}
}
9 changes: 5 additions & 4 deletions Assets/SWPPT3/Scripts/Main/PlayerLogic/State/PlayerState.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,10 @@ public virtual void InteractWithProp(Player player, PropBase obstacle)
{
if (obstacle is ItemBox itemBox)
{
player.Item[itemBox.ItemState] += 1;
Debug.Log(itemBox.ItemState);
itemBox.InteractWithPlayer();
player.SetItemCounts(0,
itemBox.ItemState == PlayerStates.Metal ? player.Item[PlayerStates.Metal] + 1 : player.Item[PlayerStates.Metal],
itemBox.ItemState == PlayerStates.Rubber ? player.Item[PlayerStates.Rubber] + 1 : player.Item[PlayerStates.Rubber]
);
}
else if (obstacle is PoisonPool)
{
Expand All @@ -31,7 +32,7 @@ public virtual void InteractWithProp(Player player, PropBase obstacle)
{
foreach(PlayerStates playerState in System.Enum.GetValues(typeof(PlayerStates)))
{
player.Item[playerState] = 0;
player.SetItemCounts(0,0,0);
}
player.TryChangeState(PlayerStates.Slime);
}
Expand Down
1 change: 0 additions & 1 deletion Assets/SWPPT3/Scripts/Main/StageDirector/StageManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ public abstract class StageManager : MonoWeakSingleton<StageManager>

public void Awake()
{
Debug.Log("Stage Manager initialized");
InitializeStage();
StartStage();
GameManager.Instance._stageManager = this;
Expand Down
58 changes: 33 additions & 25 deletions Assets/SWPPT3/Scripts/Main/UI/InGameScreenBehaviour.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ public class InGameScreenBehaviour : MonoBehaviour
[SerializeField] private RectTransform _rubberButton;
[SerializeField] private RectTransform _metalButton;
[SerializeField] private RectTransform _slimeButton;
private float _maxDistance = 200f; // 최대 거리 (이 값에 따라 확대 감도가 달라짐)
private Vector2 _screenCenter;


Expand Down Expand Up @@ -101,7 +100,6 @@ public void ShowRadialUI()
}
private void UpdateRadialScale()
{
Vector2 mousePosition = Mouse.current.position.ReadValue();
UpdateButtonScale();
}

Expand All @@ -110,7 +108,7 @@ private void UpdateButtonScale()
Vector2 screenCenter = new Vector2(Screen.width / 2f, Screen.height / 2f);
Vector2 relativePos = Mouse.current.position.ReadValue() - screenCenter;

if (relativePos.magnitude < 50f)
if (relativePos.magnitude < 50f || relativePos.magnitude > 100f)
{
SetButtonScale(_slimeButton, 1.0f);
SetButtonScale(_metalButton, 1.0f);
Expand All @@ -121,24 +119,22 @@ private void UpdateButtonScale()
float angle = Mathf.Atan2(relativePos.y, relativePos.x) * Mathf.Rad2Deg;
if (angle < 0) angle += 360f;

float scaleFactor = Mathf.Lerp(1.5f, 1.0f, relativePos.magnitude / _maxDistance);
scaleFactor = Mathf.Clamp(scaleFactor, 1.0f, 2.0f);

if (angle >= 0 && angle < 120)
if (angle <=90 && angle > 330)
{
SetButtonScale(_slimeButton, scaleFactor);
SetButtonScale(_slimeButton, 1.5f);
SetButtonScale(_metalButton, 1.0f);
SetButtonScale(_rubberButton, 1.0f);
}
else if (angle >= 120 && angle < 240)
else if (angle >= 90 && angle < 210)
{
SetButtonScale(_metalButton, scaleFactor);
SetButtonScale(_metalButton, 1.5f);
SetButtonScale(_rubberButton, 1.0f);
SetButtonScale(_slimeButton, 1.0f);
}
else
{
SetButtonScale(_rubberButton, scaleFactor);
SetButtonScale(_rubberButton, 1.5f);
SetButtonScale(_metalButton, 1.0f);
SetButtonScale(_slimeButton, 1.0f);
}
Expand Down Expand Up @@ -235,7 +231,6 @@ private void HandleTransform(bool isClick)

// 커서를 화면 중앙으로 이동
Vector2 screenCenter = new Vector2(Screen.width / 2f, Screen.height / 2f);

Mouse.current.WarpCursorPosition(screenCenter);

GameManager.Instance.GameState = GameState.OnChoice;
Expand All @@ -255,25 +250,38 @@ private void CheckRadial()
Vector2 cursorPos = Mouse.current.position.ReadValue();
Vector2 screenCenter = new Vector2(Screen.width / 2f, Screen.height / 2f);
Vector2 relativePos = cursorPos - screenCenter;
if (relativePos.magnitude < 50f) return;
float angle = Mathf.Atan2(relativePos.y, relativePos.x) * Mathf.Rad2Deg;
if (angle < 0)
{
angle += 360f;
}

if (angle >= 0 && angle < 120)
{
_player.TryChangeState(PlayerStates.Rubber);
}
else if (angle >= 120 && angle < 240)
if (relativePos.magnitude < 50f || relativePos.magnitude > 100f)
{
_player.TryChangeState(PlayerStates.Metal);
return;
}
else
{
_player.TryChangeState(PlayerStates.Slime);

float angle = Mathf.Atan2(relativePos.y, relativePos.x) * Mathf.Rad2Deg;
if (angle < 0)
{
angle += 360f;
}
Debug.Log(angle);

if (angle <=90 || angle >330 )
{
Debug.Log("atRubber");
_player.TryChangeState(PlayerStates.Rubber);
}
else if (angle >= 90 && angle < 210)
{
Debug.Log("atMetal");
_player.TryChangeState(PlayerStates.Metal);
}
else
{
Debug.Log("Slime");
_player.TryChangeState(PlayerStates.Slime);
}
Debug.Log("finish!");
}

}


Expand Down
1 change: 0 additions & 1 deletion Assets/SWPPT3/Scripts/Main/UI/TitleScreenBehaviour.cs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,6 @@ private void Start()
// _exitGame = transform.Find("ExitGame");
// _optionScene = GameObject.Find("OptionScene");

Debug.Log($"{_optionScene == null}");
var parentSlider = _optionScene.transform.Find("VerticalAlign");
_bgmSlider = parentSlider.Find("BGMSlider").GetComponent<Slider>();
_sfxSlider = parentSlider.Find("SoundEffectSlider").GetComponent<Slider>();
Expand Down

0 comments on commit 86a8fdc

Please sign in to comment.