コード例 #1
0
ファイル: Level.cs プロジェクト: sogatron/Kismet
        /// <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;
                }
            }
        }
コード例 #2
0
ファイル: ObjectEditor.cs プロジェクト: dsawyer/Kismet
 // 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);
     }
 }
コード例 #3
0
ファイル: Level.cs プロジェクト: sogatron/Kismet
        /// <summary>
        /// Adds a warp point to the level
        /// </summary>
        public void AddWarp(Warp warp)
        {
            // Check to see if there is already a warp with the same
            // name/tag, if so, change it for the new one
            for (int i = 0; i < NumWarps; i += 1)
            {
                if (Warps[i].Name == warp.Name)
                {
                    Warps[i] = warp;
                    return;
                }
            }

            // If it really is a new warp, then add it to the list
            NumWarps += 1;
            Warp[] temp = new Warp[NumWarps];
            for (int i = 0; i < NumWarps - 1; i += 1)
            {
                temp[i] = Warps[i];
            }
            temp[NumWarps - 1] = warp;
            Warps = temp;

            TDManager.DataList.Add(warp.Name, warp);
        }