예제 #1
0
        public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
        {
            var result = new GetNewSensorsResponse();

            while (reader.Read())
            {
                if (reader.TokenType == JsonToken.PropertyName && reader.Value.ToString().Equals("lastscan"))
                {
                    reader.Read();
                    if (reader.Value.ToString().Equals("none"))
                    {
                        result.LastScan = DateTime.MinValue;
                    }
                    else if (reader.Value.ToString().Equals("active"))
                    {
                        result.LastScan = DateTime.MaxValue;
                    }
                    else
                    {
                        result.LastScan = DateTime.Parse(reader.Value.ToString());
                    }
                }
                else if (reader.TokenType == JsonToken.PropertyName)
                {
                    var newBasicSensor = new BasicSensor();
                    newBasicSensor.Id = Convert.ToInt32(reader.Value);
                    reader.Read();
                    newBasicSensor.Name = reader.Value.ToString();
                    result.Add(newBasicSensor);
                }
            }
            return(result);
        }
예제 #2
0
 public void RemoveSensor(BasicSensor sensor)
 {
     foreach (Vector3 direction in sensor.Directions)
     {
         Vector3Int pos = new Vector3Int(sensor.transform.position + direction);
         sensorSpaces [pos].Remove(sensor);
     }
 }
예제 #3
0
    /// <summary>
    /// Erstellt einen Roboter an Stelle 0, 0 und fügt einen BasicArm, ein BasicLeg und einen BasicSensor zu iihm hinzu.
    /// </summary>
    public GameObject CreateDefaultRobot()
    {
        GameObject  robotObject = CreateRobot(0, 0);
        BasicArm    arm         = new BasicArm();
        BasicLeg    leg         = new BasicLeg();
        BasicSensor sensor      = new BasicSensor();

        AddPartToRobot(robotObject, arm);
        AddPartToRobot(robotObject, leg);
        AddPartToRobot(robotObject, sensor);
        return(robotObject);
    }
예제 #4
0
 public void AddSensor(BasicSensor sensor)
 {
     foreach (Vector3 direction in sensor.Directions)
     {
         Vector3Int pos = new Vector3Int(sensor.transform.position + direction);
         if (!sensorSpaces.ContainsKey(pos))
         {
             sensorSpaces [pos] = new List <BasicSensor> ();
         }
         sensorSpaces [pos].Add(sensor);
     }
 }
예제 #5
0
    /// <summary>
    /// Erstellt die Für den Test nötigen Objekte.
    /// </summary>
    public void TestSolve()
    {
        //Robot1
        GameObject robot1Object = robotManager.CreateRobot(-6, 3);

        robotManager.TurnRobotStartingDirection(robot1Object);
        robotManager.TurnRobotStartingDirection(robot1Object);
        ShreddingTool tool1      = new ShreddingTool(robot1Object.GetComponent <Robot>());
        BasicLeg      leg1       = new BasicLeg(robot1Object.GetComponent <Robot>());
        TextAsset     text       = Resources.Load <TextAsset>("Texts/Robot 1Actions");
        string        scriptCode = text.text;

        robot1Object.GetComponent <Robot>().ChangeScriptCode(scriptCode);

        //Robot2
        GameObject  robot2Object = robotManager.CreateRobot(-7, 5);
        BasicArm    tool2        = new BasicArm(robot2Object.GetComponent <Robot>());
        SpiderLeg   leg2         = new SpiderLeg(robot2Object.GetComponent <Robot>());
        BasicSensor sensor2      = new BasicSensor(robot2Object.GetComponent <Robot>());

        text       = Resources.Load <TextAsset>("Texts/Robot 2Actions");
        scriptCode = text.text;
        robot2Object.GetComponent <Robot>().ChangeScriptCode(scriptCode);

        //Robot3
        GameObject robot3Object = robotManager.CreateRobot(-7, 2);

        robotManager.TurnRobotStartingDirection(robot3Object);
        robotManager.TurnRobotStartingDirection(robot3Object);
        BasicArm     tool3     = new BasicArm(robot3Object.GetComponent <Robot>());
        Boat         leg3      = new Boat(robot3Object.GetComponent <Robot>());
        BasicSensor  sensor3   = new BasicSensor(robot3Object.GetComponent <Robot>());
        GroundSensor sensor3_2 = new GroundSensor(robot3Object.GetComponent <Robot>());

        text       = Resources.Load <TextAsset>("Texts/Robot 3Actions");
        scriptCode = text.text;
        robot3Object.GetComponent <Robot>().ChangeScriptCode(scriptCode);

        //Robot4
        GameObject robot4Object = robotManager.CreateRobot(-7, -2);

        robotManager.TurnRobotStartingDirection(robot4Object);
        robotManager.TurnRobotStartingDirection(robot4Object);
        BasicArm    tool4   = new BasicArm(robot4Object.GetComponent <Robot>());
        BasicLeg    leg4    = new BasicLeg(robot4Object.GetComponent <Robot>());
        BasicSensor sensor4 = new BasicSensor(robot4Object.GetComponent <Robot>());

        text       = Resources.Load <TextAsset>("Texts/Robot 4Actions");
        scriptCode = text.text;
        robot4Object.GetComponent <Robot>().ChangeScriptCode(scriptCode);

        //Robot5
        GameObject robot5Object = robotManager.CreateRobot(-2, -3);

        robotManager.TurnRobotStartingDirection(robot5Object);
        BasicArm    tool5   = new BasicArm(robot5Object.GetComponent <Robot>());
        SpiderLeg   leg5    = new SpiderLeg(robot5Object.GetComponent <Robot>());
        BasicSensor sensor5 = new BasicSensor(robot5Object.GetComponent <Robot>());

        text       = Resources.Load <TextAsset>("Texts/Robot 5Actions");
        scriptCode = text.text;
        robot5Object.GetComponent <Robot>().ChangeScriptCode(scriptCode);

        //Robot6
        GameObject  robot6Object = robotManager.CreateRobot(4, -1);
        WeldingTool tool6        = new WeldingTool(robot6Object.GetComponent <Robot>());
        SpiderLeg   leg6         = new SpiderLeg(robot6Object.GetComponent <Robot>());
        BasicSensor sensor6      = new BasicSensor(robot6Object.GetComponent <Robot>());
        Scanner     sensor6_2    = new Scanner(robot6Object.GetComponent <Robot>());

        text       = Resources.Load <TextAsset>("Texts/Robot 6Actions");
        scriptCode = text.text;
        robot6Object.GetComponent <Robot>().ChangeScriptCode(scriptCode);

        //Robot7
        GameObject robot7Object = robotManager.CreateRobot(0, -1);

        robotManager.TurnRobotStartingDirection(robot7Object);
        robotManager.TurnRobotStartingDirection(robot7Object);
        robotManager.TurnRobotStartingDirection(robot7Object);
        BasicArm    tool7   = new BasicArm(robot7Object.GetComponent <Robot>());
        SpiderLeg   leg7    = new SpiderLeg(robot7Object.GetComponent <Robot>());
        BasicSensor sensor7 = new BasicSensor(robot7Object.GetComponent <Robot>());

        text       = Resources.Load <TextAsset>("Texts/Robot 7Actions");
        scriptCode = text.text;
        robot7Object.GetComponent <Robot>().ChangeScriptCode(scriptCode);
    }
예제 #6
0
 public void RemoveSensor(BasicSensor sensor)
 {
     foreach (Vector3 direction in sensor.Directions) {
         Vector3Int pos = new Vector3Int (sensor.transform.position + direction);
         sensorSpaces [pos].Remove (sensor);
     }
 }
예제 #7
0
 public void AddSensor(BasicSensor sensor)
 {
     foreach (Vector3 direction in sensor.Directions) {
         Vector3Int pos = new Vector3Int (sensor.transform.position + direction);
         if (!sensorSpaces.ContainsKey (pos)) {
             sensorSpaces [pos] = new List<BasicSensor> ();
         }
         sensorSpaces [pos].Add (sensor);
     }
 }