Skip to content

Commit

Permalink
chore: redefine some function in Prop and remove comments in PlayerLogic
Browse files Browse the repository at this point in the history
  • Loading branch information
yeonjae11 committed Nov 9, 2024
1 parent 99b59b4 commit 7c4ddb3
Show file tree
Hide file tree
Showing 10 changed files with 52 additions and 53 deletions.
2 changes: 1 addition & 1 deletion Assets/SWPPT3/Scripts/Main/PlayerLogic/Player.cs
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ public void OnChangeState(InputAction.CallbackContext context)
PlayerState.ChangeRigidbody(_rb);
PlayerState.ChangePhysics(_collider, _physicMaterial);
UpdateJumpForce();
Debug.Log($"New state: {newState} mass: {_rb.mass} kg");
// Debug.Log($"New state: {newState} mass: {_rb.mass} kg");
}
}

Expand Down
5 changes: 1 addition & 4 deletions Assets/SWPPT3/Scripts/Main/PlayerLogic/State/MetalState.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,7 @@ public override void InteractWithProp(Player player, PropBase obstacle)
{
if (false)
{
// SomeSpecificProp에 대한 특별한 상호작용 처리
Debug.Log("Interacting with a specific prop in SlimeState.");
// 여기에서 player 또는 obstacle에 대한 특정 작업 수행
obstacle.InteractWithPlayer(States.Metal);

}
else
{
Expand Down
2 changes: 0 additions & 2 deletions Assets/SWPPT3/Scripts/Main/PlayerLogic/State/RubberState.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@ public override void InteractWithProp(Player player, PropBase obstacle)
if (false)
{
// SomeSpecificProp에 대한 특별한 상호작용 처리
Debug.Log("Interacting with a specific prop in SlimeState.");
// 여기에서 player 또는 obstacle에 대한 특정 작업 수행
obstacle.InteractWithPlayer(States.Rubber);
}
else
{
Expand Down
5 changes: 1 addition & 4 deletions Assets/SWPPT3/Scripts/Main/PlayerLogic/State/SlimeState.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,7 @@ public override void InteractWithProp(Player player, PropBase obstacle)
{
if (false)
{
// SomeSpecificProp에 대한 특별한 상호작용 처리
Debug.Log("Interacting with a specific prop in SlimeState.");
// 여기에서 player 또는 obstacle에 대한 특정 작업 수행
obstacle.InteractWithPlayer(States.Slime);

}
else
{
Expand Down
5 changes: 3 additions & 2 deletions Assets/SWPPT3/Scripts/Main/Prop/ElectricWire.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System.Runtime.CompilerServices;
using UnityEngine;

namespace SWPPT3.Main.Prop
Expand Down Expand Up @@ -28,12 +29,12 @@ public override void StateChangeEvent()
{
if (_objectMaterial != null)
{
if (this.State == (int)StateLevel.On)
if (this.State == On)
{
_objectMaterial.EnableKeyword("_EMISSION");
_objectMaterial.SetColor("_EmissionColor", emissionColor * emissionIntensityOn);
}
else if (this.State == (int)StateLevel.Off)
else if (this.State == Off)
{
_objectMaterial.DisableKeyword("_EMISSION");
_objectMaterial.SetColor("_EmissionColor", emissionColor * emissionIntensityOff);
Expand Down
26 changes: 14 additions & 12 deletions Assets/SWPPT3/Scripts/Main/Prop/FloorButton.cs
Original file line number Diff line number Diff line change
@@ -1,35 +1,37 @@
using System;
using System.Collections.Generic;
using UnityEngine;

namespace SWPPT3.Main.Prop
{
public class FloorButton : StateSource
{
public StatefulProp targetProp;
public ElectricWire electricWire;
public List<StatefulProp> targetProps = new List<StatefulProp>();

public override void ActivateProp(StatefulProp prop, int state)
{
if (state == On) prop.Activate();
else prop.Deactivate();
prop.StateChangeEvent();
}

public override void StateChangeEvent()
{
if (this.State == (int)StateLevel.On)
foreach (StatefulProp prop in targetProps)
{
ActivateState(targetProp, StateLevel.On);
ActivateState(electricWire, StateLevel.On);
}
else
{
ActivateState(targetProp, StateLevel.Off);
ActivateState(electricWire, StateLevel.Off);
ActivateProp(prop, this.State);
}
}

private void OnCollisionEnter(Collision other)
{
this.State = (int)StateLevel.On;
this.State = On;
StateChangeEvent();
}

private void OnCollisionExit(Collision other)
{
this.State = (int)StateLevel.Off;
this.State = Off;
StateChangeEvent();
}
}
Expand Down
26 changes: 14 additions & 12 deletions Assets/SWPPT3/Scripts/Main/Prop/MagicCircle.cs
Original file line number Diff line number Diff line change
@@ -1,29 +1,31 @@
using UnityEngine;

namespace SWPPT3.Main.Prop
{
public class MagicCircle : StatefulProp
{
[SerializeField]
private int stateChangeAmount;
public override void StateChangeEvent()
{
if (this.State == (int)StateLevel.Off)
{

}
else if (this.State == (int)StateLevel.Quarter)
if (this.State == Full)
{

}
else if (this.State == (int)StateLevel.Half)
else if (this.State == Off)
{

}
else if (this.State == (int)StateLevel.ThreeQuarters)
{
}

}
else if (this.State == (int)StateLevel.On)
{
public override void Activate()
{
this.State += stateChangeAmount;
}

}
public override void Deactivate()
{
this.State -= stateChangeAmount;
}
}
}
2 changes: 0 additions & 2 deletions Assets/SWPPT3/Scripts/Main/Prop/PropBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,10 @@ namespace SWPPT3.Main.Prop
public abstract class PropBase : MonoBehaviour
{
public virtual void InteractWithPlayer()
// Player에 의해 StateProb이 어떻게 변하는지
{

}
public virtual void InteractWithPlayer(States state)
// Player에 의해 StateProb이 어떻게 변하는지
{

}
Expand Down
7 changes: 2 additions & 5 deletions Assets/SWPPT3/Scripts/Main/Prop/StateSource.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,7 @@ namespace SWPPT3.Main.Prop
{
public abstract class StateSource : StatefulProp
{
protected virtual void ActivateState(StatefulProp prop, StateLevel level)
{
prop.State = (int)level;
prop.StateChangeEvent();
}
public abstract void ActivateProp(StatefulProp prop, int state);

}
}
25 changes: 16 additions & 9 deletions Assets/SWPPT3/Scripts/Main/Prop/StatefulProp.cs
Original file line number Diff line number Diff line change
@@ -1,18 +1,25 @@
namespace SWPPT3.Main.Prop
{
public enum StateLevel
{
Off = 0,
On = 100,
Quarter = 25,
Half = 50,
ThreeQuarters = 75,
Full = 100
}
public abstract class StatefulProp : PropBase
{
protected const int On = 1;
protected const int Off = 0;
protected const int Full = 100;

public int StateChangeAmount;

public int State { get; set; } = 0;
public abstract void StateChangeEvent();

public virtual void Activate()
{
State = On;
}

public virtual void Deactivate()
{
State = Off;
}
}

}

0 comments on commit 7c4ddb3

Please sign in to comment.