Ejemplo n.º 1
0
    public GameObject InsertButton(int index, RobotStateObject rso)
    {
        GameObject button = AddButton(rso);

        button.transform.SetSiblingIndex(index);
        return(button);
    }
Ejemplo n.º 2
0
    public GameObject ChangeButton(int index, RobotStateObject rso)
    {
        GameObject button = AddButton(rso);

        button.transform.SetSiblingIndex(index);
        DeleteButton();
        return(button);
    }
 public void OnClickClear()
 {
     if (currentBehaviorObject != null)
     {
         currentBehaviorObject.listOfRobotStateObjects.Clear();
     }
     ma2MaComManager.ma2UIComManager.uI2MaComDirector.panelBehaviorDirector.ClearAllButtons();
     currentRobotStateObject = null;
 }
Ejemplo n.º 4
0
 public void SpawnRobot(RobotStateObject rso)
 {
     Destroy(newRobot);
     newRobot = new GameObject("newRobot");
     ma2MaComManager.modulesManager.SpawnModules(rso.listOfModuleStateObjects, newRobot);
     ma2MaComManager.connectionManager.SpawnConnections(rso.listOfConnectionObjects, newRobot.transform);
     dragMode.status = true;
     nodeOnNewRobot  = null;
 }
    public void OnClickAddState()
    {
        RobotStateObject rso = ma2MaComManager.robotManager.GetRobotStateObject();

        rso.name = Guid.NewGuid().ToString();
        currentBehaviorObject.listOfRobotStateObjects.Add(rso);
        GameObject button = ma2MaComManager.ma2UIComManager.uI2MaComDirector.panelBehaviorDirector.AddButton(rso);

        rso.button = button;
    }
Ejemplo n.º 6
0
    public GameObject AddButton(RobotStateObject rso)
    {
        GameObject newButton = Instantiate(buttonRobotStateObject) as GameObject;
        ButtonRobotStateObjectDirector buttonRobotStateObjectDirector = newButton.GetComponent <ButtonRobotStateObjectDirector> ();

        buttonRobotStateObjectDirector.nameLabel.text   = "State: \n" + rso.name;
        buttonRobotStateObjectDirector.robotStateObject = rso;
        buttonRobotStateObjectDirector.button.onClick.AddListener(() => OnButtonClick(buttonRobotStateObjectDirector));
        newButton.transform.SetParent(panelBehaviorList);
        scrollRect.normalizedPosition = new Vector2(0f, 0f);
        return(newButton);
    }
Ejemplo n.º 7
0
    public void LoadConfiguration(string fileContent)
    {
        XmlSerializer serializer = new XmlSerializer(typeof(RobotStateObject));

        XmlReaderSettings settings = new XmlReaderSettings();

        // No settings need modifying here

        using (StringReader textReader = new StringReader(fileContent)) {
            using (XmlReader xmlReader = XmlReader.Create(textReader, settings)) {
                RobotStateObject rso = serializer.Deserialize(xmlReader) as RobotStateObject;
                StartCoroutine(ma2MaComManager.robotManager.ReplaceRobot(rso));
            }
        }
    }
    public IEnumerator PlayRobotStateObjectAndWait(RobotStateObject rso)
    {
        ma2MaComManager.robotManager.SetRobotState(rso);
        yield return(new WaitForSeconds(rso.period));

        if (rso.button != null)
        {
            rso.button.GetComponent <ButtonRobotStateObjectDirector> ().SetSeletedOrNot(false);
        }
        robotStateObjectIndex++;
        if (robotStateObjectIndex == currentBehaviorObject.listOfRobotStateObjects.Count)
        {
            robotStateObjectIndex = 0;
        }
        reachRobotStateObject = true;
    }
    public void OnClickInsertState()
    {
        int index = currentBehaviorObject.listOfRobotStateObjects.IndexOf(currentRobotStateObject);

        if (index == -1)
        {
            ma2MaComManager.ma2UIComManager.uI2MaComDirector.statusBarDirector.SetTempTextMessage("Cannot insert state: No state is selected.");
        }
        else
        {
            RobotStateObject rso = ma2MaComManager.robotManager.GetRobotStateObject();
            rso.name = Guid.NewGuid().ToString();
            currentBehaviorObject.listOfRobotStateObjects.Insert(index, rso);
            GameObject button = ma2MaComManager.ma2UIComManager.uI2MaComDirector.panelBehaviorDirector.InsertButton(index, rso);
            rso.button = button;
        }
    }
Ejemplo n.º 10
0
    public void InsertConfiguration(File file, string fileContent)
    {
        XmlSerializer serializer = new XmlSerializer(typeof(RobotStateObject));

        XmlReaderSettings settings = new XmlReaderSettings();

        // No settings need modifying here

        using (StringReader textReader = new StringReader(fileContent)) {
            using (XmlReader xmlReader = XmlReader.Create(textReader, settings)) {
                RobotStateObject rso = serializer.Deserialize(xmlReader) as RobotStateObject;
                ma2MaComManager.robotManager.SpawnRobot(rso);
            }
        }

        ma2MaComManager.robotManager.currentConfigurationID = file.configurationID;
    }
Ejemplo n.º 11
0
    public RobotStateObject GetRobotStateObject(bool withConnection = false, bool forConfiguration = false)
    {
        RobotStateObject rso = new RobotStateObject();

        rso.listOfModuleStateObjects = ma2MaComManager.modulesManager.GetAllModuleStateObjects(forConfiguration);
        if (withConnection)
        {
            rso.listOfConnectionObjects = ma2MaComManager.connectionManager.GetAllConnectionObjects();
        }
        rso.anchorModuleName = ma2MaComManager.modulesManager.anchorModule.name;
        foreach (ModuleStateObject mso in rso.listOfModuleStateObjects)
        {
            if (rso.period < mso.period)
            {
                rso.period = mso.period;
            }
        }
        return(rso);
    }
Ejemplo n.º 12
0
    public IEnumerator ReplaceRobot(RobotStateObject rso)
    {
        robotPosition = GetRobotPosition();
        ma2MaComManager.modulesManager.Clear(false);

        yield return(new WaitForSeconds(2f));

        ma2MaComManager.modulesManager.SpawnModules(rso.listOfModuleStateObjects);
        yield return(new WaitForSeconds(0.5f));

        GameObject m = ma2MaComManager.modulesManager.FindModuleWithName(rso.anchorModuleName, robot);

        ma2MaComManager.modulesManager.SetAnchorModule(m);

        yield return(new WaitForSeconds(3f));

        ma2MaComManager.modulesManager.SetAllModuleMode(ModuleModeController.ModuleMode.Edit);
        Vector3 offset = robotPosition - GetRobotPosition();

        ma2MaComManager.modulesManager.MoveAllModulesByOffset(offset);

        ma2MaComManager.connectionManager.SpawnConnections(rso.listOfConnectionObjects, robot);
    }
 public void OnClickDeleteState()
 {
     currentBehaviorObject.listOfRobotStateObjects.Remove(currentRobotStateObject);
     ma2MaComManager.ma2UIComManager.uI2MaComDirector.panelBehaviorDirector.DeleteButton();
     currentRobotStateObject = null;
 }
 public void SetCurrentRobotStateObject(RobotStateObject rso)
 {
     currentRobotStateObject = rso;
 }
Ejemplo n.º 15
0
 public void SetRobotState(RobotStateObject rso, bool reset = false)
 {
     ma2MaComManager.modulesManager.SetAllModuleStateObjects(rso.listOfModuleStateObjects, reset);
 }
Ejemplo n.º 16
0
 public void TakeSnapshot()
 {
     snapshotRSO   = GetRobotStateObject(true);
     robotPosition = GetRobotPosition();
 }