Exemplo n.º 1
0
        /// <summary>
        /// Finishing player movement
        /// </summary>
        /// <param name="pendingMovement"></param>
        /// <exception cref="Exception"></exception>
        private void OnMovementFinished(PendingMovement pendingMovement)
        {
            var character = pendingMovement.ParentCharacter;

            if (character == null)
            {
                Out.QuickLog("Something went wrong, character in PendingMovement is null");
                throw new Exception("Something went wrong during movement finishing");
            }

            character.OnConfigurationChanged -= OnMovementRateChange;
            character.Controller.GetInstance <CharacterMovementController>().OnMovementFinished();
            Out.WriteLog("Movement finished for character", LogKeys.ALL_CHARACTER_LOG, character.Id);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Creating and queueing the movement
        /// </summary>
        /// <param name="movement">Pending movement class containing datas</param>
        /// <exception cref="Exception">Same movement exists</exception>
        public void CreateMovement(PendingMovement movement)
        {
            CharacterStateManager.Instance.RequestStateChange(movement.ParentCharacter,
                                                              CharacterStates.MOVING, out var stateChanged);
            if (!stateChanged)
            {
                Out.WriteLog("Error moving character", LogKeys.ERROR_LOG, movement.ParentCharacter.Id);
                throw new Exception("Something went totally wrong with movement state of character");
            }

            if (PendingMovements.Contains(movement))
            {
                Out.QuickLog("Trying to create a duplicate movement", LogKeys.ERROR_LOG);
                throw new Exception("Trying to create a duplicate movement, something went wrong");
            }
            PendingMovements.Enqueue(movement);
        }