Exemple #1
0
        /// <summary>
        /// Get a task to do some work
        /// </summary>
        /// <param name="caste"></param>
        /// <returns>null, if the queue is empty</returns>
        public Task GetTask(string caste)
        {
            if (caste == Consts.Collector && collectorQ.Any())
            {
                return(collectorQ.Dequeue());
            }
            else if (caste == Consts.Hunter && Insects.Any())
            {
                return(new InsectTask(Insects.First()));
            }

            return(null);
        }
Exemple #2
0
        public IHttpActionResult DeleteInsects(int id)
        {
            Insects insects = db.Insects.Find(id);

            if (insects == null)
            {
                return(NotFound());
            }

            db.Insects.Remove(insects);
            db.SaveChanges();

            return(Ok(insects));
        }
Exemple #3
0
 public void OnInteraction(Player player)
 {
     Debug.Log("Bag : This is a bag of " + objectType + " .");
     if (player.selectedObject == null)
     {
         var seed = new Insects(objectType, objectSprite);
         seed.selected();
         player.setSelectedObject(seed);
     }
     else if (player.selectedObject.getName() == this.objectType)
     {
         player.selectedObject.deSelected();
         player.setSelectedObject(null);
     }
 }
        private async Task LoadNorthData()
        {
            Insects.Clear();
            BookCount   = 0;
            MuseumCount = 0;

            var normalAnimals = await CommonDataService.GetAllInsects(CommonDataService.Hemisphere.North);

            //BookCount = bookCount;
            //MuseumCount = museumCount;
            foreach (var item in normalAnimals)
            {
                Insects.Add(item);
            }
        }
Exemple #5
0
        private void LoadNorthData()
        {
            Insects.Clear();
            BookCount   = 0;
            MuseumCount = 0;

            var normalAnimals = CommonDataService.GetAllInsects(out int bookCount, out int museumCount, CommonDataService.Hemisphere.North);

            BookCount   = bookCount;
            MuseumCount = museumCount;
            foreach (var item in normalAnimals)
            {
                Insects.Add(item);
            }
        }
Exemple #6
0
        public void ReportInsect(Insect insect)
        {
            if (Insects.Contains(insect) && insect.CurrentEnergy > 0)
            {
                return;
            }

            if (insect.CurrentEnergy <= 0)
            {
                Insects.Remove(insect);
            }
            else
            {
                Insects.Add(insect);
            }
        }
Exemple #7
0
        public IHttpActionResult PostInsects(Insects insects)
        {
            db.Insects.Add(insects);

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateException)
            {
                if (InsectsExists(insects.ID))
                {
                    return(Conflict());
                }
                else
                {
                    throw;
                }
            }

            return(CreatedAtRoute("DefaultApi", new { id = insects.ID }, insects));
        }
Exemple #8
0
        public IHttpActionResult PutInsects(int id, Insects insects)
        {
            if (id != insects.ID)
            {
                return(BadRequest());
            }

            string        procedure = "";
            int           number;
            string        connectionString = @"Data Source=DESKTOP-RDKB255\SQLEXPRESS;Initial Catalog=articles;Integrated Security=True";
            SqlConnection connection       = new SqlConnection(connectionString);

            try
            {
                string commandStr =
                    $"EXEC InsectsRating @id = '{insects.ID}'," +
                    $" @rating = '{insects.Rating}'";
                connection.Open();
                SqlCommand command = new SqlCommand(commandStr, connection);
                number = command.ExecuteNonQuery();
            }
            catch (SqlException ex)
            {
                return(BadRequest(ex.Message));
            }
            finally
            {
                connection.Close();
            }
            if (number != null)
            {
                return(Ok());
            }

            return(null);
        }
Exemple #9
0
 public static string GetInsects(Insects insects)
 {
     return(m_Insects[(int)insects]);
 }