Beispiel #1
0
        public async Task <bool> DeleteFirstAidKit(int firstAidKitID)
        {
            var fak = new FirstAidKit {
                FirstAidKitID = firstAidKitID
            };

            Delete(fak);
            return(await SaveAll());
        }
Beispiel #2
0
        public void AddUFAK(UserFirstAidKit uFAK)
        {
            var fak = new FirstAidKit()
            {
                UserFirstAidKits = new List <UserFirstAidKit> {
                    uFAK
                }
            };

            Add(fak);
        }
 // Use this for initialization
 void Start()
 {
     Timepassed = 0;
     Timecheck  = 0;
     Food       = 10;
     Health     = 10;
     healthinc  = false;
     AnimZombie = GetComponent <Animator>();
     Food3.SetActive(false);
     coin             = new Coin();
     bulletfire       = new BulletFire();
     Aidkit           = new FirstAidKit();
     AgentStartingPos = this.transform.position;
 }
 // Use this for initialization
 void Start()
 {
     //   OxetocinInHalloForMarko = 0;
     // OxetocinInLaraForMarko = 0;
     coin       = new Coin();
     Timepassed = 0;
     Food       = 10;
     //  PrevFoodForDopamin = 10;
     Health           = 10;
     healthinc        = false;
     AnimZombie       = GetComponent <Animator>();
     Aidkit           = new FirstAidKit();
     bulletfire       = new BulletFire();
     py               = new PythonCommunicator();
     AgentStartingPos = this.transform.position;
 }
Beispiel #5
0
 // Use this for initialization
 void Start()
 {
     Reward     = 0;
     Timepassed = 0;
     Timecheck  = 0;
     Food       = 10;
     Health     = 10;
     healthinc  = false;
     AnimZombie = GetComponent <Animator>();
     Food3.SetActive(false);
     //Dopamin = 0;
     //OxetocinInHalloForLara = 0;
     //OxetocinInMarkoForLara = 0;
     coin             = new Coin();
     Aidkit           = new FirstAidKit();
     bulletfire       = new BulletFire();
     AgentStartingPos = this.transform.position;
     //  py = new PythonCommunicator();
 }
 public FirstAidKitEventArgs([NotNull] FirstAidKit firstAidKit)
 {
     FirstAidKit = firstAidKit ?? throw new ArgumentNullException(nameof(firstAidKit));
 }
Beispiel #7
0
        public static void Update()
        {
            Random rnd = new Random();

            foreach (BaseObject baseObject in baseObjects)
            {
                baseObject.Update();
            }
            foreach (Bullet bullet in _bullets)
            {
                bullet?.Update();
            }
            firstAidKit?.Update();
            for (int i = 0; i < asteroids.Length; i++)
            {
                if (asteroids[i] == null)
                {
                    continue;
                }
                asteroids[i].Update();
                for (int j = 0; j < _bullets.Count; j++)
                {
                    if (asteroids[i] != null && _bullets[j].Collision(asteroids[i]))
                    {
                        System.Media.SystemSounds.Beep.Play();
                        _bullets.RemoveAt(j);
                        asteroids[i] = null;
                        j--;
                    }
                }
                if (asteroids[i] != null && !ship.Collision(asteroids[i]))
                {
                    continue;
                }
                if (asteroids[i] != null && ship.Collision(asteroids[i]))
                {
                    ship.EnergyLow(rnd.Next(1, 10));
                    System.Media.SystemSounds.Asterisk.Play();
                }

                if (ship.Energy <= 0)
                {
                    ship?.Die();
                }
            }
            if (asteroids.All(p => p == null))
            {
                Random random = new Random();
                int    r      = random.Next(5, 50);
                count++;
                asteroids = new Asteroid[count];
                for (int i = 0; i < asteroids.Length; i++)
                {
                    asteroids[i] = new Asteroid(new Point(600, random.Next(0, Height)), new Point(-r, r), new Size(50, 50));
                    asteroids[i].Update();
                }
            }
            if (firstAidKit != null && ship.Collision(firstAidKit))
            {
                ship.EnergyHigh(rnd.Next(0, 30));
                firstAidKit = null;
            }
        }
Beispiel #8
0
        /// <summary>
        /// Метод обновляет координаты объектов
        /// </summary>
        public static void Update()
        {
            foreach (BaseObject obj in _objs)
            {
                obj.Update();
            }
            foreach (Bullet b in _bullets)
            {
                b.Update();
            }

            if (asteroidsArr.Length != 0)
            {
                for (var i = asteroidsArr.Length - 1; i >= 0; i--)
                {
                    asteroidsArr[i].Update();
                    if (_ship.Collision(asteroidsArr[i]))
                    {
                        asteroidsArr.AsteroidDestruction(i);
                        var rnd = new Random();
                        _ship?.EnergyLow(rnd.Next(10, 20));
                        System.Media.SystemSounds.Asterisk.Play();
                    }
                    else
                    {
                        for (int j = _bullets.Count - 1; j >= 0; j--)
                        {
                            if (_bullets[j].Collision(asteroidsArr[i]))
                            {
                                System.Media.SystemSounds.Hand.Play();
                                asteroidsArr.AsteroidDestruction(i);
                                _bullets.RemoveAt(j);
                                _ship.ScoreChange(10);
                                if (_ship.Energy < 100 && _fak == null)
                                {
                                    var rnd = new Random();
                                    _fak = new FirstAidKit(new Point(Width, rnd.Next(10, Height - 10)), new Point(-10, 0), new Size(50, 50), _images[9]);
                                }
                                break;
                            }
                        }
                    }
                    if (_ship.Energy <= 0)
                    {
                        _ship?.Die();
                    }
                }
            }
            else
            {
                asteroidsArr.AddAsteroids(asteroidsArr.numbOfAsteroids + 1, Width, Height, _images[7]);
            }
            if (_fak != null)
            {
                if (_ship.Collision(_fak))
                {
                    _ship.Heal(_fak);
                    _fak = null;
                }
            }
            _fak?.Update();
        }
Beispiel #9
0
        public static void Initialize(DataContext context)
        {
            if (context.Users.Any())
            {
                return;   // DB has been seeded
            }



            var users = new User[] {
                new User {
                    Name = "Bogdan", Surname = "Bogdanowicz", Email = "*****@*****.**"
                },
                new User {
                    Name = "Jan", Surname = "Kowalski", Email = "*****@*****.**"
                },
                new User {
                    Name = "Tomasz", Surname = "Nowak", Email = "*****@*****.**"
                },
                new User {
                    Name = "Kamil", Surname = "Limak", Email = "*****@*****.**"
                },
            };

            foreach (User u in users)
            {
                byte[] passwordHash, passwordSalt;
                CreatePasswordHash("password", out passwordHash, out passwordSalt);
                u.PasswordHash = passwordHash;
                u.PasswordSalt = passwordSalt;
                u.Name         = u.Name.ToLower();
                u.Surname      = u.Surname.ToLower();
                context.Users.Add(u);
            }
            context.SaveChanges();

            var firstAidKits = new FirstAidKit[] {
                new FirstAidKit {
                },
                new FirstAidKit {
                },
                new FirstAidKit {
                },
                new FirstAidKit {
                },
            };

            foreach (FirstAidKit fak in firstAidKits)
            {
                context.FirstAidKits.Add(fak);
            }

            context.SaveChanges();

            var userFirstAidKits = new UserFirstAidKit[] {
                new UserFirstAidKit {
                    UserID = 1, FirstAidKitID = 1, Name = "apteczka dom"
                },

                new UserFirstAidKit {
                    UserID = 1, FirstAidKitID = 2, Name = "apteczka biuro"
                },

                new UserFirstAidKit {
                    UserID = 3, FirstAidKitID = 3, Name = "apteczka dom"
                },

                new UserFirstAidKit {
                    UserID = 4, FirstAidKitID = 4, Name = "apteczka dom"
                },
            };

            foreach (UserFirstAidKit ufak in userFirstAidKits)
            {
                context.UserFirstAidKits.Add(ufak);
            }
            context.SaveChanges();

            var medicines = new Medicine[] {
                new Medicine {
                    Name = "Apap", QuantityInPackage = 10
                },
                new Medicine {
                    Name = "Ketonal", QuantityInPackage = 10
                },
                new Medicine {
                    Name = "Ibuprom", QuantityInPackage = 10
                },
                new Medicine {
                    Name = "No-Spa", QuantityInPackage = 10
                },
            };

            foreach (Medicine m in medicines)
            {
                context.Medicines.Add(m);
            }

            context.SaveChanges();
            var currentDayMinus7 = DateTime.Today.AddDays(-7);


            var firstAidKitMedicines = new FirstAidKitMedicine[] {
                new FirstAidKitMedicine {
                    FirstAidKitID = 1, MedicineID = 1, ExpirationDate = currentDayMinus7, IsTaken = true
                },
                new FirstAidKitMedicine {
                    FirstAidKitID = 1, MedicineID = 2, ExpirationDate = currentDayMinus7, IsTaken = true
                },
                new FirstAidKitMedicine {
                    FirstAidKitID = 2, MedicineID = 3, ExpirationDate = currentDayMinus7, IsTaken = false
                },
                new FirstAidKitMedicine {
                    FirstAidKitID = 2, MedicineID = 4, ExpirationDate = DateTime.Today.AddDays(7), IsTaken = false
                }
            };

            foreach (FirstAidKitMedicine fakm in firstAidKitMedicines)
            {
                fakm.RemainingQuantity = context.Medicines.FirstOrDefault(x => x.MedicineID == fakm.MedicineID).QuantityInPackage;
                context.FirstAidKitMedicines.Add(fakm);
            }

            context.SaveChanges();
        }
Beispiel #10
0
 private void PickUpFirstAidKit(FirstAidKit firstAidKit)
 {
     Regeneration.Regenerate(firstAidKit.RegenerationAmount);
     Battlefield.Remove(firstAidKit);
 }
 private void OnFirstAidKitRemoved(FirstAidKit firstAidKit) =>
 FirstAidKitRemoved?.Invoke(this, new FirstAidKitEventArgs(firstAidKit));
 public void Remove(FirstAidKit firstAidKit)
 {
     myFirstAidKits.Remove(firstAidKit);
     OnFirstAidKitRemoved(firstAidKit);
 }
 public void Add(FirstAidKit firstAidKit)
 {
     myFirstAidKits.Add(firstAidKit);
     OnFirstAidKitAdded(firstAidKit);
 }