Esempio n. 1
0
        public void AddObjectToLvl(LevelObject lo, bool remove)
        {
            if (!remove)
            {
                worldObjects.Add(lo.Name, lo);
                if (ObjectInstanceAdded != null)
                {
                    LevelEventArgs e = new LevelEventArgs();
                    e.lo = lo;
                    ObjectInstanceAdded(this, e);
                }
            }
            else
            {
                worldObjects.Remove(lo.Name);
                if (ObjectInstanceRemoved != null)
                {
                    LevelEventArgs e = new LevelEventArgs();
                    e.lo = lo;
                    ObjectInstanceRemoved(this, e);
                }

            }
        }
Esempio n. 2
0
 public void OnObjectTypeRemoved(object sender, LevelEventArgs e)
 {
     DirtyData(true);
 }
Esempio n. 3
0
 public void OnObjectTerrainAdded(object sender, LevelEventArgs e)
 {
     rdr_renderPane.AddTerrainToScene(e.terr);
     DirtyData(true);
 }
Esempio n. 4
0
 public void OnObjectInstanceAdded(object sender, LevelEventArgs e)
 {
     rdr_renderPane.AddObjectInstanceToScene(e.lo, m_data);
     DirtyData(true);
 }
Esempio n. 5
0
        public void AddObjectTypeToPalette(LevelObjectType lot, bool remove)
        {
            if (!remove)
            {
                bool done = false;
                while (!done)
                {
                    try
                    {
                        objectPalette.Add(lot.Name, lot);
                        done = true;
                    }
                    catch (ArgumentException)
                    {
                        /* Given name is already taken, try to create a new name */
                        String name = lot.Name.Substring(0, lot.Name.Length-1);
                        name += GetNextTypeIdx().ToString();
                        lot.Name = name;
                    }

                }

                if (ObjectTypeAdded != null)
                {
                    LevelEventArgs e = new LevelEventArgs();
                    e.lot = lot;
                    ObjectTypeAdded(this, e);
                }
            }
            else
            {
                objectPalette.Remove(lot.Name);
                if (ObjectTypeRemoved != null)
                {
                    LevelEventArgs e = new LevelEventArgs();
                    e.lot = lot;
                    ObjectTypeRemoved(this, e);
                }

            }
        }
Esempio n. 6
0
        public void AddTerrainToLvl(LevelTerrain terr, bool remove)
        {
            if (!remove)
            {

                bool found = true;
                while (found == true)
                {
                    found = false;
                    foreach (KeyValuePair<String, LevelTerrain> kv in terrainObjects)
                    {
                        if (kv.Key == terr.Name)
                        {
                            /* find a new name that doesn't conflict */
                            int id = Convert.ToInt32(terr.Name.Substring(terr.Name.Length - 1));
                            terr.Name = terr.Name.Substring(0, terr.Name.Length - 1) + id.ToString();
                            found = true;
                            break;
                        }

                    }
                }

                terrainObjects.Add(terr.Name, terr);
                if (ObjectTerrainAdded != null)
                {
                    LevelEventArgs e = new LevelEventArgs();
                    e.terr = terr;
                    ObjectTerrainAdded(this, e);
                }
            }
            else
            {
                terrainObjects.Remove(terr.Name);
                if (ObjectTerrainRemoved != null)
                {
                    LevelEventArgs e = new LevelEventArgs();
                    e.terr = terr;
                    ObjectTerrainRemoved(this, e);
                }
            }
        }