Exemple #1
0
        public static void Add(TriggerBox p_TriggerBox)
        {
            string type = p_TriggerBox.Type;
            string target = p_TriggerBox.Target;
            //get object from list
            Object point = DataList[target];
            string objectType = point.GetType().ToString(); ;

            switch (objectType)
            {

                case "KismetDataTypes.SpawnPoint":
                     SpawnPoint newObject = (SpawnPoint)point;
                     NPCManager.SpawnObject(newObject.Type, newObject.Position);
                     // Remove the trigger box for a spawn point
                     TriggerboxList.Remove(p_TriggerBox);
                     DataList.Remove(target);
                    break;
                case "KismetDataTypes.PickUpPoint":
                    PickUpPoint newPickUpObject = (PickUpPoint)point;
                    PickUpItemManager.CreatePickUpItem(newPickUpObject.Type, newPickUpObject.Position);
                    TriggerboxList.Remove(p_TriggerBox);
                    DataList.Remove(target);
                    break;

                case "KismetDataTypes.CheckPoint":
                     CheckPoint newcheckpoint = (CheckPoint)point;
                     GV.Player.CheckPoint = newcheckpoint.Position;
                    TriggerboxList.Remove(p_TriggerBox);
                    DataList.Remove(target);
                    break;
                case "KismetDataTypes.Warp":
                    Warp warp = (Warp)point;
                    if (GV.Level.Name == warp.DestinationLevel)
                    {
                        GV.Player.Position = warp.TargetPosition;
                        GV.Player.Velocity = Vector2.Zero;
                    }
                    else // Change the level
                    {
                        // Load and initialise the new level
                        // Reset everything in the Tech Data Manager
                        // as well as the NPC Manager
                        TDManager.Release();
                        NPCManager.sceneObjectsList = new List<Enemy>();
                        GV.Level = GV.ContentManager.Load<Level>("Levels/" + warp.DestinationLevel);
                        GV.Level.Initialise(GV.ContentManager);
                        Camera.WorldRectangle = new Rectangle(0, 0, GV.Level.Width, GV.Level.Height);
                        // Put the player in the new level
                        GV.Player.Position = warp.TargetPosition;
                        GV.Player.Velocity = Vector2.Zero;
                    }
                    break;
                default:
                    Console.WriteLine("Invalid selection in Tech Data Manager");
                    break;
            }
        }
Exemple #2
0
        public static void Add(TriggerBox p_TriggerBox)
        {
            string type = p_TriggerBox.Type;
            string target = p_TriggerBox.Target;
            //get object from list
            Object point = DataList[target];
            string objectType = point.GetType().ToString(); ;

            switch (objectType)
            {

                case "KismetDataTypes.SpawnPoint":
                     SpawnPoint newObject = (SpawnPoint)point;
                     NPCManager.SpawnObject(newObject.Type, newObject.Position);
                     // Remove the trigger box for a spawn point
                     TriggerboxList.Remove(p_TriggerBox);
                     DataList.Remove(target);
                    break;
                case "KismetDataTypes.PickUpPoint":
                    PickUpPoint newPickUpObject = (PickUpPoint)point;
                    PickUpItemManager.CreatePickUpItem(newPickUpObject.Type, newPickUpObject.Position);
                    // Remove the trigger box for a spawn point
                    TriggerboxList.Remove(p_TriggerBox);
                    DataList.Remove(target);
                    break;
                case "KismetDataTypes.Warp":
                    Warp warp = (Warp)point;
                    if (GV.Level.Name == warp.DestinationLevel)
                    {
                        GV.Player.Position = warp.TargetPosition;
                        GV.Player.Velocity = Vector2.Zero;
                    }
                    else
                    {
                        // Add a loading method to change the level and set the player inside it
                    }
                    break;
                default:
                    Console.WriteLine("Invalid selection");
                    break;
            }
        }
Exemple #3
0
 // Save changes
 private void setButton_Click(object sender, EventArgs e)
 {
     game.currentObject.BoundingBox = new Microsoft.Xna.Framework.Rectangle(
                                                    Convert.ToInt32(xPositionTextBox.Text),
                                                    Convert.ToInt32(yPositionTextBox.Text),
                                                    Convert.ToInt32(widthTextBox.Text),
                                                    Convert.ToInt32(heightTextBox.Text));
     game.currentObject.Position = new Vector2(Convert.ToInt32(xPositionTextBox.Text),
                                               Convert.ToInt32(yPositionTextBox.Text));
     game.currentObject.Name = objectName.Text;
     // Add a warp object to the level's list
     if (game.CurrentCodeValue == "Warp")
     {
         Warp warp = new Warp((int)game.currentObject.Position.X, (int)game.currentObject.Position.Y,
                              game.currentObject.BoundingBox.Width, game.currentObject.BoundingBox.Height,
                              warpDestinationLevel.Text, new Vector2(Convert.ToInt32(warpDestinationX.Text),
                              Convert.ToInt32(warpDestinationY.Text)));
         warp.Name = game.currentObject.Name;
         GV.Level.AddWarp(warp);
         Console.WriteLine("Added: " + warp.Name);
     }
     else if (game.CurrentCodeValue == "Spawner")
     {
         SpawnPoint spawner = new SpawnPoint(game.MonsterType, game.currentObject.Name, game.currentObject.Position);
         GV.Level.AddSpawnPoint(spawner);
         Console.WriteLine("Added: " + spawner.Name);
     }
     else if (game.CurrentCodeValue == "Light Source")
     {
         LightSource light = new LightSource((int)game.currentObject.Position.X, (int)game.currentObject.Position.Y,
                                             Convert.ToInt32(lightCentreXTextBox.Text), Convert.ToInt32(lightCentreYTextBox.Text),
                                             Convert.ToInt32(lightRadiusTextBox.Text), Convert.ToInt32(brightnessTextBox.Text));
         light.Name = game.currentObject.Name;
         GV.Level.AddLight(light);
     }
     else if (game.CurrentCodeValue == "Trigger Box")
     {
         TriggerBox trigger = new TriggerBox(triggerBoxTarget.Text, triggerBoxTarget.Text, game.currentObject.BoundingBox);
         trigger.Name = game.currentObject.Name;
         GV.Level.AddTriggerBox(trigger);
     }
 }
Exemple #4
0
        /// <summary>
        /// Removes an object form the level
        /// </summary>
        public void RemoveObject(int x, int y)
        {
            // The area clicked to check for an intersection
            Rectangle remove = new Rectangle(x, y, 2, 2);
            // Remove a spawner
            for (int i = 0; i < NumSpawners; i += 1)
            {
                if (Spawners[i].BoundingBox.Intersects(remove))
                {
                    NumSpawners -= 1;
                    SpawnPoint[] temp = new SpawnPoint[NumSpawners];
                    for (int j = 0; j < i; j += 1)
                    {
                        temp[j] = Spawners[j];
                    }
                    for (int j = i; j < NumSpawners; j += 1)
                    {
                        temp[j] = Spawners[j + 1];
                    }
                    Spawners = temp;
                    return;
                }
            }

            // Remove a Warp Point
            for (int i = 0; i < NumWarps; i += 1)
            {
                if (Warps[i].BoundingBox.Intersects(remove))
                {
                    NumWarps -= 1;
                    Warp[] temp = new Warp[NumWarps];
                    for (int j = 0; j < i; j += 1)
                    {
                        temp[j] = Warps[j];
                    }
                    for (int j = i; j < NumWarps; j += 1)
                    {
                        temp[j] = Warps[j + 1];
                    }
                    Warps = temp;
                    return;
                }
            }

            // Remove a Light Source
            for (int i = 0; i < NumLights; i += 1)
            {
                if (Lights[i].BoundingBox.Intersects(remove))
                {
                    NumLights -= 1;
                    LightSource[] temp = new LightSource[NumLights];
                    for (int j = 0; j < i; j += 1)
                    {
                        temp[j] = Lights[j];
                    }
                    for (int j = i; j < NumLights; j += 1)
                    {
                        temp[j] = Lights[j + 1];
                    }
                    Lights = temp;
                    return;
                }
            }

            // Remove a trigger box
            for (int i = 0; i < NumTriggers; i += 1)
            {
                if (Triggers[i].BoundingBox.Intersects(remove))
                {
                    NumTriggers -= 1;
                    TriggerBox[] temp = new TriggerBox[NumTriggers];
                    for (int j = 0; j < i; j += 1)
                    {
                        temp[j] = Triggers[j];
                    }
                    for (int j = i; j < NumTriggers; j += 1)
                    {
                        temp[j] = Triggers[j + 1];
                    }
                    Triggers = temp;
                    return;
                }
            }
        }
Exemple #5
0
        /// <summary>
        /// Add a trigger box to the level
        /// </summary>
        public void AddTriggerBox(TriggerBox trigger)
        {
            // Check to see if there is already a trigger box with the same
            // name/tag, if so, change it for the new one
            for (int i = 0; i < NumTriggers; i += 1)
            {
                if (Triggers[i].Name == trigger.Name)
                {
                    Triggers[i] = trigger;
                    return;
                }
            }

            // If it really is a new trigger box, then add it to the list
            NumTriggers += 1;
            TriggerBox[] temp = new TriggerBox[NumTriggers];
            for (int i = 0; i < NumTriggers - 1; i += 1)
            {
                temp[i] = Triggers[i];
            }
            temp[NumTriggers - 1] = trigger;
            Triggers = temp;

            TDManager.TriggerboxList.Add(trigger);
        }