public void UnObserverGameObject()
 {
     GameObserver observer = new GameObserver();
     GameObject newGameObject = new GameObject("new game object");
     observer.ObserveGameObject(newGameObject);
     Assert.IsTrue(observer.UnobserveGameObject(newGameObject.Name));
 }
 public void AddPropertyToGameObject()
 {
     GameObject newGameObject = new GameObject("new game object");
     Property newProperty = new Property(PropertyType.String, "new property", "a new value");
     Assert.IsTrue(newGameObject.AddProperty(newProperty));
     Assert.IsTrue(newGameObject.DoesPropertyExist(newProperty.Name));
 }
 public void GetPropertyFromGameObject()
 {
     GameObject newGameObject = new GameObject("new game object");
     Property newProperty = new Property(PropertyType.String, "new property", "a new value");
     newGameObject.AddProperty(newProperty);
     Assert.IsTrue(newProperty.Value == newGameObject.GetProperty(newProperty.Name).Value);
 }
 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;
 }
 public bool ObserveGameObject(GameObject newGameObject)
 {
     bool doesObjectExist = _objectList.ContainsKey(newGameObject.Name);
     if (doesObjectExist)
     {
         return false;
     }
     _objectList.Add(newGameObject.Name, newGameObject);
     return true;
 }
        public void InvalidReceiveMessage_SetProperty()
        {
            GameObject newGameObject = new GameObject("new game object");

            Message setMessage = new Message(newGameObject.Name, MessageAction.Set, "a property name that is wrong or doesn't exist", "a new value", PropType.String);
            Response response = newGameObject.ReceiveMessage(setMessage);
            Assert.IsFalse(response.Status);
            Assert.IsTrue(response.Value == "Property name does not exist");
            Assert.IsTrue(response.PropType == PropType.Error);
        }
 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();
 }
        public void SendMessageToMissingObject()
        {
            GameObserver observer = new GameObserver();
            GameObject newGameObject = new GameObject("new game object");

            Message message = new Message(newGameObject.Name, MessageAction.Add, "new property", "a value", PropType.String);
            Response response = observer.SendMessage(message);
            Assert.IsFalse(response.Status);
            Assert.IsTrue(response.Value == "GameObject is not being observed");
            Assert.IsTrue(response.PropType == PropType.Error);
        }
 public void SaveDataToDrive()
 {
     GameObject gameObject = new GameObject("new game object");
     Property newProperty = new Property(PropertyType.String, "new property", "new value");
     gameObject.AddProperty(newProperty);
     GameObserver Observer = GameObserver.Instance;
     Observer.ObserveGameObject(gameObject, ObjectStatus.Active);
     GameData gameData = new GameData(Observer.GetObserverData());
     GameArchive Archive = GameArchive.Instance;
     Archive.SaveData(gameData, "C:\\GameCraftData\\testgamedata.gcd");
     Assert.IsTrue(true);
 }
        public void InvalidReceiveMesssage_RemoveProperty()
        {
            GameObject newGameObject = new GameObject("new game object");
            Property newProperty = new Property(PropertyType.String, "new property", "a value");
            newGameObject.AddProperty(newProperty);

            Message removeMessage = new Message(newGameObject.Name, MessageAction.Remove, "a name this is wrong or missing");
            Response response = newGameObject.ReceiveMessage(removeMessage);
            Assert.IsFalse(response.Status);
            Assert.IsTrue(response.Value == "Property name does not exist");
            Assert.IsTrue(response.PropType == PropType.Error);
        }
 public void SendMessageToActiveObject()
 {
     GameObserver observer = new GameObserver();
     GameObject newGameObject = new GameObject("new game object");
     observer.ObserveGameObject(newGameObject);
     Message message = new Message(newGameObject.Name, MessageAction.Add, "new property", "a value", PropType.String);
     Response response = observer.SendMessage(message);
     Assert.IsTrue(response.Status);
     Assert.IsTrue(response.Property == "new property");
     Assert.IsTrue(response.Value == "a value");
     Assert.IsTrue(response.PropType == PropType.String);
 }
        public void InvalidReceiveMessage_AddProperty()
        {
            GameObject newGameObject = new GameObject("new game object");
            Property newProperty = new Property(PropertyType.String, "new property", "a new value");
            newGameObject.AddProperty(newProperty);

            Message newMessage = new Message(newGameObject.Name, MessageAction.Add, "new property", "a value", PropType.String);
            Response response = newGameObject.ReceiveMessage(newMessage);

            Assert.IsFalse(response.Status);
            Assert.IsTrue(response.Value == "Property name already exists");
            Assert.IsTrue(response.Property == newProperty.Name);
            Assert.IsTrue(response.PropType == PropType.Error);
        }
        public GameObject CloneGameObject()
        {
            GameObject newGameObject = new GameObject(Name);
            foreach (KeyValuePair<string, Property> prop in _properties)
            {
                newGameObject.AddProperty(prop.Value);
            }
            if (Image != null)
            {
                newGameObject.SetImage(Image.ConvertBinaryToImage());
            }

            return newGameObject;
        }
Beispiel #14
0
        private void btn_DeleteGameObject_Click(object sender, EventArgs e)
        {
            string objectName = txtBox_GameObjectName.Text;

            if (string.IsNullOrWhiteSpace(objectName))
            {
                MessageBox.Show("Game Object's name cannot be empty", "Empty Game Object Name", MessageBoxButtons.OK);
                return;
            }

            if (!Observer.DoesGameObjectNameExist(txtBox_GameObjectName.Text))
            {
                MessageBox.Show("GameObject name " + txtBox_GameObjectName.Text + " does not exist");
                return;
            }
            DialogResult result = MessageBox.Show("Are you sure you want to delete " + objectName + "?", "Delete Game Object",
                MessageBoxButtons.OKCancel);
            switch (result)
            {
                case DialogResult.OK:
                    bool observe = Observer.UnobserveGameObject(txtBox_GameObjectName.Text);
                    if (!observe)
                    {
                        MessageBox.Show("Nope", "Nope", MessageBoxButtons.OK);
                    }
                    RemoveGameObjectFromDisplay(txtBox_GameObjectName.Text);
                    txtBox_GameObjectName.Text = string.Empty;
                    listBox_GameObjects.SelectedItem = null;
                    selectedGameObject = null;
                    selectedProperty = null;
                    DisableGamePropertyEntry();
                    DisableGameObjectEntry();
                    break;
                case DialogResult.Cancel:
                    return;
            }
        }
        private Response SaveTemplate(GameObject gameObject)
        {
            string defaultName = "";
            switch (DefaultFileNames.ContainsKey(gameObject.Name))
            {
                case true:
                    defaultName = DefaultFileNames[gameObject.Name];
                    break;
                case false:
                    defaultName = gameObject.Name;
                    break;

            }

            return gameFileDialog.SaveFile(gameObject, "got", "Game Object Template", defaultName);
        }
 public void SetPropertyOnGameObject()
 {
     GameObject newGameObject = new GameObject("new game object");
     Property newProperty = new Property(PropertyType.String, "new property", "a new value");
     newGameObject.AddProperty(newProperty);
     string newPropValue = "even newer value ";
     Assert.IsTrue(newGameObject.SetProperty(newProperty.Name, newPropValue, newProperty.Type ));
     Assert.IsTrue(newGameObject.GetProperty(newProperty.Name).Value == newPropValue);
 }
        public void ReceiveMessage_SetProperty()
        {
            GameObject newGameObject = new GameObject("new game object");
            Property newProperty = new Property(PropertyType.String, "new property", "a value");
            newGameObject.AddProperty(newProperty);

            Message setMessage = new Message(newGameObject.Name, MessageAction.Set, newProperty.Name,"a new value", PropType.String);
            Response response = newGameObject.ReceiveMessage(setMessage);
            Assert.IsTrue(response.Status);
            Assert.IsTrue(response.Property == newProperty.Name);
            Assert.IsTrue(response.Value != newProperty.Value);
            Assert.IsTrue(response.Value == newGameObject.GetProperty(newProperty.Name).Value);
        }
        public void ReceiveMessage_RemoveProperty()
        {
            GameObject newGameObject = new GameObject("new game object");
            Property newProperty = new Property(PropertyType.String, "new property", "a value");
            newGameObject.AddProperty(newProperty);

            Message removeMessage = new Message(newGameObject.Name,MessageAction.Remove, newProperty.Name);
            Response response = newGameObject.ReceiveMessage(removeMessage);
            Assert.IsTrue(response.Status);
            Assert.IsTrue(response.Property == newProperty.Name);
            Assert.IsTrue(response.Value == "none");
            Assert.IsFalse(newGameObject.DoesPropertyExist(newProperty.Name));
        }
Beispiel #19
0
 private void RemoveGameObjectFromDisplay(GameObject gameObject)
 {
     displayObjectList.Remove(gameObject.Name);
     listBox_GameObjects.Items.Remove(gameObject.Name);
 }
 private void listBox_Templates_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (listBox_Templates.SelectedItem == null)
     {
         DisableGameObjectControls();
         return;
     }
     string objectName = listBox_Templates.SelectedItem.ToString();
     if (arePropFieldsActive)
     {
         SavePropertyFields();
     }
     ClearPropertyFields();
     EnableGameObjectControls();
     selectedObject = currentTemplates[objectName];
     DisplayObjectPropertiers(selectedObject);
     txtBox_TemplateName.Text = selectedObject.Name;
 }
 public NewGameObjectProperty(GameObject gameObject)
 {
     InitializeComponent();
     currentGameObject = gameObject;
 }
 public void ObserveGameObject()
 {
     GameObserver observer = new GameObserver();
     GameObject newGameObject = new GameObject("new game object");
     Assert.IsTrue(observer.ObserveGameObject(newGameObject));
 }
Beispiel #23
0
        private void listObjectBox_OnSelect(object sender, EventArgs args)
        {
            if (listBox_GameObjects.SelectedItem == null)
            {
                DisableGameObjectEntry();
                DisableGamePropertyEntry();
                listBox_Properties.Items.Clear();
                displayObjectPropertiesList = new Dictionary<string, Property>();
                selectedGameObject = null;
                selectedProperty = null;
                return;
            }
            string gameObjectName = (string)listBox_GameObjects.SelectedItem;
            if (selectedGameObject != null && gameObjectName == selectedGameObject.Name && selectedProperty != null)
            {
                listBox_Properties.SelectedItem = selectedProperty.Name;
                return;
            }
            DisableGamePropertyEntry();
            EnableGameObjectEntry();
            txtBox_GameObjectName.Text = gameObjectName;

            GameObject gameObject = displayObjectList[gameObjectName];
            selectedGameObject = gameObject;
            ClearPropertyFields();
            FillPropertyBox(gameObject.GetAllProperties());
        }
Beispiel #24
0
 private void AddGameObjectToDisplay(GameObject gameObject)
 {
     displayObjectList.Add(gameObject.Name, gameObject);
     listBox_GameObjects.Items.Add(gameObject.Name);
 }
 public void ReceiveMessage_AddProperty()
 {
     GameObject newGameObject = new GameObject("new game object");
     Message newMessage = new Message(newGameObject.Name,MessageAction.Add, "new property", "a value", PropType.String);
     Response response = newGameObject.ReceiveMessage(newMessage);
     Assert.IsTrue(response.Status);
     Assert.IsTrue(newGameObject.DoesPropertyExist("new property"));
     Assert.IsTrue("a value" == newGameObject.GetProperty("new property").Value);
 }
 private void DisplayObjectPropertiers(GameObject gameObject)
 {
     currentProperties = gameObject.GetAllProperties();
     listBox_Properties.Items.Clear();
     foreach (KeyValuePair<string, Property> pair in currentProperties)
     {
         listBox_Properties.Items.Add(pair.Key);
     }
 }