Esempio n. 1
0
        /// <summary>
        /// Handles a death
        /// </summary>
        /// <param name="deathConfirmation"></param>
        /// <param name="sender"></param>
        private void HandleDeath(DeathConfirmation deathConfirmation, ActorProcess sender)
        {
            GetActorProcessByRank(deathConfirmation.Rank).IsDeadProcess = true;

            if (AreAllActorsFinished())
            {
                // Stop the MapManager reception of messages if all actor's processes are dead
                ContinueExecution = false;
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Handle a request message
        /// </summary>
        /// <param name="request"></param>
        private void HandleRequest(Communication.Request request)
        {
            ActorProcess sender = GetActorProcessByRank(request.Rank);

            // Death confirmation
            DeathConfirmation deathConfirmation = request as DeathConfirmation;

            if (deathConfirmation != null)
            {
                HandleDeath(deathConfirmation, sender);

                return;
            }

            // Validate that the process is still in the game (playing).
            // This is meant to deny requests that were sent in between the moment the actor was removed from the game and the moment the actor learned about it.
            if (!sender.Playing)
            {
                return; // Ignore the request, the process is no longer playing
            }

            // Move request
            MoveRequest moveRequest = request as MoveRequest;

            if (moveRequest != null)
            {
                HandleMovePlayer(moveRequest, sender);

                return;
            }

            // Meow request
            MeowRequest meowRequest = request as MeowRequest;

            if (meowRequest != null)
            {
                HandleMeow(meowRequest, sender);

                return;
            }
        }