Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public IEnumerator CreatePlayerAndTestDecay()
Debug.Assert(circle != null, nameof(circle) + " != null");
var ourEntity = GameManager.Conn.Db.Entity.EntityId.Find(circle.EntityId);
var toChosenFood = new UnityEngine.Vector2(1000, 0);
uint chosenFoodId = 0;
int chosenFoodId = 0;
foreach (var food in GameManager.Conn.Db.Food.Iter())
{
var thisFoodId = food.EntityId;
Expand Down
10 changes: 5 additions & 5 deletions demo/Blackholio/client-unity/Assets/Scripts/EntityController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ public abstract class EntityController : MonoBehaviour

private static readonly int ShaderColorProperty = Shader.PropertyToID("_Color");

[DoNotSerialize] public uint EntityId;
[DoNotSerialize] public int EntityId;

protected float LerpTime;
protected Vector3 LerpStartPosition;
protected Vector3 LerpTargetPosition;
protected Vector3 TargetScale;

protected virtual void Spawn(uint entityId)
protected virtual void Spawn(int entityId)
{
EntityId = entityId;

Expand Down Expand Up @@ -82,12 +82,12 @@ public virtual void Update()
transform.localScale = Vector3.Lerp(transform.localScale, TargetScale, Time.deltaTime * 8);
}

public static Vector3 MassToScale(uint mass)
public static Vector3 MassToScale(int mass)
{
var diameter = MassToDiameter(mass);
return new Vector3(diameter, diameter, 1);
}

public static float MassToRadius(uint mass) => Mathf.Sqrt(mass);
public static float MassToDiameter(uint mass) => MassToRadius(mass) * 2;
public static float MassToRadius(int mass) => Mathf.Sqrt(mass);
public static float MassToDiameter(int mass) => MassToRadius(mass) * 2;
}
20 changes: 12 additions & 8 deletions demo/Blackholio/client-unity/Assets/Scripts/GameManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ public class GameManager : MonoBehaviour
public static Identity LocalIdentity { get; private set; }
public static DbConnection Conn { get; private set; }

public static Dictionary<uint, EntityController> Entities = new Dictionary<uint, EntityController>();
public static Dictionary<uint, PlayerController> Players = new Dictionary<uint, PlayerController>();
public static Dictionary<int, EntityController> Entities = new Dictionary<int, EntityController>();
public static Dictionary<int, PlayerController> Players = new Dictionary<int, PlayerController>();

private void Start()
{
Expand Down Expand Up @@ -102,19 +102,19 @@ private void HandleSubscriptionApplied(SubscriptionEventContext ctx)
{
Debug.Log("Subscription applied!");
OnSubscriptionApplied?.Invoke();

// Once we have the initial subscription sync'd to the client cache
// Get the world size from the config table and set up the arena
var worldSize = Conn.Db.Config.Id.Find(0).WorldSize;
SetupArena(worldSize);

// Check to see if we already have a player, if we don't we'll need to create one
var player = ctx.Db.Player.Identity.Find(LocalIdentity);
if (string.IsNullOrEmpty(player.Name))
{
// The player has to choose a username
UIUsernameChooser.Instance.Show(true);

// When our username is updated, hide the username chooser
Conn.Db.Player.OnUpdate += (_, _, newPlayer) =>
{
Expand All @@ -123,14 +123,18 @@ private void HandleSubscriptionApplied(SubscriptionEventContext ctx)
UIUsernameChooser.Instance.Show(false);
}
};
} else {
}
else
{
// We already have a player
if (ctx.Db.Circle.PlayerId.Filter(player.PlayerId).Any())
{
// We already have at least one circle, we should just be able to start
// playing immediately.
UIUsernameChooser.Instance.Show(false);
} else {
}
else
{
// Create a new circle for our player.
ctx.Reducers.EnterGame(player.Name);
}
Expand Down Expand Up @@ -209,7 +213,7 @@ private static void PlayerOnDelete(EventContext context, Player deletedvalue)
}
}

private static PlayerController GetOrCreatePlayer(uint playerId)
private static PlayerController GetOrCreatePlayer(int playerId)
{
if (!Players.TryGetValue(playerId, out var playerController))
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ public class LeaderboardRow : MonoBehaviour
public TextMeshProUGUI UsernameText;
public TextMeshProUGUI MassText;

public void SetData(string username, uint mass)
public void SetData(string username, int mass)
{
UsernameText.text = username;
MassText.text = mass.ToString();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public class PlayerController : MonoBehaviour

public static PlayerController Local { get; private set; }

private uint PlayerId;
private int PlayerId;
private float LastMovementSendTimestamp;
private Vector2? LockInputPosition;
private List<CircleController> OwnedCircles = new List<CircleController>();
Expand Down Expand Up @@ -56,9 +56,9 @@ public void OnCircleDeleted(CircleController deletedCircle)
}
}

public uint TotalMass()
public int TotalMass()
{
return (uint)OwnedCircles
return (int)OwnedCircles
.Select(circle => GameManager.Conn.Db.Entity.EntityId.Find(circle.EntityId))
.Sum(e => e?.Mass ?? 0); //If this entity is being deleted on the same frame that we're moving, we can have a null entity here.
}
Expand Down

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.

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.

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.

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.

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.

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

Binary file modified demo/Blackholio/client-unreal/Content/Blackholio.umap
Binary file not shown.
Loading
Loading