예제 #1
0
        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);
        }
예제 #2
0
        private void OnCollision(CollisionPayload payload)
        {
            Instantiate(explosion).transform.position = transform.position;

            Messenger.Default.Publish <SpaceshipDestructionPayload>(new SpaceshipDestructionPayload());

            Destroy(gameObject);
        }
예제 #3
0
 private bool CollisionPredicate(CollisionPayload payload)
 {
     return(payload.GameObject != null && payload.GameObject == gameObject);
 }