/// <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); }
/// <summary> /// Überprüft alle RobotParts auf ihre TerrainCompatability. /// Wenn die TerrainTypen mit dem TerrainTypen des übergebenen tiles übereinstimmen, wird true, sonst wird false zurückgegeben. /// </summary> /// <param name="tile"></param> /// <returns></returns> public bool CanWalkOn(GroundTile tile) { bool canWalk = false; foreach (RobotPart part in parts) { if (part is BasicLeg) { BasicLeg leg = part as BasicLeg; if (leg.TerrainCompatability == tile.terrainType) { canWalk = true; break; } } else if (part is SpiderLeg) { SpiderLeg leg = part as SpiderLeg; if (leg.TerrainCompatability == tile.terrainType) { canWalk = true; break; } } else if (part is Boat) { Boat leg = part as Boat; if (leg.TerrainCompatability == tile.terrainType) { canWalk = true; break; } } } return(canWalk); }
/// <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); }