Ejemplo n.º 1
0
    public void ExternalMovement(string action)
    {
        switch (action)
        {
        case "RR":
            theirHandler.AddExternalAction(ActionInformation.AgentState.Turning, 1);
            break;

        case "RL":
            theirHandler.AddExternalAction(ActionInformation.AgentState.Turning, -1);
            break;

        case "MF":
            theirHandler.AddExternalAction(ActionInformation.AgentState.Walking, 1);
            break;

        case "MB":
            theirHandler.AddExternalAction(ActionInformation.AgentState.Walking, -1);
            break;
        }
    }
Ejemplo n.º 2
0
    /*  Outdated replay function. Runs by constant time intervals.
     *  // Calculate initial time.
     *  int prevTime;
     *  if(!Int32.TryParse(bufList[0][3], out prevTime))
     *      yield return null;
     *
     *  // Iterate through list of moves by moveId.
     *  foreach(var move in bufList.OrderBy(move => move[0], new SemiNumericComparer()))
     *  {
     *          // Displays instructions if move ID matches.
     *          while(instructionList.Any() && instructionList.First()[0] == move[0])
     *          {
     *                  instrControl.DisplayInstruction(instructionList.First()[1]);
     *                  instructionList.RemoveAt(0);
     *          }
     *
     *          int newTime;
     *          if(!Int32.TryParse(move[3], out newTime))
     *                  continue;
     *      int elapsed = newTime - prevTime;
     *      prevTime = newTime;
     *
     *      Tuple<string, string, int> moveArg = Tuple.Create(move[1], move[2], elapsed);
     *      CallMovement(moveArg);
     *  }
     *  humanHandler.DoExternalActions();
     *  agentHandler.DoExternalActions();
     * }
     */

    // Calls the correct movement on the given agent.
    private void QueueMovement(Tuple <string, string> moveArg)
    {
        if (moveArg.Item1 == "Human")
        {
            handler = humanHandler;
        }
        else if (moveArg.Item1 == "Agent")
        {
            handler = agentHandler;
        }
        else
        {
            return;
        }

        switch (moveArg.Item2)
        {
        case "RR":
            handler.AddExternalAction(ActionInformation.AgentState.Turning, 1);
            break;

        case "RL":
            handler.AddExternalAction(ActionInformation.AgentState.Turning, -1);
            break;

        case "MF":
            handler.AddExternalAction(ActionInformation.AgentState.Walking, 1);
            break;

        case "MB":
            handler.AddExternalAction(ActionInformation.AgentState.Walking, -1);
            break;

        default:
            break;
        }
    }