-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
add: class hierarchy abstraction for Player, Prop, SystemObject
- Loading branch information
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
using System.Collections.Generic; | ||
using Unity; | ||
using UnityEngine; | ||
using SWPPT3.Main.Prop; | ||
using SWPPT3.Main.PlayerLogic.State; | ||
|
||
namespace SWPPT3.Main.PlayerLogic | ||
{ | ||
public class Player : MonoBehaviour | ||
{ | ||
private States _currentState = States.Slime; | ||
private PlayerState PlayerState => _playerStates[_currentState]; | ||
|
||
private readonly Dictionary<States, PlayerState> _playerStates = new() | ||
{ | ||
{ States.Metal, new MetalState() }, | ||
{ States.Rubber, new RubberState() }, | ||
{ States.Slime, new SlimeState() }, | ||
}; | ||
|
||
public void PlayerMove() | ||
{ | ||
|
||
} | ||
|
||
public void ChangeState(States state) | ||
{ | ||
_currentState = state; | ||
} | ||
|
||
public void InteractWithObject(PropBase prop) | ||
{ | ||
PlayerState.InteractWithProp(prop); | ||
} | ||
|
||
void OnCollisionEnter(Collision collision) | ||
{ | ||
var obstacle = collision.gameObject.GetComponent<PropBase>(); | ||
InteractWithObject(obstacle); | ||
} | ||
|
||
|
||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
using SWPPT3.Main.Prop; | ||
using UnityEngine; | ||
|
||
namespace SWPPT3.Main.PlayerLogic.State | ||
{ | ||
public class MetalState : PlayerState | ||
{ | ||
public override void InteractWithProp(PropBase obstacle) | ||
{ | ||
// player의 변화 | ||
obstacle.InteractWithPlayer(); | ||
} | ||
|
||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
using SWPPT3.Main.Prop; | ||
|
||
namespace SWPPT3.Main.PlayerLogic.State | ||
{ | ||
public enum States | ||
{ | ||
Slime = 0, | ||
Metal, | ||
Rubber, | ||
} | ||
|
||
public abstract class PlayerState | ||
{ | ||
public virtual void InteractWithProp(PropBase obstacle) | ||
{ | ||
|
||
} | ||
} | ||
|
||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
using SWPPT3.Main.Prop; | ||
|
||
namespace SWPPT3.Main.PlayerLogic.State | ||
{ | ||
public class RubberState : PlayerState | ||
{ | ||
public override void InteractWithProp(PropBase obstacle) | ||
{ | ||
// player의 변화 | ||
obstacle.InteractWithPlayer(); | ||
} | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
using SWPPT3.Main.Prop; | ||
|
||
namespace SWPPT3.Main.PlayerLogic.State | ||
{ | ||
public class SlimeState : PlayerState | ||
{ | ||
public override void InteractWithProp(PropBase obstacle) | ||
{ | ||
// player의 변화 | ||
obstacle.InteractWithPlayer(); | ||
} | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
namespace SWPPT3.Main.Prop | ||
{ | ||
public class Door : StatefulProp | ||
{ | ||
|
||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
namespace SWPPT3.Main.Prop | ||
{ | ||
public class ElectricPool : StatelessProp | ||
{ | ||
|
||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
namespace SWPPT3.Main.Prop | ||
{ | ||
public class ElectricWire : StatefulProp | ||
{ | ||
|
||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
namespace SWPPT3.Main.Prop | ||
{ | ||
public class FloorButton : StateSource | ||
{ | ||
public override void ActivateState(StatefulProp prop) | ||
{ | ||
|
||
} | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
using SWPPT3.Main.PlayerLogic; | ||
using SWPPT3.Main.PlayerLogic.State; | ||
|
||
namespace SWPPT3.Main.Prop | ||
{ | ||
public class ItemBox : StatelessProp | ||
{ | ||
private States _state; | ||
|
||
public ItemBox(States state) | ||
{ | ||
_state = state; | ||
} | ||
|
||
public override void InteractWithPlayer() | ||
{ | ||
// Destroy(gameObject); | ||
} | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
namespace SWPPT3.Main.Prop | ||
{ | ||
public class MagicCircle : StatefulProp | ||
{ | ||
|
||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
namespace SWPPT3.Main.Prop | ||
{ | ||
public class PoisonPool : StatelessProp | ||
{ | ||
|
||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
using UnityEngine; | ||
|
||
namespace SWPPT3.Main.Prop | ||
{ | ||
public abstract class PropBase : MonoBehaviour | ||
{ | ||
public virtual void InteractWithPlayer() | ||
// Player에 의해 StateProb이 어떻게 변하는지 | ||
{ | ||
|
||
} | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
namespace SWPPT3.Main.Prop | ||
{ | ||
public abstract class StateSource : StatefulProp | ||
{ | ||
public abstract void ActivateState(StatefulProp prop); | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
namespace SWPPT3.Main.Prop | ||
{ | ||
public abstract class StatefulProp : PropBase | ||
{ | ||
public int State { get; set; } = 0; | ||
} | ||
} |