Example #1
0
        private void CopyDecor()
        {
            if (listBox.SelectedIndex == -1)
            {
                return;
            }

            //Make a new piece of decor exactly like the one we have selected:
            Decor selectedDecor = (Decor)game.map.decor[listBox.SelectedIndex];
            Decor newDecor      = new Decor(selectedDecor.position, selectedDecor.imagePath, selectedDecor.layerDepth);

            //Load it:
            newDecor.Load(game.Content, newDecor.imagePath);

            //Add to our list:
            game.map.decor.Add(newDecor);
            SetListBox(game.map.decor, false);
        }
Example #2
0
        //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        //
        // IMPORTANT FUNCTION!! WHENEVER YOU ADD NEW GAMEOBJECTS TO YOUR GAME YOU'LL NEED TO ADD THEM HERE TO THE EDITOR!!!!!!
        //
        //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        private void addButton_Click(object sender, EventArgs e) //ADD NEW OBJECT CONSTRUCTORS IN THIS FUNCTION!!!
        {
            if (objectTypes.SelectedIndex == -1)
            {
                return;
            }

            if (mode == CreateMode.Objects)
            {
                ObjectType selectedObject = (ObjectType)objectTypes.Items[objectTypes.SelectedIndex];
                GameObject newObject      = null;

                //IMPORTANT: CREATE NEW GAME OBJECTS IN THIS IF STATEMENT BLOCK!
                //Each object you want to add needs to be specifically typed with its own constructor (new Enemy, new PowerUp etc.):
                if (selectedObject == ObjectType.Enemy)
                {
                    newObject = new Enemy(Vector2.Zero);
                }

                else if (selectedObject == ObjectType.PowerUp)
                {
                    newObject = new PowerUp();
                }

                else if (selectedObject == ObjectType.IslamicEnemy)
                {
                    newObject = new IslamicEnemy();
                }

                else if (selectedObject == ObjectType.EnemyFifthLevel)
                {
                    newObject = new EnemyFifthLevel(Vector2.Zero);
                }

                else if (selectedObject == ObjectType.IslamicEnemyFifthLevel)
                {
                    newObject = new IslamicEnemyFifthLevel();
                }

                if (newObject == null)
                {
                    return; //No valid object created.
                }
                //Load the object and add it into our list:
                newObject.Load(game.Content);
                game.objects.Add(newObject);

                placingItem = true;
                FocusGameWindow();

                SetListBox(game.objects, false);
            }
            else if (mode == CreateMode.Decor)
            {
                Decor newDecor = new Decor();
                newDecor.imagePath = "decorplaceholder"; //Default image until we load the one we want.
                newDecor.Load(game.Content, newDecor.imagePath);
                game.map.decor.Add(newDecor);

                placingItem = true;
                SetListBox(game.map.decor, false);
                FocusGameWindow();
            }
        }