Skip to content

Commit

Permalink
Merge pull request #7 from 2024FALL-SWPP/feature/abstract_props_model
Browse files Browse the repository at this point in the history
add: class hierarchy abstraction for Player, Prop, SystemObject
  • Loading branch information
integraldx authored Nov 6, 2024
2 parents 8204d27 + bccbba9 commit 206ffc4
Show file tree
Hide file tree
Showing 41 changed files with 419 additions and 2 deletions.
8 changes: 8 additions & 0 deletions Assets/SWPPT3/Scripts/Main/PlayerLogic.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

44 changes: 44 additions & 0 deletions Assets/SWPPT3/Scripts/Main/PlayerLogic/Player.cs
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);
}


}
}
11 changes: 11 additions & 0 deletions Assets/SWPPT3/Scripts/Main/PlayerLogic/Player.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions Assets/SWPPT3/Scripts/Main/PlayerLogic/State.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 15 additions & 0 deletions Assets/SWPPT3/Scripts/Main/PlayerLogic/State/MetalState.cs
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();
}

}
}
11 changes: 11 additions & 0 deletions Assets/SWPPT3/Scripts/Main/PlayerLogic/State/MetalState.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 20 additions & 0 deletions Assets/SWPPT3/Scripts/Main/PlayerLogic/State/PlayerState.cs
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)
{

}
}

}
11 changes: 11 additions & 0 deletions Assets/SWPPT3/Scripts/Main/PlayerLogic/State/PlayerState.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 13 additions & 0 deletions Assets/SWPPT3/Scripts/Main/PlayerLogic/State/RubberState.cs
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();
}
}
}
11 changes: 11 additions & 0 deletions Assets/SWPPT3/Scripts/Main/PlayerLogic/State/RubberState.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 13 additions & 0 deletions Assets/SWPPT3/Scripts/Main/PlayerLogic/State/SlimeState.cs
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();
}
}
}
11 changes: 11 additions & 0 deletions Assets/SWPPT3/Scripts/Main/PlayerLogic/State/SlimeState.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 9 additions & 1 deletion Assets/SWPPT3/Scripts/Main/PlayerMover.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions Assets/SWPPT3/Scripts/Main/Prop.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions Assets/SWPPT3/Scripts/Main/Prop/Door.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
namespace SWPPT3.Main.Prop
{
public class Door : StatefulProp
{

}
}
3 changes: 3 additions & 0 deletions Assets/SWPPT3/Scripts/Main/Prop/Door.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions Assets/SWPPT3/Scripts/Main/Prop/ElectricPool.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
namespace SWPPT3.Main.Prop
{
public class ElectricPool : StatelessProp
{

}
}
11 changes: 11 additions & 0 deletions Assets/SWPPT3/Scripts/Main/Prop/ElectricPool.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions Assets/SWPPT3/Scripts/Main/Prop/ElectricWire.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
namespace SWPPT3.Main.Prop
{
public class ElectricWire : StatefulProp
{

}
}
11 changes: 11 additions & 0 deletions Assets/SWPPT3/Scripts/Main/Prop/ElectricWire.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions Assets/SWPPT3/Scripts/Main/Prop/FloorButton.cs
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)
{

}
}
}
11 changes: 11 additions & 0 deletions Assets/SWPPT3/Scripts/Main/Prop/FloorButton.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 20 additions & 0 deletions Assets/SWPPT3/Scripts/Main/Prop/ItemBox.cs
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);
}
}
}
11 changes: 11 additions & 0 deletions Assets/SWPPT3/Scripts/Main/Prop/ItemBox.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions Assets/SWPPT3/Scripts/Main/Prop/MagicCircle.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
namespace SWPPT3.Main.Prop
{
public class MagicCircle : StatefulProp
{

}
}
3 changes: 3 additions & 0 deletions Assets/SWPPT3/Scripts/Main/Prop/MagicCircle.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions Assets/SWPPT3/Scripts/Main/Prop/PoisonPool.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
namespace SWPPT3.Main.Prop
{
public class PoisonPool : StatelessProp
{

}
}
11 changes: 11 additions & 0 deletions Assets/SWPPT3/Scripts/Main/Prop/PoisonPool.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 13 additions & 0 deletions Assets/SWPPT3/Scripts/Main/Prop/PropBase.cs
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이 어떻게 변하는지
{

}
}
}
11 changes: 11 additions & 0 deletions Assets/SWPPT3/Scripts/Main/Prop/PropBase.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions Assets/SWPPT3/Scripts/Main/Prop/StateSource.cs
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);
}
}
3 changes: 3 additions & 0 deletions Assets/SWPPT3/Scripts/Main/Prop/StateSource.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions Assets/SWPPT3/Scripts/Main/Prop/StatefulProp.cs
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;
}
}
Loading

0 comments on commit 206ffc4

Please sign in to comment.