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);
        }
Beispiel #2
0
        public void UnObserverGameObject()
        {
            GameObserver observer      = new GameObserver();
            GameObject   newGameObject = new GameObject("new game object");

            observer.ObserveGameObject(newGameObject);
            Assert.IsTrue(observer.UnobserveGameObject(newGameObject.Name));
        }