예제 #1
0
 public static void Interact(this LocalInputHandler instance, WorldObjectView target, string collider = null) => _doActionStaticObjectInteraction.Invoke(instance, new object[] { target, collider ?? string.Empty });
예제 #2
0
 public static void Interact(this LocalPlayerCharacterView instance, WorldObjectView target)
 {
     _doActionStaticObjectInteraction.Invoke(instance.InputHandler, new object[] { target, String.Empty });
 }
 public static void Interact(this LocalPlayerCharacterView instance, WorldObjectView target, string collider = null) => instance.InputHandler.Interact(target, collider);
예제 #4
0
        private void checkDeath(WorldObject collisionObject, WorldObjectView[] worldObjectViews)
        {
            // If the object is dead, remove it and its view from the World and -View.
            if (collisionObject.Health <= 0)    // --> object is dead
            {
                gameModel.World.RemoveWorldObject(collisionObject);

                /* If the object is a spaceship, delete the according player from the players list
                 * and check whether there was only two players left, meaning the other player has won
                 * the game. */
                if (collisionObject is Spaceship)
                {
                    Player[] players = gameModel.Players;
                    foreach (Player player in players)
                    {
                        if (player.Spaceship == collisionObject)
                        {
                            gameModel.RemovePlayer(player);
                            // checking whether the game has ended and determining the winner
                            if (players.Length == 2)
                            {
                                if (players[0] == player)
                                {
                                    gameHandler.OnGameEnded(players[1].PlayerId);
                                }
                                else
                                {
                                    gameHandler.OnGameEnded(players[0].PlayerId);
                                }
                            }
                        }
                    }
                }
            }
        }