public override Statement generateStatementFromUI(GameObject commandContainer) { MoveStatement1 moveStatement = new MoveToJ1(); BruteMove bruteStatement = new BruteMoveToJ1(); Statement defaultStatement = new MoveToL1(); bool isMoveStatement = true; //also the below toggle suction is not needed for NXT robot /* * foreach (Transform child in commandContainer.transform) * { * if (child.name.StartsWith("ToggleSuction")) * { * ToggleSuction1 toggleSuctionCommand = new ToggleSuction1(); * if (child.name.Contains("false")) * { * toggleSuctionCommand.isSuctionEnabled = false; * } * if (child.name.Contains("true")) * { * toggleSuctionCommand.isSuctionEnabled = true; * } * return toggleSuctionCommand; * isMoveStatement = false; * } * } */ //Deciding on statement type /* foreach (Transform child in commandContainer.transform) * { * if (child.name.StartsWith("ClawUp")) * { * ClawUp clawupCommand = new ClawUp(); * if (child.name.Contains("false")) * { * clawupCommand.isClawUp = false; * } * if (child.name.Contains("true")) * { * clawupCommand.isClawUp = true; * } * return clawupCommand; * isMoveStatement = false; * } * } */ foreach (Transform child in commandContainer.transform) { if (child.name.StartsWith("Brute")) { List <Toggle> toggles = new List <Toggle>(); commandContainer.GetComponentsInChildren <Toggle>(toggles); List <Transform> childTransforms = new List <Transform>(); commandContainer.GetComponentsInChildren <Transform>(childTransforms); foreach (Transform childTransform in childTransforms) { if (childTransform.name.Contains(movementTypeSelector.nameIdentifier())) { bruteStatement = movementTypeSelector.getBruteMoveFromUI(childTransform.gameObject); } else if (childTransform.name.Contains(coordinateSelector.nameIdentifier())) { bruteStatement.target = coordinateSelector.getCoordinateValues(childTransform.gameObject); } } //Returning bruteStatement bruteType = false; //countbruteType--; //Debug Debug.Log("Brute found in generateStatementFromUI"); isMoveStatement = false; return(bruteStatement); } if (child.name.StartsWith("Move")) { List <Toggle> toggles = new List <Toggle>(); commandContainer.GetComponentsInChildren <Toggle>(toggles); List <Transform> childTransforms = new List <Transform>(); commandContainer.GetComponentsInChildren <Transform>(childTransforms); foreach (Transform childTransform in childTransforms) { if (childTransform.name.Contains(movementTypeSelector.nameIdentifier())) { moveStatement = movementTypeSelector.getMoveStatementFromUI(childTransform.gameObject); } else if (childTransform.name.Contains(coordinateSelector.nameIdentifier())) { moveStatement.target = coordinateSelector.getCoordinateValues(childTransform.gameObject); } } //Returning moveStatement Debug.Log("Move found in generateStatementFromUI"); return(moveStatement); } //ClawUp Command if (child.name.StartsWith("Toggle")) { ClawUp clawupCommand = new ClawUp(); if (child.name.Contains("false")) { clawupCommand.isClawUp = false; } if (child.name.Contains("true")) { clawupCommand.isClawUp = true; } //Returning ClawUp return(clawupCommand); isMoveStatement = false; } } /* if(isMoveStatement) * { * List<Toggle> toggles = new List<Toggle>(); * commandContainer.GetComponentsInChildren<Toggle>(toggles); * * List<Transform> childTransforms = new List<Transform>(); * commandContainer.GetComponentsInChildren<Transform>(childTransforms); * foreach (Transform childTransform in childTransforms) * { * * if (childTransform.name.Contains(movementTypeSelector.nameIdentifier())) * { * moveStatement = movementTypeSelector.getMoveStatementFromUI(childTransform.gameObject); * } * else if (childTransform.name.Contains(coordinateSelector.nameIdentifier())) * { * moveStatement.target = coordinateSelector.getCoordinateValues(childTransform.gameObject); * } * * } * //Returning moveStatement * Debug.Log("Move found in generateStatementFromUI"); * return moveStatement; * } */ //Returning defaultStatement //Debug Debug.Log("Default found in generateStatementFromUI"); return(defaultStatement); }