Bunch of cleaning
This commit is contained in:
@@ -51,16 +51,16 @@ namespace Marro.PacManUdon
|
||||
transform.localPosition = new Vector3(position.x, position.y, transform.localPosition.z);
|
||||
}
|
||||
|
||||
public Vector2 GetVector(Direction direction)
|
||||
{
|
||||
return directionVectors[(int)direction];
|
||||
}
|
||||
|
||||
public Direction GetDirection()
|
||||
{
|
||||
return direction;
|
||||
}
|
||||
|
||||
public Direction GetTargetDirection()
|
||||
{
|
||||
return targetDirection;
|
||||
}
|
||||
|
||||
public void SetDirection(Direction direction)
|
||||
{
|
||||
this.direction = direction;
|
||||
@@ -80,31 +80,6 @@ namespace Marro.PacManUdon
|
||||
UpdateAnimator();
|
||||
}
|
||||
|
||||
protected static Direction VectorToDirection(Vector2 vector)
|
||||
{
|
||||
var directionId = 0;
|
||||
|
||||
if (vector.x < 0)
|
||||
{
|
||||
directionId = 4;
|
||||
}
|
||||
else if (vector.x > 0)
|
||||
{
|
||||
directionId = 8;
|
||||
}
|
||||
|
||||
if (vector.y < 0)
|
||||
{
|
||||
directionId += 1;
|
||||
}
|
||||
else if (vector.y > 0)
|
||||
{
|
||||
directionId += 2;
|
||||
}
|
||||
|
||||
return (Direction)directionId;
|
||||
}
|
||||
|
||||
protected static Direction HorizontalToDirection(float horizontal)
|
||||
{
|
||||
if (horizontal < 0)
|
||||
@@ -137,26 +112,22 @@ namespace Marro.PacManUdon
|
||||
{
|
||||
data.Append(GetPosition(), ref index);
|
||||
data.AppendAsByte((int)direction, ref index);
|
||||
}
|
||||
|
||||
public void PadSyncedData(byte[] data, ref int index, NetworkEventType eventType)
|
||||
{
|
||||
index += 9;
|
||||
data.AppendAsByte((int)targetDirection, ref index);
|
||||
}
|
||||
|
||||
public override bool WriteSyncedData(byte[] data, ref int index, NetworkEventType eventType)
|
||||
{
|
||||
SetPosition(data.ReadVector2(ref index));
|
||||
SetDirection((Direction)data.ReadByte(ref index));
|
||||
direction = (Direction)data.ReadByte(ref index);
|
||||
targetDirection = (Direction)data.ReadByte(ref index);
|
||||
UpdateAnimator();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool ConsumeSyncedData(byte[] data, ref int index, NetworkEventType eventType)
|
||||
public void PadSyncedData(ref int index)
|
||||
{
|
||||
index += 9;
|
||||
|
||||
return true;
|
||||
index += 10;
|
||||
}
|
||||
|
||||
#region Utils
|
||||
@@ -231,6 +202,7 @@ namespace Marro.PacManUdon
|
||||
{
|
||||
result = Math.Round(currentPosition.y) != Math.Round(nextPosition.y);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
#endregion
|
||||
|
||||
Reference in New Issue
Block a user