private void SaveSelectedGameObject()
        {
            string objectName          = selectedGameObject.Name;
            bool   doesGameObjectExist = Observer.DoesGameObjectNameExist(txtBox_GameObjectName.Text);

            if (string.IsNullOrWhiteSpace(objectName))
            {
                MessageBox.Show("Game Object's name cannot be empty", "Empty Game Object Name", MessageBoxButtons.OK);
                return;
            }
            if (objectName != txtBox_GameObjectName.Text)
            {
                if (doesGameObjectExist)
                {
                    MessageBox.Show("GameObject name " + txtBox_GameObjectName.Text + " already exists");
                    return;
                }
                GameObject clonedObject = selectedGameObject.CloneGameObject();
                clonedObject.Name = txtBox_GameObjectName.Text;
                Observer.UnobserveGameObject(objectName);
                Observer.ObserveGameObject(clonedObject);
                RemoveGameObjectFromDisplay(objectName);
                AddGameObjectToDisplay(clonedObject);
            }
            Observer.UnobserveGameObject(objectName);
            Observer.ObserveGameObject(selectedGameObject);
        }
 private bool AddGameObject(GameObject gameObject)
 {
     if (Observer.DoesGameObjectNameExist(gameObject.Name))
     {
         return(false);
     }
     Observer.ObserveGameObject(gameObject);
     listBox_Templates.Items.Add(gameObject.Name);
     currentTemplates.Add(gameObject.Name, gameObject);
     return(true);
 }
Beispiel #3
0
 private void btn_Create_Click(object sender, EventArgs e)
 {
     if (Observer.DoesGameObjectNameExist(txtBox_Name.Text))
     {
         MessageBox.Show("GameObject Name " + txtBox_Name.Text + " already exists", "Name exists", MessageBoxButtons.OK);
         return;
     }
     ReturnGameObject = new GameObject(txtBox_Name.Text);
     ValidObject      = true;
     this.Close();
 }