Skip to content

Instantly share code, notes, and snippets.

View handlePlayerActions.ts
export const listenForPlayerAction = (game: Game): Promise<ActionValue> => {
return new Promise((res, rej) => {
const { sockets, currentPlayerIndex } = game;
const currentSocket = sockets[currentPlayerIndex];
currentSocket.once('action', async (action: ActionTypes, value: number) => {
if (!checkIfValidAction(game, action, value)) {
rej("Invalid Action");
} else {
res({ action, value });
View Card.tsx
interface Props {
card: Card
}
export default (props: Props)=>{
const { name, optional, requirements, effects } = props.card;
return <div class='game-card text-center'>
<div class='title'>{name}</div>
View GameManager.cs
public class GameManager : MonoBehaviour
{
[SerializeField]
Player playerPrefab;
Timeline timeline;
static GameManager t;
List<ITimed> timedThings = new List<ITimed>();
IInput currentInput;
View PlayerInput.cs
public class InputPlayer : IInput
{
public bool ShouldPlay{get{
return !GameSettings.PauseOnInaction ||
(
Input.GetKey(KeyCode.W) ||
Input.GetKey(KeyCode.A) ||
Input.GetKey(KeyCode.S) ||
Input.GetKey(KeyCode.D) ||
View IInput.cs
public interface IInput
{
void GetInput();
void EndInput();
void StartInput();
bool ShouldPlay {get;}
}
public enum InputTypes{
Player,
View Player.cs
public class Player : MonoBehaviour, ITimed
{
[SerializeField]
float speed = 1;
[SerializeField]
bool isStartingPlayer = false;
public bool IsStartingPlayer {get{return isStartingPlayer;}}
[SerializeField]
CollDetector forwardDetector;
View TimedState.cs
public class TimedState
{
SeriealizedState data;
ITimed timed;
public ITimed Target { get { return timed; } }
public SeriealizedState Data { get { return data; } }
public TimedState(ITimed timedObject, SeriealizedState serialized)
View Timeline.cs
public class Timeline
{
int currentFrame = 0;
public int CurrentFrame
{
get { return currentFrame; }
set { currentFrame = value; }
}
View ITimed.cs
public interface ITimed
{
TimedState Serialize();
void Hydrate(SeriealizedState state);
void Play(float time);
void ProcessAction(Action action);
}
View ActionEnum.cs
public enum ActionEnum
{
PressForward,
ReleaseForward,
PressRight,
ReleaseRight,
PressBack,
ReleaseBack,
PressLeft,
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.