Example #1
0
 /// <summary>
 /// Constructs the command parser.
 /// </summary>
 public CommandParser()
 {
     _commandChainDictionary = new Dictionary <CommandChainType, Func <string, IExplorerCommand> > {
         {
             CommandChainType.InitializeDeploymentZone,
             (deploymentZoneString) => {
                 var arguments = deploymentZoneString.Split(' ');
                 var zoneSize  = new Size(int.Parse(arguments[0]), int.Parse(arguments[1]));
                 return(new DeploymentZoneChartCommand(zoneSize));
             }
         }, {
             CommandChainType.Explore,
             (explorationCommandString) => {
                 var arguments = explorationCommandString.ToCharArray();
                 var movements = arguments.Select(argument => MovementMethods.FromString(argument.ToString()))
                                 .ToList();
                 return(new ExploreCommand(movements));
             }
         }, {
             CommandChainType.DeployExplorer,
             (deployExplorerCommand) => {
                 var arguments = deployExplorerCommand.Split(' ');
                 var position  = new Position(int.Parse(arguments[0]), int.Parse(arguments[1]));
                 var heading   = HeadingMethods.FromString(arguments[2]);
                 return(new DeployExplorerCommand(position, heading));
             }
         }
     };
 }
Example #2
0
    /*
     ########################## Private ##########################
     */

    private void UpdateCurrentMovement(bool airborn)
    {
        currentMovement = ((this.flySettings.canFly && airborn) ? (MovementMethods)flySettings : (MovementMethods)walkSettings);

        if (!airborn)
        {
            this.characterController.enabled = true;
            this.rigidbody.isKinematic       = true;
        }
        else
        {
            this.characterController.enabled = false;
            this.rigidbody.isKinematic       = false;
        }
    }