public void OnCollision(string senderId, CollisionPayload payload) { if (!players.ContainsKey(payload.AlphaId)) { return; } if (!players.ContainsKey(payload.BravoId)) { return; } var alphaPlayer = players[payload.AlphaId]; var bravoPlayer = players[payload.BravoId]; if (alphaPlayer.Score == bravoPlayer.Score) { return; } var loser = alphaPlayer.Score < bravoPlayer.Score ? alphaPlayer : bravoPlayer; lock (players) { players.Remove(loser.Uid); } var deletePlayerRpc = new DeletePlayer(new DeletePlayerPayload(loser.Uid)); var deletePlayerJson = JsonConvert.SerializeObject(deletePlayerRpc); broadcast(deletePlayerJson); }
private void OnCollision(CollisionPayload payload) { Instantiate(explosion).transform.position = transform.position; Messenger.Default.Publish <SpaceshipDestructionPayload>(new SpaceshipDestructionPayload()); Destroy(gameObject); }
private bool CollisionPredicate(CollisionPayload payload) { return(payload.GameObject != null && payload.GameObject == gameObject); }