コード例 #1
0
        public string getNextMeal(ref int nextMealTime)
        {
            nextMeal = "";
            Eat eat = EatDB.getByDayID(_day.DayID).Where(et => et.Kind == "Dinner").First() as Eat;

            if (user.DinnerTime > DateTime.Now.TimeOfDay.TotalMinutes && !eat.Done && !eat.Skipped)
            {
                nextMeal     = "Dinner";
                nextMealTime = user.DinnerTime;
            }

            eat = EatDB.getByDayID(_day.DayID).Where(et => et.Kind == "Lunch").First() as Eat;
            if (user.LunchTime > DateTime.Now.TimeOfDay.TotalMinutes && !eat.Done && !eat.Skipped)
            {
                nextMeal     = "Lunch";
                nextMealTime = user.LunchTime;
            }

            eat = EatDB.getByDayID(_day.DayID).Where(et => et.Kind == "Breakfest").First() as Eat;
            if (user.BreakfestTime > DateTime.Now.TimeOfDay.TotalMinutes && !eat.Done && !eat.Skipped)
            {
                nextMeal     = "Breakfest";
                nextMealTime = user.BreakfestTime;
            }

            return(nextMeal);
        }
コード例 #2
0
    public override void Update()
    {
        base.Update();

        switch (eat)
        {
        case Eat.Opening:
            Opening();
            break;

        case Eat.Closing:

            Closing();

            if (color.a >= 1)
            {
                eat = Eat.Kill;
            }

            break;

        case Eat.Kill:
            PlayerManager.instance.KillPlayer();
            eat = Eat.Opening;
            break;
        }
    }
コード例 #3
0
        public async Task <Eat> Create(Eat eat)
        {
            eat.CreatedAt     = DateTime.Now;
            eat.LastUpdatedAt = DateTime.Now;

            var food = await _context.Foods.Where(x => x.Barcode == eat.Barcode).FirstOrDefaultAsync();

            if (food is null)
            {
                food = new Food
                {
                    Barcode       = await GenerateBarcode(eat.Barcode),
                    Calories      = eat.Calories,
                    Name          = eat.Name,
                    CreatedAt     = DateTime.Now,
                    LastUpdatedAt = DateTime.Now,
                    Notes         = "User submitted data. Info may be inaccurrate."
                };

                await _context.Foods.AddAsync(food);

                await _context.SaveChangesAsync();
            }

            eat.FoodId = food.FoodId;

            await _context.EatRecords.AddAsync(eat);

            await _context.SaveChangesAsync();

            return(eat);
        }
コード例 #4
0
        public async Task <Eat> Update(Eat eat)
        {
            _context.EatRecords.Update(eat);
            await _context.SaveChangesAsync();

            return(eat);
        }
コード例 #5
0
    // Update is called once per frame
    void Update()
    {
        GameObject Player = GameObject.Find("Player");
        Eat        eat    = Player.GetComponent <Eat>();

        GameObject Enemy1 = GameObject.Find("Enemy1");
        Eat        eat2   = Enemy1.GetComponent <Eat>();

        GameObject Spawner = GameObject.Find("Spawner");
        Spawn      spawn   = Spawner.GetComponent <Spawn>();

        if (GameOverState == false)
        {
            if (eat.FoodEaten + eat2.FoodEaten >= spawn.FoodPoolMax) // Level won
            {
                if (eat.FoodEaten >= Eat.FoodNeeded)
                {
                    LoadNextLevel();
                }
                else // Game over
                {
                    GameOver();
                }
            }
        }
    }
コード例 #6
0
ファイル: Agent.cs プロジェクト: jballaban/game1
    private void Awake()
    {
        if (gameObject.activeSelf == true)
        {
            idle   = new Idle(this);
            rest   = new Rest(this);
            eat    = new Eat(this);
            wander = new Wander(this);
            chase  = new Chase(this);
            flee   = new Flee(this);
            attack = new Attack(this);
            dead   = new Dead(this);

            navAgent = GetComponentInParent <NavMeshAgent>();

            tracker = GameObject.FindGameObjectWithTag("Tracker").GetComponent <Tracking>();

            damageOutput = gameObject.GetComponentsInChildren <Damage>();

            if (useAnimator == true)
            {
                anim = GetComponent <Animator>();
            }

            if (dynamicWandering == false)
            {
                spawnpoint = transform.position;
            }
        }
    }
コード例 #7
0
        public async Task <ActionResult <Eat> > Update([FromRoute] int id, [FromBody] Eat model)
        {
            try
            {
                var eat = await _eatsService.GetById(id);

                if (eat is null)
                {
                    _logger.LogDebug($"Eat with ID {id} is not found");
                    return(NotFound());
                }

                return(await _eatsService.Update(model));
            }
            catch (LaprTrackrException ex)
            {
                _logger.LogDebug(ex.Message);
                return(ex.GetActionResult());
            }
            catch (Exception ex)
            {
                const string message = "Failed to update eat";
                _logger.LogError(ex, message);
                return(new LaprTrackrException(LaprTrackrStatusCodes.ServiceUnavailable, message).GetActionResult());
            }
        }
コード例 #8
0
        public void TestEat()
        {
            //Arrange
            Room room = new Room {
                Id = 1, Name = "D3320", Description = "Test"
            };
            ApplicationUser user = new ApplicationUser {
                FirstName = "Eivind", Room = room
            };
            Item item1 = new Item {
                Name = "salad", Room = room, isEatable = true
            };
            Item item2 = new Item {
                Name = "cake", Room = room, isEatable = true
            };


            List <Item> items = new List <Item>();

            items.Add(item1);
            items.Add(item2);
            Mock <IRepository> repo = new Mock <IRepository>();

            repo.Setup(x => x.GetUser("userid")).Returns(user);
            repo.Setup(x => x.GetEatableItems()).Returns(items);

            var eat = new Eat(repo.Object);

            string expected = "You just ate salad";
            string actual   = eat.RunCommand("salad", "userid");

            Assert.AreEqual(expected, actual);
        }
コード例 #9
0
ファイル: Become.cs プロジェクト: evoucou/Obstacle_Island
    void Start()
    {
        actionPickup = GetComponentInParent <Pickupper>();
        actionEat    = GetComponentInParent <Eat>();
        actionShield = GetComponentInParent <ShieldActivator>();

        st     = GameObject.FindWithTag("ShieldTimer");
        stimer = st.GetComponent <ShieldTimer>();


        fpsCam           = GetComponent <Camera>();
        firstCamPosition = GetComponent <Transform>().localPosition;
        thirdCamPosition = firstCamPosition + new Vector3(0, 5, -5);
        actionThrow      = GetComponent <Throw>();

        // set the current object to ActivePlayer
        gameObject.transform.parent.tag = "ActivePlayer";

        shield = GameObject.FindWithTag("Shield");

        //shieldOff = shield.GetComponent<ShieldActivator>();
//    if(shield != null) {
//    render = shield.GetComponent<MeshRenderer>();
//    collider = shield.GetComponent<Collider>();
//    shieldActivated = false;
//        }
    }
コード例 #10
0
 void OnTriggerExit2D(Collider2D other)
 {
     if (other.name == "Player")
     {
         Debug.Log("exited kill zone");
         eat = Eat.Opening;
     }
 }
コード例 #11
0
 void die()
 {
     HeadMove.Stop();
     Eat.Stop();
     BodyMove.Stop();
     Panel.Stop();
     button1.Enabled = true;
     button2.Enabled = false;
     MessageBox.Show("Your score is : " + score.ToString());
 }
コード例 #12
0
 public Pacman(Eat eat)
 {
     picture = new PictureBox()
     {
         Location = new Point(33, 32),
         Size     = new Size(32, 32)
     };
     speed     = 32;
     direction = Direction.Right;
     this.eat  = eat;
 }
コード例 #13
0
        public IActionResult Index()
        {
            //This list will be used for a string that will be displayed on the page.
            List <string> eatList = new List <string>();

            foreach (Eat eat in Eat.GetEats())
            {
                eatList.Add($"#{eat.Rank}: {eat.Name}    |   Favorite Dish: {eat.FavoriteDish ?? "It's all tasty!"}   |   Address: {eat.Address}   |   Phone: {eat.Phone ?? "No phone listed."}    |     Website: {eat.Website ?? "Coming Soon"}");
            }

            return(View(eatList));
        }
コード例 #14
0
 public void AddAge(float time) //ages all the humans at each time interval
 {
     timer      += time;
     Deathtimer += time * GameManager.secondsPerMonth;
     if (Deathtimer < 5)
     {
         if (Input.GetKeyDown(KeyCode.F))
         {
             EventHandler.instance.AddAchievement(Achievement.respect);
         }
     }
     SortList();
     if (timer > 1 && GameController.instance.canFoodUpKeep)
     {
         Eat[] resources = new Eat[humans.Count];
         int   count     = 0;
         foreach (Human h in humans) //foodupkeep
         {
             resources[count].resource = new ResourceManager.Resources(h._humanSkills.FoodUpKeep(), ResourceManager.ResourceType.Food);
             resources[count].human    = h;
             count++;
         }
         Array.Sort(resources, (x, y) => y.resource.amount.CompareTo(x.resource.amount)); //descending
         starving = false;
         foreach (Eat e in resources)
         {
             if (GameController.instance.gameManager.resourceManager.EnoughResources(e.resource))
             {
                 GameController.instance.gameManager.resourceManager.DeductResources(e.resource);
                 e.human.health = Mathf.Clamp(e.human.health + (int)e.resource.amount, -1, 101);
             }
             else
             {
                 starving       = true;
                 e.human.health = Mathf.Clamp(e.human.health - (int)e.resource.amount, -1, 101);
                 if (e.human.health < 0)
                 {
                     EventHandler.instance.AddAchievement(Achievement.diet);
                     e.human._age._go.GetComponent <HumanController>().Die(true);
                 }
             }
         }
         if (starving)
         {
             GameController.instance.StartCoroutine(UIScript.instance.FlashPopulationPanel(UIScript.Option.food, Color.red));
         }
         timer = 0;
     }
     foreach (Human h in humans)
     {
         h._age.AddMonth(time);
     }
 }
コード例 #15
0
        public ElementsInit()
        {
            IHead    head     = new Head();
            IElement element  = new Element();
            IElement element1 = new Element();
            IElement element2 = new Element();
            IElement element3 = new Element();
            IElement element4 = new Element();

            Eat eat = new Eat();

            ElementManager.Instance.GetEat = eat;
        }
コード例 #16
0
        /**
         * Load and parse data from animal_data.csv
         */
        internal static void LoadData(AnimalData animalData)
        {
            if (IsDataLoaded)
            {
                return;
            }

            List <string[]> rows = new List <string[]>();

            using (StreamReader reader = File.OpenText("Data/animal_data.csv"))
            {
                while (reader.Peek() >= 0)
                {
                    string   line      = reader.ReadLine();
                    string[] rowArrray = CSVRowToStringArray(line);
                    if (rowArrray.Length > 0)
                    {
                        rows.Add(rowArrray);
                    }
                }
            }

            string[] headers = rows[0];
            rows.Remove(headers);

            /**
             * Parse each row array into a Animal object.
             * Assumes CSV column ordering:
             *      name,employer,location,position type,core competency
             */
            foreach (string[] row in rows)
            {
                Size   size   = animalData.Sizes.AddUnique(row[1]);
                Origin origin = animalData.Origins.AddUnique(row[2]);
                Kind   kind   = animalData.Kinds.AddUnique(row[3]);
                Eat    eat    = animalData.Eats.AddUnique(row[4]);

                Animal newAnimal = new Animal
                {
                    Name   = row[0],
                    Size   = size,
                    Origin = origin,
                    Kind   = kind,
                    Eat    = eat
                };
                animalData.Animals.Add(newAnimal);
            }

            IsDataLoaded = true;
        }
コード例 #17
0
 public void DeleteEat()
 {
     if (eat.SelectedItems.Count > 0)
     {
         for (int i = 0; i < eat.SelectedItems.Count; i++)
         {
             Eat el = eat.SelectedItems[i] as Eat;
             if (el != null)
             {
                 _context.Eat.Remove(el);
             }
         }
     }
     _context.SaveChanges();
 }
コード例 #18
0
        public void checkAndNotify()
        {
            //check if it is time
            string current = getCurrentMeal();

            if (!current.Equals(""))
            {
                Eat eat = null;
                eat = EatDB.getByDayID(_day.DayID).Where(et => et.Kind == current).First() as Eat;

                if (!eat.Notified)
                {
                    eat.Notified = true;
                    EatDB edb = new EatDB(eat);
                    edb.save();
                    //notify:
                    string toast = "<toast>"
                                   + "<visual>"
                                   + "<binding template = \"ToastGeneric\" >"
                                   + "<text> Time to eat! </text>"
                                   + "</binding>"
                                   + "</visual>"
                                   + "<audio src=\"ms - winsoundevent:Notification.Reminder\"/>"
                                   + "</toast>";


                    Windows.Data.Xml.Dom.XmlDocument toastDOM = new Windows.Data.Xml.Dom.XmlDocument();
                    toastDOM.LoadXml(toast);

                    ToastNotification toastNotification = new ToastNotification(toastDOM);

                    var toastNotifier = Windows.UI.Notifications.ToastNotificationManager.CreateToastNotifier();
                    toastNotifier.Show(toastNotification);
                }
                this.tbNextMeal.Text  = "It is time for your";
                this.countdown.Text   = current + " now!";
                rectTime.Visibility   = Visibility.Collapsed;
                rectTimeBG.Visibility = Visibility.Collapsed;
                //countdown.Visibility = Visibility.Collapsed;
            }
            else
            {
                rectTime.Visibility   = Visibility.Visible;
                rectTimeBG.Visibility = Visibility.Visible;
                countdown.Visibility  = Visibility.Visible;
                updateCountdown();
            }
        }
コード例 #19
0
 private void updateHunger()
 {
     mHunger += Globals.UNIT_HUNGER_CYCLE_INCREASE;
     if (mHunger >= 100f)
     {
         mHunger = 100f;
         mHP    -= Globals.UNIT_HUNGRY_DAMAGE_TAKEN;
     }
     if (mHunger > 80f && !mActions.hasActionOfType("Eat"))
     {
         //go and eat
         //Debug.Log("Adding Eat Action");
         Eat eat = ObjectManager.initEat(mActions.transform);
         mActions.prependAction(eat);
     }
 }
コード例 #20
0
 void startgame()
 {
     R     = true;
     L     = false;
     D     = false;
     U     = false;
     score = 0;
     load();
     obstacle = new Obstacle();
     obstacle.taovatcan(panel1, tuong);
     HeadMove.Start();
     Eat.Start();
     BodyMove.Start();
     food = new FoodforAdvanced();
     food.TaoThucAn(panel1, listthucan);
     Panel.Start();
 }
コード例 #21
0
    public AgentBehaviorTreeBuilder Action(ActionType type)
    {
        Action action = null;

        switch (type)
        {
        case ActionType.AssignTarget_Agent_ClosestInView:
            action = new AssignTarget(agent, TargetType.Agent, TargetCriteria.ClosestInView);
            break;

        case ActionType.AssignTarget_Food_ClosestInView:
            action = new AssignTarget(agent, TargetType.Food, TargetCriteria.ClosestInView);
            break;

        case ActionType.Eat:
            action = new Eat(agent);
            break;

        case ActionType.AttackTarget:
            action = new AttackTarget(agent);
            break;

        case ActionType.MoveToTarget:
            action = new MoveToTarget(agent);
            break;

        case ActionType.SteerToTarget:
            action = new SteerToTarget(agent);
            break;

        case ActionType.Wander:
            action = new Wander(agent);
            break;

        case ActionType.ChangeColor_Aggressive:
            action = new ChangeColorStatus(agent, ColorStatus.Aggressive);
            break;

        case ActionType.ChangeColor_Passive:
            action = new ChangeColorStatus(agent, ColorStatus.Passive);
            break;
        }

        base.Action(action);
        return(this);
    }
コード例 #22
0
 private void button2_Click(object sender, EventArgs e)
 {
     if (button2.Text == "Stop (P)")
     {
         button2.Text = "Continue";
         HeadMove.Stop();
         Eat.Stop();
         BodyMove.Stop();
     }
     else
     {
         button2.Text = "Stop (P)";
         HeadMove.Start();
         Eat.Start();
         BodyMove.Start();
     }
 }
コード例 #23
0
 public async Task <ActionResult <Eat> > Add([FromRoute] Eat model)
 {
     try
     {
         return(await _eatsService.Create(model));
     }
     catch (LaprTrackrException ex)
     {
         _logger.LogDebug(ex.Message);
         return(ex.GetActionResult());
     }
     catch (Exception ex)
     {
         const string message = "Failed to add eat";
         _logger.LogError(ex, message);
         return(new LaprTrackrException(LaprTrackrStatusCodes.ServiceUnavailable, message).GetActionResult());
     }
 }
コード例 #24
0
    void ShootRaysRight()
    {
        for (int i = 0; i < horizontalRayCount; i++)
        {
            float rayLength = 0.015f * 2f;                                                                  //Short rayLength

            Vector2      rayOrigin = raycastOrigins.topRight + Vector2.down * horizontalRaySpacing * i;     //Rayorigin allways on topLeft.
            RaycastHit2D hit       = Physics2D.Raycast(rayOrigin, Vector2.right, rayLength, passengerMask); //Allways casting ray upwards.

            Debug.DrawRay(rayOrigin, Vector2.up * rayLength * 4, Color.red);

            if (hit)
            {
                Debug.Log("you've hit it");
                eat = Eat.Closing;
            }
        }
    }
コード例 #25
0
ファイル: Program.cs プロジェクト: SWT19GRP1/VisitorFruit
        static void Main(string[] args)
        {
            IItem banana = new Banana();
            IItem apple  = new Apple();
            IItem pear   = new Pear();

            IOperation operation = new Eat();

            Console.WriteLine(banana.AcceptOperation(operation));
            Console.WriteLine(apple.AcceptOperation(operation));
            Console.WriteLine(pear.AcceptOperation(operation));

            operation = new Throw();

            Console.WriteLine(banana.AcceptOperation(operation));
            Console.WriteLine(apple.AcceptOperation(operation));
            Console.WriteLine(pear.AcceptOperation(operation));
        }
コード例 #26
0
    //生成超级豆
    private IEnumerator BornSuperBeans()
    {
        //等待生成的时间
        yield return(new WaitForSeconds(SuperBeansTime));

        Eat[] AllBeans = GameObject.FindObjectsOfType <Eat>();

        //豆子数目少于50则不再产生超级豆;
        if (AllBeans.Length < 50)
        {
            yield break;
        }

        //随机一个数
        Eat SuperBean = AllBeans[Random.Range(0, AllBeans.Length)];

        //生成超级豆
        SuperBean.MakeSuperBeans();
    }
コード例 #27
0
    private void Start()
    {
        arrivalBehavior = gameObject.GetComponent <Arrival>();
        persueBehavior  = gameObject.GetComponent <Persue>();
        attackBehavior  = gameObject.GetComponent <Attack>();
        eatBehavior     = gameObject.GetComponent <Eat>();

        botActuators = gameObject.GetComponent <BotController>();

        mySpriteRend = GetComponent <SpriteRenderer>();
        GetComponentInChildren <TextMesh>().text = botNumber.ToString();

        heading = new Vector3(0.0f, 0.0f, 0.0f);
        timerToNextUpdateCycle = 0.0f;
        currentHp            = startingHp;
        currentPercentHealth = 1.0f;
        isScared             = false;
        originalColor        = mySpriteRend.color;
    }
コード例 #28
0
    // Start is called before the first frame update
    void Start()
    {
        animator = GetComponent <Animator> ();
        stairs   = false;
        if (this.gameObject.name == "Player")
        {
            eat = gameObject.GetComponent <Eat>();
        }
        else
        {
            eat = null;
        }

        characterBod = GetComponent <Rigidbody>();
        //characterBod.constraints = RigidbodyConstraints.FreezePositionY;
        rotateXAxis = characterBod.transform.eulerAngles.x;
        rotateYAxis = characterBod.transform.eulerAngles.y;
        jump        = new Vector3(0.0f, 2.0f, 0.0f);
    }
コード例 #29
0
ファイル: Eatjs.cs プロジェクト: garkan/Hotel
        public Eat Booking(User user, DateTime start, DateTime end)
        {
            //var lst = eat.Where(eat =>
            //{
            //    return eat.id == room.id && ((start > eat.date && start < eat.dateend) ||
            //    (end > eat.date && end < eat.dateend));
            //});
            //if (lst.Count() != 0)
            //    return null;
            //else
            //{
            //    double amount = room.cost_per_day * (end.Subtract(start).TotalDays);
            var eats = new Eat(user.id, start, end);

            //    eat.Add(eats);
            //    Update();
            return(eats);
            //}
        }
コード例 #30
0
        public async Task <Schedule> ScheduleEatReminderNotificationAsync(Eat eat, DateTime utcDeliverTime, bool commitChanges = false)
        {
            var timeOffset = utcDeliverTime.ToDateTimeOffset(TimeZoneInfo.Utc);

            var jobId = BackgroundJob.Schedule <INotificationService>(x => x.NotifyEatReminderAsync(eat.Id), timeOffset);

            var schedule = new Schedule
            {
                JobId       = jobId,
                IsProcessed = false
            };

            await _uow.ScheduleRepository.AddAsync(schedule);

            if (commitChanges)
            {
                await _uow.CommitAsync();
            }

            return(schedule);
        }