Exemple #1
0
 public Cel(Enums.Object typeCel, int x, int y)
 {
     this._typeCel  = typeCel;
     _powerUpInCell = null;
     _locationX     = x;
     _locationY     = y;
 }
Exemple #2
0
        public List <Map> LoadAllMaps()
        {
            try
            {
                PrepareConnection();
                Query = "SELECT * FROM Map";
                OpenConnection();

                SQLiteDataReader reader = Command.ExecuteReader();

                List <Map> Maps = new List <Map>();

                while (reader.Read())
                {
                    Maps.Add(new Map(Convert.ToInt32(reader["CellSize"]),
                                     Convert.ToInt32(reader["MapSize"]),
                                     Convert.ToInt32(reader["AmountOfBots"]), true));
                }

                List <Cel> Cells = new List <Cel>();

                for (int i = 0; i < 10; i++)
                {
                    Query = "SELECT * FROM Cell WHERE `Map_ID` = " + i.ToString();
                    OpenConnection();

                    reader = Command.ExecuteReader();

                    while (reader.Read())
                    {
                        string       typestring = Convert.ToString(reader["Type"]);
                        Enums.Object type       = (Enums.Object)Enum.Parse(typeof(Enums.Object), typestring);
                        int          x          = Convert.ToInt32(reader["X"]);
                        int          y          = Convert.ToInt32(reader["Y"]);
                        Cells.Add(new Cel(type,
                                          x,
                                          y));
                    }

                    if (Cells.Count != 0)
                    {
                        Maps[i].SetCells(new List <Cel>(Cells));
                    }

                    Cells.Clear();
                }

                CloseConnection();

                if (Maps.Count == 0)
                {
                    return(null);
                }
                else
                {
                    return(Maps);
                }
            }
            catch (Exception e)
            {
                string exception = e.ToString();

                return(null);
            }
        }
Exemple #3
0
 public void SetObject(Enums.Object typeCel)
 {
     this._typeCel = typeCel;
 }
Exemple #4
0
 /// <summary>
 /// Replaces the object of a cel in the current man.
 /// </summary>
 /// <param name="typeCel">The new object of the cell</param>
 /// <param name="x">The x coördinate of the cell</param>
 /// <param name="y">The y coördinate of the cell</param>
 public void PlaceObject(Enums.Object typeCel, int x, int y)
 {
     _maps[_currentMap].PlaceObject(typeCel, x, y);
 }